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
Strip domain in Actions component?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Strip domain in Actions component?
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%
http://somewebsite.domain.com/something ... isplayname%
Re: Strip domain in Actions component?
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?
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?
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
something like
Code: Select all
$parts = explode("=", $url);
$fqdnparts = explode(".", $parts[1]);
$url = $parts[0]."=".$fqdnparts[0];
Re: Strip domain in Actions component?
Thanks! I will give this a try to see if I can make it work.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 likeCode: Select all
$parts = explode("=", $url); $fqdnparts = explode(".", $parts[1]); $url = $parts[0]."=".$fqdnparts[0];
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Strip domain in Actions component?
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.