2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/noaaport/novra_s300
2014-09-07 14:20:12 +02:00

85 lines
1.8 KiB
Perl
Executable File

#!/usr/bin/perl -w
# -*- perl -*-
# novra_s300
# Munin plugin for Novra S300 Satellite Receiver
# Displays Signal and Carrier to Noise values
#
#%# family=auto
#%# capabilities=autoconf
#
###############################################################################
#
# This plugin monitors the signal strength and carrier to noise ratio on
# a Novra S300 satellite receiver
# @author Jason Brooks
# @version 2011.05.20.01
# @email icedown@gmail.com
#
# Usage:
# Copy this to your plugin folder (default: /usr/share/munin/plugins)
# Edit is file, replacing CMCS, IP, and PW with your values
# Make a symlink to your active plugins folder (default: /etc/munin/plugins)
# Finally run munin-node-config and restart munin-node
#
#
################################################################################
use strict;
use warnings;
my $CMCS = "/usr/bin/cmcs";
my $IP = "192.168.1.1";
my $PW = "Password";
my $xmlcheck = 0;
if(! eval "require XML::Simple;") {
$xmlcheck = "Missing XML::Simple";
}
my $command = "$CMCS -ip $IP -pw $PW -xmlstatus";
if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) {
print "graph_title Novra S300\n";
print "graph_vlabel Signal\n";
print "graph_category weather\n";
print "s300.signal Signal\n";
print "s300.ctn CtN\n";
exit(0);
}
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) {
if($xmlcheck) {
print "no ($xmlcheck)\n";
exit(0);
}
if(-e $CMCS) {
my $status = `$command`;
if($status =~ m/Login unsuccessful/) {
print "No (Invalid receiver details)\n";
exit(0);
}
print "yes\n";
exit(0);
}
print "no (Cannot locate CMCS)\n";
exit(0);
}
require XML::Simple;
my $data = `$command`;
my $xml = new XML::Simple;
my $output = $xml->XMLin($data);
print "s300.signal " . $output->{SIGNAL_STRENGTH_AS_DBM} . "\n";
print "s300.ctn " . $output->{CARRIER_TO_NOISE} . "\n";