run script via VMA and monitor ESXI paths on nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

run script via VMA and monitor ESXI paths on nagios

Post by baber »

Dear all
Hi
i write a script that can detect number of path now want to know how can run this script via VMA because want monitor that via nagios core

script is in below
when i run this script on esxi that work correctly but how can run it via vma and monitor that on nagios ?

BR
Babak

Code: Select all

link=`esxcli storage nmp path list | grep fc.20000000 | wc -l`
if [ $link="28" ] 
    then
 echo -e "Storage Links is OK"
        exit 0
else
        echo -e "Storage Links has problem"
        exit 2
           
     fi
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: run script via VMA and monitor ESXI paths on nagios

Post by scottwilkerson »

You would have to either install some sort of agent on that machine like NRPE that could execute the command, or setup shared ssh keys and execute the command with something like check_by_ssh

Page 1-5 of this doc can show how to setup ssh
https://assets.nagios.com/downloads/nag ... ng_SSH.pdf
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: run script via VMA and monitor ESXI paths on nagios

Post by baber »

thanks but i want run script on VMA for esxi servers as i know check_by_ssh not use for esxi servers that script have to connect to each esxi server and run on esxi servers and i'm sure this topic have to put on nagios demo on vm
and also i did trust between VMA server and nagios server thus can connect to VMA server via nagios server without authentication

BR
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: run script via VMA and monitor ESXI paths on nagios

Post by scottwilkerson »

So you want this script to run on the VMA server or the ESXi Server?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: run script via VMA and monitor ESXI paths on nagios

Post by baber »

i know this script had to run on esxi server via vma server
now i create a trust key between nagios and vma server and when use ssh command from nagios server
ssh vi-admin@vma


also i add my esxi server to vma server while type ssh root@esxi1 on vma server it connect without authentication
it connect to vma server without authentication now my problem is how run above script on vma server through nagios server ?

BR
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: run script via VMA and monitor ESXI paths on nagios

Post by scottwilkerson »

That's what I was mentioning, you could connect from the nagios server to the vma via ssh (check_by_ssh) and kick that script off.

Another option would be to install an agent on the vma such as NRPE
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
baber
Posts: 295
Joined: Wed Oct 21, 2015 4:39 am

Re: run script via VMA and monitor ESXI paths on nagios

Post by baber »

so thanks
my script now is ok i run it with follow command through nagios server

/usr/local/nagios/libexec/check_by_ssh -E 1 -t 90 -l vi-admin -H vmaSERVER -C /home/vi-admin/nagios/storage_chk0.sh

that command excellent but how do i have to define service in .cfg file

i use this command but not work

check_command check_by_ssh -E 1 -t 90 -l vi-admin -H 172.20.68.205 -C /home/vi-admin/nagios/storage_chk0.sh

BR
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: run script via VMA and monitor ESXI paths on nagios

Post by scottwilkerson »

first you need to define a command for check_by_ssh if you don't have one

Code: Select all

define command {
    command_name    check_xi_by_ssh
    command_line    $USER1$/check_by_ssh -H $HOSTADDRESS$ $ARG1$ $ARG2$
}
Then you can add the line like this

Code: Select all

check_command   check_by_ssh!-E 1 -t 90 -l vi-admin -C /home/vi-admin/nagios/storage_chk0.sh|
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked