Notifications - modify %host% output

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jacek
Posts: 255
Joined: Wed Sep 09, 2015 5:49 am

Notifications - modify %host% output

Post by jacek »

We use our Nagios from an central point and monitor many sites.
So the host names have their naming convention, and are ALWAYS looking this way:
Site-Type-Hostname
example: London-Server-SERVER01, Berlin-Switch-MAIN01, and so on.

What I'm looking for is cutting down the %host% variable to show only the "Hostname" part in the e-mail subject.
Like using some regexp to cut out everything from the left side untill (and including) the second minus "Site-Type-" and leave "Hostname".

The naming convention is very good from an administering point of view, but for the notified people don't need the whole story ;-)
I hope I made my point somehow clear :-)
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Notifications - modify %host% output

Post by bwallace »

This doc should enable you to make the modifications you've mentioned:

https://assets.nagios.com/downloads/nag ... iables.pdf

Note that it applies to XI users, not contacts - which of these are "...the notified people?"
Be sure to check out the Knowledgebase for helpful articles and solutions!
jacek
Posts: 255
Joined: Wed Sep 09, 2015 5:49 am

Re: Notifications - modify %host% output

Post by jacek »

So You mean I would need to create an additional variable?
I have an 1:1 core contact and XI user setup if thats what You are asking for?
I could also consider using the alias field with the hostname only, or? Would there be a way to automate this?
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Notifications - modify %host% output

Post by bwallace »

Glad that these are XI users so yeah that doc will work. I 'd suggest using %hostalias% instead. You can use the bulk renaming tool to appoint an alias name for hosts en mass if you haven't already. Other than the doc below (I don't think it is good for this task or scenario) I'm unaware of any other alternatives for automating these changes unfortunately - I take it you have a lot of XI users ?

https://assets.nagios.com/downloads/nag ... gement.pdf
Be sure to check out the Knowledgebase for helpful articles and solutions!
jacek
Posts: 255
Joined: Wed Sep 09, 2015 5:49 am

Re: Notifications - modify %host% output

Post by jacek »

Ok, then I will consider both solutions.
But I think I would go with the first one.

I have under 20 users, so I dont think thats much, but why are You asking?
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Notifications - modify %host% output

Post by bwallace »

Just asking out of an assumption is all - since you were inquiring about automation I assumed there were a ton of users involved, of course making it tedious to implement the changes one by one, but 20 is definitely manageable!
Be sure to check out the Knowledgebase for helpful articles and solutions!
jacek
Posts: 255
Joined: Wed Sep 09, 2015 5:49 am

Re: Notifications - modify %host% output

Post by jacek »

I seem I am getting confused?
How does the XI user ammount affect the ammount of work that I need to do?
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Notifications - modify %host% output

Post by dwhitfield »

For an automated system, it shouldn't matter (although at some point performance would become an issue). @bwallace was just curious about the scale.

Did you have any questions about https://assets.nagios.com/downloads/nag ... iables.pdf ?
jacek
Posts: 255
Joined: Wed Sep 09, 2015 5:49 am

Re: Notifications - modify %host% output

Post by jacek »

The "Understanding (...) Variables" doesn't help me much further.
It seems that the custom variables are static and added to each host, right?

If so, then I think it would be better to use the Alias field to put there an shorter hostname.
I presume aliases can be duplicated?

Am I here on an right track? It could be also an good use for the users of Nagios - having shorter names if they want (using aliases on the lists - saw that option somewhere).
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Notifications - modify %host% output

Post by dwhitfield »

slytheer wrote: I presume aliases can be duplicated?
Yes.

If you set an alias, you'll still want to use the variable in the notification...unless you are scripting things some other way.
Locked