Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a -i option for changing the style #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions idrac_2.2rc4 → idrac_2.2rc5
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__author__ = 'Nguyen Duc Trung Dung'
__contact__ = '[email protected] - [email protected]'
__blog__ = 'dybn.blogspot.com'
__version__ = '2.2rc4'
__version__ = '2.2rc5'
__license__ = 'GPLv3'

import commands
Expand Down Expand Up @@ -172,6 +172,7 @@ def cli_reader():
optp.add_option('-n', '--no-alert', help='always return with exit code 0', action='store_true', dest='no_alert')
optp.add_option('-w', help='hardware to check. If no hardware specified, all will be listed: DISK, VDISK, FAN, SENSOR, CPU, PS, PU, MEM, BATTERY', dest='hardware', metavar='FAN|FAN#1|MEM')
optp.add_option('-p', help='enable performance data', dest='perf', action='store_true')
optp.add_option('-i', help='only display WARN and CRIT, else OK', dest='style', action='store_true')
optp.add_option('--fan-warn', help='FAN rpm warning thresholds', dest='fan_warn', metavar='MIN,MAX')
optp.add_option('--fan-crit', help='FAN rpm critical thresholds', dest='fan_crit', metavar='MIN,MAX')
optp.add_option('--temp-warn', help='TEMPERATURE warning thresholds', dest='temp_warn', metavar='MIN,MAX')
Expand Down Expand Up @@ -211,6 +212,8 @@ def cli_reader():
if opts.crit: conf['state_crit'] = opts.crit
if opts.no_alert is True: conf['alert'] = False
if opts.perf is True: conf['perf'] = True
if opts.style is True: conf['style'] = True
else: conf['style'] = False
# parse fan threshold
conf['fan_thresholds'] = []
for x in [opts.fan_warn, opts.fan_crit]:
Expand Down Expand Up @@ -842,7 +845,26 @@ if __name__ == '__main__':
config_verify()
if conf['hardware'] is None: # check all hardware
exit_code = 0
for key in all_hardware.keys():
if conf['style'] is True:
for key in all_hardware.keys():
conf['hardware'] = [key, None]
hw_info = all_hardware[key]
result, tmp_code = PARSER().main()
if tmp_code[0] == 2:
exit_code = tmp_code[0]
for line in result:
if "CRITICAL" in line and "systemStateGlobal" not in line:
print(line)
elif tmp_code[0] == 1:
for line in result:
if "(!)" in line and "systemStateGlobal" not in line:
print(line)
if exit_code != 2:
exit_code = tmp_code[0]
if exit_code == 0:
print("OK")
else:
for key in all_hardware.keys():
conf['hardware'] = [key, None]
hw_info = all_hardware[key]
result, tmp_code = PARSER().main()
Expand Down