1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-22 10:23:46 +01:00

--sudo parameter added

This commit is contained in:
Páll Guðjón Sigurðsson 2010-09-10 11:45:53 +00:00
parent 59501029ff
commit 92848de04c

View File

@ -47,6 +47,7 @@ state[unknown] = "Unknown"
longserviceoutput="\n" longserviceoutput="\n"
perfdata="" perfdata=""
summary="" summary=""
sudo=False
from sys import exit from sys import exit
@ -155,10 +156,15 @@ def run_hpacucli(type='controllers', controller=None):
#command="hpacucli controller slot=1 ld all show detail" #command="hpacucli controller slot=1 ld all show detail"
#command="hpacucli controller slot=1 ld all show detail" #command="hpacucli controller slot=1 ld all show detail"
debug ( command ) debug ( command )
if sudo: command = "sudo " + command
output = runCommand(command) output = runCommand(command)
# Some basic error checking # Some basic error checking
if output.find('Error: You need to have administrator rights to continue.') > -1: error_strings = [ 'Permission denied' ]
error_strings.append('Error: You need to have administrator rights to continue.')
for error in error_strings:
if output.find( error ) > -1 and output.find("sudo") != 0:
command = "sudo " + command command = "sudo " + command
print command
output = runCommand(command) output = runCommand(command)
output = output.split('\n') output = output.split('\n')
objects = [] objects = []
@ -299,6 +305,9 @@ def parse_arguments():
elif arg == '--debug': elif arg == '--debug':
global debugging global debugging
debugging = True debugging = True
elif arg == '--sudo':
global sudo
sudo = True
else: else:
print_help() print_help()
exit(unknown) exit(unknown)