Ik ben eens begonnen om een nieuw nagios scriptie te schrijven in Python, want met bash ga ik er maar lastig uit komen. Ik loop echter tegen een vaag probleem aan dat ik niet snap.
Mijn code:
t0_failures = 3
t0_success = 0
if [t0_failures < 1]:
t0_success = 1
print ' "t0_failures" : "{0}"'.format(t0_failures)
print ' "t0_failures type" : "{0}"'.format(type(t0_failures))
print ' "t0_success" : "{0}"'.format(t0_success)
print ' "t0_success type" : "{0}"'.format(type(t0_success))
Geeft de output:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/angelo/PycharmProjects/untitled/debug.py
"t0_failures" : "3"
"t0_failures type" : "<type 'int'>"
"t0_success" : "1"
"t0_success type" : "<type 'int'>"
Process finished with exit code 0
Wait, what? Ik zou verwachten dat 3 niet kleiner is dan 1, en dat daarom t0_success 0 zou blijven. Maar ben ik nou gekke henkie? Ik kijk vast over een typo heen.
Mijn code:
t0_failures = 3
t0_success = 0
if [t0_failures < 1]:
t0_success = 1
print ' "t0_failures" : "{0}"'.format(t0_failures)
print ' "t0_failures type" : "{0}"'.format(type(t0_failures))
print ' "t0_success" : "{0}"'.format(t0_success)
print ' "t0_success type" : "{0}"'.format(type(t0_success))
Geeft de output:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/angelo/PycharmProjects/untitled/debug.py
"t0_failures" : "3"
"t0_failures type" : "<type 'int'>"
"t0_success" : "1"
"t0_success type" : "<type 'int'>"
Process finished with exit code 0
Wait, what? Ik zou verwachten dat 3 niet kleiner is dan 1, en dat daarom t0_success 0 zou blijven. Maar ben ik nou gekke henkie? Ik kijk vast over een typo heen.

Two advices for network troubleshooting.. learn to draw diagrams in Visio, and THINK IN LAYERS!