rivers/getstations.pl

20 lines
739 B
Perl
Raw Normal View History

2014-01-05 10:54:46 +00:00
#!/usr/bin/env perl
# (C) Matthew Slowe, 2014
# This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
# http://creativecommons.org/licenses/by-sa/4.0/
2014-01-04 20:39:39 +00:00
use JSON::PP;
$DEBUG = $ENV{DEBUG};
$CatchmentId = shift @ARGV;
print "Decoding...\n" if $DEBUG;
$in = decode_json(<>) or die;
2014-01-07 10:43:18 +00:00
print "# ln -s /path/to/river_levels_ /etc/munin/plugins/river_levels_$CatchmentId\n\n[river_levels_$CatchmentId]\nenv.urlbase http://path.to/service\nenv.catchmentname Name\nenv.stations " unless $DEBUG;
2014-01-04 20:39:39 +00:00
foreach $station (@{$in->{data}}) {
if ($station->{url} =~ /CatchmentId=$CatchmentId$/) {
print "$station->{id}", $DEBUG ? ": $station->{station} on $station->{river}\n" : " ";
}
}
print "\n" unless $DEBUG;