Macro for server name?

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
thewinelake
Posts: 3
Joined: Fri Aug 01, 2014 10:09 am

Macro for server name?

Post by thewinelake »

Is there a macro that I can use to give me the hostname of the nagios server itself?

I want this as we may have several nagios servers, and when they send an SMS, I'd like to know which one is sending it.

Of course I could manually put it into the command, but would be nice if it were simpler.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Macro for server name?

Post by eloyd »

Nope. No such thing in the docs or the source.

I would think if you're sending an SMS, then you would want to make each character count, so I don't know why you want the hostname in there, but you can always add it in the printf command within commands.cfg. Here's one idea. Note the `/bin/hostname` in the middle of the printf:

Code: Select all

define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%b" "$NOTIFICATIONTYPE$ - `/bin/hostname`: $SERVICEDESC$ ($HOSTNAME$) $SERVICESTATE$ - $SERVICEOUTPUT$\n" | $USER1$/send_sms 2>/dev/null
}
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
thewinelake
Posts: 3
Joined: Fri Aug 01, 2014 10:09 am

Re: Macro for server name?

Post by thewinelake »

Thanks - an interesting idea! However, in the end I just decided to rewrite the sender.

BTW, the hostname doesn't actually take any valuable SMS real-estate, as I'm putting it as the sender ID
Locked