Strip domain in Actions component?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
eclypse
Posts: 50
Joined: Thu Dec 01, 2011 4:55 pm

Strip domain in Actions component?

Post by eclypse »

I would like to to add an Action link to point to our data center inventory tool, but the HOSTNAME variable is set to the FQDN, and the data center inventory tool expects the host's short name.

Is there a way I can customize the Actions component to strip the domain before generating the url?

For example, my HOSTNAME is "myhost.domain.com" , but I'd like it to generate a link like:

http://somewebsite.domain.com/something.php?host=myhost
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Strip domain in Actions component?

Post by scottwilkerson »

One way to do this would be to put just the host's name in the "Display name" field, then you could use a url like

http://somewebsite.domain.com/something ... isplayname%
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
eclypse
Posts: 50
Joined: Thu Dec 01, 2011 4:55 pm

Re: Strip domain in Actions component?

Post by eclypse »

Hmm, that would work, but a bit of a pain as we have 500 hosts and have left Display blank for now. I guess a script to modify the DB would be the fastest way.

In the meantime, I found I was able to edit the php script and have it strip of the domain before it did the DB lookup to gather information to be displayed on the web page.

However, if there was a way we could do this in Nagios XI, that would help in the case where editing the php script isn't possible. Maybe this is possible via some work in the "code" section of the Actions component for this link?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Strip domain in Actions component?

Post by scottwilkerson »

This would be possible in the code section, you would need to would some code that manipulates $url which will already be set by this point.

something like

Code: Select all

$parts = explode("=", $url);
$fqdnparts = explode(".", $parts[1]);
$url = $parts[0]."=".$fqdnparts[0];

Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
eclypse
Posts: 50
Joined: Thu Dec 01, 2011 4:55 pm

Re: Strip domain in Actions component?

Post by eclypse »

scottwilkerson wrote:This would be possible in the code section, you would need to would some code that manipulates $url which will already be set by this point.

something like

Code: Select all

$parts = explode("=", $url);
$fqdnparts = explode(".", $parts[1]);
$url = $parts[0]."=".$fqdnparts[0];

Thanks! I will give this a try to see if I can make it work.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Strip domain in Actions component?

Post by sreinhardt »

Great, let us know!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked