bundles/icinga2: always print status line in check_usv_snmp
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit
This commit is contained in:
parent
07d5a8cdae
commit
18674a1a4a
1 changed files with 17 additions and 16 deletions
|
@ -28,33 +28,22 @@ try:
|
|||
|
||||
# Estimated runtime in minutes
|
||||
if int(result['1.2.3.0']) < 15:
|
||||
crit.add('Remaining runtime is less than 15 minutes! Only {} minutes left.'.format(result['1.2.3.0']))
|
||||
crit.add('Remaining runtime is less than 15 minutes!')
|
||||
elif int(result['1.2.3.0']) < 25:
|
||||
warn.add('Remaining runtime is less than 25 minutes! Only {} minutes left.'.format(result['1.2.3.0']))
|
||||
warn.add('Remaining runtime is less than 25 minutes!')
|
||||
|
||||
# Battery status in percent
|
||||
if int(result['1.2.4.0']) < 10:
|
||||
crit.add('Remaining runtime is less than 10%! Only {}% left.'.format(result['1.2.4.0']))
|
||||
crit.add('Remaining runtime is less than 10%!')
|
||||
elif int(result['1.2.4.0']) < 25:
|
||||
warn.add('Remaining runtime is less than 25%! Only {}% left.'.format(result['1.2.4.0']))
|
||||
warn.add('Remaining runtime is less than 25%!')
|
||||
|
||||
# Output load in percent
|
||||
if int(result['1.4.4.1.5.1']) > 90:
|
||||
crit.add('Output Power is more than 90% of rated capacity: {} W'.format(result['1.4.4.1.4.1']))
|
||||
crit.add('Output Power is more than 90% of rated capacity!')
|
||||
elif int(result['1.4.4.1.5.1']) > 80:
|
||||
warn.add('Output Power is more than 80% of rated capacity: {} W'.format(result['1.4.4.1.4.1']))
|
||||
warn.add('Output Power is more than 80% of rated capacity!')
|
||||
|
||||
for line in sorted(crit):
|
||||
print(line)
|
||||
|
||||
for line in sorted(warn):
|
||||
print(line)
|
||||
|
||||
if crit:
|
||||
exit(2)
|
||||
elif warn:
|
||||
exit(1)
|
||||
else:
|
||||
print('{model} running{from_bat} at {out_pct}% load ({out_w} W), battery at {bat_pct}% ({bat_min} min)'.format(
|
||||
model=result['1.1.2.0'],
|
||||
out_pct=result['1.4.4.1.5.1'],
|
||||
|
@ -63,6 +52,18 @@ try:
|
|||
bat_min=result['1.2.3.0'],
|
||||
from_bat=' from battery' if int(result['1.2.2.0']) else '',
|
||||
))
|
||||
|
||||
for line in sorted(crit):
|
||||
print('CRIT: ' + line)
|
||||
|
||||
for line in sorted(warn):
|
||||
print('WARN: ' + line)
|
||||
|
||||
if crit:
|
||||
exit(2)
|
||||
elif warn:
|
||||
exit(1)
|
||||
else:
|
||||
exit(0)
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
|
|
Loading…
Reference in a new issue