5 Replies Latest reply on Jun 26, 2020 2:26 AM by GKaveH

    How to Run external Script on ESXi Host

    GKaveH Lurker

      Hello guys

       

      i need some advice to run disk check script on esxi Host, my script run via zabbix ssh agent.

      i know i can put id_rsa.pub of zabbix in /etc/ssh/keys-root/authorized_keys  but i don't like my zabbix server have root privilege to each esxi host.

       

      my script run ssacli, megacli or storcli, perccli and i need to check all logical volume with these commands and i'm not familiar enough with esxi user permission's.

      i want to have zabbix user so this user could run just this script on esxi host by the way this script is in zabbix item now.

      can anybody help me whit this ?

       

      by the way maybe some of you ask me why i'm not using snmp because 80% of my server's are supermicro.

        • 1. Re: How to Run external Script on ESXi Host
          GKaveH Lurker

          any help ?

          • 2. Re: How to Run external Script on ESXi Host
            continuum Guru
            vExpertCommunity Warriors

            What do you plan to actually use as a command to check disks on an ESXi host ?

            All options that I am aware of require a quiesced datastore and should only be used by a person that knows exactly what he is doing and that user should watch what is going on and that user needs root access.

            All of that speaks against automating that process

            • 3. Re: How to Run external Script on ESXi Host
              GKaveH Lurker

              hi thanks for your reply

               

              I think you know something about my condition now in another post I said about losing one of my datastore in one server, so I'm afraid to lose another datastore and decided to check each hard disk of every ESXi host and use this script to get logical volume states :

               

              VENDOR="$(esxcli hardware platform get | grep Vendor | awk '{print $3}')"

              if [ "$VENDOR" == "HP" ]

              then

                      /opt/smartstorageadmin/ssacli/bin/ssacli ctrl all show config | grep physicaldrive | egrep -cv ' OK\)| spare\)$'

              elif [ "$VENDOR" == "Supermicro" ]

              then

                      LD_LIBRARY_PATH=/opt/lsi/MegaCLI /opt/lsi/MegaCLI/MegaCli -LDInfo -Lall -Aall | egrep -i 'State|Permission' | grep -cv Optimal

              elif [ "$VENDOR" == "Dell" ]

              then

                     cd /opt/lsi/perccli ; /opt/lsi/perccli/perccli -LDInfo -Lall -aALL| egrep -i 'State|Permission' | grep -cv Optimal

              fi

               

              The above script runs via ssh-agent on the Zabbix server so if the output of this script becomes 1 in the Zabbix server trigger will be activated, and I will get a message on my phone, so I can change it as soon as possible.

              by the way, I know, I can get Info from SNMP  from iLO or ipmi of HP servers or dell server's but 80% of my servers are supermicro and I can't get info from them because i cant see storage configuration in iLO of them.

              • 4. Re: How to Run external Script on ESXi Host
                continuum Guru
                Community WarriorsvExpert

                I have to admit that I have not seen any of the tools you mentioned in action.

                They seem to be vendor-specific so you will then also need another tool or logic to analyse the results.

                 

                What about just reading vmkernel.log every few hours or daily.

                You can then use a routine that greps the vmkernel.log for messages.

                Create a file named "early-warnings.grepfile" and collect terms that suggest a problem in near future.

                Create another file named "red-alert.grepfile" and colllect terms that require immediate action.

                 

                Anyway - do you know vcheck - if not have a look here:

                http://www.virtu-al.net/vcheck-pluginsheaders/vcheck/

                 

                If you set that up and enable those plugins you need (you can easily customize the selection) you get enough material to anticpate coming desasters.

                Not sure if vcheck has support for latest ESXi versions - but if it does - it is a very useful tool because you can easily customize the output.

                If done well - you get an email every morning that shows the state of your system.

                • 5. Re: How to Run external Script on ESXi Host
                  GKaveH Lurker

                  for this part

                   

                  They seem to be vendor-specific so you will then also need another tool or logic to analyze the results.

                   

                  yep, those tool's are for raid controller which you can use them to see which hard drive is failed or which logical drive is degraded in HP customize ESXi is already installed but for supermicro you need to install it and with that script, I wrote you can grep optimal logical drive stats and if it's optimal script output is 0 but if one logical drive is not optimal script output give you 1 so in Zabbix server I have a trigger for it and when the output of the script is 1 that trigger will be activated and Zabbix will send me a notification.

                   

                  so already I have done it and I'm getting notification right know.

                   

                  but that script is running with root privilege and this is my problem. I want to be able to create another user with just permission of running that script.