Service Notes Pupup

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
whitest
Posts: 107
Joined: Tue Dec 30, 2014 8:16 am

Service Notes Pupup

Post by whitest »

Hello.
I trying to display onhover popup with Service Notes in the same way as Host Address displayed when you point mouse on a HostName:
Image

I've found in status.c where it coded and can to display there Service Description popup (for test):

Code: Select all

			
/* service name column */
			printf("<td class='status%s'>", status_bg_class);
			printf("<table border=0 WIDTH='100%%' cellspacing=0 cellpadding=0>");
			printf("<tr>");
			printf("<td align='left'>");
			printf("<table border=0 cellspacing=0 cellpadding=0>\n");
			printf("<tr>\n");
			printf("<td align='left' valign=center class='status%s'><a href='%s?type=%d&host=%s", status_bg_class, EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(temp_status->host_name));
			printf("&service=%s' title='%s'>", url_encode(temp_status->description), temp_status->description);
			printf("%s</a></td>", temp_status->description);
			printf("</tr>\n");
			printf("</table>\n");
			printf("</td>\n");
			printf("<td ALIGN=RIGHT class='status%s'>\n", status_bg_class);
			printf("<table border=0 cellspacing=0 cellpadding=0>\n");
			printf("<tr>\n");
(my changes made in the line: printf("&service=%s' title='%s'>", url_encode(temp_status->description), temp_status->description);)

It's works:
Image

I'm not very familiar with programming, so the quastion is how to display service notes instead service description in the popup windows?
It would be ideal if notes popup message will be trunkated to ~150 chars (for example).

Could somebody help me please?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Service Notes Pupup

Post by tmcdonald »

I did some hacking around and it looks like service notes are not passed to that CGI script, so it would not be as simple as printing temp_service->notes. I tried that and it just appeared to echo out the description.

This will likely need to be requested on the GitHub directly: https://github.com/NagiosEnterprises/nagioscore
Former Nagios employee
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Service Notes Pupup

Post by ssax »

This should do what you're looking for, I tested it on 4.1.1 and 4.2.1 and it works for me:

(Around line 1755)

Code: Select all

                       /* service name column */
                        printf("<td class='status%s'>", status_bg_class);
                        printf("<table border=0 WIDTH='100%%' cellspacing=0 cellpadding=0>");
                        printf("<tr>");
                        printf("<td align='left'>");
                        printf("<table border=0 cellspacing=0 cellpadding=0>\n");
                        printf("<tr>\n");
                        printf("<td align='left' valign=center class='status%s'><a href='%s?type=%d&host=%s", status_bg_class, EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(temp_status->host_name));
                        printf("&service=%s' title='%.150s'>", url_encode(temp_status->description), temp_service->notes);
                        printf("%s</a></td>", temp_status->description);
                        printf("</tr>\n");
                        printf("</table>\n");
                        printf("</td>\n");
                        printf("<td ALIGN=RIGHT class='status%s'>\n", status_bg_class);
                        printf("<table border=0 cellspacing=0 cellpadding=0>\n");
                        printf("<tr>\n");
Let us know if that works for you.


Thank you
whitest
Posts: 107
Joined: Tue Dec 30, 2014 8:16 am

Re: Service Notes Pupup

Post by whitest »

Thank you very much, ssax!
It works on 4.0.8 too. =)

You may close the thread.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Service Notes Pupup

Post by rkennedy »

Awesome!

/closed
Former Nagios Employee
Locked