Edit Nagios Core Web GUI Host URL to open in new tab.
-
humblestudent
- Posts: 6
- Joined: Fri Jun 14, 2019 1:33 pm
Edit Nagios Core Web GUI Host URL to open in new tab.
Hello Community,
I am trying to customize the Nagios Core Web GUI to have the hosts' URL open in a new tab on a web browser. Particularly, I am trying to configure the https://name_of_nagios_host/nagios/cgi-bin/status.cgi?hostgroup=all&style=overview
I am trying to find this style=overview, but it looks like it is some how generating the list of hosts based off the cgi. I was wondering if there was a way to configure it to add target="_blank" to each a herf for host names.
I am trying to customize the Nagios Core Web GUI to have the hosts' URL open in a new tab on a web browser. Particularly, I am trying to configure the https://name_of_nagios_host/nagios/cgi-bin/status.cgi?hostgroup=all&style=overview
I am trying to find this style=overview, but it looks like it is some how generating the list of hosts based off the cgi. I was wondering if there was a way to configure it to add target="_blank" to each a herf for host names.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
The only way I can think to do this would be with JS, you would have to add the following to the botton of the /nagios/js/nag_funcs.js script
On a source install this file would be
On a source install this file would be
Code: Select all
/usr/local/nagios/share/js/nag_funcs.jsCode: Select all
$(document).ready(function() {
$( "a[href*='status.cgi?host']" ).attr( "target", "_blank" );
});-
humblestudent
- Posts: 6
- Joined: Fri Jun 14, 2019 1:33 pm
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
Thank you for your prompt reply @scottwilkersonscottwilkerson wrote:The only way I can think to do this would be with JS, you would have to add the following to the botton of the /nagios/js/nag_funcs.js script
On a source install this file would beCode: Select all
/usr/local/nagios/share/js/nag_funcs.jsCode: Select all
$(document).ready(function() { $( "a[href*='status.cgi?host']" ).attr( "target", "_blank" ); });
Unfortunately I do not see that file.
I am running Nagios Core 4.2.4
and here is what is listed in my js directory:
Code: Select all
$ pwd
/usr/local/nagios/share/js
$ ls
histogram-events.js histogram-graph.js jquery-1.7.1.min.js map-directive.js map.js nagios-time.js trends-graph.js
histogram-form.js histogram.js jsonquery.js map-form.js nagios-decorations.js trends-form.js trends.jsAny additional tips or help would greatly be appreciated.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
What version of nagios are you using? The file I showed is in the latest
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
Technically you could add a few new lines and add it to jquery-1.7.1.min.js
-
humblestudent
- Posts: 6
- Joined: Fri Jun 14, 2019 1:33 pm
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
I am running Nagios Core Version 4.2.4scottwilkerson wrote:Technically you could add a few new lines and add it to jquery-1.7.1.min.js
Your tip looks like it may have worked.
I added your code snippet to jquery-1.7.1.min.js and restarted the nagios and httpd services, and it looks like that was able to do the trick.
Code: Select all
/*! jQuery v1.7.1 jquery.com | jquery.org/license */
$(document).ready(function() {
$( "a[href*='status.cgi?host']" ).attr( "target", "_blank" );
});-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
You would have to play with this to get what you want
Example: all URL's that contain host=
Example: all URL's that contain host=
Code: Select all
$(document).ready(function() {
$( "a[href*='host=']" ).attr( "target", "_blank" );
});-
humblestudent
- Posts: 6
- Joined: Fri Jun 14, 2019 1:33 pm
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
Think I answered my follow up question. when clicking on hosts under the Hosts and Services tab, they open to the following URL:humblestudent wrote:I am running Nagios Core Version 4.2.4scottwilkerson wrote:Technically you could add a few new lines and add it to jquery-1.7.1.min.js
Your tip looks like it may have worked.
I added your code snippet to jquery-1.7.1.min.js and restarted the nagios and httpd services, and it looks like that was able to do the trick.
This seems to work when clicking on hosts under "Host Groups" and "Service Groups" but it doesn't seem to work when clicking on Hosts under "Hosts" (https://host_name/nagios/cgi-bin/status.cgi?hostgroup=all&style=hostdetail) and "Services" (https://host_name/nagios/cgi-bin/status.cgi?host=all) Any other thoughts?Code: Select all
/*! jQuery v1.7.1 jquery.com | jquery.org/license */ $(document).ready(function() { $( "a[href*='status.cgi?host']" ).attr( "target", "_blank" ); });
Code: Select all
https://name_of_nagios_server/nagios/cgi-bin/extinfo.cgi?type=1&host=server_or_service_nameCode: Select all
$(document).ready(function() {
$( "a[href*='extinfo.cgi?type']" ).attr( "target", "_blank" );
});-
humblestudent
- Posts: 6
- Joined: Fri Jun 14, 2019 1:33 pm
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
scottwilkerson post resolved this issue.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Edit Nagios Core Web GUI Host URL to open in new tab.
Great!humblestudent wrote:scottwilkerson post resolved this issue.
Locking thread