eventhandler | start a VM

Discuss new project and feature ideas here.
See labs.nagios.com for new projects under development.

eventhandler | start a VM

Postby matanr » Mon Jan 07, 2019 3:37 am

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*

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

Re: eventhandler | start a VM

Postby scottwilkerson » Mon Jan 07, 2019 9:28 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
DevOps Engineer
Posts: 16617
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Return to Nagios Ideas

Who is online

Users browsing this forum: No registered users and 2 guests