1 /* 2 * Alarm Pinger (c) 2002 Jacek Konieczny <jajcus@pld.org.pl> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as published 6 * by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 16 * USA 17 * 18 * $Id: conf.h,v 1.14 2003/03/26 11:27:47 cvs-jajcus Exp $ 19 */ 20 21 #ifndef conf_h 22 #define conf_h 23 24 struct pool_item { 25 struct pool_item *next; 26 }; 27 28 void *pool_malloc(struct pool_item **pool,size_t size); 29 char *pool_strdup(struct pool_item **pool,const char *str); 30 void pool_free(struct pool_item **pool,void *ptr); 31 void pool_clear(struct pool_item **pool); 32 33 #define PNEW(pool,type,size) ((type *)pool_malloc(&pool,sizeof(type)*size)) 34 35 enum alarm_type { 36 AL_NONE=-1, 37 AL_DOWN=0, 38 AL_DELAY, 39 AL_LOSS, 40 NR_ALARMS 41 }; 42 43 struct alarm_cfg { 44 enum alarm_type type; 45 char *name; 46 char *mailto; 47 char *mailfrom; 48 char *mailenvfrom; 49 char *mailsubject; 50 char *command_on; 51 char *command_off; 52 char *pipe_on; 53 char *pipe_off; 54 int combine_interval; 55 int repeat_interval; 56 int repeat_max; 57 union { 58 int val; 59 struct { 60 int low; 61 int high; 62 }lh; 63 }p; 64 struct alarm_cfg *next; 65 }; 66 67 struct alarm_list { 68 struct alarm_cfg *alarm; 69 struct alarm_list *next; 70 }; 71 72 struct target_cfg { 73 char *name; 74 char *description; 75 int interval; 76 int avg_delay_samples; 77 int avg_loss_delay_samples; 78 int avg_loss_samples; 79 char *rrd_filename; 80 81 struct alarm_list *alarms; 82 int alarms_override; 83 struct target_cfg *next; 84 }; 85 86 struct config { 87 struct pool_item *pool; 88 struct alarm_cfg *alarms; 89 struct target_cfg *targets; 90 struct alarm_cfg alarm_defaults; 91 struct target_cfg target_defaults; 92 int rrd_interval; 93 int debug; 94 char *user; 95 char *group; 96 char *mailer; 97 char *pid_file; 98 char *status_file; 99 int status_interval; 100 char *timestamp_format; 101 }; 102 103 extern struct config cur_config,default_config; 104 extern struct config * config; 105 extern struct alarm_cfg *cur_alarm; 106 extern struct target_cfg *cur_target; 107 108 struct alarm_cfg * make_alarm(); 109 struct target_cfg * make_target(); 110 void add_alarm(enum alarm_type type); 111 void add_target(void); 112 struct alarm_list *alarm2list(const char *aname,struct alarm_list *list); 113 114 int load_config(const char *filename); 115 void free_config(void); 116 117 #endif 118