Run 2to3 on all Python wrappers

This commit is contained in:
Adam Cecile 2021-08-17 09:42:37 +02:00
parent e0d3be643a
commit 8e78deda38
7 changed files with 129 additions and 129 deletions

View File

@ -7,7 +7,7 @@ import sys
binarypath = "/usr/sbin/tw-cli"
if len(sys.argv) > 2:
print "Usage: 3ware-status [--nagios]"
print("Usage: 3ware-status [--nagios]")
sys.exit(1)
nagiosmode = False
@ -21,7 +21,7 @@ if len(sys.argv) > 1:
if sys.argv[1] == "--nagios":
nagiosmode = True
else:
print "Usage: 3ware-status [--nagios]"
print("Usage: 3ware-status [--nagios]")
sys.exit(1)
# Check binary exists (and +x), if not print an error message
@ -30,9 +30,9 @@ if os.path.exists(binarypath) and os.access(binarypath, os.X_OK):
pass
else:
if nagiosmode:
print "UNKNOWN - Cannot find " + binarypath
print("UNKNOWN - Cannot find " + binarypath)
else:
print "Cannot find " + binarypath + ". Please install it."
print("Cannot find " + binarypath + ". Please install it.")
sys.exit(3)
@ -92,8 +92,8 @@ bad = False
# List available controller
if not nagiosmode:
print "-- Controller informations --"
print "-- ID | Model"
print("-- Controller informations --")
print("-- ID | Model")
for controller in controllerlist:
cmd = binarypath + " info " + controller + " model"
# https://github.com/eLvErDe/hwraid/issues/69
@ -101,13 +101,13 @@ if not nagiosmode:
model = getOutput(cmd)[0].split(" = ")[1].strip()
except IndexError:
model = "N/A"
print controller + " | " + model
print ""
print(controller + " | " + model)
print("")
# List arrays
if not nagiosmode:
print "-- Arrays informations --"
print "-- ID\tType\tSize\tStatus"
print("-- Arrays informations --")
print("-- ID\tType\tSize\tStatus")
for controller in controllerlist:
cmd = binarypath + " info " + controller
output = getOutput(cmd)
@ -123,14 +123,14 @@ for controller in controllerlist:
else:
nagiosgoodarray = nagiosgoodarray + 1
if not nagiosmode:
print id + "\t" + type + "\t" + size + "\t" + status
print(id + "\t" + type + "\t" + size + "\t" + status)
if not nagiosmode:
print ""
print("")
# List disks
if not nagiosmode:
print "-- Disks informations"
print "-- ID\tModel\t\t\tStatus"
print("-- Disks informations")
print("-- ID\tModel\t\t\tStatus")
for controller in controllerlist:
cmd = binarypath + " info " + controller
output = getOutput(cmd)
@ -147,19 +147,19 @@ for controller in controllerlist:
else:
nagiosgooddisk = nagiosgooddisk + 1
if not nagiosmode:
print id + "\t" + model + "\t" + status
print(id + "\t" + model + "\t" + status)
if nagiosmode:
if bad:
print "RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
sys.exit(2)
else:
print "RAID OK - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("RAID OK - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
else:
if bad:
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
sys.exit(1)

View File

@ -225,12 +225,12 @@ if arcconfpath != None:
pass
else:
if config.nagios:
print "UNKNOWN - Cannot find " + arcconfpath
print("UNKNOWN - Cannot find " + arcconfpath)
else:
print "Cannot find " + arcconfpath + "in your PATH. Please install it."
print("Cannot find " + arcconfpath + "in your PATH. Please install it.")
sys.exit(3)
else:
print 'Cannot find "arcconf, "arcconf.exe" in your PATH. Please install it.'
print('Cannot find "arcconf, "arcconf.exe" in your PATH. Please install it.')
sys.exit(3)
@ -238,14 +238,14 @@ cmd = '"%s" GETVERSION' % arcconfpath
output = getOutput(cmd)
controllernumber = returnControllerNumber(output)
if not controllernumber:
print '"arcconf" returned no controller, are you sure to have an Adaptec adapter?'
print('"arcconf" returned no controller, are you sure to have an Adaptec adapter?')
sys.exit(3)
# List controllers
if printcontroller:
if not config.nagios:
print "-- Controller informations --"
print "-- ID | Model | Status"
print("-- Controller informations --")
print("-- ID | Model | Status")
controllerid = 1
while controllerid <= controllernumber:
cmd = '"%s" GETCONFIG %d' % (arcconfpath, controllerid)
@ -258,17 +258,17 @@ if printcontroller:
else:
nagiosgoodctrl += 1
if not config.nagios:
print "c" + str(controllerid - 1) + " | " + controllermodel + " | " + controllerstatus
print("c" + str(controllerid - 1) + " | " + controllermodel + " | " + controllerstatus)
controllerid += 1
if not config.nagios:
print ""
print("")
# List arrays
if printarray:
controllerid = 1
if not config.nagios:
print "-- Arrays informations --"
print "-- ID | Type | Size | Status | Task | Progress"
print("-- Arrays informations --")
print("-- ID | Type | Size | Status | Task | Progress")
while controllerid <= controllernumber:
arrayid = 0
cmd = '"%s" GETCONFIG %s' % (arcconfpath, controllerid)
@ -297,23 +297,23 @@ if printarray:
for tasks in tasksinfo:
if int(tasks[0]) == int(arrayid):
if not config.nagios:
print "c" + str(controllerid - 1) + "u" + str(arrayid) + " | " + raidtype + " | " + arrayinfo[2] + "G | " + arrayinfo[
print("c" + str(controllerid - 1) + "u" + str(arrayid) + " | " + raidtype + " | " + arrayinfo[2] + "G | " + arrayinfo[
1
] + " | " + tasks[1] + " | " + tasks[2] + "%"
] + " | " + tasks[1] + " | " + tasks[2] + "%")
done = True
break
if done == False:
if not config.nagios:
print "c" + str(controllerid - 1) + "u" + str(arrayid) + " | " + raidtype + " | " + arrayinfo[2] + "G | " + arrayinfo[1]
print("c" + str(controllerid - 1) + "u" + str(arrayid) + " | " + raidtype + " | " + arrayinfo[2] + "G | " + arrayinfo[1])
controllerid += 1
if not config.nagios:
print ""
print("")
# List disks
controllerid = 1
if not config.nagios:
print "-- Disks informations"
print "-- ID | Model | Status"
print("-- Disks informations")
print("-- ID | Model | Status")
while controllerid <= controllernumber:
arrayid = 0
cmd = '"%s" GETCONFIG %s' % (arcconfpath, controllerid)
@ -346,34 +346,34 @@ while controllerid <= controllernumber:
# Matched in members of this array
if disk[0] == member:
if not config.nagios:
print "c" + str(controllerid - 1) + "u" + str(arrayid) + "d" + str(memberid) + " | " + disk[2] + " " + disk[3] + " " + disk[
print("c" + str(controllerid - 1) + "u" + str(arrayid) + "d" + str(memberid) + " | " + disk[2] + " " + disk[3] + " " + disk[
4
] + " | " + disk[1]
] + " | " + disk[1])
array_member = True
memberid += 1
# Some disks may not be attached to any array (ie: global hot spare)
if not array_member:
if not config.nagios:
print "c" + str(controllerid - 1) + "uX" + "d" + str(no_array_disk_id) + " | " + disk[2] + " " + disk[3] + " " + disk[4] + " | " + disk[1]
print("c" + str(controllerid - 1) + "uX" + "d" + str(no_array_disk_id) + " | " + disk[2] + " " + disk[3] + " " + disk[4] + " | " + disk[1])
no_array_disk_id += 1
controllerid += 1
if config.nagios:
if bad:
print (
print((
"RAID ERROR - Controllers OK:%d Bad:%d - Arrays OK:%d Bad:%d - Disks OK:%d Bad:%d"
% (nagiosgoodctrl, nagiosbadctrl, nagiosgoodarray, nagiosbadarray, nagiosgooddisk, nagiosbaddisk)
)
))
sys.exit(2)
else:
print (
print((
"RAID OK - Controllers OK:%d Bad:%d - Arrays OK:%d Bad:%d - Disks OK:%d Bad:%d"
% (nagiosgoodctrl, nagiosbadctrl, nagiosgoodarray, nagiosbadarray, nagiosgooddisk, nagiosbaddisk)
)
))
else:
if bad:
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print '\nUse "arcconf GETCONFIG [1-9]" to get details.'
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
print('\nUse "arcconf GETCONFIG [1-9]" to get details.')
sys.exit(1)

View File

@ -64,7 +64,7 @@ if __name__ == "__main__":
except AttributeError:
root_or_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
if not root_or_admin:
print "# This script requires Administrator privileges"
print("# This script requires Administrator privileges")
sys.exit(5)
# Functions
@ -116,12 +116,12 @@ if megaclipath != None:
pass
else:
if nagiosmode:
print "UNKNOWN - Cannot find " + megaclipath
print("UNKNOWN - Cannot find " + megaclipath)
else:
print "Cannot find " + megaclipath + "in your PATH. Please install it."
print("Cannot find " + megaclipath + "in your PATH. Please install it.")
sys.exit(3)
else:
print 'Cannot find "MegaCli{64,}", "megacli{64,}", "perccli{64,}" or "storcli{64,}" in your PATH. Please install one of them.'
print('Cannot find "MegaCli{64,}", "megacli{64,}", "perccli{64,}" or "storcli{64,}" in your PATH. Please install one of them.')
sys.exit(3)
@ -139,7 +139,7 @@ def returnWdthFromArrayCol(glarray, idx):
# Get and cache command output
def getOutput(cmd):
lines = []
if Outputs.has_key(cmd):
if cmd in Outputs:
dbgprint("Got Cached value: " + str(cmd))
lines = Outputs[cmd]
else:
@ -155,7 +155,7 @@ def getOutput(cmd):
# Get and cache disks, make sure we don't count the same disk twice
def AddDisk(mytable, disk):
lines = []
if mytable.has_key(disk):
if disk in mytable:
dbgprint("Disk: " + str(disk) + " Already present in Disk Table")
return False
else:
@ -649,7 +649,7 @@ bad = False
if printcontroller:
if controllernumber:
if not nagiosmode:
print "-- Controller information --"
print("-- Controller information --")
i = 0
controllerid = 0
@ -668,19 +668,19 @@ if printcontroller:
# Header
if i == 0:
if not nagiosmode:
print hbafmt % ("-- ID", "H/W Model", "RAM", "Temp", "BBU", "Firmware")
print(hbafmt % ("-- ID", "H/W Model", "RAM", "Temp", "BBU", "Firmware"))
if not nagiosmode:
print hbafmt % (hba[0], hba[1], hba[2], hba[3], hba[4], hba[5])
print(hbafmt % (hba[0], hba[1], hba[2], hba[3], hba[4], hba[5]))
i += 1
if not nagiosmode:
print ""
print("")
else:
print "No MegaRAID or PERC adapter detected on your system!"
print("No MegaRAID or PERC adapter detected on your system!")
exit(1)
if printarray:
if not nagiosmode:
print "-- Array information --"
print("-- Array information --")
controllerid = 0
pcipath = ""
@ -768,9 +768,9 @@ if printarray:
# Header
if i == 0:
if not nagiosmode:
print ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "DskCache", "Status", "OS Path", "CacheCade", "InProgress")
print(ldfmt % ("-- ID", "Type", "Size", "Strpsz", "Flags", "DskCache", "Status", "OS Path", "CacheCade", "InProgress"))
if not nagiosmode:
print ldfmt % (
print(ldfmt % (
arrayinfo[0],
arrayinfo[1],
arrayinfo[2],
@ -781,7 +781,7 @@ if printarray:
arrayinfo[7],
arrayinfo[8],
arrayinfo[9],
)
))
dbgprint("Array state : LD " + arrayinfo[0] + ", status : " + arrayinfo[6])
if arrayinfo[6] not in ["Optimal", "N/A"]:
bad = True
@ -792,7 +792,7 @@ if printarray:
i += 1
controllerid += 1
if not nagiosmode:
print ""
print("")
controllerid = 0
while controllerid < controllernumber:
@ -803,7 +803,7 @@ while controllerid < controllernumber:
if totaldrivenumber:
if not nagiosmode:
print "-- Disk information --"
print("-- Disk information --")
i = 0
dlen = 0
@ -859,10 +859,10 @@ if totaldrivenumber:
# Header
if i == 0:
if not nagiosmode:
print drvfmt % ("-- ID", "Type", "Drive Model", "Size", "Status", "Speed", "Temp", "Slot ID", "LSI ID")
print(drvfmt % ("-- ID", "Type", "Drive Model", "Size", "Status", "Speed", "Temp", "Slot ID", "LSI ID"))
# Drive information
if not nagiosmode:
print drvfmt % (
print(drvfmt % (
str("c" + str(controllerid) + "u" + array[0] + "p" + array[1]), # c0p0
array[2], # HDD/SDD
array[3], # Model Information (Variable len)
@ -872,11 +872,11 @@ if totaldrivenumber:
array[7], # Temp
str("[" + array[8] + ":" + array[9] + "]"), # Slot ID
array[10],
) # LSI ID
)) # LSI ID
i = i + 1
controllerid += 1
if not nagiosmode:
print ""
print("")
controllerid = 0
totalconfdrivenumber = 0
@ -906,7 +906,7 @@ dbgprint("Total Unconfigured Drives : " + str(totalunconfdrivenumber))
if totalunconfdrivenumber:
if not nagiosmode:
print "-- Unconfigured Disk information --"
print("-- Unconfigured Disk information --")
controllerid = 0
pcipath = ""
@ -966,10 +966,10 @@ if totalunconfdrivenumber:
# Header
if i == 0:
if not nagiosmode:
print drvfmt % ("-- ID", "Type", "Drive Model", "Size", "Status", "Speed", "Temp", "Slot ID", "LSI ID", "Path")
print(drvfmt % ("-- ID", "Type", "Drive Model", "Size", "Status", "Speed", "Temp", "Slot ID", "LSI ID", "Path"))
# Drive information
if not nagiosmode:
print drvfmt % (
print(drvfmt % (
str("c" + str(controllerid) + "uXpY"), # cXpY
array[0], # HDD/SDD
array[1], # Model Information (Variable len)
@ -980,11 +980,11 @@ if totalunconfdrivenumber:
str("[" + array[6] + ":" + array[7] + "]"), # Slot ID
array[8], # LSI ID
array[9],
) # OS path, if any
)) # OS path, if any
i += 1
controllerid += 1
if not nagiosmode:
print ""
print("")
if debugmode:
dbgprint("Printing Outputs[][]")
@ -1002,21 +1002,21 @@ if debugmode:
if nagiosmode:
if bad:
print "RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
sys.exit(2)
else:
print "RAID OK - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("RAID OK - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
else:
if bad:
# DO NOT MODIFY OUTPUT BELOW
# Scripts may relies on it
# https://github.com/eLvErDe/hwraid/issues/99
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print "RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
print("RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
sys.exit(1)

View File

@ -5,7 +5,7 @@ import re
import sys
if len(sys.argv) > 2:
print "Usage: megaide-status [-d]"
print("Usage: megaide-status [-d]")
sys.exit(1)
printarray = True
@ -15,7 +15,7 @@ if len(sys.argv) > 1:
printarray = False
printcontroller = False
else:
print "Usage: megaide-status [-d]"
print("Usage: megaide-status [-d]")
sys.exit(1)
@ -88,32 +88,32 @@ bad = False
if printarray:
controllerid = 0
print "-- Arrays informations --"
print "-- ID | Type | Size | Status"
print("-- Arrays informations --")
print("-- ID | Type | Size | Status")
while controllerid <= controllernumber:
arrayid = 0
arraynumber = returnArrayNumber(controllerid)
while arrayid <= arraynumber:
arrayinfo = returnArrayInfo(controllerid, arrayid)
print arrayinfo[0] + " | " + arrayinfo[1] + " | " + arrayinfo[2] + " | " + arrayinfo[3]
print(arrayinfo[0] + " | " + arrayinfo[1] + " | " + arrayinfo[2] + " | " + arrayinfo[3])
arrayid += 1
if not arrayinfo[3] == "ONLINE":
bad = True
controllerid += 1
print ""
print("")
print "-- Disks informations"
print "-- ID | Model | Status"
print("-- Disks informations")
print("-- ID | Model | Status")
controllerid = 0
while controllerid <= controllernumber:
diskinfo = returnDiskInfo()
for disk in diskinfo:
print disk[0] + " | " + disk[2] + " | " + disk[1]
print(disk[0] + " | " + disk[2] + " | " + disk[1])
if not disk[1] == "ONLINE":
bad = True
controllerid += 1
if bad:
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
sys.exit(1)

View File

@ -7,7 +7,7 @@ import sys
binarypath = "/usr/sbin/megactl"
if len(sys.argv) > 2:
print "Usage: megaraid-status [-d]"
print("Usage: megaraid-status [-d]")
sys.exit(1)
printarray = True
@ -15,7 +15,7 @@ if len(sys.argv) > 1:
if sys.argv[1] == "-d":
printarray = False
else:
print "Usage: megaraid-status [-d]"
print("Usage: megaraid-status [-d]")
sys.exit(1)
# Check binary exists (and +x), if not print an error message
@ -77,21 +77,21 @@ disklist = returnDiskList(output)
arraylist = returnArrayList(output)
if printarray:
print "-- Arrays informations --"
print "-- ID | Type | Size | Status"
print("-- Arrays informations --")
print("-- ID | Type | Size | Status")
for array in arraylist:
print array[0] + " | " + array[2] + " " + array[3] + " | " + array[1] + " | " + array[-1]
print ""
print(array[0] + " | " + array[2] + " " + array[3] + " | " + array[1] + " | " + array[-1])
print("")
print "-- Disks informations"
print "-- ID | Model | Status | Warnings"
print("-- Disks informations")
print("-- ID | Model | Status | Warnings")
for disk in disklist:
# Check if there's some smart non critical warnings
if re.match(r"^errs:.*$", disk[-2]):
# Some disk may have vendor or model containing spaces
print disk[0] + " | " + " ".join(disk[1:-3]) + " | " + disk[-1] + " | " + disk[-2]
print(disk[0] + " | " + " ".join(disk[1:-3]) + " | " + disk[-1] + " | " + disk[-2])
else:
print disk[0] + " | " + " ".join(disk[1:-2]) + " | " + disk[-1]
print(disk[0] + " | " + " ".join(disk[1:-2]) + " | " + disk[-1])
# Check if there's a bad disk
bad = False
@ -104,5 +104,5 @@ for disk in disklist:
bad = True
if bad:
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
sys.exit(1)

View File

@ -7,7 +7,7 @@ import sys
binarypath = "/usr/sbin/megasasctl"
if len(sys.argv) > 2:
print "Usage: megaraidsas-status [-d]"
print("Usage: megaraidsas-status [-d]")
sys.exit(1)
printarray = True
@ -15,7 +15,7 @@ if len(sys.argv) > 1:
if sys.argv[1] == "-d":
printarray = False
else:
print "Usage: megaraidsas-status [-d]"
print("Usage: megaraidsas-status [-d]")
sys.exit(1)
# Check binary exists (and +x), if not print an error message
@ -77,21 +77,21 @@ disklist = returnDiskList(output)
arraylist = returnArrayList(output)
if printarray:
print "-- Arrays informations --"
print "-- ID | Type | Size | Status"
print("-- Arrays informations --")
print("-- ID | Type | Size | Status")
for array in arraylist:
print array[0] + " | " + array[2] + " " + array[3] + " | " + array[1] + " | " + array[-1]
print ""
print(array[0] + " | " + array[2] + " " + array[3] + " | " + array[1] + " | " + array[-1])
print("")
print "-- Disks informations"
print "-- ID | Model | Status | Warnings"
print("-- Disks informations")
print("-- ID | Model | Status | Warnings")
for disk in disklist:
# Check if there's some smart non critical warnings
if re.match(r"^errs:.*$", disk[-2]):
# Some disk may have vendor or model containing spaces
print disk[0] + " | " + " ".join(disk[1:-3]) + " | " + disk[-1] + " | " + disk[-2]
print(disk[0] + " | " + " ".join(disk[1:-3]) + " | " + disk[-1] + " | " + disk[-2])
else:
print disk[0] + " | " + " ".join(disk[1:-2]) + " | " + disk[-1]
print(disk[0] + " | " + " ".join(disk[1:-2]) + " | " + disk[-1])
# Check if there's a bad disk
bad = False
@ -104,5 +104,5 @@ for disk in disklist:
bad = True
if bad:
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
sys.exit(1)

View File

@ -6,11 +6,11 @@ import sys
binarypath = "/usr/sbin/sas2ircu"
if not os.path.isfile(binarypath):
print "sas2ircu is not available in expected location: {}".format(binarypath)
print("sas2ircu is not available in expected location: {}".format(binarypath))
sys.exit(1)
if len(sys.argv) > 2:
print "Usage: sas2ircu-status [--nagios]"
print("Usage: sas2ircu-status [--nagios]")
sys.exit(1)
nagiosmode = False
@ -24,7 +24,7 @@ if len(sys.argv) > 1:
if sys.argv[1] == "--nagios":
nagiosmode = True
else:
print "Usage: sas2ircu-status [--nagios]"
print("Usage: sas2ircu-status [--nagios]")
sys.exit(1)
bad = False
@ -136,15 +136,15 @@ def getDiskList(ctrlnmbr):
ctrls = getCtrlList()
arraymap = {}
if not nagiosmode:
print "-- Controller informations --"
print "-- ID | Model"
print("-- Controller informations --")
print("-- ID | Model")
for ctrl in ctrls:
print "c" + str(ctrl[0]) + " | " + ctrl[1]
print ""
print("c" + str(ctrl[0]) + " | " + ctrl[1])
print("")
if not nagiosmode:
print "-- Arrays informations --"
print "-- ID | Type | Size | Status"
print("-- Arrays informations --")
print("-- ID | Type | Size | Status")
for ctrl in ctrls:
for array in getArrayList(ctrl[0]):
arraymap[ctrl[0]] = array
@ -154,13 +154,13 @@ for ctrl in ctrls:
else:
nagiosgoodarray = nagiosgoodarray + 1
if not nagiosmode:
print "c" + str(ctrl[0]) + "u" + str(array[0]) + " | " + array[1] + " | " + array[2] + " | " + array[3]
print("c" + str(ctrl[0]) + "u" + str(array[0]) + " | " + array[1] + " | " + array[2] + " | " + array[3])
if not nagiosmode:
print ""
print("")
if not nagiosmode:
print "-- Disks informations"
print "-- ID | Model | Status"
print("-- Disks informations")
print("-- ID | Model | Status")
for ctrl in ctrls:
for disk in getDiskList(ctrl[0]):
# Compare disk enc/slot to array's ones
@ -173,19 +173,19 @@ for ctrl in ctrls:
else:
nagiosgooddisk = nagiosgooddisk + 1
if not nagiosmode:
print "c" + str(ctrl[0]) + "u" + str(array[0]) + "p" + str(disk[0]) + " | " + disk[2] + " (" + disk[3] + ") | " + disk[1]
print("c" + str(ctrl[0]) + "u" + str(array[0]) + "p" + str(disk[0]) + " | " + disk[2] + " (" + disk[3] + ") | " + disk[1])
if nagiosmode:
if bad:
print "RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("RAID ERROR - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
sys.exit(2)
else:
print "RAID OK - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
print("RAID OK - Arrays: OK:" + str(nagiosgoodarray) + " Bad:" + str(nagiosbadarray) + " - Disks: OK:" + str(nagiosgooddisk) + " Bad:" + str(
nagiosbaddisk
)
))
else:
if bad:
print "\nThere is at least one disk/array in a NOT OPTIMAL state."
print("\nThere is at least one disk/array in a NOT OPTIMAL state.")
sys.exit(1)