eventhandler | start a VM

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
matanr
Posts: 1
Joined: Sun Jan 06, 2019 10:38 am

eventhandler | start a VM

Post by matanr »

hi all,

I want to start a VM on ESXI with powercli script.

My nagios is installed on CestOs.
Also, i installed powershell and powercli on the CentOs.
my script to power on a vm from the centos is working good.
however, i seems that when i want to call it from nagios it doesnt work.
what do i do wrong?

the scrips:

Code: Select all

#!/usr/bin/pwsh -Command

connect-VIServer -Server *SOME IP* -User *SOME USER* -Password *SOME PASSWORD* 
Start-VM -VM "SOME SERVER"
the command:

Code: Select all

define command {

    command_name   restart-server
    command_line   /usr/local/nagios/libexec/eventhandlers/test1.ps1
}
the host:

Code: Select all

define host {

    contact_groups          Regular
    use                     windows-server          ; Inherit default values from a template
    host_name               test              ; The name we're giving to this host
    alias                   test       ; A longer name associated with the host
    address                 *SOME IP*             ; IP address of the host
    event_handler           restart-server
}
thank you.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: eventhandler | start a VM

Post by scottwilkerson »

When you test it from the command line are you running it as the nagios user?

Also, you may need to add the full path to connect-VIServer to make sure nagios knows where to find the file
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked