Sep-18-2018, 01:49 PM
This is exactly the purpose of a function().
Here I pass the index (
Here I pass the index (
idx
) for test_tuple()
but you can make a for and check all the content of t
too.def test_tuple(input_value, t, idx): if input_value in ["desert", "ocean"]: if t[0] > c_value: print("CRITICAL - Active: ",t[idx]) sys.exit(2) elif t[0] > w_value: print("WARNING - Active:",t[idx]) sys.exit(1) else: print("OK - Active Users:",t[idx]) sys.exit(0) else: print("Invalid input") # validate args if len(sys.argv)==1: print("# Usage:\t -w <warn> -c <crit>") sys.exit("No argument pass") else: test_tuple(input_value, t, idx)PS: If you use
tuple
in your code, you'll overwrite the tuple class of python!