![]() |
Icinga-core 1.4.0
next gen monitoring
|
00001 /***************************************************************************** 00002 * 00003 * XCDDEFAULT.C - Default external comment data routines for Icinga 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 /*********** COMMON HEADER FILES ***********/ 00028 00029 #include "../include/config.h" 00030 #include "../include/common.h" 00031 #include "../include/locations.h" 00032 #include "../include/comments.h" 00033 #include "../include/macros.h" 00034 00035 #ifdef NSCORE 00036 #include "../include/objects.h" 00037 #include "../include/icinga.h" 00038 #endif 00039 00040 #ifdef NSCGI 00041 #include "../include/cgiutils.h" 00042 #endif 00043 00044 00045 /**** IMPLEMENTATION SPECIFIC HEADER FILES ****/ 00046 #include "xcddefault.h" 00047 00048 00049 #ifdef NSCORE 00050 extern unsigned long next_comment_id; 00051 extern comment *comment_list; 00052 #endif 00053 00054 00055 00056 #ifdef NSCORE 00057 00058 /******************************************************************/ 00059 /************ COMMENT INITIALIZATION/CLEANUP FUNCTIONS ************/ 00060 /******************************************************************/ 00061 00062 00063 /* initialize comment data */ 00064 int xcddefault_initialize_comment_data(char *main_config_file){ 00065 comment *temp_comment=NULL; 00066 00067 /* find the new starting index for comment id if its missing*/ 00068 if(next_comment_id==0L){ 00069 for(temp_comment=comment_list;temp_comment!=NULL;temp_comment=temp_comment->next){ 00070 if(temp_comment->comment_id>=next_comment_id) 00071 next_comment_id=temp_comment->comment_id+1; 00072 } 00073 } 00074 00075 /* initialize next comment id if necessary */ 00076 if(next_comment_id==0L) 00077 next_comment_id=1; 00078 00079 return OK; 00080 } 00081 00082 00083 /* removes invalid and old comments from the comment file */ 00084 int xcddefault_cleanup_comment_data(char *main_config_file){ 00085 00086 /* nothing to do anymore */ 00087 00088 return OK; 00089 } 00090 00091 00092 00093 00094 00095 /******************************************************************/ 00096 /***************** DEFAULT DATA OUTPUT FUNCTIONS ******************/ 00097 /******************************************************************/ 00098 00099 00100 /* adds a new host comment */ 00101 int xcddefault_add_new_host_comment(int entry_type, char *host_name, time_t entry_time, char *author_name, char *comment_data, int persistent, int source, int expires, time_t expire_time, unsigned long *comment_id){ 00102 00103 /* find the next valid comment id */ 00104 while(find_host_comment(next_comment_id)!=NULL) 00105 next_comment_id++; 00106 00107 /* add comment to list in memory */ 00108 add_host_comment(entry_type,host_name,entry_time,author_name,comment_data,next_comment_id,persistent,expires,expire_time,source); 00109 00110 /* update comment file */ 00111 xcddefault_save_comment_data(); 00112 00113 /* return the id for the comment we are about to add (this happens in the main code) */ 00114 if(comment_id!=NULL) 00115 *comment_id=next_comment_id; 00116 00117 /* increment the comment id */ 00118 next_comment_id++; 00119 00120 return OK; 00121 } 00122 00123 00124 /* adds a new service comment */ 00125 int xcddefault_add_new_service_comment(int entry_type, char *host_name, char *svc_description, time_t entry_time, char *author_name, char *comment_data, int persistent, int source, int expires, time_t expire_time, unsigned long *comment_id){ 00126 00127 /* find the next valid comment id */ 00128 while(find_service_comment(next_comment_id)!=NULL) 00129 next_comment_id++; 00130 00131 /* add comment to list in memory */ 00132 add_service_comment(entry_type,host_name,svc_description,entry_time,author_name,comment_data,next_comment_id,persistent,expires,expire_time,source); 00133 00134 /* update comment file */ 00135 xcddefault_save_comment_data(); 00136 00137 /* return the id for the comment we are about to add (this happens in the main code) */ 00138 if(comment_id!=NULL) 00139 *comment_id=next_comment_id; 00140 00141 /* increment the comment id */ 00142 next_comment_id++; 00143 00144 return OK; 00145 } 00146 00147 00148 00149 /******************************************************************/ 00150 /**************** COMMENT DELETION FUNCTIONS **********************/ 00151 /******************************************************************/ 00152 00153 00154 /* deletes a host comment */ 00155 int xcddefault_delete_host_comment(unsigned long comment_id){ 00156 00157 /* update comment file */ 00158 xcddefault_save_comment_data(); 00159 00160 return OK; 00161 } 00162 00163 00164 /* deletes a service comment */ 00165 int xcddefault_delete_service_comment(unsigned long comment_id){ 00166 00167 /* update comment file */ 00168 xcddefault_save_comment_data(); 00169 00170 return OK; 00171 } 00172 00173 00174 00175 /******************************************************************/ 00176 /****************** COMMENT OUTPUT FUNCTIONS **********************/ 00177 /******************************************************************/ 00178 00179 /* writes comment data to file */ 00180 int xcddefault_save_comment_data(void){ 00181 00182 /* don't update the status file now (too inefficent), let aggregated status updates do it */ 00183 return OK; 00184 } 00185 00186 #endif 00187