/* cgi/cgiutils.h. Generated automatically by configure. */ /************************************************************************ * * CGIUTILS.H - Header file for common CGI functions * Written By: Ethan Galstad (netsaint@netsaint.org) * Last Modified: 02-03-2002 * * License: * * 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. ************************************************************************/ #ifndef _CGIUTILS_H #define _CGIUTILS_H #include "../common/objects.h" #include "auth.h" #include "edata.h" #define USE_STATUSMAP 1 /* should we compile and use the statusmap CGI? */ #define USE_STATUSWRL 1 /* should we compile and use the statuswrl CGI? */ #define USE_TRENDS 1 /* should we compile and use the trends CGI? */ /**************************** CGI REFRESH RATE ******************************/ #define DEFAULT_REFRESH_RATE 60 /* 60 second refresh rate for CGIs */ /******************************* CGI NAMES **********************************/ #define STATUS_CGI "status.cgi" #define STATUSMAP_CGI "statusmap.cgi" #define STATUSWORLD_CGI "statuswrl.cgi" #define COMMAND_CGI "cmd.cgi" #define EXTINFO_CGI "extinfo.cgi" #define SHOWLOG_CGI "showlog.cgi" #define NOTIFICATIONS_CGI "notifications.cgi" #define HISTORY_CGI "history.cgi" #define CONFIG_CGI "config.cgi" #define OUTAGES_CGI "outages.cgi" #define TRENDS_CGI "trends.cgi" #define AVAIL_CGI "avail.cgi" #define TAC_CGI "tac.cgi" #define STATUSWML_CGI "statuswml.cgi" #define TRACEROUTE_CGI "traceroute.cgi" /**************************** SYLE SHEET NAMES ******************************/ #define SHOWLOG_CSS "showlog.css" #define STATUS_CSS "status.css" #define STATUSMAP_CSS "statusmap.css" #define COMMAND_CSS "cmd.css" #define EXTINFO_CSS "extinfo.css" #define NOTIFICATIONS_CSS "notifications.css" #define HISTORY_CSS "history.css" #define CONFIG_CSS "config.css" #define OUTAGES_CSS "outages.css" #define TRENDS_CSS "trends.css" #define AVAIL_CSS "avail.css" #define TAC_CSS "tac.css" /********************************* ICONS ************************************/ #define STATUS_ICON_WIDTH 20 #define STATUS_ICON_HEIGHT 20 #define INFO_ICON "info.gif" #define INFO_ICON_ALT "Informational Message" #define START_ICON "start.gif" #define START_ICON_ALT "Program Start" #define STOP_ICON "stop.gif" #define STOP_ICON_ALT "Program End" #define RESTART_ICON "restart.gif" #define RESTART_ICON_ALT "Program Restart" #define RECOVERY_ICON "recovery.gif" #define RECOVERY_ICON_ALT "Service Recovery" #define CRITICAL_ICON "critical.gif" #define CRITICAL_ICON_ALT "Service State Critical" #define WARNING_ICON "warning.gif" #define WARNING_ICON_ALT "Service State Warning" #define UNKNOWN_ICON "unknown.gif" #define UNKNOWN_ICON_ALT "Service State Unknown" #define NOTIFICATION_ICON "notify.gif" #define NOTIFICATION_ICON_ALT "Service Notification" #define LOG_ROTATION_ICON "logrotate.gif" #define LOG_ROTATION_ICON_ALT "Log Rotation" #define EXTERNAL_COMMAND_ICON "command.gif" #define EXTERNAL_COMMAND_ICON_ALT "External Command" #define STATUS_DETAIL_ICON "status2.gif" #define STATUS_OVERVIEW_ICON "status.gif" #define STATUSMAP_ICON "status3.gif" #define STATUSWORLD_ICON "status4.gif" #define EXTINFO_ICON "extinfo.gif" #define HISTORY_ICON "history.gif" #define CONTACTGROUP_ICON "contactgroup.gif" #define TRENDS_ICON "trends.gif" #define DISABLED_ICON "disabled.gif" #define ENABLED_ICON "enabled.gif" #define NOTIFICATIONS_DISABLED_ICON "ndisabled.gif" #define ACKNOWLEDGEMENT_ICON "ack.gif" #define REMOVE_ACKNOWLEDGEMENT_ICON "noack.gif" #define COMMENT_ICON "comment.gif" #define DELETE_ICON "delete.gif" #define DELAY_ICON "delay.gif" #define DOWNTIME_ICON "delay.gif" #define PASSIVE_ICON "unknown.gif" #define RIGHT_ARROW_ICON "right.gif" #define LEFT_ARROW_ICON "left.gif" #define UP_ARROW_ICON "up.gif" #define DOWN_ARROW_ICON "down.gif" #define FLAPPING_ICON "flapping.gif" #define SCHEDULED_DOWNTIME_ICON "downtime.gif" #define ACTIVE_ICON "active.gif" #define ACTIVE_ICON_ALT "Active Mode" #define STANDBY_ICON "standby.gif" #define STANDBY_ICON_ALT "Standby Mode" #define HOST_CRITICAL_ICON "critical.gif" #define HOST_CRITICAL_ICON_ALT "Host Down" #define HOST_RECOVERY_ICON "recovery.gif" #define HOST_RECOVERY_ICON_ALT "Host Recovery" #define HOST_NOTIFICATION_ICON "notify.gif" #define HOST_NOTIFICATION_ICON_ALT "Host Notification" #define SERVICE_EVENT_ICON "serviceevent.gif" #define SERVICE_EVENT_ICON_ALT "Service Event Handler" #define HOST_EVENT_ICON "hostevent.gif" #define HOST_EVENT_ICON_ALT "Host Event Handler" #define THERM_OK_IMAGE "thermok.gif" #define THERM_WARNING_IMAGE "thermwarn.gif" #define THERM_CRITICAL_IMAGE "thermcrit.gif" #define CONFIGURATION_ICON "config.gif" #define NOTES_ICON "notes.gif" #define PARENT_TRAVERSAL_ICON "parentup.gif" #define TAC_DISABLED_ICON "tacdisabled.jpg" #define TAC_ENABLED_ICON "tacenabled.jpg" #define ZOOM1_ICON "zoom1.gif" #define ZOOM2_ICON "zoom2.gif" /************************** PLUGIN RETURN VALUES ****************************/ #define STATE_OK 0 #define STATE_WARNING 1 #define STATE_CRITICAL 2 #define STATE_UNKNOWN 3 /* changed from -1 on 02/24/2001 */ /********************* EXTENDED INFO CGI DISPLAY TYPES *********************/ #define DISPLAY_PROCESS_INFO 0 #define DISPLAY_HOST_INFO 1 #define DISPLAY_SERVICE_INFO 2 #define DISPLAY_COMMENTS 3 #define DISPLAY_PERFORMANCE 4 #define DISPLAY_HOSTGROUP_INFO 5 /************************ COMMAND CGI COMMAND MODES *************************/ #define CMDMODE_NONE 0 #define CMDMODE_REQUEST 1 #define CMDMODE_COMMIT 2 /******************** HOST AND SERVICE NOTIFICATION TYPES ******************/ #define NOTIFICATION_ALL 0 /* all service and host notifications */ #define NOTIFICATION_SERVICE_ALL 1 /* all types of service notifications */ #define NOTIFICATION_HOST_ALL 2 /* all types of host notifications */ #define NOTIFICATION_SERVICE_WARNING 4 #define NOTIFICATION_SERVICE_UNKNOWN 8 #define NOTIFICATION_SERVICE_CRITICAL 16 #define NOTIFICATION_SERVICE_RECOVERY 32 #define NOTIFICATION_HOST_DOWN 64 #define NOTIFICATION_HOST_UNREACHABLE 128 #define NOTIFICATION_HOST_RECOVERY 256 #define NOTIFICATION_SERVICE_ACK 512 #define NOTIFICATION_HOST_ACK 1024 /********************** HOST AND SERVICE ALERT TYPES **********************/ #define HISTORY_ALL 0 /* all service and host alert */ #define HISTORY_SERVICE_ALL 1 /* all types of service alerts */ #define HISTORY_HOST_ALL 2 /* all types of host alerts */ #define HISTORY_SERVICE_WARNING 4 #define HISTORY_SERVICE_UNKNOWN 8 #define HISTORY_SERVICE_CRITICAL 16 #define HISTORY_SERVICE_RECOVERY 32 #define HISTORY_HOST_DOWN 64 #define HISTORY_HOST_UNREACHABLE 128 #define HISTORY_HOST_RECOVERY 256 /****************************** SORT TYPES *******************************/ #define SORT_NONE 0 #define SORT_ASCENDING 1 #define SORT_DESCENDING 2 /**************************** DATE/TIME TYPES ****************************/ #define LONG_DATE_TIME 0 /* ctime() style */ #define SHORT_DATE_TIME 1 #define HTTP_DATE_TIME 2 /* expiration style for HTTP headers */ /***************************** SORT OPTIONS ******************************/ #define SORT_NOTHING 0 #define SORT_HOSTNAME 1 #define SORT_SERVICENAME 2 #define SORT_SERVICESTATUS 3 #define SORT_LASTCHECKTIME 4 #define SORT_CURRENTATTEMPT 5 #define SORT_STATEDURATION 6 /****************** HOST AND SERVICE FILTER PROPERTIES *******************/ #define HOST_SCHEDULED_DOWNTIME 1 #define HOST_NO_SCHEDULED_DOWNTIME 2 #define HOST_STATE_ACKNOWLEDGED 4 #define HOST_STATE_UNACKNOWLEDGED 8 #define HOST_CHECKS_DISABLED 16 #define HOST_CHECKS_ENABLED 32 #define HOST_EVENT_HANDLER_DISABLED 64 #define HOST_EVENT_HANDLER_ENABLED 128 #define HOST_FLAP_DETECTION_DISABLED 256 #define HOST_FLAP_DETECTION_ENABLED 512 #define HOST_IS_FLAPPING 1024 #define HOST_IS_NOT_FLAPPING 2048 #define HOST_NOTIFICATIONS_DISABLED 4096 #define HOST_NOTIFICATIONS_ENABLED 8192 #define SERVICE_SCHEDULED_DOWNTIME 1 #define SERVICE_NO_SCHEDULED_DOWNTIME 2 #define SERVICE_STATE_ACKNOWLEDGED 4 #define SERVICE_STATE_UNACKNOWLEDGED 8 #define SERVICE_CHECKS_DISABLED 16 #define SERVICE_CHECKS_ENABLED 32 #define SERVICE_EVENT_HANDLER_DISABLED 64 #define SERVICE_EVENT_HANDLER_ENABLED 128 #define SERVICE_FLAP_DETECTION_ENABLED 256 #define SERVICE_FLAP_DETECTION_DISABLED 512 #define SERVICE_IS_FLAPPING 1024 #define SERVICE_IS_NOT_FLAPPING 2048 #define SERVICE_NOTIFICATIONS_DISABLED 4096 #define SERVICE_NOTIFICATIONS_ENABLED 8192 #define SERVICE_PASSIVE_CHECKS_DISABLED 16384 #define SERVICE_PASSIVE_CHECKS_ENABLED 32768 #define SERVICE_PASSIVE_CHECK 65536 #define SERVICE_ACTIVE_CHECK 131072 /******************************** FUNCTIONS *******************************/ void reset_cgi_vars(void); void free_cgi_vars(void); void free_memory(void); int read_cgi_config_file(char *); int read_main_config_file(char *); int read_all_object_configuration_data(char *,int); int read_all_status_data(char *,int); void strip(char *); /* strips newlines, carriage returns, and spaces from end of buffer */ void sanitize_plugin_output(char *); /* strips HTML and bad characters from plugin output */ char * read_raw_line(char *,int,FILE *); /* reads a line of text from a file and strip()s it clean */ char * read_line(char *,int,FILE *); /* reads only valid lines (no comments or blank lines) */ void get_time_string(time_t *,char *,int,int); /* gets a date/time string */ void get_interval_time_string(int,char *,int); /* gets a time string for an interval of time */ void get_expire_time_string(time_t *,char *,int); /* gets a date/time string in the format used for Expire: tags*/ char * my_strtok(char *,char *); /* replacement for strtok() function - doesn't skip multiple tokens */ char *my_strsep (char **, const char *); char * url_encode(char *); /* encodes a string in proper URL format */ char * html_encode(char *); /* encodes a string in HTML format (for display on screen) */ int get_netsaint_process_info(void); /* gets information about the state of the netsaint process */ void get_time_breakdown(unsigned long,int *,int *,int *,int *); /* given total seconds, get days, hours, minutes, seconds */ void get_log_archive_to_use(int,char *,int); /* determines the name of the log archive to use */ void determine_log_rotation_times(int); int determine_archive_to_use_from_time(time_t); void calculate_host_state_times(char *, unsigned long *, unsigned long *, float *, unsigned long *, float *, unsigned long *, float *); void calculate_service_state_times(char *, char *, unsigned long *, unsigned long *, float *, unsigned long *, float *, unsigned long *, float *, unsigned long *, float *); void print_host_notes_url(hostextinfo *); void print_service_notes_url(serviceextinfo *); void display_info_table(char *,int,authdata *); void display_nav_table(char *,int); #endif