Page 1 of 1

Service Notes Pupup

Posted: Tue Sep 20, 2016 4:00 am
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?

Re: Service Notes Pupup

Posted: Tue Sep 20, 2016 1:00 pm
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

Re: Service Notes Pupup

Posted: Tue Sep 20, 2016 1:21 pm
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

Re: Service Notes Pupup

Posted: Tue Sep 20, 2016 2:07 pm
by whitest
Thank you very much, ssax!
It works on 4.0.8 too. =)

You may close the thread.

Re: Service Notes Pupup

Posted: Tue Sep 20, 2016 2:44 pm
by rkennedy
Awesome!

/closed