Re: nrpe check_proliant
Posted: Mon Nov 18, 2013 4:56 pm
Let us know.
Support for Nagios products and services
https://support.nagios.com/forum/
SELinux - disabled-rwxr-xr-x 1 root root 184800 Jun 29 06:18 hpasmcli
[root@callme-lekki-smg1 plugins]# ./check_proliant.py --type=fan
CRITICAL: Fan #1 Status=No. Fan #1 Speed=-. Fan #1 Redundant=N/A. Fan #2 Status=No. Fan #2 Speed=-. Fan #2 Redundant=N/A.
Code: Select all
echo $PATH[root@callme-lekki-smg1 plugins]# ./check_proliant.py --type=fan
CRITICAL: Fan #1 Status=No. Fan #1 Speed=-. Fan #1 Redundant=N/A. Fan #2 Status=No. Fan #2 Speed=-. Fan #2 Redundant=N/A.
now everything works fine for me34 import time, sys, pexpect, getopt
35
36 HPASMCMD = "sudo /sbin/hpasmcli"
37 HPASM_PROMPT = "hpasmcli>"
38 WARN_TEMP_PCT = 10 # warn if we're within 10% of our temp threshold
39
40 is_CRITICAL = 0
41 is_WARNING = 0
42 message = ""
43
44 fans_to_skip = [ "#1", "#2" ]
45
46 # usage info
47 def usage():
48 print "check_proliant.py - GPL Python Script by Jason Antman"
49 print "http://www.jasonantman.com"
50 print "checks hplog and returns values for use by Nagios"
51 print ""
52 print "Usage:"
53 print "check_hplog.py --type=[fan|ps|temp|proc|dimm|all] [--ignore-redundant] [-h | --h elp]"
54 print " type: what information to get - fan, ps, temp, proc, dimm, all"
55 print " -h --help: print this usage summary"
56
57 def doFans(ignoreRedundant):
58 result = ""
59 try:
60 child = pexpect.spawn(HPASMCMD)
61 child.expect(HPASM_PROMPT)
62 child.sendline("SHOW FANS")
63 child.expect(HPASM_PROMPT)
64 result = child.before
65 child.sendline("EXIT")
66 time.sleep(1)
67 child.close()
68 child.close()
69 except pexpect.ExceptionPexpect:
70 pass
71 except exceptions.OSError:
72 pass
73
74 if result.strip() == "":
75 print "UNKNOWN: Error in pexpect while running hpasmcli"
76 sys.exit(3)
77 lines = result.split("\n")
78
79 # variables to hold state
80 total_fans = 0
81 fans_missing = 0
82 global is_CRITICAL
83 global is_WARNING
84 global message
85 test_ok = 1
86
87 for line in lines:
88 # skip over blank lines or command echo
89 if line.strip() == "" or line.strip() == "SHOW FANS":
90 continue
91 # skip over formatting lines and column headings
92 if line[:8] == "Fan Loc" or line[:8] == "--- ---":
93 continue
94
95 # THIS IS AN IMPORTANT LINE
96 total_fans = total_fans + 1
97 fields = line.split() # get the fields
98 fanNum = fields[0]
99 # is_present
100 if fanNum in fans_to_skip:
101 total_fans -= 1
102 if (fields[2] != "Yes") and (fanNum not in fans_to_skip):
103 fans_missing = fans_missing + 1
104 is_CRITICAL = 1
105 test_ok=0
106 message = message + "Fan " + fanNum + " Status=" + fields[2] + ". "
107 # speed
108 if (fields[3] != "NORMAL") and (fanNum not in fans_to_skip):
109 is_WARNING = 1
110 test_ok=0
111 message = message + "Fan " + fanNum + " Speed=" + fields[3] + ". "
112 # is redundant
113 if (ignoreRedundant == 0) and (fields[5] != "Yes") and (fanNum not in fans_to_skip) :
114 is_CRITICAL = 1
115 test_ok=0
116 message = message + "Fan " + fanNum + " Redundant=" + fields[5] + ". "
117
118 if test_ok == 1:
119 message = message + str(total_fans) + " fans normal."
120 return test_ok