RESOLVED: Change Service Warning text to differnet color in Tac.cgi???...

Jon Lyons jlyons30 at yahoo.com
Thu Jan 9 20:06:24 CET 2003


I'm not sure what you're asking, the default behavior is any services that are in a Critical, Warning, Unknown state on the TAC web page have a red background. With either black text, or with white text(acknowleged) or both. 
The changes I've made allow you to change the background colors for the Warning/unknown sections(Yellow for warnings, Brown for unknown). The text still changes color depending on whether the service has been acknowledged....I've also changed some of the title colors, so the Red/yellow/brown catch your eye... :)
 
 
 
 Wayne Mery <vseerror at Lehigh.EDU> wrote:Jon,

via this change, does your background color change with the highest 
warning level? Or are you only changing some text?

Thanks
Wayne


Jon Lyons wrote:
> FYI, I've updated my tac.c and tac.css (1.0b6) stylesheet to change 
> the default colors of the tac.cgi text backgrounds from red to yellow 
> for warnings, and brownish for unknown. Now only the critical alerts on 
> the tac.cgi are in red...
> 
> Basically I added two stylesheet definitions to tac.css; and call them 
> in tac.c...
> 
> warningserviceImportantProblem { text-align: left; font-family: arial; 
> font-size: 8pt; background-color: #FFFF00; color: black; }
> .unknownserviceImportantProblem { text-align: left; font-family: arial; 
> font-size: 8pt; background-color: #FF9966; color: black; }
> 
> /your/nagios/path/share/stylesheets/tac.css
> 
> */Jon Lyons /* wrote:
> 
> Hi, I've modified my tac.css stylesheet colors, but I'd like to
> change the service warning text block from red to something more
> like yellow for the tac.cgi, is this in the style sheet or somewhere
> else?? I'd like the critical sections to only use red.. :)
> 
> Thanks....
> 
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus
> -
> Powerful. Affordable. Sign up now
> 
> 
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus 
> - 
> Powerful. Affordable. Sign up now 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> /***********************************************************************
> *
> * TAC.C - Nagios Tactical Monitoring Overview CGI
> *
> * Copyright (c) 2001-2002 Ethan Galstad (nagios at nagios.org)
> * Last Modified: 08-07-2002
> *
> * This CGI program will display the contents of the Nagios
> * log file.
> *
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> * the Free Software Foundation; either version 2 of the License, or
> * (at your option) any later version.
> *
> * This program is distributed in the hope that it will be useful,
> * but WITHOUT ANY WARRANTY; without even the implied warranty of
> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> * GNU General Public License for more details.
> *
> * You should have received a copy of the GNU General Public License
> * along with this program; if not, write to the Free Software
> * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> ***********************************************************************/
> 
> #include "../common/config.h"
> #include "../common/locations.h"
> #include "../common/common.h"
> #include "../common/objects.h"
> #include "../common/statusdata.h"
> 
> #include "getcgi.h"
> #include "cgiutils.h"
> #include "auth.h"
> #include "lifo.h"
> 
> 
> #define HEALTH_WARNING_PERCENTAGE 90
> #define HEALTH_CRITICAL_PERCENTAGE 75
> 
> 
> /* HOSTOUTAGE structure */
> typedef struct hostoutage_struct{
> host *hst;
> int affected_child_hosts;
> struct hostoutage_struct *next;
> }hostoutage;
> 
> 
> extern char main_config_file[MAX_FILENAME_LENGTH];
> extern char url_images_path[MAX_FILENAME_LENGTH];
> extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
> extern char url_media_path[MAX_FILENAME_LENGTH];
> 
> extern int refresh_rate;
> 
> extern char *service_critical_sound;
> extern char *service_warning_sound;
> extern char *service_unknown_sound;
> extern char *host_down_sound;
> extern char *host_unreachable_sound;
> extern char *normal_sound;
> 
> extern hostgroup *hostgroup_list;
> extern hoststatus *hoststatus_list;
> extern servicestatus *servicestatus_list;
> extern host *host_list;
> extern service *service_list;
> 
> extern int enable_notifications;
> extern int execute_service_checks;
> extern int accept_passive_service_checks;
> extern int enable_event_handlers;
> extern int enable_flap_detection;
> 
> extern int nagios_process_state;
> 
> 
> 
> void analyze_status_data(void);
> void display_tac_overview(void);
> 
> void find_hosts_causing_outages(void);
> void calculate_outage_effect_of_host(host *,int *);
> int is_route_to_host_blocked(host *);
> int number_of_host_services(host *);
> void add_hostoutage(host *);
> void free_hostoutage_list(void);
> 
> void document_header(int);
> void document_footer(void);
> int process_cgivars(void);
> 
> authdata current_authdata;
> 
> int embedded=FALSE;
> int display_header=FALSE;
> 
> hostoutage *hostoutage_list=NULL;
> 
> int total_blocking_outages=0;
> int total_nonblocking_outages=0;
> 
> int total_service_health=0;
> int total_host_health=0;
> int potential_service_health=0;
> int potential_host_health=0;
> double percent_service_health=0.0;
> double percent_host_health=0.0;
> 
> int total_hosts=0;
> int total_services=0;
> 
> int total_active_checks=0;
> int total_passive_checks=0;
> 
> int min_execution_time=-1;
> int max_execution_time=-1;
> unsigned long total_execution_time=0L;
> double average_execution_time=-1.0;
> int min_latency=-1;
> int max_latency=-1;
> unsigned long total_latency=0L;
> double average_latency=-1.0;
> 
> int flapping_services=0;
> int flapping_hosts=0;
> int flap_disabled_services=0;
> int flap_disabled_hosts=0;
> int notification_disabled_services=0;
> int notification_disabled_hosts=0;
> int event_handler_disabled_services=0;
> int event_handler_disabled_hosts=0;
> int active_checks_disabled_services=0;
> int active_checks_disabled_hosts=0;
> int passive_checks_disabled_services=0;
> 
> int hosts_pending=0;
> int hosts_pending_disabled=0;
> int hosts_up_disabled=0;
> int hosts_up_unacknowledged=0;
> int hosts_up=0;
> int hosts_down_scheduled=0;
> int hosts_down_acknowledged=0;
> int hosts_down_disabled=0;
> int hosts_down_unacknowledged=0;
> int hosts_down=0;
> int hosts_unreachable_scheduled=0;
> int hosts_unreachable_acknowledged=0;
> int hosts_unreachable_disabled=0;
> int hosts_unreachable_unacknowledged=0;
> int hosts_unreachable=0;
> 
> int services_pending=0;
> int services_pending_disabled=0;
> int services_ok_disabled=0;
> int services_ok_unacknowledged=0;
> int services_ok=0;
> int services_warning_host_problem=0;
> int services_warning_scheduled=0;
> int services_warning_acknowledged=0;
> int services_warning_disabled=0;
> int services_warning_unacknowledged=0;
> int services_warning=0;
> int services_unknown_host_problem=0;
> int services_unknown_scheduled=0;
> int services_unknown_acknowledged=0;
> int services_unknown_disabled=0;
> int services_unknown_unacknowledged=0;
> int services_unknown=0;
> int services_critical_host_problem=0;
> int services_critical_scheduled=0;
> int services_critical_acknowledged=0;
> int services_critical_disabled=0;
> int services_critical_unacknowledged=0;
> int services_critical=0;
> 
> 
> 
> int main(void){
> int result=OK;
> char *sound=NULL;
> 
> 
> /* get the CGI variables passed in the URL */
> process_cgivars();
> 
> /* reset internal variables */
> reset_cgi_vars();
> 
> /* read the CGI configuration file */
> result=read_cgi_config_file(DEFAULT_CGI_CONFIG_FILE);
> if(result==ERROR){
> document_header(FALSE);
> cgi_config_file_error(DEFAULT_CGI_CONFIG_FILE);
> document_footer();
> return ERROR;
> }
> 
> /* read the main configuration file */
> result=read_main_config_file(main_config_file);
> if(result==ERROR){
> document_header(FALSE);
> main_config_file_error(main_config_file);
> document_footer();
> return ERROR;
> }
> 
> /* read all object configuration data */
> result=read_all_object_configuration_data(main_config_file,READ_ALL_OBJECT_DATA);
> if(result==ERROR){
> document_header(FALSE);
> object_data_error();
> document_footer();
> return ERROR;
> }
> 
> /* read all status data */
> result=read_all_status_data(DEFAULT_CGI_CONFIG_FILE,READ_ALL_STATUS_DATA);
> if(result==ERROR){
> document_header(FALSE);
> status_data_error();
> document_footer();
> free_memory();
> return ERROR;
> }
> 
> document_header(TRUE);
> 
> /* get authentication information */
> get_authentication_information(¤t_authdata);
> 
> if(display_header==TRUE){
> 
> /* begin top table */
> printf("\n");
> printf("\n");
> 
> /* left column of top table - info box */
> printf("\n");
> display_info_table("Tactical Status Overview",TRUE,¤t_authdata);
> printf("\n");
> 
> /* middle column of top table - log file navigation options */
> printf("\n");
> printf("\n");
> 
> /* right hand column of top row */
> printf("\n");
> printf("\n");
> 
> /* end of top table */
> printf("\n");
> printf("\n");
> printf("

\n");
> 
> }
> 
> 
> /* analyze current host and service status data for tac overview */
> analyze_status_data();
> 
> /* find all hosts that are causing network outages */
> find_hosts_causing_outages();
> 
> 
> /* embed sound tag if necessary... */
> if(hosts_unreachable_unacknowledged > 0 && host_unreachable_sound!=NULL)
> sound=host_unreachable_sound;
> else if(hosts_down_unacknowledged > 0 && host_down_sound!=NULL)
> sound=host_down_sound;
> else if(services_critical_unacknowledged > 0 && service_critical_sound!=NULL)
> sound=service_critical_sound;
> else if(services_warning_unacknowledged > 0 && service_warning_sound!=NULL)
> sound=service_warning_sound;
> else if(services_unknown_unacknowledged==0 && services_warning_unacknowledged==0 && services_critical_unacknowledged==0 && hosts_down_unacknowledged==0 && hosts_unreachable_unacknowledged==0 && normal_sound!=NULL)
> sound=normal_sound;
> if(sound!=NULL)
> printf("",url_media_path,sound);
> 
> 
> /**** display main tac screen ****/
> display_tac_overview();
> 
> document_footer();
> 
> /* free memory allocated to the host outage list */
> free_hostoutage_list();
> 
> /* free allocated memory */
> free_memory();
> 
> return OK;
> }
> 
> 
> 
> 
> void document_header(int use_stylesheet){
> char date_time[MAX_DATETIME_LENGTH];
> time_t current_time;
> time_t expire_time;
> 
> printf("Cache-Control: no-store\n");
> printf("Pragma: no-cache\n");
> printf("Refresh: %d\n",refresh_rate);
> 
> time(¤t_time);
> get_time_string(¤t_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME);
> printf("Last-Modified: %s\n",date_time);
> 
> expire_time=(time_t)0L;
> get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME);
> printf("Expires: %s\n",date_time);
> 
> printf("Content-type: text/html\n\n");
> 
> if(embedded==TRUE)
> return;
> 
> printf("\n");
> printf("\n");
> printf("\n");
> 
> if(use_stylesheet==TRUE)
> printf("
\n",url_stylesheets_path,TAC_CSS);
> 
> printf("\n");
> printf("\n");
> 
> /* include user SSI header */
> include_ssi_files(TAC_CGI,SSI_HEADER);
> 
> return;
> }
> 
> 
> void document_footer(void){
> 
> if(embedded==TRUE)
> return;
> 
> /* include user SSI footer */
> include_ssi_files(TAC_CGI,SSI_FOOTER);
> 
> printf("\n");
> printf("\n");
> 
> return;
> }
> 
> 
> int process_cgivars(void){
> char **variables;
> int error=FALSE;
> int x;
> 
> variables=getcgivars();
> 
> for(x=0;variables[x]!=NULL;x++){
> 
> /* do some basic length checking on the variable identifier to prevent buffer overflows */
> if(strlen(variables[x])>=MAX_INPUT_BUFFER-1){
> continue;
> }
> 
> /* we found the embed option */
> else if(!strcmp(variables[x],"embedded"))
> embedded=TRUE;
> 
> /* we found the noheader option */
> else if(!strcmp(variables[x],"noheader"))
> display_header=FALSE;
> 
> /* we recieved an invalid argument */
> else
> error=TRUE;
> 
> }
> 
> /* free memory allocated to the CGI variables */
> free_cgivars(variables);
> 
> return error;
> }
> 
> 
> 
> void analyze_status_data(void){
> servicestatus *temp_servicestatus;
> service *temp_service;
> hoststatus *temp_hoststatus;
> host *temp_host;
> int problem=TRUE;
> 
> 
> /* check all services */
> for(temp_servicestatus=servicestatus_list;temp_servicestatus!=NULL;temp_servicestatus=temp_servicestatus->next){
> 
> /* see if user is authorized to view this service */
> temp_service=find_service(temp_servicestatus->host_name,temp_servicestatus->description,NULL);
> if(is_authorized_for_service(temp_service,¤t_authdata)==FALSE)
> continue;
> 
> /******** CHECK FEATURES *******/
> 
> /* check flapping */
> if(temp_servicestatus->flap_detection_enabled==FALSE)
> flap_disabled_services++;
> else if(temp_servicestatus->is_flapping==TRUE)
> flapping_services++;
> 
> /* check notifications */
> if(temp_servicestatus->notifications_enabled==FALSE)
> notification_disabled_services++;
> 
> /* check event handler */
> if(temp_servicestatus->event_handler_enabled==FALSE)
> event_handler_disabled_services++;
> 
> /* active check execution */
> if(temp_servicestatus->checks_enabled==FALSE)
> active_checks_disabled_services++;
> 
> /* passive check acceptance */
> if(temp_servicestatus->accept_passive_service_checks==FALSE)
> passive_checks_disabled_services++;
> 
> 
> /********* CHECK STATUS ********/
> 
> problem=TRUE;
> 
> if(temp_servicestatus->status==SERVICE_OK || temp_servicestatus->status==SERVICE_RECOVERY){
> if(temp_servicestatus->checks_enabled==FALSE)
> services_ok_disabled++;
> else
> services_ok_unacknowledged++;
> services_ok++;
> }
> 
> else if(temp_servicestatus->status==SERVICE_WARNING){
> temp_hoststatus=find_hoststatus(temp_servicestatus->host_name);
> if(temp_hoststatus!=NULL && (temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE)){
> services_warning_host_problem++;
> problem=FALSE;
> }
> if(temp_servicestatus->scheduled_downtime_depth>0){
> services_warning_scheduled++;
> problem=FALSE;
> }
> if(temp_servicestatus->problem_has_been_acknowledged==TRUE){
> services_warning_acknowledged++;
> problem=FALSE;
> }
> if(temp_servicestatus->checks_enabled==FALSE){
> services_warning_disabled++;
> problem=FALSE;
> }
> if(problem==TRUE)
> services_warning_unacknowledged++;
> services_warning++;
> }
> 
> else if(temp_servicestatus->status==SERVICE_UNKNOWN){
> temp_hoststatus=find_hoststatus(temp_servicestatus->host_name);
> if(temp_hoststatus!=NULL && (temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE)){
> services_unknown_host_problem++;
> problem=FALSE;
> }
> if(temp_servicestatus->scheduled_downtime_depth>0){
> services_unknown_scheduled++;
> problem=FALSE;
> }
> if(temp_servicestatus->problem_has_been_acknowledged==TRUE){
> services_unknown_acknowledged++;
> problem=FALSE;
> }
> if(temp_servicestatus->checks_enabled==FALSE){
> services_unknown_disabled++;
> problem=FALSE;
> }
> if(problem==TRUE)
> services_unknown_unacknowledged++;
> services_unknown++;
> }
> 
> else if(temp_servicestatus->status==SERVICE_CRITICAL){
> temp_hoststatus=find_hoststatus(temp_servicestatus->host_name);
> if(temp_hoststatus!=NULL && (temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE)){
> services_critical_host_problem++;
> problem=FALSE;
> }
> if(temp_servicestatus->scheduled_downtime_depth>0){
> services_critical_scheduled++;
> problem=FALSE;
> }
> if(temp_servicestatus->problem_has_been_acknowledged==TRUE){
> services_critical_acknowledged++;
> problem=FALSE;
> }
> if(temp_servicestatus->checks_enabled==FALSE){
> services_critical_disabled++;
> problem=FALSE;
> }
> if(problem==TRUE)
> services_critical_unacknowledged++;
> services_critical++;
> }
> 
> else if(temp_servicestatus->status==SERVICE_PENDING){
> if(temp_servicestatus->checks_enabled==FALSE)
> services_pending_disabled++;
> services_pending++;
> }
> 
> 
> /* get health stats */
> if(temp_servicestatus->status==SERVICE_OK)
> total_service_health+=2;
> 
> else if(temp_servicestatus->status==SERVICE_WARNING || temp_servicestatus->status==SERVICE_UNKNOWN)
> total_service_health++;
> 
> if(temp_servicestatus->status!=SERVICE_PENDING)
> potential_service_health+=2;
> 
> 
> /* calculate execution time and latency stats */
> if(temp_servicestatus->check_type==SERVICE_CHECK_ACTIVE){
> 
> total_active_checks++;
> 
> if(min_latency==-1 || temp_servicestatus->latency> min_latency=temp_servicestatus->latency;
> if(max_latency==-1 || temp_servicestatus->latency>max_latency)
> max_latency=temp_servicestatus->latency;
> 
> if(min_execution_time==-1 || temp_servicestatus->execution_time> min_execution_time=temp_servicestatus->execution_time;
> if(max_execution_time==-1 || temp_servicestatus->execution_time>max_execution_time)
> max_execution_time=temp_servicestatus->execution_time;
> 
> total_latency+=temp_servicestatus->latency;
> total_execution_time+=temp_servicestatus->execution_time;
> }
> else
> total_passive_checks++;
> 
> 
> total_services++;
> }
> 
> 
> 
> /* check all hosts */
> for(temp_hoststatus=hoststatus_list;temp_hoststatus!=NULL;temp_hoststatus=temp_hoststatus->next){
> 
> /* see if user is authorized to view this host */
> temp_host=find_host(temp_hoststatus->host_name,NULL);
> if(is_authorized_for_host(temp_host,¤t_authdata)==FALSE)
> continue;
> 
> /******** CHECK FEATURES *******/
> 
> /* check flapping */
> if(temp_hoststatus->flap_detection_enabled==FALSE)
> flap_disabled_hosts++;
> else if(temp_hoststatus->is_flapping==TRUE)
> flapping_hosts++;
> 
> /* check notifications */
> if(temp_hoststatus->notifications_enabled==FALSE)
> notification_disabled_hosts++;
> 
> /* check event handler */
> if(temp_hoststatus->event_handler_enabled==FALSE)
> event_handler_disabled_hosts++;
> 
> /* active check execution */
> if(temp_hoststatus->checks_enabled==FALSE)
> active_checks_disabled_hosts++;
> 
> 
> /********* CHECK STATUS ********/
> 
> problem=TRUE;
> 
> if(temp_hoststatus->status==HOST_UP){
> if(temp_hoststatus->checks_enabled==FALSE)
> hosts_up_disabled++;
> else
> hosts_up_unacknowledged++;
> hosts_up++;
> }
> 
> else if(temp_hoststatus->status==HOST_DOWN){
> if(temp_hoststatus->scheduled_downtime_depth>0){
> hosts_down_scheduled++;
> problem=FALSE;
> }
> if(temp_hoststatus->problem_has_been_acknowledged==TRUE){
> hosts_down_acknowledged++;
> problem=FALSE;
> }
> if(temp_hoststatus->checks_enabled==FALSE){
> hosts_down_disabled++;
> problem=FALSE;
> }
> if(problem==TRUE)
> hosts_down_unacknowledged++;
> hosts_down++;
> }
> 
> else if(temp_hoststatus->status==HOST_UNREACHABLE){
> if(temp_hoststatus->scheduled_downtime_depth>0){
> hosts_unreachable_scheduled++;
> problem=FALSE;
> }
> if(temp_hoststatus->problem_has_been_acknowledged==TRUE){
> hosts_unreachable_acknowledged++;
> problem=FALSE;
> }
> if(temp_hoststatus->checks_enabled==FALSE){
> hosts_unreachable_disabled++;
> problem=FALSE;
> }
> if(problem==TRUE)

=== message truncated ===


---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20030109/ef28b5b5/attachment.html>


More information about the Users mailing list