From 56a75f637fef6d485aeddf7ec259e49df0edff22 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Mon, 22 Jun 2009 16:22:47 -0400 Subject: [PATCH] added output of rrdtool lastupdate Signed-off-by: Mariano Alvira --- rimecollect-rrd/meshstat.cgi | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rimecollect-rrd/meshstat.cgi b/rimecollect-rrd/meshstat.cgi index c95a1b3a7..f4ba0405e 100755 --- a/rimecollect-rrd/meshstat.cgi +++ b/rimecollect-rrd/meshstat.cgi @@ -10,21 +10,21 @@ use CGI qw/:standard/; # paths my $meshpath = "/home/malvira/work"; my $wwwpath = "/var/www"; -my $hostname = "localhost"; +my $hostname = "hotdog.redwirellc.com"; # aliases my %aliases = ( "2.0" => { alias => "Lower Door", ds=> { - "GPIO29" => "Lock", + "GPIO29" => "Lock (0 - locked, 1 - unlocked)", }, }, "4.0" => { alias => "Upper Door", }, "1.0" => { - alias => "Sink (Hotdog)", + alias => "Hotdog (datasink)", }, ); @@ -42,13 +42,17 @@ foreach my $file (@files) { print h1("$addr: $aliases{$addr}{'alias'}"); my @info = split(/\n/,qx(rrdtool info $meshpath/$addr.rrd)); - my %ds; + my %dses; foreach my $info (@info) { - next if $info !~ /ds\[([\w\d]+)\]/; - $ds{$1}++; + next if $info !~ /ds\[([\w\d]+)\]\.([\w\d_]+)\s+=\s+([\w\d]+)/; + $dses{$1}{$2} = $3; } + + my $lastupdate = qx(rrdtool lastupdate $meshpath/$addr.rrd); + $lastupdate =~ /([\w\d]+)\s+(\d+):\s+([\w\d]+)/; + print gmtime($2) . " $1 $3
"; - foreach my $ds (keys(%ds)) { + foreach my $ds (keys(%dses)) { print h2("$ds: $aliases{$addr}{'ds'}{$ds}"); qx(rrdtool graph $wwwpath/$addr-$ds.png --start end-60min DEF:$ds=$meshpath/$addr.rrd:$ds:LAST LINE2:$ds#00a000:\"$ds\"); print img({src=>"http://$hostname/$addr-$ds.png"});