Page 1 of 1

Reflect status in browser title bar

Posted: Fri Apr 18, 2014 9:25 pm
by bobc
Hi all,

I'm new here so I hope this is the place to show how we modified Nagios to reflect the current status in the title bar, so for tabbed browsers you can simply glance and the tab is see if everything is OK.

Edit cgi/status.c to add "nowrap" to host column (line 1671). /* because I don't like it when hostnames wrap */

Before the main() code add a global variable:

Code: Select all

int title_problems = 0;
Add the following code before the return() statement in show_host_status_totals() and show_service_status_totals():

Code: Select all

	title_problems += total_problems;
And finally add the following code before the return() statement in main():

Code: Select all

    if(title_problems == 0)
        printf("<script> top.document.title='OK - Freedom Communications Nagios';</script>\n");
    else
        printf("<script> top.document.title='PROBLEMS - Freedom Communications Nagios';</script>\n");
Edit cgi/tac.c and add the following code return before the return statement in main():

Code: Select all

    if((total_hosts == hosts_up) && (total_services == services_ok))
        printf("<script> top.document.title='OK - Freedom Communications Nagios';</script>\n");
    else
        printf("<script> top.document.title='PROBLEMS - Freedom Communications Nagios';</script>\n");
Hope this helps others.

Thanks,
Bob.