From 192618ecef7f86fdc7431a5d8756ccd5691a5d35 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 15 Feb 2022 12:06:26 +0100 Subject: [PATCH 1/2] remove tabs --- check_aacraid | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/check_aacraid b/check_aacraid index a02ddef..278353e 100755 --- a/check_aacraid +++ b/check_aacraid @@ -14,9 +14,9 @@ segmentfind = re.compile(r'(\d+,\d+)') def check_arcconf(): arcconf = None for p in os.environ['PATH'].split(os.path.pathsep)+['/usr/StorMan/']: - if os.path.isfile(os.path.join(p, 'arcconf')): - arcconf = os.path.join(p, 'arcconf') - break + if os.path.isfile(os.path.join(p, 'arcconf')): + arcconf = os.path.join(p, 'arcconf') + break return arcconf if not hasattr(subprocess, 'check_output'): @@ -150,7 +150,7 @@ def cmk_info(controllerid): statustxt = 'OK' if cinfo['status'] != 'Optimal': status = 2 - statustxt = 'CRITICAL' + statustxt = 'CRITICAL' item_name = 'Controller_'+str(controllerid) performance_data = '-' check_output = statustxt + " Model:%(model)s Serial:%(serial)s Bios:%(bios)s Firmware:%(firmware)s Driver:%(driver)s LDs:%(lds)s Status:%(status)s" % cinfo @@ -160,25 +160,25 @@ def cmk_info(controllerid): for l in range(0,cinfo['lds']): linfo = get_logicaldevice_info(controllerid,l) status = 0 - statustxt = 'OK' - if linfo['status'] != 'Optimal': + statustxt = 'OK' + if linfo['status'] != 'Optimal': status = 2 - statustxt = 'CRITICAL' - item_name = 'LogicalDevice_'+linfo['id'] - performance_data = '-' - check_output = statustxt + " RAID:%(level)s Size:%(size)s Status:%(status)s" % linfo + statustxt = 'CRITICAL' + item_name = 'LogicalDevice_'+linfo['id'] + performance_data = '-' + check_output = statustxt + " RAID:%(level)s Size:%(size)s Status:%(status)s" % linfo output.append("%s %s %s %s" % (status,item_name,performance_data,check_output) ) # LOGICAL DEVICE SEGMENTS - ldsegs = linfo['members'] - segn = 0 - for m in ldsegs: + ldsegs = linfo['members'] + segn = 0 + for m in ldsegs: status = 0 - statustxt = 'OK' - if m.startswith('Missing'): + statustxt = 'OK' + if m.startswith('Missing'): status = 2 - statustxt = 'CRITICAL' - item_name = 'LogicalDevice_'+linfo['id']+'_Segment_'+str(segn) + statustxt = 'CRITICAL' + item_name = 'LogicalDevice_'+linfo['id']+'_Segment_'+str(segn) performance_data = '-' check_output = statustxt + " " + m output.append("%s %s %s %s" % (status,item_name,performance_data,check_output) ) @@ -192,7 +192,7 @@ def cmk_info(controllerid): statustxt = 'OK' if disks[k]['status'] not in ["Online", "Dedicated Hot-Spare", "Ready", "Online (JBOD)" ]: status = 2 - statustxt = 'CRITICAL' + statustxt = 'CRITICAL' item_name = 'Disk_'+disks[k]['id'] performance_data = '-' check_output = statustxt + " DiskID:%(diskid)s Model:%(model)s Vendor:%(vendor)s Status:%(status)s" % disks[k] @@ -200,10 +200,10 @@ def cmk_info(controllerid): return '\n'.join(output) if __name__ == '__main__': - arcconf = check_arcconf() - if arcconf: - n = get_num_controllers() - for c in range(1,n+1): - print cmk_info(c) - else: - print "3 No_arcconf_Found - UNKNOWN (No arcconf binary Found or no Adaptec Controller present (remove check from local checks))" + arcconf = check_arcconf() + if arcconf: + n = get_num_controllers() + for c in range(1,n+1): + print cmk_info(c) + else: + print "3 No_arcconf_Found - UNKNOWN (No arcconf binary Found or no Adaptec Controller present (remove check from local checks))" From 8e77c82d2cfe42e71769c4aca669c8bbc156786d Mon Sep 17 00:00:00 2001 From: root Date: Tue, 15 Feb 2022 12:50:51 +0100 Subject: [PATCH 2/2] migrate to python3 --- check_aacraid | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/check_aacraid b/check_aacraid index 278353e..953752d 100755 --- a/check_aacraid +++ b/check_aacraid @@ -41,7 +41,7 @@ def get_val(string): def get_num_controllers(): cmd = [arcconf, 'GETVERSION'] ret = subprocess.check_output(cmd) - for line in ret.splitlines(): + for line in ret.decode('utf-8').splitlines(): if line.startswith('Controllers found:'): num = get_val(line) return int(num) @@ -52,7 +52,7 @@ def get_controller_info(controllerid): ret = subprocess.check_output(cmd) model = serial = bios = firmware = driver = bootflash = lds = status = None id = 'c%i' % controllerid - for line in ret.splitlines(): + for line in ret.decode('utf-8').splitlines(): line = line.strip() if line.startswith('Controller Model'): model = get_val(line) @@ -80,7 +80,7 @@ def get_logicaldevice_info(controllerid, ldid): id = 'c%iu%i' % (controllerid, ldid) level = status = size = None members = [] - for line in ret.splitlines(): + for line in ret.decode('utf-8').splitlines(): line = line.strip() if line.startswith('RAID level'): level = get_val(line) @@ -101,7 +101,7 @@ def get_disks_info(controllerid): ret = subprocess.check_output(cmd) diskid = vendor = model = status = None disks = {} - for line in ret.splitlines(): + for line in ret.decode('utf-8').splitlines(): line = line.strip() if line.startswith('Reported Channel,Device(T:L)'): line = line.replace('T:L', 'TL') @@ -185,7 +185,7 @@ def cmk_info(controllerid): segn += 1 # DISKS disks = get_disks_info(controllerid) - disk_keys = disks.keys() + disk_keys = list(disks.keys()) disk_keys.sort() for k in disk_keys: status = 0 @@ -204,6 +204,6 @@ if __name__ == '__main__': if arcconf: n = get_num_controllers() for c in range(1,n+1): - print cmk_info(c) + print(cmk_info(c)) else: - print "3 No_arcconf_Found - UNKNOWN (No arcconf binary Found or no Adaptec Controller present (remove check from local checks))" + print("3 No_arcconf_Found - UNKNOWN (No arcconf binary Found or no Adaptec Controller present (remove check from local checks))")