![]() |
Icinga-core 1.4.0
next gen monitoring
|
00001 /***************************************************************************** 00002 * 00003 * COMMENTS.H - Header file for comment functions 00004 * 00005 * Copyright (c) 1999-2009 Ethan Galstad (egalstad@nagios.org) 00006 * Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors 00007 * Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org) 00008 * 00009 * License: 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License version 2 as 00013 * published by the Free Software Foundation. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 * 00024 *****************************************************************************/ 00025 00026 00027 #ifndef _COMMENTS_H 00028 #define _COMMENTS_H 00029 00030 #include "config.h" 00031 #include "common.h" 00032 #include "objects.h" 00033 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 /**************************** COMMENT SOURCES ******************************/ 00040 00041 #define COMMENTSOURCE_INTERNAL 0 00042 #define COMMENTSOURCE_EXTERNAL 1 00043 00044 00045 00046 /***************************** COMMENT TYPES *******************************/ 00047 00048 #define HOST_COMMENT 1 00049 #define SERVICE_COMMENT 2 00050 #define ANY_COMMENT 3 00051 00052 00053 /****************************** ENTRY TYPES ********************************/ 00054 00055 #define USER_COMMENT 1 00056 #define DOWNTIME_COMMENT 2 00057 #define FLAPPING_COMMENT 3 00058 #define ACKNOWLEDGEMENT_COMMENT 4 00059 00060 00061 /*************************** CHAINED HASH LIMITS ***************************/ 00062 00063 #define COMMENT_HASHSLOTS 1024 00064 00065 00066 00067 /**************************** DATA STRUCTURES ******************************/ 00068 00069 00070 /* COMMENT structure */ 00071 typedef struct comment_struct{ 00072 int comment_type; 00073 int entry_type; 00074 unsigned long comment_id; 00075 int source; 00076 int persistent; 00077 time_t entry_time; 00078 int expires; 00079 time_t expire_time; 00080 char *host_name; 00081 char *service_description; 00082 char *author; 00083 char *comment_data; 00084 struct comment_struct *next; 00085 struct comment_struct *nexthash; 00086 }comment; 00087 00088 00089 #ifdef NSCORE 00090 int initialize_comment_data(char *); /* initializes comment data */ 00091 int cleanup_comment_data(char *); /* cleans up comment data */ 00092 int add_new_comment(int,int,char *,char *,time_t,char *,char *,int,int,int,time_t,unsigned long *); /* adds a new host or service comment */ 00093 int add_new_host_comment(int,char *,time_t,char *,char *,int,int,int,time_t,unsigned long *); /* adds a new host comment */ 00094 int add_new_service_comment(int,char *,char *,time_t,char *,char *,int,int,int,time_t,unsigned long *); /* adds a new service comment */ 00095 int delete_comment(int,unsigned long); /* deletes a host or service comment */ 00096 int delete_host_comment(unsigned long); /* deletes a host comment */ 00097 int delete_service_comment(unsigned long); /* deletes a service comment */ 00098 int delete_all_comments(int,char *,char *); /* deletes all comments for a particular host or service */ 00099 int delete_all_host_comments(char *); /* deletes all comments for a specific host */ 00100 int delete_host_acknowledgement_comments(host *); /* deletes all non-persistent ack comments for a specific host */ 00101 int delete_all_service_comments(char *,char *); /* deletes all comments for a specific service */ 00102 int delete_service_acknowledgement_comments(service *); /* deletes all non-persistent ack comments for a specific service */ 00103 00104 int check_for_expired_comment(unsigned long); /* expires a comment */ 00105 #endif 00106 00107 comment *find_comment(unsigned long,int); /* finds a specific comment */ 00108 comment *find_service_comment(unsigned long); /* finds a specific service comment */ 00109 comment *find_host_comment(unsigned long); /* finds a specific host comment */ 00110 comment *find_comment_by_similar_content(int,char *,char *,char *,char *); /* finds a comment based on content - used for distributed nagios instances */ 00111 00112 comment *get_first_comment_by_host(char *); 00113 comment *get_next_comment_by_host(char *,comment *); 00114 00115 int number_of_host_comments(char *); /* returns the number of comments associated with a particular host */ 00116 int number_of_service_comments(char *, char *); /* returns the number of comments associated with a particular service */ 00117 00118 /* If you are going to be adding a lot of comments in sequence, set 00119 defer_comment_sorting to 1 before you start and then call 00120 sort_comments afterwards. Things will go MUCH faster. */ 00121 00122 extern int defer_comment_sorting; 00123 int add_comment(int,int,char *,char *,time_t,char *,char *,unsigned long,int,int,time_t,int); /* adds a comment (host or service) */ 00124 int sort_comments(void); 00125 int add_host_comment(int,char *,time_t,char *,char *,unsigned long,int,int,time_t,int); /* adds a host comment */ 00126 int add_service_comment(int,char *,char *,time_t,char *,char *,unsigned long,int,int,time_t,int); /* adds a service comment */ 00127 00128 int add_comment_to_hashlist(comment *); 00129 00130 void free_comment_data(void); /* frees memory allocated to the comment list */ 00131 00132 #ifdef __cplusplus 00133 } 00134 #endif 00135 00136 #endif