Nagios acquires ESXi hard drive smart information via Python

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.