librenms / librenms-agent

LibreNMS Agent & Scripts
GNU General Public License v2.0
117 stars 188 forks source link

Redesigned mdadm script to be more robust #398

Closed Trae32566 closed 2 years ago

Trae32566 commented 2 years ago

This updates the mdadm SNMP script to be cleaner and more robust (it was failing prior with specific RAID configurations). Here is a random set of assorted RAID 0s:

[root@stor01a-rh8 ~]# /etc/snmp/mdadm 
{"data":[{"name":"md124","level":"raid0","size":"18003119308800","disc_count":"3","hotspare_count":"0","device_list":["sdc","sdd","sde"],"missing_devices_list":[],"state":"clean","action":"0","degraded":"0","sync_speed":"0","sync_completed":"0"},{"name":"md125","level":"raid0","size":"12002079539200","disc_count":"2","hotspare_count":"0","device_list":["sda","sdb"],"missing_devices_list":[],"state":"clean","action":"0","degraded":"0","sync_speed":"0","sync_completed":"0"},{"name":"md126","level":"raid0","size":"1860725374976","disc_count":"2","hotspare_count":"0","device_list":["nvme0n1p4","nvme1n1p2"],"missing_devices_list":[],"state":"clean","action":"0","degraded":"0","sync_speed":"0","sync_completed":"0"},{"name":"md127","level":"raid0","size":"137571074048","disc_count":"2","hotspare_count":"0","device_list":["nvme0n1p3","nvme1n1p1"],"missing_devices_list":[],"state":"clean","action":"0","degraded":"0","sync_speed":"0","sync_completed":"0"}],"error":"0","errorString":"","version":"1"}

And a separate RAID 1 (and with --debug):

[root@kvm01-rh8 ~]# /etc/snmp/mdadm  --debug
{"data":[{"name":"md127","level":"raid1","size":"2000398778368","disc_count":"2","hotspare_count":"0","device_list":["nvme0n1","nvme1n1"],"missing_devices_list":[],"state":"clean","action":"idle","degraded":"0","sync_speed":"0","sync_completed":"none"}],"error":"0","errorString":"","version":"1"}
{ "data": [{
        "name": "md127",
        "level": "raid1",
        "size": "2000398778368",
        "disc_count": "2",
        "hotspare_count": "0",
        "device_list": [
            "nvme0n1",
            "nvme1n1"
        ],
        "missing_devices_list": [

        ],
        "state": "clean",
        "action": "idle",
        "degraded": "0",
        "sync_speed": "0",
        "sync_completed": "none"
    }],
    "error": "0",
    "errorString": "",
    "version": "1"
}
CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.