← Back to team overview

graphite-dev team mailing list archive

[Question #97754]: perl script not working

 

Question #97754 on Graphite changed:
https://answers.launchpad.net/graphite/+question/97754

Description changed to:
This script is not updating in graphite.  Any ideas?

OUTPUT:
weather.temperature 35 1263766247
weather.humidity 64 1263766247
weather.wind_speed 6 1263766247

SCHEMAS:
/usr/local/graphite/storage/storage-schemas.conf
[everything_1min_1day]
priority = 100
pattern = .*
retentions = 60:1440

[weather_data]
priority = 100
pattern = .*
retentions = 60:1440


CODE:
#!/usr/bin/perl -w

use IO::Socket;
use strict;
use Weather::Google;

# init host and port
my $host = '127.0.0.1';
my $port = 2003;

my $gw;

my $date = `date +%s`;

## Initialize the module
$gw = new Weather::Google(60657); # Zip code

my $temp = $gw->current_conditions('temp_f');

my $humidity = $gw->current_conditions('humidity');
$humidity =~ m#Humidity:(.*)%#;
$humidity = $1;

my $wind = $gw->current_conditions('wind_condition');
$wind =~ m#at (.*) mph#;
$wind = $1;

my $line1 = "weather.temperature $temp $date";
my $line2 = "weather.humidity$humidity $date";
my $line3 = "weather.wind_speed $wind $date";

my $line = "$line1$line2$line3";


my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket: $!";

$sock->send($line);
print $line;
close($sock); 

LOGS:
/opt/graphite/carbon/storage/log/carbon-cache/log/
18/01/2010 01:01:01 :: Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 477, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.6/dist-packages/twisted/python/threadpool.py", line 210, in _worker
    result = context.call(ctx, function, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/twisted/python/context.py", line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/python/context.py", line 37, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/opt/graphite/carbon/lib/carbon/writer.py", line 144, in writeForever
    writeCachedDataPoints()
  File "/opt/graphite/carbon/lib/carbon/writer.py", line 83, in writeCachedDataPoints
    for schema in schemas:
exceptions.NameError: global name 'schemas' is not defined

You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.