From ba0184341fad2d11673cd6cb118e516519dfbaf9 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Fri, 13 Jul 2012 11:52:32 +0200 Subject: [PATCH] check_naf: Teach all vol_* checks target 'ALL'. This target may be used to check all volumes against the specified thresholds. This currently involves a lot of SNMP queries, so it's rather slow. --- check_naf.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/check_naf.py b/check_naf.py index f9dec94..6228481 100755 --- a/check_naf.py +++ b/check_naf.py @@ -647,7 +647,7 @@ class CheckNAF(SNMPMonitoringPlugin): return target - def check_vol_data(self, volume, warn, crit): + def check_vol_data_one(self, volume, warn, crit): (idx, sn_idx) = self.common_vol_idx(volume) if idx == None: @@ -682,7 +682,19 @@ class CheckNAF(SNMPMonitoringPlugin): return self.remember_check('vol_data', returncode, output, perfdata=perfdata, target=target) - def check_vol_snap(self, volume, warn, crit): + def check_vol_data(self, volume, warn, crit): + if volume.startswith('ALL'): + volumes = self.SNMPWALK(self.OID['df_FS_Name']) + for vol in volumes: + if vol.endswith('.snapshot') or vol.endswith('.snapshot/'): + continue + + self.check_vol_data_one(vol, warn, crit) + else: + return self.check_vol_data_one(volume, warn, crit) + + + def check_vol_snap_one(self, volume, warn, crit): (idx, sn_idx) = self.common_vol_idx(volume) if idx == None: @@ -715,7 +727,19 @@ class CheckNAF(SNMPMonitoringPlugin): return self.remember_check('vol_snap', returncode, output, perfdata=perfdata, target=target) - def check_vol_inode(self, volume, warn, crit): + def check_vol_snap(self, volume, warn, crit): + if volume.startswith('ALL'): + volumes = self.SNMPWALK(self.OID['df_FS_Name']) + for vol in volumes: + if vol.endswith('.snapshot') or vol.endswith('.snapshot/'): + continue + + self.check_vol_snap_one(vol, warn, crit) + else: + return self.check_vol_snap_one(volume, warn, crit) + + + def check_vol_inode_one(self, volume, warn, crit): (idx, sn_idx) = self.common_vol_idx(volume) if idx == None: @@ -741,7 +765,19 @@ class CheckNAF(SNMPMonitoringPlugin): return self.remember_check('vol_inode', returncode, output, perfdata=perfdata, target=target) - def check_vol_files(self, volume, warn, crit): + def check_vol_inode(self, volume, warn, crit): + if volume.startswith('ALL'): + volumes = self.SNMPWALK(self.OID['df_FS_Name']) + for vol in volumes: + if vol.endswith('.snapshot') or vol.endswith('.snapshot/'): + continue + + self.check_vol_inode_one(vol, warn, crit) + else: + return self.check_vol_inode_one(volume, warn, crit) + + + def check_vol_files_one(self, volume, warn, crit): (idx, sn_idx) = self.common_vol_idx(volume) if idx == None: @@ -769,6 +805,18 @@ class CheckNAF(SNMPMonitoringPlugin): return self.remember_check('vol_files', returncode, output, perfdata=perfdata, target=target) + def check_vol_files(self, volume, warn, crit): + if volume.startswith('ALL'): + volumes = self.SNMPWALK(self.OID['df_FS_Name']) + for vol in volumes: + if vol.endswith('.snapshot') or vol.endswith('.snapshot/'): + continue + + self.check_vol_files_one(vol, warn, crit) + else: + return self.check_vol_files_one(volume, warn, crit) + +