Closed jeremyml closed 8 years ago
Python's json
module was added in 2.6 (according to https://docs.python.org/2/library/json.html).
I need this script to run on 2.4. I'll check tomorrow, but I'm pretty sure I won't be able to use JSON.
I'm thinking about writing a script in NodeJS, hosted on a non-ESXi server such as Ubuntu. The Ubuntu cron job would call the NodeJS script, which will ssh remote execute the storcli command and capture the outputed json file. Then I plan to parse the json file in NodeJS. That way nothing is stored on the ESXi server.
I wanted to see if anyone has done anything with storcli yet, and yours looks like the best one out there so far!
That's a good idea, especially if you'll have more than 1 server.
I've verified that Python 2.4 doesn't have JSON.
I just realized that I shouldn't need the JSON library to parse the output. I should be able to use eval
instead, since JSON output is compatible with Python. Not quite as safe, but I think for this is fine (until the storcli
development team gets hacked ;) ).
I might look into reworking the script.
After working with the JSON output, or at least trying to, I've decided to stick with scraping the tabular output. I think the code is cleaner, and I'd still need to scrape the output they use, albeit slightly less than now.
Storcli can give json output. Are you searching the human-readable output with regular expressions? Why not parse the json output instead?
[root@localhost:~] /opt/lsi/storcli/storcli /c0 show all J
{ "Controllers":[ { "Command Status" : { "Controller" : 0, "Status" : "Success", "Description" : "None" }, "Response Data" : { "Basics" : { "Controller" : 0, "Model" : "LSI 3108 MegaRAID", "Serial Number" : "FW-AB8B4HEAARBWA", "Current Controller Date/Time" : "04/19/2016, 00:04:46", "Current System Date/time" : "04/19/2016, 00:04:47", "SAS Address" : "500304801c1d7c00", "PCI Address" : "00:03:00:00", "Mfg Date" : "00/00/00", "Rework Date" : "00/00/00", "Revision No" : "" }, "Version" : { "Firmware Package Build" : "24.7.0-0026", "Firmware Version" : "4.270.00-3972", "Bios Version" : "6.22.03.0_4.16.08.00_0x060B0200", "Ctrl-R Version" : "5.08-0006", "Preboot CLI Version" : "01.07-05:#%0", "NVDATA Version" : "3.1411.00-0009", "Boot Block Version" : "3.06.00.00-0001", "Driver Name" : "lsi-mr3", "Driver Version" : "6.605.08.00" }, "Bus" : { "Vendor Id" : 4096, "Device Id" : 93, "SubVendor Id" : 5593, "SubDevice Id" : 2057, "Host Interface" : "PCI-E", "Device Interface" : "SAS-12G", "Bus Number" : 3, "Device Number" : 0, "Function Number" : 0 }, "Pending Images in Flash" : { "Image name" : "No pending images" }, "Status" : { "Controller Status" : "Optimal", "Memory Correctable Errors" : 0, "Memory Uncorrectable Errors" : 0, "ECC Bucket Count" : 0, "Any Offline VD Cache Preserved" : "No", "BBU Status" : "NA", "Support PD Firmware Download" : "No", "Lock Key Assigned" : "No", "Failed to get lock key on bootup" : "No", "Lock key has not been backed up" : "No", "Bios was not detected during boot" : "No", "Controller must be rebooted to complete security operation" : "No", "A rollback operation is in progress" : "No", "At least one PFK exists in NVRAM" : "Yes", "SSC Policy is WB" : "No", "Controller has booted into safe mode" : "No" }, "Supported Adapter Operations" : { "Rebuild Rate" : "Yes", "CC Rate" : "Yes", "BGI Rate " : "Yes", "Reconstruct Rate" : "Yes", "Patrol Read Rate" : "Yes", "Alarm Control" : "Yes", "Cluster Support" : "No", "BBU " : "Yes", "Spanning" : "Yes", "Dedicated Hot Spare" : "Yes", "Revertible Hot Spares" : "Yes", "Foreign Config Import" : "Yes", "Self Diagnostic" : "Yes", "Allow Mixed Redundancy on Array" : "No", "Global Hot Spares" : "Yes", "Deny SCSI Passthrough" : "No", "Deny SMP Passthrough" : "No", "Deny STP Passthrough" : "No", "Support more than 8 Phys" : "Yes", "FW and Event Time in GMT" : "No", "Support Enhanced Foreign Import" : "Yes", "Support Enclosure Enumeration" : "Yes", "Support Allowed Operations" : "Yes", "Abort CC on Error" : "Yes", "Support Multipath" : "Yes", "Support Odd & Even Drive count in RAID1E" : "No", "Support Security" : "No", "Support Config Page Model" : "Yes", "Support the OCE without adding drives" : "Yes", "Support EKM" : "No", "Snapshot Enabled" : "No", "Support PFK" : "Yes", "Support PI" : "Yes", "Support LDPI Type1" : "No", "Support LDPI Type2" : "No", "Support LDPI Type3" : "No", "Support Ld BBM Info" : "No", "Support Shield State" : "Yes", "Block SSD Write Disk Cache Change" : "Yes", "Support Suspend Resume BG ops" : "Yes", "Support Emergency Spares" : "Yes", "Support Set Link Speed" : "Yes", "Support Boot Time PFK Change" : "No", "Support JBOD" : "Yes", "Disable Online PFK Change" : "No", "Support Perf Tuning" : "Yes", "Support SSD PatrolRead" : "Yes", "Real Time Scheduler" : "Yes", "Support Reset Now" : "Yes", "Support Emulated Drives" : "Yes", "Headless Mode" : "Yes", "Dedicated HotSpares Limited" : "No", "Point In Time Progress" : "Yes", "Extended LD" : "Yes", "Boot Volume Supported" : "No", "Support Uneven span " : "No", "Support Config Auto Balance" : "No", "Support Maintenance Mode" : "No", "Support Diagnostic results" : "Yes", "Support Ext Enclosure" : "No", "Support Sesmonitoring" : "Yes", "Support SecurityonJBOD" : "Yes", "Support ForceFlash" : "No", "Support DisableImmediateIO" : "Yes", "Support DisableLargeIoSupport" : "No", "Support DrvActivityLEDSetting" : "No", "Support FlushWriteVerify" : "No", "Support CPLDUpdate" : "No", "Support ForceTo512e" : "Yes", "Support discardCacheDuringLDDelete" : "Yes", "Support JBOD Write cache" : "No" }, "Supported PD Operations" : { "Force Online" : "Yes", "Force Offline" : "Yes", "Force Rebuild" : "Yes", "Deny Force Failed" : "No", "Deny Force Good/Bad" : "No", "Deny Missing Replace" : "No", "Deny Clear" : "No", "Deny Locate" : "No", "Support Power State" : "Yes", "Set Power State For Cfg" : "No", "Support T10 Power State" : "No", "Support Temperature" : "Yes", "NCQ" : "Yes", "Support Max Rate SATA" : "No" }, "Supported VD Operations" : { "Read Policy" : "Yes", "Write Policy" : "Yes", "IO Policy" : "Yes", "Access Policy" : "Yes", "Disk Cache Policy" : "Yes", "Reconstruction" : "Yes", "Deny Locate" : "No", "Deny CC" : "No", "Allow Ctrl Encryption" : "No", "Enable LDBBM" : "No", "Support FastPath" : "Yes", "Performance Metrics" : "Yes", "Power Savings" : "No", "Support Powersave Max With Cache" : "No", "Support Breakmirror" : "Yes", "Support SSC WriteBack" : "No", "Support SSC Association" : "No", "Support VD Hide" : "Yes", "Support VD Cachebypass" : "Yes", "Support VD discardCacheDuringLDDelete" : "Yes" }, "Advanced Software Option" : [ { "Adv S/W Opt" : "MegaRAID FastPath", " Time Remaining" : " Unlimited", " Mode" : " -" }, { "Adv S/W Opt" : "MegaRAID RAID6", " Time Remaining" : " Unlimited", " Mode" : " -" }, { "Adv S/W Opt" : "MegaRAID RAID5", " Time Remaining" : " Unlimited", " Mode" : " -" } ], "Safe ID" : " UMWL1M1MKADBJLUME59C2QIRA6FQ3DFUIS2MHG2Z", "HwCfg" : { "ChipRevision" : " C0", "BatteryFRU" : "N/A", "Front End Port Count" : 0, "Backend Port Count" : 8, "BBU" : "Absent", "Alarm" : "On", "Serial Debugger" : "Present", "NVRAM Size" : "32KB", "Flash Size" : "16MB", "On Board Memory Size" : "2048MB", "CacheVault Flash Size" : "NA", "TPM" : "Absent", "Upgrade Key" : "Absent", "On Board Expander" : "Absent", "Temperature Sensor for ROC" : "Present", "Temperature Sensor for Controller" : "Absent", "Upgradable CPLD" : "Absent", "Current Size of CacheCade (GB)" : 0, "Current Size of FW Cache (MB)" : 1734, "ROC temperature(Degree Celsius)" : 61 }, "Policies" : { "Policies Table" : [ { "Policy" : "Predictive Fail Poll Interval", "Current" : "300 sec", "Default" : "" }, { "Policy" : "Interrupt Throttle Active Count", "Current" : "16", "Default" : "" }, { "Policy" : "Interrupt Throttle Completion", "Current" : "50 us", "Default" : "" }, { "Policy" : "Rebuild Rate", "Current" : "30 %", "Default" : "30%" }, { "Policy" : "PR Rate", "Current" : "30 %", "Default" : "30%" }, { "Policy" : "BGI Rate", "Current" : "30 %", "Default" : "30%" }, { "Policy" : "Check Consistency Rate", "Current" : "30 %", "Default" : "30%" }, { "Policy" : "Reconstruction Rate", "Current" : "30 %", "Default" : "30%" }, { "Policy" : "Cache Flush Interval", "Current" : "4s", "Default" : "" } ], "Flush Time(Default)" : "4s", "Drive Coercion Mode" : "none", "Auto Rebuild" : "On", "Battery Warning" : "Off", "ECC Bucket Size" : 15, "ECC Bucket Leak Rate (hrs)" : 24, "Restore HotSpare on Insertion" : "Off", "Expose Enclosure Devices" : "On", "Maintain PD Fail History" : "On", "Reorder Host Requests" : "On", "Auto detect BackPlane" : "SGPIO/i2c SEP", "Load Balance Mode" : "Auto", "Security Key Assigned" : "Off", "Disable Online Controller Reset" : "Off", "Use drive activity for locate" : "Off" }, "Boot" : { "BIOS Enumerate VDs" : 1, "Stop BIOS on Error" : "On", "Delay during POST" : 0, "Spin Down Mode" : "None", "Enable Ctrl-R" : "Yes", "Enable Web BIOS" : "No", "Enable PreBoot CLI" : "No", "Enable BIOS" : "Yes", "Max Drives to Spinup at One Time" : 2, "Maximum number of direct attached drives to spin up in 1 min" : 10, "Delay Among Spinup Groups (sec)" : 12, "Allow Boot with Preserved Cache" : "Off" }, "High Availability" : { "Topology Type" : "None", "Cluster Permitted" : "No", "Cluster Active" : "No" }, "Defaults" : { "Phy Polarity" : 0, "Phy PolaritySplit" : 0, "Strip Size" : "256kB", "Write Policy" : "WB", "Read Policy" : "Adaptive", "Cache When BBU Bad" : "Off", "Cached IO" : "Off", "VD PowerSave Policy" : "Controller Defined", "Default spin down time (mins)" : 30, "Coercion Mode" : "None", "ZCR Config" : "Unknown", "Max Chained Enclosures" : 16, "Direct PD Mapping" : "No", "Restore Hot Spare on Insertion" : "No", "Expose Enclosure Devices" : "Yes", "Maintain PD Fail History" : "Yes", "Zero Based Enclosure Enumeration" : "No", "Disable Puncturing" : "No", "EnableLDBBM" : "No", "DisableHII" : "No", "Un-Certified Hard Disk Drives" : "Allow", "SMART Mode" : "Mode 6", "Enable LED Header" : "Yes", "LED Show Drive Activity" : "Yes", "Dirty LED Shows Drive Activity" : "No", "EnableCrashDump" : "Yes", "Disable Online Controller Reset" : "No", "Treat Single span R1E as R10" : "No", "Power Saving option" : "Enabled", "TTY Log In Flash" : "No", "Auto Enhanced Import" : "No", "BreakMirror RAID Support" : "Yes", "Disable Join Mirror" : "Yes", "Enable Shield State" : "Yes", "Time taken to detect CME" : "60 sec" }, "Capabilities" : { "Supported Drives" : "SAS, SATA", "Boot Volume Supported" : "NO", "RAID Level Supported" : "RAID0, RAID1, RAID5, RAID6, RAID00, RAID10, RAID50, \nRAID60, PRL 11, PRL 11 with spanning, SRL 3 supported, \nPRL11-RLQ0 DDF layout with no span, PRL11-RLQ0 DDF layout with span", "Enable JBOD" : "No", "Mix in Enclosure" : "Allowed", "Mix of SAS/SATA of HDD type in VD" : "Allowed", "Mix of SAS/SATA of SSD type in VD" : "Not Allowed", "Mix of SSD/HDD in VD" : "Not Allowed", "SAS Disable" : "No", "Max Arms Per VD" : 32, "Max Spans Per VD" : 8, "Max Arrays" : 128, "Max VD per array" : 16, "Max Number of VDs" : 64, "Max Parallel Commands" : 928, "Max SGE Count" : 60, "Max Data Transfer Size" : "8192 sectors", "Max Strips PerIO" : 42, "Max Configurable CacheCade Size(GB)" : 0, "Min Strip Size" : "64 KB", "Max Strip Size" : "1.0 MB" }, "Scheduled Tasks" : { "Consistency Check Reoccurrence" : "168 hrs", "Next Consistency check launch" : "04/23/2016, 03:00:00", "Patrol Read Reoccurrence" : "168 hrs", "Next Patrol Read launch" : "04/23/2016, 03:00:00", "Battery learn Reoccurrence" : "NA", "Next Battery Learn" : "NA", "OEMID" : "LSI" }, "Drive Groups" : 1, "TOPOLOGY" : [ { "DG" : 0, "Arr" : "-", "Row" : "-", "EID:Slot" : "-", "DID" : "-", "Type" : "RAID6", "State" : "Optl", "BT" : "N", "Size" : "3.256 TB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "N" }, { "DG" : 0, "Arr" : 0, "Row" : "-", "EID:Slot" : "-", "DID" : "-", "Type" : "RAID6", "State" : "Optl", "BT" : "N", "Size" : "3.256 TB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "N" }, { "DG" : 0, "Arr" : 0, "Row" : 0, "EID:Slot" : "0:0", "DID" : 7, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 1, "EID:Slot" : "0:1", "DID" : 24, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 2, "EID:Slot" : "0:2", "DID" : 9, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 3, "EID:Slot" : "0:3", "DID" : 11, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 4, "EID:Slot" : "0:4", "DID" : 16, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 5, "EID:Slot" : "0:5", "DID" : 2, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 6, "EID:Slot" : "0:6", "DID" : 1, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 7, "EID:Slot" : "0:7", "DID" : 4, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : 0, "Row" : 8, "EID:Slot" : "0:8", "DID" : 6, "Type" : "DRIVE", "State" : "Onln", "BT" : "N", "Size" : "476.437 GB", "PDC" : "dflt", "PI" : "N", "SED" : "N", "DS3" : "dflt", "FSpace" : "-" }, { "DG" : 0, "Arr" : "-", "Row" : "-", "EID:Slot" : "0:9", "DID" : 3, "Type" : "DRIVE", "State" : "DHS", "BT" : "-", "Size" : "476.437 GB", "PDC" : "-", "PI" : "-", "SED" : "-", "DS3" : "-", "FSpace" : "-" } ], "Virtual Drives" : 1, "VD LIST" : [ { "DG/VD" : "0/0", "TYPE" : "RAID6", "State" : "Optl", "Access" : "RW", "Consist" : "Yes", "Cache" : "RWTD", "Cac" : "-", "sCC" : "ON", "Size" : "3.256 TB", "Name" : "raid6" } ], "Physical Drives" : 10, "PD LIST" : [ { "EID:Slt" : "0:0", "DID" : 7, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:1", "DID" : 24, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:2", "DID" : 9, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:3", "DID" : 11, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:4", "DID" : 16, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:5", "DID" : 2, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:6", "DID" : 1, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:7", "DID" : 4, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:8", "DID" : 6, "State" : "Onln", "DG" : 0, "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" }, { "EID:Slt" : "0:9", "DID" : 3, "State" : "DHS", "DG" : "0", "Size" : "476.437 GB", "Intf" : "SATA", "Med" : "SSD", "SED" : "N", "PI" : "N", "SeSz" : "512B", "Model" : "Samsung SSD 850 PRO 512GB", "Sp" : "U" } ] } } ] }