From 6d75aa1bed9ace3a41c2262c5be94934df0ed16b Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Mon, 18 May 2009 17:53:51 -0400 Subject: [PATCH] added a script that creates a webpage of all the collected data. has basic naming capabilities. --- rimecollect-rrd/meshstat.cgi | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 rimecollect-rrd/meshstat.cgi diff --git a/rimecollect-rrd/meshstat.cgi b/rimecollect-rrd/meshstat.cgi new file mode 100755 index 000000000..c95a1b3a7 --- /dev/null +++ b/rimecollect-rrd/meshstat.cgi @@ -0,0 +1,66 @@ +#!/usr/bin/perl -w + +# CGI script that creates a fill-out form +# and echoes back its values. + +use CGI qw/:standard/; + +# configs + +# paths +my $meshpath = "/home/malvira/work"; +my $wwwpath = "/var/www"; +my $hostname = "localhost"; + +# aliases +my %aliases = ( + "2.0" => { + alias => "Lower Door", + ds=> { + "GPIO29" => "Lock", + }, + }, + "4.0" => { + alias => "Upper Door", + }, + "1.0" => { + alias => "Sink (Hotdog)", + }, + ); + +opendir(MESHDIR, $meshpath); +my @files = readdir(MESHDIR); + +print header; +print start_html('Collect Mesh'); + + +foreach my $file (@files) { + next if $file !~ /([\d\.]+)\.rrd$/; + my $addr = $1; + print hr; + print h1("$addr: $aliases{$addr}{'alias'}"); + my @info = split(/\n/,qx(rrdtool info $meshpath/$addr.rrd)); + + my %ds; + foreach my $info (@info) { + next if $info !~ /ds\[([\w\d]+)\]/; + $ds{$1}++; + } + + foreach my $ds (keys(%ds)) { + 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"}); + } + +} + +print hr; + +print end_html; + +#/var/www/demo.png --title="Door" --start end-60min +# --imginfo '' +# DEF:door=/home/malvira/work/2.0.rrd:GPIO29:LAST +# LINE2:door#00a000:"Door lock">