When calling commands, can I have the addresses of other hosts, by something like:
$HOSTADDRESS:Servername$
?
Can I have access to this variables/macros inside a shell script or command?
Thanks!
$HOSTADDRESS:Servername$
Re: $HOSTADDRESS:Servername$
From:
https://assets.nagios.com/downloads/nag ... acros.html
https://assets.nagios.com/downloads/nag ... gmain.html
https://assets.nagios.com/downloads/nag ... acros.html
Also from:Macros as Environment Variables
Most macros are made available as environment variables for easy reference by scripts or commands that are executed by Nagios Core. For purposes of security and sanity, $USERn$ and "on-demand" host and service macros are not made available as environment variables.
Environment variables that contain standard macros are named the same as their corresponding macro names (listed here), with "NAGIOS_" prepended to their names. For example, the $HOSTNAME$ macro would be available as an environment variable named "NAGIOS_HOSTNAME".
https://assets.nagios.com/downloads/nag ... gmain.html
But your specific question:Environment Macros Option
Format: enable_environment_macros=<0/1>
Example: enable_environment_macros=0
This option determines whether or not the Nagios daemon will make all standard macros available as environment variables to your check, notification, event hander, etc. commands. In large Nagios installations this can be problematic because it takes additional memory and (more importantly) CPU to compute the values of all macros and make them available to the environment.
0 = Don't make macros available as environment variables
1 = Make macros available as environment variables (default)
Depends on the context of this script/command. Where it's executed, how it's executed, what you want to do with it, etc.Can I have access to this variables/macros inside a shell script or command?
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
kyang
Re: $HOSTADDRESS:Servername$
Thanks @mcapra!
@eltrasimaco, Take a look at what mcapra said, and let us know if you have any more questions.
@eltrasimaco, Take a look at what mcapra said, and let us know if you have any more questions.
-
eltrasimaco
- Posts: 75
- Joined: Thu Aug 02, 2012 7:15 am
Re: $HOSTADDRESS:Servername$
Thanks for your immediate response; I only miss the solution for my first question:
When calling commands, can I have the addresses of other hosts, by something like:
$HOSTADDRESS:Servername$ ?
$HOSTADDRESS$, as you now well, refers to the IP address of the "current" host.
But sometimes I need, in the called script, other IP addresses of other hosts.
How can I get those addresses, if I only know their display names?
I was thinking about something like "$HOSTADDRESS:hostname$", but this doesn't work for me
When calling commands, can I have the addresses of other hosts, by something like:
$HOSTADDRESS:Servername$ ?
$HOSTADDRESS$, as you now well, refers to the IP address of the "current" host.
But sometimes I need, in the called script, other IP addresses of other hosts.
How can I get those addresses, if I only know their display names?
I was thinking about something like "$HOSTADDRESS:hostname$", but this doesn't work for me
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: $HOSTADDRESS:Servername$
your question is already answered by @mcapra here - https://assets.nagios.com/downloads/nag ... acros.html - define custom variables at a host or service level, and you can then call them.eltrasimaco wrote:Thanks for your immediate response; I only miss the solution for my first question:
When calling commands, can I have the addresses of other hosts, by something like:
$HOSTADDRESS:Servername$ ?
$HOSTADDRESS$, as you now well, refers to the IP address of the "current" host.
But sometimes I need, in the called script, other IP addresses of other hosts.
How can I get those addresses, if I only know their display names?
I was thinking about something like "$HOSTADDRESS:hostname$", but this doesn't work for me
to answer the second part - i'm not following your logic. "But sometimes I need, in the called script, other IP addresses of other hosts." - this sounds custom of some sort which you need to work with. the above option will work, but it won't be dynamic.
-
eltrasimaco
- Posts: 75
- Joined: Thu Aug 02, 2012 7:15 am
Re: $HOSTADDRESS:Servername$
OK it's clear now; question has been resolved.
Thanks
Thanks
Re: $HOSTADDRESS:Servername$
In Nagios XI, you could use the REST API. See the "Help" section of the Nagios XI GUI for usage instructions.eltrasimaco wrote: But sometimes I need, in the called script, other IP addresses of other hosts.
How can I get those addresses, if I only know their display names?
In Nagios Core, you could use the back-end JSON CGIs.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: $HOSTADDRESS:Servername$
Thanks @mcapra! Locking, as OP said resolved.