Skip to main content
added 371 characters in body
Source Link

I'm trying to utilize argparse for a scale-able solution for SNMP (Nagios).

The issue i'm running into is trying to have constants and vars be passed along through the add_argument()

example :

./SNMP.py -j 10 20 -l

-j would store the str ".1.5.5.8" the arguments after would set the warn integer level and the critical integer level bypassing the defaults set in parser.add_argument()

-l would store a different OID str but would use the default warn and critical levels stored in parser.add_argument()

Thanks!

In short the code i have to get around this dilemma :

parser = argparse.ArgumentParser(description = "This is used to parse latency, jitter, and packet loss on an HDX") parser.add_argument("-j", action = 'append', dest = 'jitter', default = [".2.51.5.9.4","20 40"]) args = parser.parse_args() warn, crit = args.jitter[-1].split() 

I'm trying to utilize argparse for a scale-able solution for SNMP (Nagios).

The issue i'm running into is trying to have constants and vars be passed along through the add_argument()

example :

./SNMP.py -j 10 20 -l

-j would store the str ".1.5.5.8" the arguments after would set the warn integer level and the critical integer level bypassing the defaults set in parser.add_argument()

-l would store a different OID str but would use the default warn and critical levels stored in parser.add_argument()

Thanks!

I'm trying to utilize argparse for a scale-able solution for SNMP (Nagios).

The issue i'm running into is trying to have constants and vars be passed along through the add_argument()

example :

./SNMP.py -j 10 20 -l

-j would store the str ".1.5.5.8" the arguments after would set the warn integer level and the critical integer level bypassing the defaults set in parser.add_argument()

-l would store a different OID str but would use the default warn and critical levels stored in parser.add_argument()

Thanks!

In short the code i have to get around this dilemma :

parser = argparse.ArgumentParser(description = "This is used to parse latency, jitter, and packet loss on an HDX") parser.add_argument("-j", action = 'append', dest = 'jitter', default = [".2.51.5.9.4","20 40"]) args = parser.parse_args() warn, crit = args.jitter[-1].split() 
Source Link

Argparse passing constants and variables

I'm trying to utilize argparse for a scale-able solution for SNMP (Nagios).

The issue i'm running into is trying to have constants and vars be passed along through the add_argument()

example :

./SNMP.py -j 10 20 -l

-j would store the str ".1.5.5.8" the arguments after would set the warn integer level and the critical integer level bypassing the defaults set in parser.add_argument()

-l would store a different OID str but would use the default warn and critical levels stored in parser.add_argument()

Thanks!