ESXi can see the smart information on the relevant panel, my side of the company with the assembled server, and then do not support, had to use the method of SSH to obtain.
Nagios Monitoring displays relevant information by exiting the status code.
The exit code is as follows:
0 OK; 1 warning; 2 critical; 3 Unknown
python can use the Paramiko to implement the SSH connection and execute the command process.
Paramiko Download Location
Pypi.python.org/pypi/paramiko
#!/usr/bin/env pythonimport paramikoimport reimport sys#0 ok; 1 warning; 2 critical; 3 unknownuser, passwd = "root", "123" Def get_disk_ Status (IP,USERNAME,PASSWD): ssh = paramiko. Sshclient () ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ()) ssh.connect (IP,22,USERNAME,PASSWD) stdin, Stdout, stderr = ssh.exec_command (' for i in ' esxcli storage core device list | grep "Local ata disk" | sed "s/.* (\|) G "'; do esxcli storage core device smart get -d " $i " | grep health ; done ') d = stdout.read () ssh.close () if len (Re.findall (' OK ', d)) == len(Re.findall (' health ', d)): print "Dist Smart ok " sys.exit (0) else: print "Disk smart fail" sys.exit (2) if __name__ == ' __main__ ': get_disk_status ( SYS.ARGV[1],USER, PASSWD)
define service{ use one-day-service host_name ESX_100_3 service_description Disk_Smart check_command check_esxi }
Reboot, Nagios, fix it.
Nagios acquires ESXi hard drive smart information via Python