Edit Nagios Core Web GUI Host URL to open in new tab.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
humblestudent
Posts: 6
Joined: Fri Jun 14, 2019 1:33 pm

Edit Nagios Core Web GUI Host URL to open in new tab.

Post by humblestudent »

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.
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.

Post by scottwilkerson »

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

Code: Select all

/usr/local/nagios/share/js/nag_funcs.js

Code: Select all

$(document).ready(function() {
    $( "a[href*='status.cgi?host']" ).attr( "target", "_blank" );
});
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
humblestudent
Posts: 6
Joined: Fri Jun 14, 2019 1:33 pm

Re: Edit Nagios Core Web GUI Host URL to open in new tab.

Post by humblestudent »

scottwilkerson 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 be

Code: Select all

/usr/local/nagios/share/js/nag_funcs.js

Code: Select all

$(document).ready(function() {
    $( "a[href*='status.cgi?host']" ).attr( "target", "_blank" );
});
Thank you for your prompt reply @scottwilkerson

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.js
I am looking around for that string of code you referenced to see if it resides in another location on this version.

Any 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.

Post by scottwilkerson »

What version of nagios are you using? The file I showed is in the latest
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
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.

Post by scottwilkerson »

Technically you could add a few new lines and add it to jquery-1.7.1.min.js
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
humblestudent
Posts: 6
Joined: Fri Jun 14, 2019 1:33 pm

Re: Edit Nagios Core Web GUI Host URL to open in new tab.

Post by humblestudent »

scottwilkerson wrote:Technically you could add a few new lines and add it to jquery-1.7.1.min.js
I am running Nagios Core Version 4.2.4

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" );
});
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?
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.

Post by scottwilkerson »

You would have to play with this to get what you want

Example: all URL's that contain host=

Code: Select all

$(document).ready(function() {
    $( "a[href*='host=']" ).attr( "target", "_blank" );
});
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
humblestudent
Posts: 6
Joined: Fri Jun 14, 2019 1:33 pm

Re: Edit Nagios Core Web GUI Host URL to open in new tab.

Post by humblestudent »

humblestudent wrote:
scottwilkerson wrote:Technically you could add a few new lines and add it to jquery-1.7.1.min.js
I am running Nagios Core Version 4.2.4

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" );
});
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?
Think I answered my follow up question. when clicking on hosts under the Hosts and Services tab, they open to the following URL:

Code: Select all

https://name_of_nagios_server/nagios/cgi-bin/extinfo.cgi?type=1&host=server_or_service_name
so I also included the following code to the bottom of the jquery-1.7.1.min.js file.

Code: 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.

Post by humblestudent »

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.

Post by scottwilkerson »

humblestudent wrote:scottwilkerson post resolved this issue.
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked