--- /dev/null
+package UPSGRAPH;
+
+$outdir="/var/www/html/temperature/";
+$step=60;
+
+$hosts = [
+ {
+ 'address' => "10.133.0.9",
+ 'name' => "al13-og",
+ 'rrdfile' => "/var/spool/upsgraph/temp.al13-og.rrd",
+
+ 'fields' => [ 'TD2501' ],
+
+ 'vars' => {
+ 'TD2501' => {
+ 'name' => 'TD2501',
+ 'url' => 'http://10.133.0.9/iolinkmaster/port[1]/iolinkdevice/pdin/getdata',
+ 'proto' => 'iotcore',
+ 'factor' => 1/10,
+ },
+ }
+ },
+];
+
+1;
use RRDs;
use File::Copy;
use Data::Dumper;
+use LWP::UserAgent;
+use JSON;
$UPSGRAPH::outdir = "";
$UPSGRAPH::daysCovered = 370;
%values;
}
+sub fetch_iotcore(@) {
+ my $url = shift;
+
+ my $ua = LWP::UserAgent->new;
+ $ua->timeout(1);
+
+ my $resp = $ua->get($url);
+ return undef if (!$resp->is_success);
+
+ my $pdin = decode_json($resp->decoded_content);
+ return undef if (!defined($pdin));
+
+ my $value = hex($pdin->{'data'}->{'value'});
+
+ $value;
+}
+
sub dayGraphFunc {
my $dataSrc = shift;
my $mode = shift;
@multi_values{keys %values} = values %values;
$result = $multi_values{$vars->{$var}->{'multi_id'}};
}
+ } elsif ($vars->{$var}->{'proto'} eq 'iotcore') {
+ $result = fetch_iotcore($vars->{$var}->{'url'});
}
next unless (defined $result);