Module: check_mk
Branch: master
Commit: d48583f5059c5dfba846025fd826e2336962d618
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d48583f5059c5d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 16 08:30:03 2010 +0100
Cleaned up global var names of several checks
---
ChangeLog | 1 +
checks/cisco_temp_perf | 4 ++--
checks/fsc_ipmi_mem_status | 4 +---
checks/hp_blade_psu | 4 ++--
checks/j4p_performance | 4 ++--
checks/netctr | 6 +++---
checks/smbios_sel | 4 +---
checks/statgrab_net | 4 ++--
checks/tcp_conn_stats | 4 ++--
doc/helpers/validate_checks | 7 ++++++-
10 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b48d32e..fffc53b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,7 @@
* j4p_performance: Added experimental agent plugin fetching data via
jmx4perl agent (does not need jmx4perl on Nagios)
* j4p_performance.mem: added new experimental check for memory usage via JMX.
+ * Cleaned up several checks to meet the variable naming conventions
Multisite:
* The custom open/close states of custom links are now stored for each
diff --git a/checks/cisco_temp_perf b/checks/cisco_temp_perf
index b5a306f..958695c 100644
--- a/checks/cisco_temp_perf
+++ b/checks/cisco_temp_perf
@@ -46,7 +46,7 @@
# sensor generates a abnormal data like
# 1000 C.
-cisco_envmon_states = {
+cisco_temp_perf_envmon_states = {
1: "normal",
2: "warning",
3: "critical",
@@ -64,7 +64,7 @@ def check_cisco_temp_perf(item, params, info):
temp = int(line[1])
perfdata = [("temp", temp)]
state = int(line[3])
- statename = cisco_envmon_states.get(state, "(invalid)")
+ statename = cisco_temp_perf_envmon_states.get(state, "(invalid)")
if state == 1:
return (0, "OK - %s degrees" % temp, perfdata)
elif state == 2:
diff --git a/checks/fsc_ipmi_mem_status b/checks/fsc_ipmi_mem_status
index 4f367c6..67e29b5 100644
--- a/checks/fsc_ipmi_mem_status
+++ b/checks/fsc_ipmi_mem_status
@@ -48,8 +48,6 @@ fsc_ipmi_mem_status_levels = [
(2, 'Prefail (module exceeded the correctable errors threshold)'),
]
-statname = [ "OK", "WARN", "CRIT" ]
-
def inventory_fsc_ipmi_mem_status(checkname, info):
# Skip all lines which have
# a) An error (Begin with "E")
@@ -64,7 +62,7 @@ def check_fsc_ipmi_mem_status(name, _no_params, info):
elif line[1] == name:
level = int(line[2])
return (fsc_ipmi_mem_status_levels[level][0], "%s: %s" % (
- statname[fsc_ipmi_mem_status_levels[level][0]],
+ nagios_state_names[fsc_ipmi_mem_status_levels[level][0]],
fsc_ipmi_mem_status_levels[level][1]))
return (3, "UNKNOWN - item %s not found" % name)
diff --git a/checks/hp_blade_psu b/checks/hp_blade_psu
index 9c84e34..76818dc 100644
--- a/checks/hp_blade_psu
+++ b/checks/hp_blade_psu
@@ -57,7 +57,7 @@ hp_blade_psu_status = {
15: 'nvramInvalid', 16: 'calibrationTableInvalid',
}
-hp_blade_inputline_status = {
+hp_blade_psu_inputline_status = {
1: 'noError', 2: 'lineOverVoltage',
3: 'lineUnderVoltage', 4: 'lineHit',
5: 'brownOut', 6: 'linePowerLoss',
@@ -82,7 +82,7 @@ def check_hp_blade_psu(item, params, info):
detail_output = ', Output: %sW' % line[3]
else:
detail_output = int(line[4]) >= 1 and ' (%s)' %
hp_blade_psu_status[4] or ''
- detail_output = int(line[5]) >= 1 and ', Inputline: %s' %
hp_blade_inputline_status[5] or ''
+ detail_output = int(line[5]) >= 1 and ', Inputline: %s' %
hp_blade_psu_inputline_status[5] or ''
perfdata = [ ('output', line[3]) ]
diff --git a/checks/j4p_performance b/checks/j4p_performance
index b11d40c..3e8feec 100644
--- a/checks/j4p_performance
+++ b/checks/j4p_performance
@@ -24,7 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-j4p_mem_default_levels = ( 1000, 2000 ) # MB
+j4p_performance_mem_default_levels = ( 1000, 2000 ) # MB
def j4p_performance_parse(info):
parsed = {}
@@ -36,7 +36,7 @@ def j4p_performance_parse(info):
def inventory_j4p_performance_mem(checktype, info):
parsed = j4p_performance_parse(info)
- return [ (k, "j4p_mem_default_levels") for k in parsed ]
+ return [ (k, "j4p_performance_mem_default_levels") for k in parsed ]
def check_j4p_performance_mem(item, params, info):
warn, crit = params
diff --git a/checks/netctr b/checks/netctr
index 03513c9..10ec00a 100644
--- a/checks/netctr
+++ b/checks/netctr
@@ -33,7 +33,7 @@ netctr_counters = [ 'rx_bytes', 'tx_bytes',
'rx_packets', 'tx_packets', 'rx_err
# Item is devicename.countername, eg,
# eth0.tx_collisions. Available are:
-counter_indices = {
+netctr_counter_indices = {
# Receive
'rx_bytes' : 0,
'rx_packets' : 1,
@@ -64,7 +64,7 @@ def check_netctr_combined(nic, params, info):
except:
warn, crit = (0.01, 0.1)
- global counter_indices
+ global netctr_counter_indices
this_time = int(info[0][0])
# Look for line describing this nic
@@ -76,7 +76,7 @@ def check_netctr_combined(nic, params, info):
packets_per_sec = 0.0
counter_wrapped = None
for countername in netctr_counters:
- index = counter_indices[countername]
+ index = netctr_counter_indices[countername]
value = int(nicline[index + 1])
try:
timedif, items_per_sec = get_counter( "netctr." + nic +
"." + countername, this_time, value)
diff --git a/checks/smbios_sel b/checks/smbios_sel
index e07e2ca..a356056 100644
--- a/checks/smbios_sel
+++ b/checks/smbios_sel
@@ -69,8 +69,6 @@
from datetime import datetime
import time
-statname = [ "OK", "WARN", "CRIT" ]
-
smbios_sel_msg_types = {
#Type: (Number-of-Entries Threshold, Status-Code, Current Count, Last Entry, Alias)
0: [1, 1, 0, None, None],
@@ -166,6 +164,6 @@ def check_smbios_sel(_no_item, _no_params, info):
smbios_sel_msg_types[type][2],
smbios_sel_msg_types[type][3])
- return (sum_status, "%s: %s" % (statname[sum_status], sum_output))
+ return (sum_status, "%s: %s" % (nagios_state_names[sum_status],
sum_output))
check_info['smbios_sel'] = (check_smbios_sel, "SMBIOS Event Log", 0,
inventory_smbios_sel)
diff --git a/checks/statgrab_net b/checks/statgrab_net
index 21eda10..536e8f9 100644
--- a/checks/statgrab_net
+++ b/checks/statgrab_net
@@ -27,7 +27,7 @@
inventory_netctr_counters = [ 'rx_bytes', 'tx_bytes',
'rx_packets', 'tx_packets', 'rx_errors', 'tx_errors',
'tx_collisions' ]
-statgrab_netif_counternames = {
+statgrab_net_counternames = {
"collisions" : "tx_collisions",
"ierrors" : "rx_errors",
"ipackets" : "rx_packets",
@@ -131,7 +131,7 @@ def check_statgrab_net_ctr(nic, _no_params, info):
nicname, ctr = var.split('.')
if nicname != nic:
continue
- countername = statgrab_netif_counternames.get(ctr, None)
+ countername = statgrab_net_counternames.get(ctr, None)
if countername == None:
continue
value = int(value)
diff --git a/checks/tcp_conn_stats b/checks/tcp_conn_stats
index 3f9cf18..712c650 100644
--- a/checks/tcp_conn_stats
+++ b/checks/tcp_conn_stats
@@ -24,7 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-tcp_conn_states = [
+tcp_conn_stats_states = [
"ESTABLISHED", # connection up and passing data
"SYN_SENT", # session has been requested by us; waiting for reply from
remote endpoint
"SYN_RECV", # session has been requested by a remote endpoint for a socket
on which we were listening
@@ -50,7 +50,7 @@ def check_tcp_conn_stats(item, params, info):
worst_state = 0
info = []
perfdata = []
- for state in tcp_conn_states:
+ for state in tcp_conn_stats_states:
num = int(stats.get(state, 0))
if num > 0:
infotext = "%s: %d" % (state, num)
diff --git a/doc/helpers/validate_checks b/doc/helpers/validate_checks
index 0d2ab6c..7dd074d 100755
--- a/doc/helpers/validate_checks
+++ b/doc/helpers/validate_checks
@@ -110,7 +110,12 @@ def usage():
print "No real help available... The only option is -v|--verbose."
sys.exit(0)
-ignored_variables = [ 'datetime', ]
+ignored_variables = [
+ # Python Module
+ 'datetime', 'timedelta',
+ # Misc vars
+ 'vars_before_check',
+]
# Load all checks and record global var definitions
# Also read the man pages