Page 1 of 1

Strip domain in Actions component?

Posted: Wed Mar 06, 2013 3:10 pm
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

Re: Strip domain in Actions component?

Posted: Wed Mar 06, 2013 3:19 pm
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%

Re: Strip domain in Actions component?

Posted: Wed Mar 06, 2013 4:42 pm
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?

Re: Strip domain in Actions component?

Posted: Thu Mar 07, 2013 8:27 am
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];


Re: Strip domain in Actions component?

Posted: Thu Mar 07, 2013 4:48 pm
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.

Re: Strip domain in Actions component?

Posted: Fri Mar 08, 2013 11:57 am
by sreinhardt
Great, let us know!