Skip to content

Commit

Permalink
Update plugins/dvb/femon
Browse files Browse the repository at this point in the history
# v1.3 25/10/2011 - Configure upper and lower graph limits with graph_args environment variable.
  • Loading branch information
nknotzer committed Sep 26, 2012
1 parent bac376c commit dacd37d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions plugins/dvb/femon
Expand Up @@ -14,16 +14,18 @@
#
# Parameters
# femonpath - Specify path to femon program (Default: /usr/bin/femon)
# graph_args - Specifiy graph args (Default: --lower-limit 0 --upper-limit 100 --rigid)
#
# Author: Nicolas Knotzer <nknotzer@gmail.com>
#
# v1.0 02/10/2011
# v1.1 20/10/2011 - Prints OSError.strerror in verbose mode, uses rsplit instead of split for parsing femon output
# v1.2 21/20/2011 - Uses subprocess.Popen instead of subprocess.check_output for compatibility with older python versions
# v1.2 21/10/2011 - Uses subprocess.Popen instead of subprocess.check_output for better compatibility with older python versions (i.e. works with python version >= 2.4)
# v1.3 25/10/2011 - Configure upper and lower graph limits with graph_args environment variable.
#
# Copyright (c) 2011 Nicolas Knotzer.
#
# The smart_ plugin by Nicolas Stransky <Nico@stransky.cx> was used as a template!
# The smart_ plugin by Nicolas Stransky <Nico@stransky.cx> was used as a template for this plugin!
#
# Permission to use, copy, and modify this software with or without fee
# is hereby granted, provided that this entire notice is included in
Expand All @@ -44,13 +46,12 @@
## You may edit the following 2 variables
# Increase verbosity (True/False)
verbose=False
# Modify to your needs:
statefiledir='/var/lib/munin/plugin-state'

# You may not modify anything below this line

import os, sys, string, subprocess
from math import log
plugin_version="1.2"
plugin_version="1.3"

def verboselog(s):
global plugin_name
Expand Down Expand Up @@ -90,10 +91,10 @@ def get_dvb_adapter_name() :
def print_adapter_config(dvb_adapter) :
verboselog('Printing configuration')
print ('graph_title DVB Femon Sensors '+dvb_adapter[0])
print ('graph_args -l 0')
print ('graph_args '+os.getenv('graph_args','--lower-limit 0 --upper-limit 100 --rigid'))
print ('graph_vlabel Quality')
print ('graph_category DVB')
print ('graph_info This graph shows the femon values for your DVB '+dvb_adapter[0])
print ('graph_info This graph shows femon output for your dvb-'+dvb_adapter[0])

print ('str.label Signal Strength')
print ('str.info Signal Strength')
Expand All @@ -114,7 +115,6 @@ def print_adapter_config(dvb_adapter) :

def print_dvb_adapter_values(dvb_adapter) :
try :

verboselog('Reading values from '+dvb_adapter[0])
mypipe = subprocess.Popen([os.getenv('femonpath','/usr/bin/femon'), '-H', '-c 1', '-a '+dvb_adapter[0].replace('adapter','')], stdout=subprocess.PIPE)
femon_output = mypipe.communicate()[0]
Expand All @@ -123,12 +123,15 @@ def print_dvb_adapter_values(dvb_adapter) :
verboselog('Cannot access femon values! Check user rights or proper femon installation.')
verboselog('Error: '+e.strerror)
sys.exit(1)
splitstr=femon_output.rsplit ('|',5)
print ('str.value '+splitstr[1].replace('signal','').strip(' %'))
print ('snr.value '+splitstr[2].replace('snr','').strip(' %'))
print ('ber.value '+splitstr[3].replace('ber','').strip(' '))
print ('unc.value '+splitstr[4].replace('unc','').strip(' '))

try :
splitstr=femon_output.rsplit ('|',5)
print ('str.value '+splitstr[1].replace('signal','').strip(' %'))
print ('snr.value '+splitstr[2].replace('snr','').strip(' %'))
print ('ber.value '+splitstr[3].replace('ber','').strip(' '))
print ('unc.value '+splitstr[4].replace('unc','').strip(' '))
except :
verboselog ('Error processing femon output string.')
sys.exit(1)

### Main part ###

Expand Down Expand Up @@ -261,7 +264,7 @@ B<munin-node-configure> use this to build the service links for this wildcard-pl
=head1 VERSION
Version 1.2
Version 1.3
=head1 BUGS
Expand All @@ -271,7 +274,7 @@ None known
(C) 2011 Nicolas Knotzer <nknotzer@gmail.com>
The smart_ plugin by Nicolas Stransky <Nico@stransky.cx> was used as a template!
The smart_ plugin by Nicolas Stransky <Nico@stransky.cx> was used as a template for this plugin!
=head1 LICENSE
Expand Down

0 comments on commit dacd37d

Please sign in to comment.