Fix table finder - don't crash but return UNKNOWN
Signed-off-by: Sven Velt <sven@velt.de>
This commit is contained in:
parent
a03ed7df41
commit
96c8da392b
17
check_naf.py
17
check_naf.py
|
@ -344,8 +344,11 @@ class CheckNAF(SNMPMonitoringPlugin):
|
||||||
if volume.endswith('.snapshot'):
|
if volume.endswith('.snapshot'):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
idx = str(self.find_in_table(self.OID['df_FS_Index'], self.OID['df_FS_Name'] , volume))
|
idx = self.find_in_table(self.OID['df_FS_Index'], self.OID['df_FS_Name'] , volume)
|
||||||
|
if idx != None:
|
||||||
sn_idx = int(idx) + 1
|
sn_idx = int(idx) + 1
|
||||||
|
else:
|
||||||
|
sn_idx = None
|
||||||
|
|
||||||
return (idx, sn_idx)
|
return (idx, sn_idx)
|
||||||
|
|
||||||
|
@ -353,6 +356,9 @@ class CheckNAF(SNMPMonitoringPlugin):
|
||||||
def check_vol_data(self, volume, warn, crit):
|
def check_vol_data(self, volume, warn, crit):
|
||||||
(idx, sn_idx) = self.common_vol_idx(volume)
|
(idx, sn_idx) = self.common_vol_idx(volume)
|
||||||
|
|
||||||
|
if idx == None:
|
||||||
|
return self.remember_check('vol_data', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
|
||||||
|
|
||||||
fs_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], idx)) * 1024L
|
fs_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], idx)) * 1024L
|
||||||
fs_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], idx)) * 1024L
|
fs_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], idx)) * 1024L
|
||||||
# fs_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], idx)) * 1024L
|
# fs_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], idx)) * 1024L
|
||||||
|
@ -385,6 +391,9 @@ class CheckNAF(SNMPMonitoringPlugin):
|
||||||
def check_vol_snap(self, volume, warn, crit):
|
def check_vol_snap(self, volume, warn, crit):
|
||||||
(idx, sn_idx) = self.common_vol_idx(volume)
|
(idx, sn_idx) = self.common_vol_idx(volume)
|
||||||
|
|
||||||
|
if idx == None:
|
||||||
|
return self.remember_check('vol_snap', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
|
||||||
|
|
||||||
# fs_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], idx)) * 1024L
|
# fs_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], idx)) * 1024L
|
||||||
# fs_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], idx)) * 1024L
|
# fs_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], idx)) * 1024L
|
||||||
# fs_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], idx)) * 1024L
|
# fs_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], idx)) * 1024L
|
||||||
|
@ -411,6 +420,9 @@ class CheckNAF(SNMPMonitoringPlugin):
|
||||||
def check_vol_inode(self, volume, warn, crit):
|
def check_vol_inode(self, volume, warn, crit):
|
||||||
(idx, sn_idx) = self.common_vol_idx(volume)
|
(idx, sn_idx) = self.common_vol_idx(volume)
|
||||||
|
|
||||||
|
if idx == None:
|
||||||
|
return self.remember_check('vol_inode', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
|
||||||
|
|
||||||
in_used = long(self.SNMPGET(self.OID['df_FS_INodeUsed'] + '.' + idx))
|
in_used = long(self.SNMPGET(self.OID['df_FS_INodeUsed'] + '.' + idx))
|
||||||
in_free = long(self.SNMPGET(self.OID['df_FS_INodeFree'] + '.' + idx))
|
in_free = long(self.SNMPGET(self.OID['df_FS_INodeFree'] + '.' + idx))
|
||||||
in_total = in_used + in_free
|
in_total = in_used + in_free
|
||||||
|
@ -434,6 +446,9 @@ class CheckNAF(SNMPMonitoringPlugin):
|
||||||
def check_vol_files(self, volume, warn, crit):
|
def check_vol_files(self, volume, warn, crit):
|
||||||
(idx, sn_idx) = self.common_vol_idx(volume)
|
(idx, sn_idx) = self.common_vol_idx(volume)
|
||||||
|
|
||||||
|
if idx == None:
|
||||||
|
return self.remember_check('vol_files', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
|
||||||
|
|
||||||
fi_avail = long(self.SNMPGET(self.OID['df_FS_MaxFilesAvail'] + '.' + idx))
|
fi_avail = long(self.SNMPGET(self.OID['df_FS_MaxFilesAvail'] + '.' + idx))
|
||||||
fi_used = long(self.SNMPGET(self.OID['df_FS_MaxFilesUsed'] + '.' + idx))
|
fi_used = long(self.SNMPGET(self.OID['df_FS_MaxFilesUsed'] + '.' + idx))
|
||||||
fi_possible = long(self.SNMPGET(self.OID['df_FS_MaxFilesPossible'] + '.' + idx))
|
fi_possible = long(self.SNMPGET(self.OID['df_FS_MaxFilesPossible'] + '.' + idx))
|
||||||
|
|
|
@ -450,7 +450,7 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
else:
|
else:
|
||||||
self.verbose(2, 'Nothing found!')
|
self.verbose(2, 'Nothing found!')
|
||||||
|
|
||||||
return str(index)
|
return index
|
||||||
|
|
||||||
|
|
||||||
def find_in_table(self, oid_index, oid_values, wanted):
|
def find_in_table(self, oid_index, oid_values, wanted):
|
||||||
|
@ -463,7 +463,7 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
|
||||||
if len(indexes) != len(values):
|
if len(indexes) != len(values):
|
||||||
self.back2nagios(3, 'Different data from 2 SNMP Walks!')
|
self.back2nagios(3, 'Different data from 2 SNMP Walks!')
|
||||||
|
|
||||||
return str(self.find_index_for_value(indexes, values, wanted))
|
return self.find_index_for_value(indexes, values, wanted)
|
||||||
|
|
||||||
|
|
||||||
def SNMPGET(self, baseoid, idx=None, exitonerror=True):
|
def SNMPGET(self, baseoid, idx=None, exitonerror=True):
|
||||||
|
|
Loading…
Reference in a new issue