Fixes.. (Rev 1.12)

This commit is contained in:
Vincent S. Cojot 2015-01-14 20:22:48 -05:00
parent 4ec7f462d4
commit b25b140994
1 changed files with 84 additions and 50 deletions

View File

@ -1,9 +1,10 @@
#!/usr/bin/python
# $Id: megaclisas-status,v 1.11 2015/01/14 19:24:10 root Exp $
# $Id: megaclisas-status,v 1.12 2015/01/14 20:22:48 root Exp $
import os
import re
import sys
import pdb
if len(sys.argv) > 2:
print 'Usage: megaraid-status [-d]'
@ -11,6 +12,8 @@ if len(sys.argv) > 2:
printarray = True
printcontroller = True
totaldrivenumber = 0
if len(sys.argv) > 1:
if sys.argv[1] == '-d':
printarray = False
@ -33,6 +36,21 @@ def returnControllerNumber(output):
if re.match(r'^Controller Count.*$',line.strip()):
return int(line.split(':')[1].strip().strip('.'))
def returnTotalDriveNumber(output):
for line in output:
if re.match(r'Number of Physical Drives on Adapter.*$',line.strip()):
return int(line.split(':')[1].strip())
def returnUnconfDriveNumber(output):
configdrives = 0
unconfdrives = 0
for line in output:
if re.match(r'.*Number of PDs:.*$',line.strip()):
configdrives += int(line.split(':')[2].strip())
#### pdb.set_trace()
unconfdrives = totaldrivenumber - configdrives
return int(unconfdrives)
def returnControllerModel(output):
for line in output:
if re.match(r'^Product Name.*$',line.strip()):
@ -230,11 +248,19 @@ if printarray:
controllerid += 1
print ''
print '-- Disks information --'
print '-- ID\t| Model | Status | Speed | Temperature | Slot ID | LSI Device ID '
controllerid = 0
while controllerid < controllernumber:
cmd = 'megacli -PDGetNum -a'+str(controllerid)+' -NoLog'
output = getOutput(cmd)
totaldrivenumber += returnTotalDriveNumber(output)
controllerid += 1
if totaldrivenumber:
print '-- Disks information --'
print '-- ID\t| Model | Status | Speed | Temperature | Slot ID | LSI Device ID '
controllerid = 0
while controllerid < controllernumber:
arrayid = 0
cmd = 'megacli -LDInfo -lall -a'+str(controllerid)+' -NoLog'
output = getOutput(cmd)
@ -247,14 +273,22 @@ while controllerid < controllernumber:
for array in arraydisk:
print 'c'+str(controllerid)+'u'+array[0]+'p'+array[1]+'\t| '+array[3]+' | '+array[2]+' | '+array[4]+' | '+array[5]+' | ID: \'['+array[6]+':'+array[7]+']\' | '+array[8]
controllerid += 1
print ''
print ''
print '-- Unconfigured Disks information --'
print '-- ID\t| Model | Status | Speed | Temperature | Slot ID | LSI Device ID '
totalunconfdrivenumber = 0
controllerid = 0
while controllerid < controllernumber:
cmd = 'megacli -LdPdInfo -a'+str(controllerid)+' -NoLog'
output = getOutput(cmd)
totalunconfdrivenumber += returnUnconfDriveNumber(output)
controllerid += 1
if ( totalunconfdrivenumber > 0):
print '-- Unconfigured Disks information --'
print '-- ID\t| Model | Status | Speed | Temperature | Slot ID | LSI Device ID '
controllerid = 0
while controllerid < controllernumber:
arrayid = 0
cmd = 'megacli -LDInfo -lall -a'+str(controllerid)+' -NoLog'
output = getOutput(cmd)
@ -267,7 +301,7 @@ while controllerid < controllernumber:
for array in arraydisk:
print 'c'+str(controllerid)+'\t| '+array[1]+' | '+array[0]+' | '+array[2]+' | '+array[3]+' | ID: \'['+array[4]+':'+array[5]+']\' | '+array[6]
controllerid += 1
print ''
if bad:
print '\nThere is at least one disk/array in a NOT OPTIMAL state.'