Merge branch 'master' of git://git.devl.org/git/malvira/mc1322x-tests
This commit is contained in:
commit
292f20c4ea
|
@ -87,7 +87,7 @@ while(1) {
|
|||
while(read(FILE, $c, 1)) {
|
||||
$i++;
|
||||
usleep(50); # this is as fast is it can go...
|
||||
usleep(25) if ($s==1);
|
||||
usleep(50) if ($s==1);
|
||||
$ob->write($c);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ if(scalar(@ARGV)!=0) {
|
|||
my $c; my $count;
|
||||
while(1) {
|
||||
($count, $c) = $ob->read(1);
|
||||
print $c if ($count != 0);
|
||||
print $c if (defined($count) && ($count != 0));
|
||||
}
|
||||
|
||||
$ob -> close or die "Close failed: $!\n";
|
||||
|
|
67
rimecollect-rrd/collect2rrd.pl
Executable file
67
rimecollect-rrd/collect2rrd.pl
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
my $verbose = 1;
|
||||
|
||||
####
|
||||
# Feed data on stdin from a RIME collect sink
|
||||
#
|
||||
# Enters data into rimeaddr.rrd
|
||||
#
|
||||
# Creates rimeaddr.rrd from a template if data shows up from a source and
|
||||
# rimeaddr.rrd doesn't exist
|
||||
#
|
||||
# default template is read from default.rrdtmpl
|
||||
#
|
||||
# if rimeaddr.rrdtmpl exisits, that is used instead.
|
||||
|
||||
####
|
||||
#
|
||||
# Templates are shell scripts that create the desired rrd
|
||||
#
|
||||
|
||||
####
|
||||
# Data messages are in the form of:
|
||||
#
|
||||
# Sink got message from 1.0, seqno 109, hops 0: len 12 'GPIO29-High'
|
||||
#
|
||||
#
|
||||
|
||||
my $datapattern = 'Sink got message from ([\d\.]+), seqno \d+, hops \d+: len \d+ \'([\w\d]+-[\w\d]+)\'';
|
||||
|
||||
sub rrdcreate {
|
||||
my ($newrrd_filename, $tmpl_filename) = @_;
|
||||
open FILE, "$tmpl_filename" or die $!;
|
||||
my $tmpl = <FILE>;
|
||||
chomp $tmpl;
|
||||
print "using template $tmpl found in $tmpl_filename\n" if $verbose;
|
||||
`rrdtool create $newrrd_filename $tmpl`;
|
||||
}
|
||||
|
||||
while(<>) {
|
||||
|
||||
next if($_ !~ /$datapattern/);
|
||||
print("rimeaddr $1 data $2\n") if $verbose;
|
||||
|
||||
my ($ds,$data) = split(/-/,$2);
|
||||
print("ds: $ds, data: $data\n") if $verbose;
|
||||
|
||||
if(-e "$1.rrd") {
|
||||
# an rrd already exists for this device
|
||||
# do an update
|
||||
`rrdtool update $1.rrd -t $ds N:$data`
|
||||
} else {
|
||||
# an rrd for this device doesn't exist yet
|
||||
# find a template and make it
|
||||
my $tmpl = "DS:speed:COUNTER:600:U:U RRA:AVERAGE:0.5:6:10";
|
||||
print "creating new rrd $1.rrd... " if $verbose;
|
||||
if(-e "$1.rrdtmpl") {
|
||||
rrdcreate("$1.rrd","$1.rrdtmpl");
|
||||
`rrdtool update $1.rrd -t $ds N:$data`
|
||||
} elsif(-e "default.rrdtmpl") {
|
||||
rrdcreate("$1.rrd","default.rrdtmpl");
|
||||
`rrdtool update $1.rrd -t $ds N:$data`
|
||||
} else {
|
||||
print "can't create rrd for $1: no template found\n";
|
||||
}
|
||||
}
|
||||
}
|
1
rimecollect-rrd/default.rrdtmpl
Normal file
1
rimecollect-rrd/default.rrdtmpl
Normal file
|
@ -0,0 +1 @@
|
|||
-s 1 DS:GPIO29:GAUGE:600:U:U RRA:LAST:0.99:1:3600
|
66
rimecollect-rrd/meshstat.cgi
Executable file
66
rimecollect-rrd/meshstat.cgi
Executable file
|
@ -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 '<IMG SRC=http://localhost/demo.png>'
|
||||
# DEF:door=/home/malvira/work/2.0.rrd:GPIO29:LAST
|
||||
# LINE2:door#00a000:"Door lock">
|
Loading…
Reference in a new issue