From dacd37d046702af2125054836b38f03869c5b5ed Mon Sep 17 00:00:00 2001 From: nknotzer Date: Wed, 26 Sep 2012 16:41:06 +0300 Subject: [PATCH] Update plugins/dvb/femon # v1.3 25/10/2011 - Configure upper and lower graph limits with graph_args environment variable. --- plugins/dvb/femon | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/plugins/dvb/femon b/plugins/dvb/femon index eb64a55d..2e429f2b 100755 --- a/plugins/dvb/femon +++ b/plugins/dvb/femon @@ -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 # # 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 was used as a template! +# The smart_ plugin by Nicolas Stransky 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 @@ -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 @@ -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') @@ -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] @@ -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 ### @@ -261,7 +264,7 @@ B use this to build the service links for this wildcard-pl =head1 VERSION -Version 1.2 +Version 1.3 =head1 BUGS @@ -271,7 +274,7 @@ None known (C) 2011 Nicolas Knotzer -The smart_ plugin by Nicolas Stransky was used as a template! +The smart_ plugin by Nicolas Stransky was used as a template for this plugin! =head1 LICENSE