root / plugins / noaaport / novra_s300 @ 81db94e2
Historique | Voir | Annoter | Télécharger (1,83 ko)
| 1 |
#!/usr/bin/perl -w |
|---|---|
| 2 |
# -*- perl -*- |
| 3 |
# novra_s300 |
| 4 |
# Munin plugin for Novra S300 Satellite Receiver |
| 5 |
# Displays Signal and Carrier to Noise values |
| 6 |
# |
| 7 |
#%# family=auto |
| 8 |
#%# capabilities=autoconf |
| 9 |
# |
| 10 |
############################################################################### |
| 11 |
# |
| 12 |
# This plugin monitors the signal strength and carrier to noise ratio on |
| 13 |
# a Novra S300 satellite receiver |
| 14 |
# @author Jason Brooks |
| 15 |
# @version 2011.05.20.01 |
| 16 |
# @email icedown@gmail.com |
| 17 |
# |
| 18 |
# Usage: |
| 19 |
# Copy this to your plugin folder (default: /usr/share/munin/plugins) |
| 20 |
# Edit is file, replacing CMCS, IP, and PW with your values |
| 21 |
# Make a symlink to your active plugins folder (default: /etc/munin/plugins) |
| 22 |
# Finally run munin-node-config and restart munin-node |
| 23 |
# |
| 24 |
# |
| 25 |
################################################################################ |
| 26 |
|
| 27 |
|
| 28 |
use strict; |
| 29 |
use warnings; |
| 30 |
|
| 31 |
my $CMCS = "/usr/bin/cmcs"; |
| 32 |
my $IP = "192.168.1.1"; |
| 33 |
my $PW = "Password"; |
| 34 |
|
| 35 |
my $xmlcheck = 0; |
| 36 |
|
| 37 |
if(! eval "require XML::Simple;") {
|
| 38 |
$xmlcheck = "Missing XML::Simple"; |
| 39 |
} |
| 40 |
my $command = "$CMCS -ip $IP -pw $PW -xmlstatus"; |
| 41 |
|
| 42 |
|
| 43 |
if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) {
|
| 44 |
print "graph_title Novra S300\n"; |
| 45 |
print "graph_vlabel Signal\n"; |
| 46 |
print "graph_category weather\n"; |
| 47 |
print "s300.signal Signal\n"; |
| 48 |
print "s300.ctn CtN\n"; |
| 49 |
exit(0); |
| 50 |
} |
| 51 |
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) {
|
| 52 |
if($xmlcheck) {
|
| 53 |
print "no ($xmlcheck)\n"; |
| 54 |
exit(0); |
| 55 |
} |
| 56 |
|
| 57 |
if(-e $CMCS) {
|
| 58 |
my $status = `$command`; |
| 59 |
if($status =~ m/Login unsuccessful/) {
|
| 60 |
print "No (Invalid receiver details)\n"; |
| 61 |
exit(0); |
| 62 |
} |
| 63 |
print "yes\n"; |
| 64 |
exit(0); |
| 65 |
} |
| 66 |
|
| 67 |
print "no (Cannot locate CMCS)\n"; |
| 68 |
exit(0); |
| 69 |
|
| 70 |
|
| 71 |
} |
| 72 |
require XML::Simple; |
| 73 |
|
| 74 |
|
| 75 |
my $data = `$command`; |
| 76 |
|
| 77 |
my $xml = new XML::Simple; |
| 78 |
|
| 79 |
my $output = $xml->XMLin($data); |
| 80 |
|
| 81 |
print "s300.signal " . $output->{SIGNAL_STRENGTH_AS_DBM} . "\n";
|
| 82 |
print "s300.ctn " . $output->{CARRIER_TO_NOISE} . "\n";
|
| 83 |
|
| 84 |
|
