Command HOST_NAME Macro
-
sistemasproadata
- Posts: 12
- Joined: Mon Jan 15, 2018 8:36 am
Command HOST_NAME Macro
Hi, i have this command defined :
$USER1$/check_nrpe -H 172.18.0.67 -t 30 -c veeam_estado -a $HOSTNAME$
the macro $HOSTNAME$ is not returning me the name defined on the host cfg:
define host {
host_name srvcon003.proa.com
use xiwizard_windowsserver_host
someone knows why?
Thanks
$USER1$/check_nrpe -H 172.18.0.67 -t 30 -c veeam_estado -a $HOSTNAME$
the macro $HOSTNAME$ is not returning me the name defined on the host cfg:
define host {
host_name srvcon003.proa.com
use xiwizard_windowsserver_host
someone knows why?
Thanks
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Command HOST_NAME Macro
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Command HOST_NAME Macro
In addition to the NSClient/NRPE command definition, It might also be worthwhile to know which version of Nagios XI you are using as well as the NSClient/NRPE version.
I didn't have any issues passing $HOSTNAME$ in a command definition on Nagios Core 4.3.2 which makes me think this is an issue with the agent's setup:
I didn't have any issues passing $HOSTNAME$ in a command definition on Nagios Core 4.3.2 which makes me think this is an issue with the agent's setup:
Code: Select all
define host{
use linux-server
host_name PRODHERMES1
address 17.212.19.8
check_command check_ping!1000.0,50%!2000.0,80%
}
define service{
use elasticsearch-prod ; Name of service template to use
hostgroup_name HERMESPROD
service_description Hermes Front-end on 7777
check_command test_macros_host
}
define command{
command_name test_macros_host
command_line echo $HOSTNAME$ is the hostname && exit 0
}
Code: Select all
servicestatus {
host_name=PRODHERMES1
service_description=Hermes Front-end on 7777
check_command=test_macros_host
plugin_output=PRODHERMES1 is the hostname
}
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
sistemasproadata
- Posts: 12
- Joined: Mon Jan 15, 2018 8:36 am
Re: Command HOST_NAME Macro
npolovenko wrote:Hello, @sistemasproadata.
Can you show us how you defined the command veeam_estado?
[/settings/external scripts/scripts]
veeam_estado = cmd /c echo scripts\\veeam_estado.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -
-
sistemasproadata
- Posts: 12
- Joined: Mon Jan 15, 2018 8:36 am
Re: Command HOST_NAME Macro
nagios:
Your Nagios XI installation is up to date.
Latest Available Version: 5.4.11
Installed Version: 5.4.11
Last Update Check: 16/01/2018 08:34:02
nrpe:
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
nsclient:
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
Your Nagios XI installation is up to date.
Latest Available Version: 5.4.11
Installed Version: 5.4.11
Last Update Check: 16/01/2018 08:34:02
nrpe:
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
nsclient:
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
mcapra wrote:In addition to the NSClient/NRPE command definition, It might also be worthwhile to know which version of Nagios XI you are using as well as the NSClient/NRPE version.
I didn't have any issues passing $HOSTNAME$ in a command definition on Nagios Core 4.3.2 which makes me think this is an issue with the agent's setup:
Code: Select all
define host{ use linux-server host_name PRODHERMES1 address 17.212.19.8 check_command check_ping!1000.0,50%!2000.0,80% } define service{ use elasticsearch-prod ; Name of service template to use hostgroup_name HERMESPROD service_description Hermes Front-end on 7777 check_command test_macros_host } define command{ command_name test_macros_host command_line echo $HOSTNAME$ is the hostname && exit 0 }Code: Select all
servicestatus { host_name=PRODHERMES1 service_description=Hermes Front-end on 7777 check_command=test_macros_host plugin_output=PRODHERMES1 is the hostname }
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Command HOST_NAME Macro
@sistemasproadata, Your command definition seems right. Can you upload the veeam_estado.ps1 script here, or send it to me in a PM? That way I could actually test it on my system to see what's going on.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
sistemasproadata
- Posts: 12
- Joined: Mon Jan 15, 2018 8:36 am
Re: Command HOST_NAME Macro
hi, is a simple code to check if one virtual machines is copied on the last veeam backup, the problem is not sending the name of the server as arg, is sending "$HOSTNAME$" as text
Code: Select all
asnp VeeamPSSnapin
$VMName = $args[0].Split(".")[0]
foreach($Job in (Get-VBRJob))
{
$Session = $Job.FindLastSession()
if(!$Session){continue;}
$Tasks = $Session.GetTaskSessions()
$returncode= 0
$estado= $Tasks | ?{$_.Name -eq $VMName} | %{$_.Status}
if ($estado -eq "Success")
{
$returncode= 0
write "$estado|$returncode"
exit $returncode
}
if ($estado -eq "Warning")
{
$returncode= 1
write "$estado|$returncode"
exit $returncode
}
}
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Command HOST_NAME Macro
@sistemasproadata, I did run a test. I added the command just like you have it.
I changed the Powershell script to this:
Then I created a service that uses the following command:
I called the host: "srvcon003.proa.com"
Here's the output i'm getting:
So the macro does work. Maybe the problem is that it splits the hostname and only uses the first part before the period?
Code: Select all
[/settings/external scripts/scripts]
veeam_estado = cmd /c echo scripts\\veeam_estado.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -Code: Select all
$VMName = $args[0].Split(".")[0]
Write-Host "passed argument: $VMName "Code: Select all
$USER1$/check_nrpe -H 192.168.3.231 -c veeam_estado -a $HOSTNAME$Here's the output i'm getting:
Code: Select all
passed argument: srvcon003As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
sistemasproadata
- Posts: 12
- Joined: Mon Jan 15, 2018 8:36 am
Re: Command HOST_NAME Macro
Hi, my problem is the macro $HOSTNAME$ is sending me the name of the nagios machine, not the hostname defined on the nagios conf for the host.
Regards
Regards
-
sistemasproadata
- Posts: 12
- Joined: Mon Jan 15, 2018 8:36 am
Re: Command HOST_NAME Macro
[[email protected] ~]$ /usr/local/nagios/libexec/check_nrpe -H 172.18.0.67 -t 30 -c veeam_estado -a $HOSTNAME$
passed argument: srvmanmon002
srvmanmon002 is the hostname of nagios
passed argument: srvmanmon002
srvmanmon002 is the hostname of nagios