working for one station
This commit is contained in:
commit
56f57223fb
68
river_level_
Executable file
68
river_level_
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Wildcard-script to monitor network interfaces. To monitor an
|
||||||
|
# interface, link vlan_<interface> to this file. E.g.
|
||||||
|
#
|
||||||
|
# ln /usr/share/munin/node/plugins-contrib/vlan_ /etc/munin/node.d/vlan_eth0_1
|
||||||
|
#
|
||||||
|
# ...will monitor eth0.1
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
#
|
||||||
|
# config
|
||||||
|
# autoconf
|
||||||
|
# suggest
|
||||||
|
#
|
||||||
|
#%# family=manual
|
||||||
|
#%# capabilities=autoconf suggest
|
||||||
|
|
||||||
|
# URLBASE=
|
||||||
|
|
||||||
|
CACHE=/tmp/river_level_.dat
|
||||||
|
checkdata () {
|
||||||
|
if test `find "$CACHE" -mtime +1`
|
||||||
|
then
|
||||||
|
curl -o $CACHE -Ss $URLBASE || exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getstationname () {
|
||||||
|
checkdata
|
||||||
|
NAME=$( perl -MJSON::PP -e '
|
||||||
|
open $fh, "/tmp/river_level_.dat" or die $!;
|
||||||
|
$data_arr = decode_json(<$fh>) or die $!;
|
||||||
|
my %data;
|
||||||
|
foreach (@{$data_arr->{data}}) {
|
||||||
|
$data{$_->{id}} = $_;
|
||||||
|
}
|
||||||
|
foreach (@ARGV) { print $data{$_}->{river}, " at ", $data{$_}->{station}, "\n"; }
|
||||||
|
' $* )
|
||||||
|
}
|
||||||
|
|
||||||
|
STATION=$(basename $0 | sed 's/^river_level_//g' | cut -d_ -f 3)
|
||||||
|
|
||||||
|
if [ "$1" = "autoconf" ]; then
|
||||||
|
echo "no"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "suggest" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "config" ]; then
|
||||||
|
getstationname $STATION
|
||||||
|
echo "graph_title River Level for $NAME [$STATION]"
|
||||||
|
echo 'graph_args --base 1000 -l 0 '
|
||||||
|
echo 'graph_vlabel station level (metres)'
|
||||||
|
echo 'graph_category rivers'
|
||||||
|
echo 'graph_info This graph shows river levels'
|
||||||
|
echo "level.label $NAME"
|
||||||
|
echo 'level.info Current river level (metres)'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -sS $URLBASE/$STATION |
|
||||||
|
perl -MJSON::PP -e '$d=decode_json(<>) or die; print "level.value $d->{data}->{current}->{level}\n";'
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user