diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/bartlby.cfg.in bartlby-core/bartlby.cfg.in --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/bartlby.cfg.in 2007-01-05 02:48:59.000000000 +0100 +++ bartlby-core/bartlby.cfg.in 2008-04-03 11:15:43.000000000 +0200 @@ -14,6 +14,7 @@ sched_round_pause=6 sirene_interval=10 instant_write_back=true +micros_before_after=700 ui_right_dir=/var/www/htdocs/dev.bartlby.org/bartlby-ui/rights/ diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/include/bartlby.h bartlby-core/include/bartlby.h --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/include/bartlby.h 2008-01-03 18:50:30.000000000 +0100 +++ bartlby-core/include/bartlby.h 2008-04-06 22:57:54.000000000 +0200 @@ -1,10 +1,12 @@ #define PROGNAME "bartlby" -#define REL_NAME "zero-eight" -#define VERSION "1.3.0" -#define EXPECTCORE 1103051 //Module V Check's +#define REL_NAME "autobot" +#define VERSION "1.3.1" +#define EXPECTCORE 1103381 //Module V Check's #define MAX_CCACHE 1024 +#define MAX_CCACHE_KEY 1024 +#define MAX_CCACHE_VALUE 1024 #define RECOVERY_OUTSTANDING 1 @@ -168,7 +170,8 @@ int flap_count; int last_notify_send; struct service * dead_marker; - + int is_gone; + } xxyz; @@ -235,6 +238,11 @@ int is_server_dead; + /**/ + long renotify_interval; // interval to renotify + long escalate_divisor; // + + int is_gone; }; struct service_sort { @@ -260,7 +268,7 @@ char t[500]; long escalation_limit; long escalation_minutes; - + int is_gone; }sa; @@ -272,6 +280,7 @@ char downtime_notice[2048]; int service_id; + int is_gone; }sb; struct btl_event { @@ -323,7 +332,7 @@ #define PORTIER_REQUEST_PACKET 3 -char * getConfigValue_ex(char * key, char * fname, int cache); +char * getConfigValue_ex(const char * key, const char * fname, int cache); char * getConfigValue(char *, char *); int clear_serviceMap(struct service **); int clear_workerMap(struct worker ** m); @@ -332,7 +341,7 @@ void sched_write_back_all(char * cfgfile, void * shm_addr, void * SOHandle); void sched_reschedule(struct service * svc); -int service_is_in_time(char * time_plan); +int service_is_in_time(const char * time_plan); void bartlby_check_service(struct service * svc, void *, void *, char *); void bartlby_check_active(struct service * svc, char * cfgfile); void bartlby_check_local(struct service * svc, char * cfgfile); @@ -364,9 +373,9 @@ int bartlby_core_perf_track(struct shm_header * hdr, struct service * svc, int type, int time); long bartlby_milli_timediff(struct timeval end, struct timeval start); -void bartlby_trigger(struct service * svc, char * cfgfile, void * shm_addr, int do_check); +void bartlby_trigger(struct service * svc, char * cfgfile, void * shm_addr, int do_check, int standby_workers_only); //Global :-) -int _log(char * str, ...); +int _log(const char * str, ...); void bartlby_decode(char * msg, int length); void bartlby_encode(char * msg, int length); @@ -389,12 +398,12 @@ //EVNT's void bartlby_event_init(void * bartlby_address); struct btl_event * bartlby_SHM_EventMap(void * shm_addr); -int bartlby_push_event(int event_id, char * str, ...); +int bartlby_push_event(int event_id, const char * str, ...); void bartlby_pre_init(char * cfgfile); void cfg_init_cache(void); -char * cfg_add_to_cache(char * k, char * v); +char * cfg_add_to_cache(const char * k, char * v); void cfg_fill_with_file(char * f); void cfg_update_cache(char * k, char * v); void bartlby_ext_init(void * shm_addr, void * data_loader, char * cfg); diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/Makefile bartlby-core/Makefile --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/Makefile 2006-10-08 01:32:59.000000000 +0200 +++ bartlby-core/Makefile 2008-04-16 23:00:55.000000000 +0200 @@ -1,17 +1,20 @@ include Makefile.conf + SUBDIRS = src/ src/libs/ src/tools/ -TRIGGERS = icq.sh jabber.sh mail.sh +TRIGGERS = icq.sh jabber.sh mail.sh sms.sh PERFHANDLERS = bartlby_http bartlby_if bartlby_load bartlby_snmp.sh bartlby_swap.sh bartlby_files_in_dir DIRR = bartlby-core bartlby-plugins bartlby-php bartlby-ui bartlby-docs all: - list='$(SUBDIRS)'; for subdir in $$list; do \ + @list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && make all); \ done + + install: all $(MKDIRP) ${BARTLBY_HOME}/bin/ $(MKDIRP) ${BARTLBY_HOME}/etc/ @@ -41,9 +44,9 @@ test "$$subdir" = . || (cd $$subdir && make install); \ done - + . ./post_compile.sh clean: - list='$(SUBDIRS)'; for subdir in $$list; do \ + @list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && make clean); \ done changelog: diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/Makefile.conf.in bartlby-core/Makefile.conf.in --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/Makefile.conf.in 2007-01-15 12:59:41.000000000 +0100 +++ bartlby-core/Makefile.conf.in 2008-04-03 11:15:43.000000000 +0200 @@ -1,4 +1,5 @@ -CC = @CC@ +CC = @echo "[CC] $<";@CC@ +LNK = @echo "[LNK] $<"; @CC@ CPPVA = @INSTALL_PATH@ @INSTALL_OPTIONS@ RMVFR = rm -vfr MKDIRP = @INSTALL_PATH@ @INSTALL_OPTIONS@ -d diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/mysql.shema bartlby-core/mysql.shema --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/mysql.shema 2007-02-07 15:36:33.000000000 +0100 +++ bartlby-core/mysql.shema 2008-04-03 11:48:53.000000000 +0200 @@ -1,7 +1,6 @@ -- phpMyAdmin SQL Dump -- version 2.6.3-pl1 -- http://www.phpmyadmin.net --- -- Host: localhost -- Erstellungszeit: 20. Mai 2006 um 22:24 -- Server Version: 4.0.24 @@ -80,6 +79,8 @@ `service_snmp_critical` int(11) NOT NULL default '80', `service_snmp_type` int(11) NOT NULL default '1', `flap_seconds` int(11) NOT NULL default '120', + `renotify_interval` int(11) NOT NULL default '0', + `escalate_divisor` int(11) NOT NULL default '0', PRIMARY KEY (`service_id`), KEY `service_id` (`service_id`), KEY `service_id_2` (`service_id`,`server_id`) diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/nsca-2.7.1-for-bartlby.patch bartlby-core/nsca-2.7.1-for-bartlby.patch --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/nsca-2.7.1-for-bartlby.patch 2007-02-16 21:40:25.000000000 +0100 +++ bartlby-core/nsca-2.7.1-for-bartlby.patch 2008-04-03 11:15:43.000000000 +0200 @@ -1,64 +1,140 @@ diff -Nur ../nsca-2.7.1/1 ./1 --- ../nsca-2.7.1/1 1970-01-01 01:00:00.000000000 +0100 -+++ ./1 2007-02-16 17:10:04.000000000 +0100 ++++ ./1 2008-03-27 20:43:34.000000000 +0100 @@ -0,0 +1,3 @@ +test Alive 2 dsadsadsa + + -diff -Nur ../nsca-2.7.1/include/bartlby.h ./include/bartlby.h ---- ../nsca-2.7.1/include/bartlby.h 1970-01-01 01:00:00.000000000 +0100 -+++ ./include/bartlby.h 2007-02-16 16:50:47.000000000 +0100 -@@ -0,0 +1,167 @@ -+#include -+#include +diff -Nur ../nsca-2.7.1/bartlby.h ./bartlby.h +--- ../nsca-2.7.1/bartlby.h 1970-01-01 01:00:00.000000000 +0100 ++++ ./bartlby.h 2008-03-27 20:08:46.000000000 +0100 +@@ -0,0 +1,422 @@ ++#include +#include -+#include -+ ++ ++#define PROGNAME "bartlby" ++#define REL_NAME "autobot" ++#define VERSION "1.3.1" ++#define EXPECTCORE 1103251 //Module V Check's ++ ++#define MAX_CCACHE 1024 ++#define MAX_CCACHE_KEY 1024 ++#define MAX_CCACHE_VALUE 1024 ++ ++ ++#define RECOVERY_OUTSTANDING 1 ++#define RECOVERY_DONE 0 ++ ++ ++#define EXTENSION_OK 0 ++#define EXTENSION_NOK 1 ++ ++ ++#define EXTENSION_CALLBACK_ALL -1 ++#define EXTENSION_CALLBACK_PRE_CHECK 1 ++#define EXTENSION_CALLBACK_POST_CHECK 2 ++#define EXTENSION_CALLBACK_STATE_CHANGED 3 ++#define EXTENSION_CALLBACK_TRIGGER_PRE 4 ++#define EXTENSION_CALLBACK_SCHED_WAIT 5 ++#define EXTENSION_CALLBACK_UNKOWN_CHECK_TYPE 6 ++#define EXTENSION_CALLBACK_ROUND_TIME 7 ++#define EXTENSION_CALLBACK_CHECK_TIME 8 ++#define EXTENSION_CALLBACK_EVENT_PUSHED 9 ++#define EXTENSION_CALLBACK_REPLICATION_GO 10 ++#define EXTENSION_CALLBACK_TRIGGER_FIRED 11 ++ ++ ++ ++#define PORTIER_CONN_TIMEOUT 30 ++ ++#define EVENT_QUEUE_MAX 128 ++#define EVENT_STATUS_CHANGED 2 ++#define EVENT_TRIGGER_PUSHED 3 ++ ++ ++ ++#define STATE_OK 0 ++#define STATE_WARNING 1 ++#define STATE_CRITICAL 2 ++#define STATE_UNKOWN 3 ++#define STATE_SIRENE 7 ++ ++ ++//Service ACK ++ ++#define ACK_NOT_NEEDED 0 ++#define ACK_NEEDED 1 ++#define ACK_OUTSTANDING 2 ++ ++#define DT_SERVICE 1 ++#define DT_SERVER 2 ++ ++#define SVC_TYPE_ACTIVE 1 +#define SVC_TYPE_PASSIVE 2 ++#define SVC_TYPE_GROUP 3 ++#define SVC_TYPE_LOCAL 4 ++#define SVC_TYPE_SNMP 5 ++#define SVC_TYPE_NRPE 6 ++#define SVC_TYPE_NRPE_SSL 7 ++#define SVC_TYPE_V2 8 ++#define SVC_TYPE_V2_NO_SSL 9 + + -+struct worker { -+ char name[2048]; -+ char mail[2048]; -+ char icq[2048]; -+ char services[2048]; -+ -+ int worker_id; -+ int active; -+ char notify_plan[2048]; -+ char password[2048]; -+ -+ int escalation_count; -+ int escalation_time; -+ char notify_levels[20]; -+ char enabled_triggers[2048]; -+ char t[500]; -+ int escalation_limit; -+ int escalation_minutes; ++#define SVC_THRESHOLD 10 + -+}sa; ++#define PERF_TYPE_SVC_TIME 1 ++#define PERF_TYPE_ROUND_TIME 2 ++ ++ ++#define PASSIVE_TIMEOUT "Passive Service has been timed out" ++#define DNS_ERROR "DNS lookup error" ++#define SOCKET_CREATE_ERROR "Socket create error" ++#define ALARM_ERROR "Alarm setup error" ++#define CONN_ERROR "Connection error" ++#define RECV_ERROR "Recieve Error" ++#define PROTOCOL_ERROR "Protocol Error" ++#define TIMEOUT_ERROR "Recv() timedout" + -+struct downtime { -+ int downtime_id; -+ int downtime_type; -+ int downtime_from; -+ int downtime_to; -+ char downtime_notice[2048]; -+ int service_id; -+ -+}sb; ++ ++ ++ ++ ++#define GROUP_CRITICAL "Group check critical" ++#define GROUP_WITHOUT_PARMS "Group check without parameters" ++#define GROUP_OK "Group check OK" ++ ++ ++ ++#define LOAD_SYMBOL(x,y,z) x=dlsym(y, z); \ ++ if((dlmsg=dlerror()) != NULL) { \ ++ _log("-Error: %s", dlmsg); \ ++ exit(1); \ ++ } ++ ++ ++ ++ ++ ++struct shm_counter { ++ long worker; ++ long services; ++ long downtimes; ++ long servers; ++}; + +struct perf_statistic { + long sum; + long counter; +}; ++ ++ +struct snmpi { + char community[512]; + int version; + char objid[1024]; -+ int warn; -+ int crit; -+ int type; ++ long warn; ++ long crit; ++ long type; +}; +struct sprocess { + int start_time; @@ -66,18 +142,27 @@ + +}; + ++struct sched_threads { ++ int pid; ++ struct service * svc; ++ int start_time; ++ int its_over; ++} astt; ++ ++ ++ +struct shm_header { -+ int size_of_structs; -+ int thrdcount; -+ int svccount; -+ int wrkcount; -+ int srvcount; -+ int current_running; ++ long size_of_structs; ++ long thrdcount; ++ long svccount; ++ long wrkcount; ++ long srvcount; ++ long current_running; + char version[50]; + int do_reload; + int last_replication; + int startup_time; -+ int dtcount; ++ long dtcount; + int sirene_mode; + struct perf_statistic pstat; + int cur_event_index; @@ -86,7 +171,7 @@ +}; + +struct server { -+ int server_id; ++ long server_id; + char client_ip[2048]; + char server_name[2048]; + char server_icon[1024]; @@ -94,7 +179,7 @@ + int client_port; + int server_dead; + int server_notify; -+ int server_flap_seconds; ++ long server_flap_seconds; + int flap_count; + int last_notify_send; + struct service * dead_marker; @@ -104,8 +189,8 @@ + + +struct service { -+ int service_id; -+ int server_id; ++ long service_id; ++ long server_id; + int last_state; + int current_state; + @@ -114,8 +199,8 @@ + + char plugin[2048]; + char plugin_arguments[2048]; -+ int check_interval; -+ int check_interval_original; ++ long check_interval; ++ long check_interval_original; + int last_check; + struct timeval lcheck; + @@ -126,24 +211,24 @@ + /*Notify things*/ + int notify_enabled; + int last_notify_send; -+ int flap_count; ++ long flap_count; + + int service_active; + + char service_var[2048]; + int service_type; -+ int service_passive_timeout; ++ long service_passive_timeout; + + int notify_last_state; + int notify_last_time; -+ int service_check_timeout; ++ long service_check_timeout; + + + + int service_ack; + -+ int service_retain; -+ int service_retain_current; ++ long service_retain; ++ long service_retain_current; + + + @@ -158,14 +243,355 @@ + + struct sprocess process; + -+ int flap_seconds; ++ long flap_seconds; + + struct server * srv; -+ int srv_place; ++ long srv_place; + + int is_server_dead; + ++ /**/ ++ long renotify_interval; // interval to renotify ++ long escalate_divisor; // ++}; ++ ++struct service_sort { ++ struct service * svc; ++}; ++ ++ ++struct worker { ++ char name[2048]; ++ char mail[2048]; ++ char icq[2048]; ++ char services[2048]; ++ ++ long worker_id; ++ int active; ++ char notify_plan[2048]; ++ char password[2048]; ++ ++ int escalation_count; ++ int escalation_time; ++ char notify_levels[20]; ++ char enabled_triggers[2048]; ++ char t[500]; ++ long escalation_limit; ++ long escalation_minutes; ++ ++}sa; ++ ++ ++struct downtime { ++ long downtime_id; ++ int downtime_type; ++ int downtime_from; ++ int downtime_to; ++ char downtime_notice[2048]; ++ int service_id; ++ ++}sb; ++ ++struct btl_event { ++ long evnt_id; ++ char evnt_message[1024]; ++ int evnt_time; ++ ++}eb; ++struct ext_notify { ++ struct service * svc; ++ struct worker * wrk; ++ char * trigger; ++} ty; ++ ++ ++ ++typedef struct v2_packet_struct{ ++ ++ u_int32_t crc32_value; ++ int16_t exit_code; ++ int16_t packet_type; ++ char output[2048]; ++ char cmdline[2048]; ++ char plugin[2048]; ++ char perf_handler[1024]; ++ ++ ++} agent_v2_packet; ++ ++typedef struct port_packet_struct{ ++ ++ u_int32_t crc32_value; ++ int16_t exit_code; ++ int16_t packet_type; ++ char output[2048]; ++ char cmdline[2048]; ++ char plugin[2048]; ++ char perf_handler[1024]; ++ int32_t service_id; ++ ++ ++} portier_packet; ++ ++#define AGENT_V2_SENT_PACKET 1 ++#define AGENT_V2_RETURN_PACKET 2 ++ ++#define PORTIER_SVCLIST_PACKET 1 ++#define PORTIER_RESULT_PACKET 2 ++#define PORTIER_REQUEST_PACKET 3 ++ ++ ++char * getConfigValue_ex(const char * key, const char * fname, int cache); ++char * getConfigValue(char *, char *); ++int clear_serviceMap(struct service **); ++int clear_workerMap(struct worker ** m); ++ ++int schedule_loop(char *, void *, void *); ++void sched_write_back_all(char * cfgfile, void * shm_addr, void * SOHandle); ++ ++void sched_reschedule(struct service * svc); ++int service_is_in_time(const char * time_plan); ++void bartlby_check_service(struct service * svc, void *, void *, char *); ++void bartlby_check_active(struct service * svc, char * cfgfile); ++void bartlby_check_local(struct service * svc, char * cfgfile); ++void bartlby_check_group(struct service * svc, void * shm_addr); ++ ++ ++void bartlby_check_snmp(struct service * svc, char * cfgfile); ++void bartlby_check_nrpe(struct service * svc, char * cfgfile, int use_ssl); ++ ++void str_mysql_safe(char * str); ++void service_mysql_safe(struct service * svc); ++ ++ ++//Replication ++int replication_go(char *, void *, void *); ++ ++//SHM ++ ++int GetDowntimeMap(struct downtime * svcs, char * config); ++struct service * bartlby_SHM_ServiceMap(void *); ++struct sched_threads * bartlby_SHM_ThreadMap(void * shm_addr); ++struct downtime * bartlby_SHM_DowntimeMap(void * shm_addr); ++struct shm_header * bartlby_SHM_GetHDR(void *); ++struct worker * bartlby_SHM_WorkerMap(void * shm_addr); ++struct server * bartlby_SHM_ServerMap(void * shm_addr); ++void bartlby_SHM_link_services_servers(void * shm_addr, char * cfgfile); ++ ++void bartlby_perf_track(struct service * svc,char * return_buffer, int return_bytes, char * cfgfile); ++int bartlby_core_perf_track(struct shm_header * hdr, struct service * svc, int type, int time); ++long bartlby_milli_timediff(struct timeval end, struct timeval start); ++ ++void bartlby_trigger(struct service * svc, char * cfgfile, void * shm_addr, int do_check, int standby_workers_only); ++//Global :-) ++int _log(const char * str, ...); ++ ++void bartlby_decode(char * msg, int length); ++void bartlby_encode(char * msg, int length); ++char * bartlby_beauty_state(int status); ++ ++void bartlby_end_clean(char *cfgfile); ++void bartlby_get_daemon(char * cfgfile); ++void set_cfg(char * cfg); ++ ++void str_replace(char *str, const char *from, const char *to, int maxlen); ++void bartlby_replace_svc_in_str(char * str, struct service * svc, int max); ++ ++void bartlby_action_handle_reply(struct service * svc, char * rmessage, char * cfgfile); ++int bartlby_action_handle_reply_line(struct service * svc, char * line, char *cfgfile); ++void bartlby_check_sirene(char * configfile, void * bartlby_address); ++int bartlby_is_in_downtime(void * bartlby_address, struct service * svc); ++ ++ ++//EVNT's ++void bartlby_event_init(void * bartlby_address); ++struct btl_event * bartlby_SHM_EventMap(void * shm_addr); ++int bartlby_push_event(int event_id, const char * str, ...); ++ ++void bartlby_pre_init(char * cfgfile); ++ ++void cfg_init_cache(void); ++char * cfg_add_to_cache(const char * k, char * v); ++void cfg_fill_with_file(char * f); ++void cfg_update_cache(char * k, char * v); ++void bartlby_ext_init(void * shm_addr, void * data_loader, char * cfg); ++void bartlby_ext_shutdown(int sched_exit_code); ++int bartlby_ext_register_callback(int type, void * fcn); ++int bartlby_callback(int type, void *data); ++ ++void bartlby_fin_service(struct service * svc, void * SOHandle, void * shm_addr,char * cfgfile); ++ ++void bartlby_check_grep_perf_line(char * l, struct service * svc, char * cfgfile); ++ ++ ++int bartlby_tcp_recvall(int s, char *buf, int *len, int timeout); ++int bartlby_tcp_sendall(int s, char *buf, int *len); ++ ++void bartlby_log_usage(void); ++ ++void nrpe_display_license(void); ++void bartlby_check_v2(struct service * svc, char * cfgfile, int use_ssl); +diff -Nur ../nsca-2.7.1/include/bartlby.h ./include/bartlby.h +--- ../nsca-2.7.1/include/bartlby.h 1970-01-01 01:00:00.000000000 +0100 ++++ ./include/bartlby.h 2008-03-27 20:39:21.000000000 +0100 +@@ -0,0 +1,167 @@ ++#include ++#include ++#include ++#include ++ ++#define SVC_TYPE_PASSIVE 2 ++struct perf_statistic { ++ long sum; ++ long counter; ++}; ++struct snmpi { ++ char community[512]; ++ int version; ++ char objid[1024]; ++ long warn; ++ long crit; ++ long type; ++}; ++struct sprocess { ++ int start_time; ++ int pid; ++ ++}; ++ ++ ++struct shm_header { ++ long size_of_structs; ++ long thrdcount; ++ long svccount; ++ long wrkcount; ++ long srvcount; ++ long current_running; ++ char version[50]; ++ int do_reload; ++ int last_replication; ++ int startup_time; ++ long dtcount; ++ int sirene_mode; ++ struct perf_statistic pstat; ++ int cur_event_index; ++ ++ ++}; ++struct server { ++ long server_id; ++ char client_ip[2048]; ++ char server_name[2048]; ++ char server_icon[1024]; ++ int server_enabled; ++ int client_port; ++ int server_dead; ++ int server_notify; ++ long server_flap_seconds; ++ int flap_count; ++ int last_notify_send; ++ struct service * dead_marker; ++ ++} xxyz; ++ ++ ++ ++struct service { ++ long service_id; ++ long server_id; ++ int last_state; ++ int current_state; ++ ++ char new_server_text[2048]; ++ char service_name[2048]; ++ ++ char plugin[2048]; ++ char plugin_arguments[2048]; ++ long check_interval; ++ long check_interval_original; ++ int last_check; ++ struct timeval lcheck; ++ ++ /*Time stuff*/ ++ ++ char service_exec_plan[2048]; ++ ++ /*Notify things*/ ++ int notify_enabled; ++ int last_notify_send; ++ long flap_count; ++ ++ int service_active; ++ ++ char service_var[2048]; ++ int service_type; ++ long service_passive_timeout; ++ ++ int notify_last_state; ++ int notify_last_time; ++ long service_check_timeout; ++ ++ ++ ++ int service_ack; ++ ++ long service_retain; ++ long service_retain_current; ++ ++ ++ ++ struct perf_statistic pstat; ++ struct perf_statistic delay_time; ++ ++ int do_force; ++ ++ struct snmpi snmp_info; ++ ++ int recovery_outstanding; //Flag to see if recover is waiting ++ ++ struct sprocess process; ++ ++ long flap_seconds; ++ ++ struct server * srv; ++ long srv_place; ++ ++ int is_server_dead; ++ ++ /**/ ++ long renotify_interval; // interval to renotify ++ long escalate_divisor; // +}; ++struct worker { ++ char name[2048]; ++ char mail[2048]; ++ char icq[2048]; ++ char services[2048]; ++ ++ long worker_id; ++ int active; ++ char notify_plan[2048]; ++ char password[2048]; ++ ++ int escalation_count; ++ int escalation_time; ++ char notify_levels[20]; ++ char enabled_triggers[2048]; ++ char t[500]; ++ long escalation_limit; ++ long escalation_minutes; ++ ++}sa; ++struct downtime { ++ long downtime_id; ++ int downtime_type; ++ int downtime_from; ++ int downtime_to; ++ char downtime_notice[2048]; ++ int service_id; ++ ++}sb; ++ + +struct service * bartlby_SHM_ServiceMap(void *); +struct sched_threads * bartlby_SHM_ThreadMap(void * shm_addr); @@ -215,6 +641,1552 @@ +++ ./nsca_tests/var/nsca.pid 2007-02-15 17:01:01.000000000 +0100 @@ -0,0 +1 @@ +3561 +diff -Nur ../nsca-2.7.1/p1 ./p1 +--- ../nsca-2.7.1/p1 1970-01-01 01:00:00.000000000 +0100 ++++ ./p1 2008-03-27 20:44:08.000000000 +0100 +@@ -0,0 +1,1542 @@ ++diff -Nur ../nsca-2.7.1/1 ./1 ++--- ../nsca-2.7.1/1 1970-01-01 01:00:00.000000000 +0100 +++++ ./1 2008-03-27 20:43:34.000000000 +0100 ++@@ -0,0 +1,3 @@ +++test Alive 2 dsadsadsa +++ +++ ++diff -Nur ../nsca-2.7.1/bartlby.h ./bartlby.h ++--- ../nsca-2.7.1/bartlby.h 1970-01-01 01:00:00.000000000 +0100 +++++ ./bartlby.h 2008-03-27 20:08:46.000000000 +0100 ++@@ -0,0 +1,422 @@ +++#include +++#include +++ +++#define PROGNAME "bartlby" +++#define REL_NAME "autobot" +++#define VERSION "1.3.1" +++#define EXPECTCORE 1103251 //Module V Check's +++ +++#define MAX_CCACHE 1024 +++#define MAX_CCACHE_KEY 1024 +++#define MAX_CCACHE_VALUE 1024 +++ +++ +++#define RECOVERY_OUTSTANDING 1 +++#define RECOVERY_DONE 0 +++ +++ +++#define EXTENSION_OK 0 +++#define EXTENSION_NOK 1 +++ +++ +++#define EXTENSION_CALLBACK_ALL -1 +++#define EXTENSION_CALLBACK_PRE_CHECK 1 +++#define EXTENSION_CALLBACK_POST_CHECK 2 +++#define EXTENSION_CALLBACK_STATE_CHANGED 3 +++#define EXTENSION_CALLBACK_TRIGGER_PRE 4 +++#define EXTENSION_CALLBACK_SCHED_WAIT 5 +++#define EXTENSION_CALLBACK_UNKOWN_CHECK_TYPE 6 +++#define EXTENSION_CALLBACK_ROUND_TIME 7 +++#define EXTENSION_CALLBACK_CHECK_TIME 8 +++#define EXTENSION_CALLBACK_EVENT_PUSHED 9 +++#define EXTENSION_CALLBACK_REPLICATION_GO 10 +++#define EXTENSION_CALLBACK_TRIGGER_FIRED 11 +++ +++ +++ +++#define PORTIER_CONN_TIMEOUT 30 +++ +++#define EVENT_QUEUE_MAX 128 +++#define EVENT_STATUS_CHANGED 2 +++#define EVENT_TRIGGER_PUSHED 3 +++ +++ +++ +++#define STATE_OK 0 +++#define STATE_WARNING 1 +++#define STATE_CRITICAL 2 +++#define STATE_UNKOWN 3 +++#define STATE_SIRENE 7 +++ +++ +++//Service ACK +++ +++#define ACK_NOT_NEEDED 0 +++#define ACK_NEEDED 1 +++#define ACK_OUTSTANDING 2 +++ +++#define DT_SERVICE 1 +++#define DT_SERVER 2 +++ +++#define SVC_TYPE_ACTIVE 1 +++#define SVC_TYPE_PASSIVE 2 +++#define SVC_TYPE_GROUP 3 +++#define SVC_TYPE_LOCAL 4 +++#define SVC_TYPE_SNMP 5 +++#define SVC_TYPE_NRPE 6 +++#define SVC_TYPE_NRPE_SSL 7 +++#define SVC_TYPE_V2 8 +++#define SVC_TYPE_V2_NO_SSL 9 +++ +++ +++#define SVC_THRESHOLD 10 +++ +++#define PERF_TYPE_SVC_TIME 1 +++#define PERF_TYPE_ROUND_TIME 2 +++ +++ +++#define PASSIVE_TIMEOUT "Passive Service has been timed out" +++#define DNS_ERROR "DNS lookup error" +++#define SOCKET_CREATE_ERROR "Socket create error" +++#define ALARM_ERROR "Alarm setup error" +++#define CONN_ERROR "Connection error" +++#define RECV_ERROR "Recieve Error" +++#define PROTOCOL_ERROR "Protocol Error" +++#define TIMEOUT_ERROR "Recv() timedout" +++ +++ +++ +++ +++ +++#define GROUP_CRITICAL "Group check critical" +++#define GROUP_WITHOUT_PARMS "Group check without parameters" +++#define GROUP_OK "Group check OK" +++ +++ +++ +++#define LOAD_SYMBOL(x,y,z) x=dlsym(y, z); \ +++ if((dlmsg=dlerror()) != NULL) { \ +++ _log("-Error: %s", dlmsg); \ +++ exit(1); \ +++ } +++ +++ +++ +++ +++ +++struct shm_counter { +++ long worker; +++ long services; +++ long downtimes; +++ long servers; +++}; +++ +++struct perf_statistic { +++ long sum; +++ long counter; +++}; +++ +++ +++struct snmpi { +++ char community[512]; +++ int version; +++ char objid[1024]; +++ long warn; +++ long crit; +++ long type; +++}; +++struct sprocess { +++ int start_time; +++ int pid; +++ +++}; +++ +++struct sched_threads { +++ int pid; +++ struct service * svc; +++ int start_time; +++ int its_over; +++} astt; +++ +++ +++ +++struct shm_header { +++ long size_of_structs; +++ long thrdcount; +++ long svccount; +++ long wrkcount; +++ long srvcount; +++ long current_running; +++ char version[50]; +++ int do_reload; +++ int last_replication; +++ int startup_time; +++ long dtcount; +++ int sirene_mode; +++ struct perf_statistic pstat; +++ int cur_event_index; +++ +++ +++}; +++ +++struct server { +++ long server_id; +++ char client_ip[2048]; +++ char server_name[2048]; +++ char server_icon[1024]; +++ int server_enabled; +++ int client_port; +++ int server_dead; +++ int server_notify; +++ long server_flap_seconds; +++ int flap_count; +++ int last_notify_send; +++ struct service * dead_marker; +++ +++} xxyz; +++ +++ +++ +++struct service { +++ long service_id; +++ long server_id; +++ int last_state; +++ int current_state; +++ +++ char new_server_text[2048]; +++ char service_name[2048]; +++ +++ char plugin[2048]; +++ char plugin_arguments[2048]; +++ long check_interval; +++ long check_interval_original; +++ int last_check; +++ struct timeval lcheck; +++ +++ /*Time stuff*/ +++ +++ char service_exec_plan[2048]; +++ +++ /*Notify things*/ +++ int notify_enabled; +++ int last_notify_send; +++ long flap_count; +++ +++ int service_active; +++ +++ char service_var[2048]; +++ int service_type; +++ long service_passive_timeout; +++ +++ int notify_last_state; +++ int notify_last_time; +++ long service_check_timeout; +++ +++ +++ +++ int service_ack; +++ +++ long service_retain; +++ long service_retain_current; +++ +++ +++ +++ struct perf_statistic pstat; +++ struct perf_statistic delay_time; +++ +++ int do_force; +++ +++ struct snmpi snmp_info; +++ +++ int recovery_outstanding; //Flag to see if recover is waiting +++ +++ struct sprocess process; +++ +++ long flap_seconds; +++ +++ struct server * srv; +++ long srv_place; +++ +++ int is_server_dead; +++ +++ /**/ +++ long renotify_interval; // interval to renotify +++ long escalate_divisor; // +++}; +++ +++struct service_sort { +++ struct service * svc; +++}; +++ +++ +++struct worker { +++ char name[2048]; +++ char mail[2048]; +++ char icq[2048]; +++ char services[2048]; +++ +++ long worker_id; +++ int active; +++ char notify_plan[2048]; +++ char password[2048]; +++ +++ int escalation_count; +++ int escalation_time; +++ char notify_levels[20]; +++ char enabled_triggers[2048]; +++ char t[500]; +++ long escalation_limit; +++ long escalation_minutes; +++ +++}sa; +++ +++ +++struct downtime { +++ long downtime_id; +++ int downtime_type; +++ int downtime_from; +++ int downtime_to; +++ char downtime_notice[2048]; +++ int service_id; +++ +++}sb; +++ +++struct btl_event { +++ long evnt_id; +++ char evnt_message[1024]; +++ int evnt_time; +++ +++}eb; +++struct ext_notify { +++ struct service * svc; +++ struct worker * wrk; +++ char * trigger; +++} ty; +++ +++ +++ +++typedef struct v2_packet_struct{ +++ +++ u_int32_t crc32_value; +++ int16_t exit_code; +++ int16_t packet_type; +++ char output[2048]; +++ char cmdline[2048]; +++ char plugin[2048]; +++ char perf_handler[1024]; +++ +++ +++} agent_v2_packet; +++ +++typedef struct port_packet_struct{ +++ +++ u_int32_t crc32_value; +++ int16_t exit_code; +++ int16_t packet_type; +++ char output[2048]; +++ char cmdline[2048]; +++ char plugin[2048]; +++ char perf_handler[1024]; +++ int32_t service_id; +++ +++ +++} portier_packet; +++ +++#define AGENT_V2_SENT_PACKET 1 +++#define AGENT_V2_RETURN_PACKET 2 +++ +++#define PORTIER_SVCLIST_PACKET 1 +++#define PORTIER_RESULT_PACKET 2 +++#define PORTIER_REQUEST_PACKET 3 +++ +++ +++char * getConfigValue_ex(const char * key, const char * fname, int cache); +++char * getConfigValue(char *, char *); +++int clear_serviceMap(struct service **); +++int clear_workerMap(struct worker ** m); +++ +++int schedule_loop(char *, void *, void *); +++void sched_write_back_all(char * cfgfile, void * shm_addr, void * SOHandle); +++ +++void sched_reschedule(struct service * svc); +++int service_is_in_time(const char * time_plan); +++void bartlby_check_service(struct service * svc, void *, void *, char *); +++void bartlby_check_active(struct service * svc, char * cfgfile); +++void bartlby_check_local(struct service * svc, char * cfgfile); +++void bartlby_check_group(struct service * svc, void * shm_addr); +++ +++ +++void bartlby_check_snmp(struct service * svc, char * cfgfile); +++void bartlby_check_nrpe(struct service * svc, char * cfgfile, int use_ssl); +++ +++void str_mysql_safe(char * str); +++void service_mysql_safe(struct service * svc); +++ +++ +++//Replication +++int replication_go(char *, void *, void *); +++ +++//SHM +++ +++int GetDowntimeMap(struct downtime * svcs, char * config); +++struct service * bartlby_SHM_ServiceMap(void *); +++struct sched_threads * bartlby_SHM_ThreadMap(void * shm_addr); +++struct downtime * bartlby_SHM_DowntimeMap(void * shm_addr); +++struct shm_header * bartlby_SHM_GetHDR(void *); +++struct worker * bartlby_SHM_WorkerMap(void * shm_addr); +++struct server * bartlby_SHM_ServerMap(void * shm_addr); +++void bartlby_SHM_link_services_servers(void * shm_addr, char * cfgfile); +++ +++void bartlby_perf_track(struct service * svc,char * return_buffer, int return_bytes, char * cfgfile); +++int bartlby_core_perf_track(struct shm_header * hdr, struct service * svc, int type, int time); +++long bartlby_milli_timediff(struct timeval end, struct timeval start); +++ +++void bartlby_trigger(struct service * svc, char * cfgfile, void * shm_addr, int do_check, int standby_workers_only); +++//Global :-) +++int _log(const char * str, ...); +++ +++void bartlby_decode(char * msg, int length); +++void bartlby_encode(char * msg, int length); +++char * bartlby_beauty_state(int status); +++ +++void bartlby_end_clean(char *cfgfile); +++void bartlby_get_daemon(char * cfgfile); +++void set_cfg(char * cfg); +++ +++void str_replace(char *str, const char *from, const char *to, int maxlen); +++void bartlby_replace_svc_in_str(char * str, struct service * svc, int max); +++ +++void bartlby_action_handle_reply(struct service * svc, char * rmessage, char * cfgfile); +++int bartlby_action_handle_reply_line(struct service * svc, char * line, char *cfgfile); +++void bartlby_check_sirene(char * configfile, void * bartlby_address); +++int bartlby_is_in_downtime(void * bartlby_address, struct service * svc); +++ +++ +++//EVNT's +++void bartlby_event_init(void * bartlby_address); +++struct btl_event * bartlby_SHM_EventMap(void * shm_addr); +++int bartlby_push_event(int event_id, const char * str, ...); +++ +++void bartlby_pre_init(char * cfgfile); +++ +++void cfg_init_cache(void); +++char * cfg_add_to_cache(const char * k, char * v); +++void cfg_fill_with_file(char * f); +++void cfg_update_cache(char * k, char * v); +++void bartlby_ext_init(void * shm_addr, void * data_loader, char * cfg); +++void bartlby_ext_shutdown(int sched_exit_code); +++int bartlby_ext_register_callback(int type, void * fcn); +++int bartlby_callback(int type, void *data); +++ +++void bartlby_fin_service(struct service * svc, void * SOHandle, void * shm_addr,char * cfgfile); +++ +++void bartlby_check_grep_perf_line(char * l, struct service * svc, char * cfgfile); +++ +++ +++int bartlby_tcp_recvall(int s, char *buf, int *len, int timeout); +++int bartlby_tcp_sendall(int s, char *buf, int *len); +++ +++void bartlby_log_usage(void); +++ +++void nrpe_display_license(void); +++void bartlby_check_v2(struct service * svc, char * cfgfile, int use_ssl); ++diff -Nur ../nsca-2.7.1/include/bartlby.h ./include/bartlby.h ++--- ../nsca-2.7.1/include/bartlby.h 1970-01-01 01:00:00.000000000 +0100 +++++ ./include/bartlby.h 2008-03-27 20:39:21.000000000 +0100 ++@@ -0,0 +1,167 @@ +++#include +++#include +++#include +++#include +++ +++#define SVC_TYPE_PASSIVE 2 +++struct perf_statistic { +++ long sum; +++ long counter; +++}; +++struct snmpi { +++ char community[512]; +++ int version; +++ char objid[1024]; +++ long warn; +++ long crit; +++ long type; +++}; +++struct sprocess { +++ int start_time; +++ int pid; +++ +++}; +++ +++ +++struct shm_header { +++ long size_of_structs; +++ long thrdcount; +++ long svccount; +++ long wrkcount; +++ long srvcount; +++ long current_running; +++ char version[50]; +++ int do_reload; +++ int last_replication; +++ int startup_time; +++ long dtcount; +++ int sirene_mode; +++ struct perf_statistic pstat; +++ int cur_event_index; +++ +++ +++}; +++struct server { +++ long server_id; +++ char client_ip[2048]; +++ char server_name[2048]; +++ char server_icon[1024]; +++ int server_enabled; +++ int client_port; +++ int server_dead; +++ int server_notify; +++ long server_flap_seconds; +++ int flap_count; +++ int last_notify_send; +++ struct service * dead_marker; +++ +++} xxyz; +++ +++ +++ +++struct service { +++ long service_id; +++ long server_id; +++ int last_state; +++ int current_state; +++ +++ char new_server_text[2048]; +++ char service_name[2048]; +++ +++ char plugin[2048]; +++ char plugin_arguments[2048]; +++ long check_interval; +++ long check_interval_original; +++ int last_check; +++ struct timeval lcheck; +++ +++ /*Time stuff*/ +++ +++ char service_exec_plan[2048]; +++ +++ /*Notify things*/ +++ int notify_enabled; +++ int last_notify_send; +++ long flap_count; +++ +++ int service_active; +++ +++ char service_var[2048]; +++ int service_type; +++ long service_passive_timeout; +++ +++ int notify_last_state; +++ int notify_last_time; +++ long service_check_timeout; +++ +++ +++ +++ int service_ack; +++ +++ long service_retain; +++ long service_retain_current; +++ +++ +++ +++ struct perf_statistic pstat; +++ struct perf_statistic delay_time; +++ +++ int do_force; +++ +++ struct snmpi snmp_info; +++ +++ int recovery_outstanding; //Flag to see if recover is waiting +++ +++ struct sprocess process; +++ +++ long flap_seconds; +++ +++ struct server * srv; +++ long srv_place; +++ +++ int is_server_dead; +++ +++ /**/ +++ long renotify_interval; // interval to renotify +++ long escalate_divisor; // +++}; +++struct worker { +++ char name[2048]; +++ char mail[2048]; +++ char icq[2048]; +++ char services[2048]; +++ +++ long worker_id; +++ int active; +++ char notify_plan[2048]; +++ char password[2048]; +++ +++ int escalation_count; +++ int escalation_time; +++ char notify_levels[20]; +++ char enabled_triggers[2048]; +++ char t[500]; +++ long escalation_limit; +++ long escalation_minutes; +++ +++}sa; +++struct downtime { +++ long downtime_id; +++ int downtime_type; +++ int downtime_from; +++ int downtime_to; +++ char downtime_notice[2048]; +++ int service_id; +++ +++}sb; +++ +++ +++struct service * bartlby_SHM_ServiceMap(void *); +++struct sched_threads * bartlby_SHM_ThreadMap(void * shm_addr); +++struct downtime * bartlby_SHM_DowntimeMap(void * shm_addr); +++struct shm_header * bartlby_SHM_GetHDR(void *); +++struct worker * bartlby_SHM_WorkerMap(void * shm_addr); +++struct server * bartlby_SHM_ServerMap(void * shm_addr); +++ +++ +++ ++diff -Nur ../nsca-2.7.1/nsca_tests/nsca_basic.cfg ./nsca_tests/nsca_basic.cfg ++--- ../nsca-2.7.1/nsca_tests/nsca_basic.cfg 2007-01-30 06:53:05.000000000 +0100 +++++ ./nsca_tests/nsca_basic.cfg 2007-02-15 17:00:49.000000000 +0100 ++@@ -70,7 +70,7 @@ ++ # messages are logged to the syslog facility. ++ # Values: 0 = debugging off, 1 = debugging on ++ ++-debug=0 +++debug=1 ++ ++ ++ ++diff -Nur ../nsca-2.7.1/nsca_tests/var/nagios.cmd ./nsca_tests/var/nagios.cmd ++--- ../nsca-2.7.1/nsca_tests/var/nagios.cmd 1970-01-01 01:00:00.000000000 +0100 +++++ ./nsca_tests/var/nagios.cmd 2007-02-15 17:01:12.000000000 +0100 ++@@ -0,0 +1,18 @@ +++[1171555264] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555264] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555265] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555265] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555266] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555266] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555267] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555267] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555268] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555268] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555269] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555269] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555270] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555270] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555271] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555271] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++[1171555272] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output +++[1171555272] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++diff -Nur ../nsca-2.7.1/nsca_tests/var/nsca.pid ./nsca_tests/var/nsca.pid ++--- ../nsca-2.7.1/nsca_tests/var/nsca.pid 1970-01-01 01:00:00.000000000 +0100 +++++ ./nsca_tests/var/nsca.pid 2007-02-15 17:01:01.000000000 +0100 ++@@ -0,0 +1 @@ +++3561 ++diff -Nur ../nsca-2.7.1/p1 ./p1 ++--- ../nsca-2.7.1/p1 1970-01-01 01:00:00.000000000 +0100 +++++ ./p1 2008-03-27 20:44:08.000000000 +0100 ++@@ -0,0 +1,643 @@ +++diff -Nur ../nsca-2.7.1/1 ./1 +++--- ../nsca-2.7.1/1 1970-01-01 01:00:00.000000000 +0100 ++++++ ./1 2008-03-27 20:43:34.000000000 +0100 +++@@ -0,0 +1,3 @@ ++++test Alive 2 dsadsadsa ++++ ++++ +++diff -Nur ../nsca-2.7.1/bartlby.h ./bartlby.h +++--- ../nsca-2.7.1/bartlby.h 1970-01-01 01:00:00.000000000 +0100 ++++++ ./bartlby.h 2008-03-27 20:08:46.000000000 +0100 +++@@ -0,0 +1,422 @@ ++++#include ++++#include ++++ ++++#define PROGNAME "bartlby" ++++#define REL_NAME "autobot" ++++#define VERSION "1.3.1" ++++#define EXPECTCORE 1103251 //Module V Check's ++++ ++++#define MAX_CCACHE 1024 ++++#define MAX_CCACHE_KEY 1024 ++++#define MAX_CCACHE_VALUE 1024 ++++ ++++ ++++#define RECOVERY_OUTSTANDING 1 ++++#define RECOVERY_DONE 0 ++++ ++++ ++++#define EXTENSION_OK 0 ++++#define EXTENSION_NOK 1 ++++ ++++ ++++#define EXTENSION_CALLBACK_ALL -1 ++++#define EXTENSION_CALLBACK_PRE_CHECK 1 ++++#define EXTENSION_CALLBACK_POST_CHECK 2 ++++#define EXTENSION_CALLBACK_STATE_CHANGED 3 ++++#define EXTENSION_CALLBACK_TRIGGER_PRE 4 ++++#define EXTENSION_CALLBACK_SCHED_WAIT 5 ++++#define EXTENSION_CALLBACK_UNKOWN_CHECK_TYPE 6 ++++#define EXTENSION_CALLBACK_ROUND_TIME 7 ++++#define EXTENSION_CALLBACK_CHECK_TIME 8 ++++#define EXTENSION_CALLBACK_EVENT_PUSHED 9 ++++#define EXTENSION_CALLBACK_REPLICATION_GO 10 ++++#define EXTENSION_CALLBACK_TRIGGER_FIRED 11 ++++ ++++ ++++ ++++#define PORTIER_CONN_TIMEOUT 30 ++++ ++++#define EVENT_QUEUE_MAX 128 ++++#define EVENT_STATUS_CHANGED 2 ++++#define EVENT_TRIGGER_PUSHED 3 ++++ ++++ ++++ ++++#define STATE_OK 0 ++++#define STATE_WARNING 1 ++++#define STATE_CRITICAL 2 ++++#define STATE_UNKOWN 3 ++++#define STATE_SIRENE 7 ++++ ++++ ++++//Service ACK ++++ ++++#define ACK_NOT_NEEDED 0 ++++#define ACK_NEEDED 1 ++++#define ACK_OUTSTANDING 2 ++++ ++++#define DT_SERVICE 1 ++++#define DT_SERVER 2 ++++ ++++#define SVC_TYPE_ACTIVE 1 ++++#define SVC_TYPE_PASSIVE 2 ++++#define SVC_TYPE_GROUP 3 ++++#define SVC_TYPE_LOCAL 4 ++++#define SVC_TYPE_SNMP 5 ++++#define SVC_TYPE_NRPE 6 ++++#define SVC_TYPE_NRPE_SSL 7 ++++#define SVC_TYPE_V2 8 ++++#define SVC_TYPE_V2_NO_SSL 9 ++++ ++++ ++++#define SVC_THRESHOLD 10 ++++ ++++#define PERF_TYPE_SVC_TIME 1 ++++#define PERF_TYPE_ROUND_TIME 2 ++++ ++++ ++++#define PASSIVE_TIMEOUT "Passive Service has been timed out" ++++#define DNS_ERROR "DNS lookup error" ++++#define SOCKET_CREATE_ERROR "Socket create error" ++++#define ALARM_ERROR "Alarm setup error" ++++#define CONN_ERROR "Connection error" ++++#define RECV_ERROR "Recieve Error" ++++#define PROTOCOL_ERROR "Protocol Error" ++++#define TIMEOUT_ERROR "Recv() timedout" ++++ ++++ ++++ ++++ ++++ ++++#define GROUP_CRITICAL "Group check critical" ++++#define GROUP_WITHOUT_PARMS "Group check without parameters" ++++#define GROUP_OK "Group check OK" ++++ ++++ ++++ ++++#define LOAD_SYMBOL(x,y,z) x=dlsym(y, z); \ ++++ if((dlmsg=dlerror()) != NULL) { \ ++++ _log("-Error: %s", dlmsg); \ ++++ exit(1); \ ++++ } ++++ ++++ ++++ ++++ ++++ ++++struct shm_counter { ++++ long worker; ++++ long services; ++++ long downtimes; ++++ long servers; ++++}; ++++ ++++struct perf_statistic { ++++ long sum; ++++ long counter; ++++}; ++++ ++++ ++++struct snmpi { ++++ char community[512]; ++++ int version; ++++ char objid[1024]; ++++ long warn; ++++ long crit; ++++ long type; ++++}; ++++struct sprocess { ++++ int start_time; ++++ int pid; ++++ ++++}; ++++ ++++struct sched_threads { ++++ int pid; ++++ struct service * svc; ++++ int start_time; ++++ int its_over; ++++} astt; ++++ ++++ ++++ ++++struct shm_header { ++++ long size_of_structs; ++++ long thrdcount; ++++ long svccount; ++++ long wrkcount; ++++ long srvcount; ++++ long current_running; ++++ char version[50]; ++++ int do_reload; ++++ int last_replication; ++++ int startup_time; ++++ long dtcount; ++++ int sirene_mode; ++++ struct perf_statistic pstat; ++++ int cur_event_index; ++++ ++++ ++++}; ++++ ++++struct server { ++++ long server_id; ++++ char client_ip[2048]; ++++ char server_name[2048]; ++++ char server_icon[1024]; ++++ int server_enabled; ++++ int client_port; ++++ int server_dead; ++++ int server_notify; ++++ long server_flap_seconds; ++++ int flap_count; ++++ int last_notify_send; ++++ struct service * dead_marker; ++++ ++++} xxyz; ++++ ++++ ++++ ++++struct service { ++++ long service_id; ++++ long server_id; ++++ int last_state; ++++ int current_state; ++++ ++++ char new_server_text[2048]; ++++ char service_name[2048]; ++++ ++++ char plugin[2048]; ++++ char plugin_arguments[2048]; ++++ long check_interval; ++++ long check_interval_original; ++++ int last_check; ++++ struct timeval lcheck; ++++ ++++ /*Time stuff*/ ++++ ++++ char service_exec_plan[2048]; ++++ ++++ /*Notify things*/ ++++ int notify_enabled; ++++ int last_notify_send; ++++ long flap_count; ++++ ++++ int service_active; ++++ ++++ char service_var[2048]; ++++ int service_type; ++++ long service_passive_timeout; ++++ ++++ int notify_last_state; ++++ int notify_last_time; ++++ long service_check_timeout; ++++ ++++ ++++ ++++ int service_ack; ++++ ++++ long service_retain; ++++ long service_retain_current; ++++ ++++ ++++ ++++ struct perf_statistic pstat; ++++ struct perf_statistic delay_time; ++++ ++++ int do_force; ++++ ++++ struct snmpi snmp_info; ++++ ++++ int recovery_outstanding; //Flag to see if recover is waiting ++++ ++++ struct sprocess process; ++++ ++++ long flap_seconds; ++++ ++++ struct server * srv; ++++ long srv_place; ++++ ++++ int is_server_dead; ++++ ++++ /**/ ++++ long renotify_interval; // interval to renotify ++++ long escalate_divisor; // ++++}; ++++ ++++struct service_sort { ++++ struct service * svc; ++++}; ++++ ++++ ++++struct worker { ++++ char name[2048]; ++++ char mail[2048]; ++++ char icq[2048]; ++++ char services[2048]; ++++ ++++ long worker_id; ++++ int active; ++++ char notify_plan[2048]; ++++ char password[2048]; ++++ ++++ int escalation_count; ++++ int escalation_time; ++++ char notify_levels[20]; ++++ char enabled_triggers[2048]; ++++ char t[500]; ++++ long escalation_limit; ++++ long escalation_minutes; ++++ ++++}sa; ++++ ++++ ++++struct downtime { ++++ long downtime_id; ++++ int downtime_type; ++++ int downtime_from; ++++ int downtime_to; ++++ char downtime_notice[2048]; ++++ int service_id; ++++ ++++}sb; ++++ ++++struct btl_event { ++++ long evnt_id; ++++ char evnt_message[1024]; ++++ int evnt_time; ++++ ++++}eb; ++++struct ext_notify { ++++ struct service * svc; ++++ struct worker * wrk; ++++ char * trigger; ++++} ty; ++++ ++++ ++++ ++++typedef struct v2_packet_struct{ ++++ ++++ u_int32_t crc32_value; ++++ int16_t exit_code; ++++ int16_t packet_type; ++++ char output[2048]; ++++ char cmdline[2048]; ++++ char plugin[2048]; ++++ char perf_handler[1024]; ++++ ++++ ++++} agent_v2_packet; ++++ ++++typedef struct port_packet_struct{ ++++ ++++ u_int32_t crc32_value; ++++ int16_t exit_code; ++++ int16_t packet_type; ++++ char output[2048]; ++++ char cmdline[2048]; ++++ char plugin[2048]; ++++ char perf_handler[1024]; ++++ int32_t service_id; ++++ ++++ ++++} portier_packet; ++++ ++++#define AGENT_V2_SENT_PACKET 1 ++++#define AGENT_V2_RETURN_PACKET 2 ++++ ++++#define PORTIER_SVCLIST_PACKET 1 ++++#define PORTIER_RESULT_PACKET 2 ++++#define PORTIER_REQUEST_PACKET 3 ++++ ++++ ++++char * getConfigValue_ex(const char * key, const char * fname, int cache); ++++char * getConfigValue(char *, char *); ++++int clear_serviceMap(struct service **); ++++int clear_workerMap(struct worker ** m); ++++ ++++int schedule_loop(char *, void *, void *); ++++void sched_write_back_all(char * cfgfile, void * shm_addr, void * SOHandle); ++++ ++++void sched_reschedule(struct service * svc); ++++int service_is_in_time(const char * time_plan); ++++void bartlby_check_service(struct service * svc, void *, void *, char *); ++++void bartlby_check_active(struct service * svc, char * cfgfile); ++++void bartlby_check_local(struct service * svc, char * cfgfile); ++++void bartlby_check_group(struct service * svc, void * shm_addr); ++++ ++++ ++++void bartlby_check_snmp(struct service * svc, char * cfgfile); ++++void bartlby_check_nrpe(struct service * svc, char * cfgfile, int use_ssl); ++++ ++++void str_mysql_safe(char * str); ++++void service_mysql_safe(struct service * svc); ++++ ++++ ++++//Replication ++++int replication_go(char *, void *, void *); ++++ ++++//SHM ++++ ++++int GetDowntimeMap(struct downtime * svcs, char * config); ++++struct service * bartlby_SHM_ServiceMap(void *); ++++struct sched_threads * bartlby_SHM_ThreadMap(void * shm_addr); ++++struct downtime * bartlby_SHM_DowntimeMap(void * shm_addr); ++++struct shm_header * bartlby_SHM_GetHDR(void *); ++++struct worker * bartlby_SHM_WorkerMap(void * shm_addr); ++++struct server * bartlby_SHM_ServerMap(void * shm_addr); ++++void bartlby_SHM_link_services_servers(void * shm_addr, char * cfgfile); ++++ ++++void bartlby_perf_track(struct service * svc,char * return_buffer, int return_bytes, char * cfgfile); ++++int bartlby_core_perf_track(struct shm_header * hdr, struct service * svc, int type, int time); ++++long bartlby_milli_timediff(struct timeval end, struct timeval start); ++++ ++++void bartlby_trigger(struct service * svc, char * cfgfile, void * shm_addr, int do_check, int standby_workers_only); ++++//Global :-) ++++int _log(const char * str, ...); ++++ ++++void bartlby_decode(char * msg, int length); ++++void bartlby_encode(char * msg, int length); ++++char * bartlby_beauty_state(int status); ++++ ++++void bartlby_end_clean(char *cfgfile); ++++void bartlby_get_daemon(char * cfgfile); ++++void set_cfg(char * cfg); ++++ ++++void str_replace(char *str, const char *from, const char *to, int maxlen); ++++void bartlby_replace_svc_in_str(char * str, struct service * svc, int max); ++++ ++++void bartlby_action_handle_reply(struct service * svc, char * rmessage, char * cfgfile); ++++int bartlby_action_handle_reply_line(struct service * svc, char * line, char *cfgfile); ++++void bartlby_check_sirene(char * configfile, void * bartlby_address); ++++int bartlby_is_in_downtime(void * bartlby_address, struct service * svc); ++++ ++++ ++++//EVNT's ++++void bartlby_event_init(void * bartlby_address); ++++struct btl_event * bartlby_SHM_EventMap(void * shm_addr); ++++int bartlby_push_event(int event_id, const char * str, ...); ++++ ++++void bartlby_pre_init(char * cfgfile); ++++ ++++void cfg_init_cache(void); ++++char * cfg_add_to_cache(const char * k, char * v); ++++void cfg_fill_with_file(char * f); ++++void cfg_update_cache(char * k, char * v); ++++void bartlby_ext_init(void * shm_addr, void * data_loader, char * cfg); ++++void bartlby_ext_shutdown(int sched_exit_code); ++++int bartlby_ext_register_callback(int type, void * fcn); ++++int bartlby_callback(int type, void *data); ++++ ++++void bartlby_fin_service(struct service * svc, void * SOHandle, void * shm_addr,char * cfgfile); ++++ ++++void bartlby_check_grep_perf_line(char * l, struct service * svc, char * cfgfile); ++++ ++++ ++++int bartlby_tcp_recvall(int s, char *buf, int *len, int timeout); ++++int bartlby_tcp_sendall(int s, char *buf, int *len); ++++ ++++void bartlby_log_usage(void); ++++ ++++void nrpe_display_license(void); ++++void bartlby_check_v2(struct service * svc, char * cfgfile, int use_ssl); +++diff -Nur ../nsca-2.7.1/include/bartlby.h ./include/bartlby.h +++--- ../nsca-2.7.1/include/bartlby.h 1970-01-01 01:00:00.000000000 +0100 ++++++ ./include/bartlby.h 2008-03-27 20:39:21.000000000 +0100 +++@@ -0,0 +1,167 @@ ++++#include ++++#include ++++#include ++++#include ++++ ++++#define SVC_TYPE_PASSIVE 2 ++++struct perf_statistic { ++++ long sum; ++++ long counter; ++++}; ++++struct snmpi { ++++ char community[512]; ++++ int version; ++++ char objid[1024]; ++++ long warn; ++++ long crit; ++++ long type; ++++}; ++++struct sprocess { ++++ int start_time; ++++ int pid; ++++ ++++}; ++++ ++++ ++++struct shm_header { ++++ long size_of_structs; ++++ long thrdcount; ++++ long svccount; ++++ long wrkcount; ++++ long srvcount; ++++ long current_running; ++++ char version[50]; ++++ int do_reload; ++++ int last_replication; ++++ int startup_time; ++++ long dtcount; ++++ int sirene_mode; ++++ struct perf_statistic pstat; ++++ int cur_event_index; ++++ ++++ ++++}; ++++struct server { ++++ long server_id; ++++ char client_ip[2048]; ++++ char server_name[2048]; ++++ char server_icon[1024]; ++++ int server_enabled; ++++ int client_port; ++++ int server_dead; ++++ int server_notify; ++++ long server_flap_seconds; ++++ int flap_count; ++++ int last_notify_send; ++++ struct service * dead_marker; ++++ ++++} xxyz; ++++ ++++ ++++ ++++struct service { ++++ long service_id; ++++ long server_id; ++++ int last_state; ++++ int current_state; ++++ ++++ char new_server_text[2048]; ++++ char service_name[2048]; ++++ ++++ char plugin[2048]; ++++ char plugin_arguments[2048]; ++++ long check_interval; ++++ long check_interval_original; ++++ int last_check; ++++ struct timeval lcheck; ++++ ++++ /*Time stuff*/ ++++ ++++ char service_exec_plan[2048]; ++++ ++++ /*Notify things*/ ++++ int notify_enabled; ++++ int last_notify_send; ++++ long flap_count; ++++ ++++ int service_active; ++++ ++++ char service_var[2048]; ++++ int service_type; ++++ long service_passive_timeout; ++++ ++++ int notify_last_state; ++++ int notify_last_time; ++++ long service_check_timeout; ++++ ++++ ++++ ++++ int service_ack; ++++ ++++ long service_retain; ++++ long service_retain_current; ++++ ++++ ++++ ++++ struct perf_statistic pstat; ++++ struct perf_statistic delay_time; ++++ ++++ int do_force; ++++ ++++ struct snmpi snmp_info; ++++ ++++ int recovery_outstanding; //Flag to see if recover is waiting ++++ ++++ struct sprocess process; ++++ ++++ long flap_seconds; ++++ ++++ struct server * srv; ++++ long srv_place; ++++ ++++ int is_server_dead; ++++ ++++ /**/ ++++ long renotify_interval; // interval to renotify ++++ long escalate_divisor; // ++++}; ++++struct worker { ++++ char name[2048]; ++++ char mail[2048]; ++++ char icq[2048]; ++++ char services[2048]; ++++ ++++ long worker_id; ++++ int active; ++++ char notify_plan[2048]; ++++ char password[2048]; ++++ ++++ int escalation_count; ++++ int escalation_time; ++++ char notify_levels[20]; ++++ char enabled_triggers[2048]; ++++ char t[500]; ++++ long escalation_limit; ++++ long escalation_minutes; ++++ ++++}sa; ++++struct downtime { ++++ long downtime_id; ++++ int downtime_type; ++++ int downtime_from; ++++ int downtime_to; ++++ char downtime_notice[2048]; ++++ int service_id; ++++ ++++}sb; ++++ ++++ ++++struct service * bartlby_SHM_ServiceMap(void *); ++++struct sched_threads * bartlby_SHM_ThreadMap(void * shm_addr); ++++struct downtime * bartlby_SHM_DowntimeMap(void * shm_addr); ++++struct shm_header * bartlby_SHM_GetHDR(void *); ++++struct worker * bartlby_SHM_WorkerMap(void * shm_addr); ++++struct server * bartlby_SHM_ServerMap(void * shm_addr); ++++ ++++ ++++ +++diff -Nur ../nsca-2.7.1/nsca_tests/nsca_basic.cfg ./nsca_tests/nsca_basic.cfg +++--- ../nsca-2.7.1/nsca_tests/nsca_basic.cfg 2007-01-30 06:53:05.000000000 +0100 ++++++ ./nsca_tests/nsca_basic.cfg 2007-02-15 17:00:49.000000000 +0100 +++@@ -70,7 +70,7 @@ +++ # messages are logged to the syslog facility. +++ # Values: 0 = debugging off, 1 = debugging on +++ +++-debug=0 ++++debug=1 +++ +++ +++ +++diff -Nur ../nsca-2.7.1/nsca_tests/var/nagios.cmd ./nsca_tests/var/nagios.cmd +++--- ../nsca-2.7.1/nsca_tests/var/nagios.cmd 1970-01-01 01:00:00.000000000 +0100 ++++++ ./nsca_tests/var/nagios.cmd 2007-02-15 17:01:12.000000000 +0100 +++@@ -0,0 +1,18 @@ ++++[1171555264] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555264] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555265] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555265] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555266] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555266] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555267] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555267] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555268] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555268] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555269] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555269] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555270] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555270] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555271] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555271] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here ++++[1171555272] PROCESS_HOST_CHECK_RESULT;hostname;0;Plugin output ++++[1171555272] PROCESS_SERVICE_CHECK_RESULT;host;service;0;A good result here +++diff -Nur ../nsca-2.7.1/nsca_tests/var/nsca.pid ./nsca_tests/var/nsca.pid +++--- ../nsca-2.7.1/nsca_tests/var/nsca.pid 1970-01-01 01:00:00.000000000 +0100 ++++++ ./nsca_tests/var/nsca.pid 2007-02-15 17:01:01.000000000 +0100 +++@@ -0,0 +1 @@ ++++3561 ++diff -Nur ../nsca-2.7.1/src/bartlby_stuff.c ./src/bartlby_stuff.c ++--- ../nsca-2.7.1/src/bartlby_stuff.c 1970-01-01 01:00:00.000000000 +0100 +++++ ./src/bartlby_stuff.c 2007-02-16 16:30:30.000000000 +0100 ++@@ -0,0 +1,57 @@ +++ +++#include "../include/bartlby.h" +++ +++ +++ +++struct shm_header * bartlby_SHM_GetHDR(void * shm_addr) { +++ return (struct shm_header *)(void *)shm_addr; +++} +++ +++ +++struct server * bartlby_SHM_ServerMap(void * shm_addr) { +++ //Is beyond the 3 integers :-) +++ struct shm_header * hdr; +++ struct service * svcmap; +++ struct downtime * dtmap; +++ +++ hdr=bartlby_SHM_GetHDR(shm_addr); +++ +++ svcmap=bartlby_SHM_ServiceMap(shm_addr); +++ //wrkmap=(struct worker *)(void*)&svcmap[hdr->svccount]+20; +++ dtmap=bartlby_SHM_DowntimeMap(shm_addr); +++ +++ return (struct server *)(void *)&dtmap[hdr->dtcount]+20; +++} +++ +++struct downtime * bartlby_SHM_DowntimeMap(void * shm_addr) { +++ //Is beyond the 3 integers :-) +++ struct shm_header * hdr; +++ struct service * svcmap; +++ struct worker * wrkmap; +++ +++ hdr=bartlby_SHM_GetHDR(shm_addr); +++ +++ svcmap=bartlby_SHM_ServiceMap(shm_addr); +++ //wrkmap=(struct worker *)(void*)&svcmap[hdr->svccount]+20; +++ wrkmap=bartlby_SHM_WorkerMap(shm_addr); +++ +++ return (struct downtime *)(void *)&wrkmap[hdr->wrkcount]+20; +++} +++ +++struct worker * bartlby_SHM_WorkerMap(void * shm_addr) { +++ //Is beyond the 3 integers :-) +++ struct shm_header * hdr; +++ struct service * svcmap; +++ hdr=bartlby_SHM_GetHDR(shm_addr); +++ +++ svcmap=bartlby_SHM_ServiceMap(shm_addr); +++ +++ return (struct worker *)(void*)&svcmap[hdr->svccount]+20; +++} +++ +++struct service * bartlby_SHM_ServiceMap(void * shm_addr) { +++ //Is beyond the 3 integers :-) +++ return (struct service *)(void *)shm_addr+sizeof(struct shm_header); +++} +++ +++ ++diff -Nur ../nsca-2.7.1/src/Makefile.in ./src/Makefile.in ++--- ../nsca-2.7.1/src/Makefile.in 2003-10-24 03:31:08.000000000 +0200 +++++ ./src/Makefile.in 2007-02-16 16:24:53.000000000 +0100 ++@@ -19,8 +19,8 @@ ++ ++ all: nsca send_nsca ++ ++-nsca: nsca.c netutils.c utils.c $(SRC_INCLUDE)/netutils.h $(SRC_INCLUDE)/utils.h $(SRC_INCLUDE)/common.h $(SRC_INCLUDE)/config.h ++- $(CC) $(CFLAGS) -o $@ nsca.c netutils.c utils.c $(LDFLAGS) $(SOCKETLIBS) $(LIBWRAPLIBS) +++nsca: bartlby_stuff.c nsca.c netutils.c utils.c $(SRC_INCLUDE)/netutils.h $(SRC_INCLUDE)/utils.h $(SRC_INCLUDE)/common.h $(SRC_INCLUDE)/config.h $(SRC_INCLUDE)/bartlby.h +++ $(CC) $(CFLAGS) -o $@ nsca.c bartlby_stuff.c netutils.c utils.c $(LDFLAGS) $(SOCKETLIBS) $(LIBWRAPLIBS) ++ ++ send_nsca: send_nsca.c netutils.c utils.c $(SRC_INCLUDE)/netutils.h $(SRC_INCLUDE)/utils.h $(SRC_INCLUDE)/common.h $(SRC_INCLUDE)/config.h ++ $(CC) $(CFLAGS) -o $@ send_nsca.c netutils.c utils.c $(LDFLAGS) $(SOCKETLIBS) ++diff -Nur ../nsca-2.7.1/src/nsca.c ./src/nsca.c ++--- ../nsca-2.7.1/src/nsca.c 2007-01-30 06:53:05.000000000 +0100 +++++ ./src/nsca.c 2007-02-16 21:40:18.000000000 +0100 ++@@ -20,7 +20,7 @@ ++ #include "../include/netutils.h" ++ #include "../include/utils.h" ++ #include "../include/nsca.h" ++- +++#include "../include/bartlby.h" ++ ++ static int server_port=DEFAULT_SERVER_PORT; ++ static char server_address[16]="0.0.0.0"; ++@@ -30,6 +30,7 @@ ++ static char alternate_dump_file[MAX_INPUT_BUFFER]="/dev/null"; ++ static char command_file[MAX_INPUT_BUFFER]=""; ++ static char password[MAX_INPUT_BUFFER]=""; +++static char bartlby_shm_key[MAX_INPUT_BUFFER]=""; ++ ++ static enum { OPTIONS_ERROR, SINGLE_PROCESS_DAEMON, MULTI_PROCESS_DAEMON, INETD } mode=SINGLE_PROCESS_DAEMON; ++ static int debug=FALSE; ++@@ -53,7 +54,7 @@ ++ int sigrestart=FALSE; ++ int sigshutdown=FALSE; ++ ++-static FILE *command_file_fp=NULL; +++void * command_file_fp=NULL; ++ ++ struct handler_entry *rhand=NULL; ++ struct handler_entry *whand=NULL; ++@@ -87,8 +88,9 @@ ++ if(result!=OK) ++ printf("Incorrect command line arguments supplied\n"); ++ printf("\n"); ++- printf("NSCA - Nagios Service Check Acceptor\n"); ++- printf("Copyright (c) 2000-2007 Ethan Galstad (www.nagios.org)\n"); +++ printf("NSCA - Nagios Service Check Acceptor (patched for bartlby.org project)\n"); +++ printf("NSCA: Copyright (c) 2000-2007 Ethan Galstad (www.nagios.org)\n"); +++ printf("Bartlby: by www.bartlby.org and its owners\n"); ++ printf("Version: %s\n",PROGRAM_VERSION); ++ printf("Last Modified: %s\n",MODIFICATION_DATE); ++ printf("License: GPL v2\n"); ++@@ -375,6 +377,14 @@ ++ strncpy(password,varvalue,sizeof(password)-1); ++ password[sizeof(password)-1]='\0'; ++ } +++ else if(strstr(input_buffer,"bartlby_shm_key")){ +++ if(strlen(varvalue)>sizeof(bartlby_shm_key)-1){ +++ syslog(LOG_ERR,"bartlby shm key is too long in config file '%s' - Line %d\n",filename,line); +++ return ERROR; +++ } +++ strncpy(bartlby_shm_key,varvalue,sizeof(bartlby_shm_key)-1); +++ password[sizeof(bartlby_shm_key)-1]='\0'; +++ } ++ else if(strstr(input_buffer,"decryption_method")){ ++ ++ decryption_method=atoi(varvalue); ++@@ -1086,64 +1096,67 @@ ++ ++ /* writes service/host check results to the Nagios command file */ ++ static int write_check_result(char *host_name, char *svc_description, int return_code, char *plugin_output, time_t check_time){ ++- +++ struct shm_header * hdr; +++ struct server * srvmap; +++ struct service * svcmap; +++ +++ int x; +++ int f=-1; +++ ++ if(aggregate_writes==FALSE){ ++ if(open_command_file()==ERROR) ++ return ERROR; ++ } ++ ++- if(!strcmp(svc_description,"")) ++- fprintf(command_file_fp,"[%lu] PROCESS_HOST_CHECK_RESULT;%s;%d;%s\n",(unsigned long)check_time,host_name,return_code,plugin_output); ++- else ++- fprintf(command_file_fp,"[%lu] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n",(unsigned long)check_time,host_name,svc_description,return_code,plugin_output); ++- ++- if(aggregate_writes==FALSE) ++- close_command_file(); ++- else ++- /* if we don't fflush() then we're writing in 4k non-CR-terminated blocks, and ++- * anything else (eg. pscwatch) which writes to the file will be writing into ++- * the middle of our commands. ++- */ ++- fflush(command_file_fp); ++- ++- return OK; ++- } +++ +++ hdr=bartlby_SHM_GetHDR(command_file_fp); +++ srvmap=bartlby_SHM_ServerMap(command_file_fp); +++ svcmap=bartlby_SHM_ServiceMap(command_file_fp); +++ +++ for(x=0; xsvccount; x++ ) { +++ +++ if(strcmp(srvmap[svcmap[x].srv_place].server_name, host_name) == 0) { +++ if(strcmp(svcmap[x].service_name, svc_description) == 0) { +++ f=1; +++ svcmap[x].current_state=return_code; +++ snprintf(svcmap[x].new_server_text, 2074, "%s", plugin_output); +++ svcmap[x].last_check = check_time; +++ break; +++ } +++ } +++ } +++ if(f < 0) { +++ syslog(LOG_ERR, "bartlby: %s/%s not found", host_name, svc_description); +++ } +++ +++ return OK; +++} ++ ++ ++ ++ /* opens the command file for writing */ ++ static int open_command_file(void){ ++- struct stat statbuf; +++ +++ int gshm_id; ++ ++ /* file is already open */ ++ if(command_file_fp!=NULL) ++ return OK; ++- ++- /* command file doesn't exist - monitoring app probably isn't running... */ ++- if(stat(command_file,&statbuf)){ ++- ++- if(debug==TRUE) ++- syslog(LOG_ERR,"Command file '%s' does not exist, attempting to use alternate dump file '%s' for output",command_file,alternate_dump_file); ++- ++- /* try and write checks to alternate dump file */ ++- command_file_fp=fopen(alternate_dump_file,"a"); ++- if(command_file_fp==NULL){ ++- if(debug==TRUE) ++- syslog(LOG_ERR,"Could not open alternate dump file '%s' for appending",alternate_dump_file); ++- return ERROR; ++- } ++- ++- return OK; ++- } ++- ++- /* open the command file for writing or appending */ ++- command_file_fp=fopen(command_file,(append_to_file==TRUE)?"a":"w"); ++- if(command_file_fp==NULL){ ++- if(debug==TRUE) ++- syslog(LOG_ERR,"Could not open command file '%s' for %s",command_file,(append_to_file==TRUE)?"appending":"writing"); ++- return ERROR; ++- } ++- +++ +++ +++ +++ gshm_id = shmget(ftok(bartlby_shm_key, 32), 0,0777); +++ if(gshm_id < 0) { +++ syslog(LOG_ERR,"bartlby: shm problem: '%s'", bartlby_shm_key); +++ return ERROR; +++ } +++ +++ command_file_fp = shmat(gshm_id,NULL,0); +++ +++ syslog(LOG_NOTICE,"bartlby: shm connected"); +++ +++ +++ ++ return OK; ++ } ++ ++@@ -1152,7 +1165,7 @@ ++ /* closes the command file */ ++ static void close_command_file(void){ ++ ++- fclose(command_file_fp); +++ shmdt(command_file_fp); ++ command_file_fp=NULL; ++ ++ return; diff -Nur ../nsca-2.7.1/src/bartlby_stuff.c ./src/bartlby_stuff.c --- ../nsca-2.7.1/src/bartlby_stuff.c 1970-01-01 01:00:00.000000000 +0100 +++ ./src/bartlby_stuff.c 2007-02-16 16:30:30.000000000 +0100 diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/post_compile.sh bartlby-core/post_compile.sh --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/post_compile.sh 1970-01-01 01:00:00.000000000 +0100 +++ bartlby-core/post_compile.sh 2008-04-03 11:15:43.000000000 +0200 @@ -0,0 +1,41 @@ +#!/bin/sh +wget_path=$(type -p wget); +wget_ex=$?; +if [ -x src/bartlby ]; +then + if [ -x src/libs/mysql.so ]; + then + echo "##########################################################################################"; + echo "# congratulations your compile seems to be successfully #"; + echo "# for helping us improving bartlby, do you wan't your compilation to be counted online? #"; + echo "# no data will be collected only a simple hit-counter is incemented #"; + echo "##########################################################################################"; + echo -ne "If you dont want to be counted type 'no' otherwise just hit enter [Y]"; + read tk; + if [ "x$tk" = "x" ] + then + tk="y"; + fi; + if [ $tk != "n" ]; + then + if [ $tk != "N" ]; + then + if [ $tk != "N" ]; + then + if [ $wget_ex = 0 ]; + then + echo "hitting...bartlby.org"; + $wget_path -O /dev/null "http://www.bartlby.org/stat.php?type=compile&result=1&extra="; + echo "Thank you, we hope you enjoy bartlby"; + fi; + fi; fi; + fi; + + + echo "##########################################################################################"; + echo "# Installation completed #"; + echo "##########################################################################################"; + + fi; +fi +echo ""; diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/postinstall-pak.in bartlby-core/postinstall-pak.in --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/postinstall-pak.in 2006-08-24 22:04:39.000000000 +0200 +++ bartlby-core/postinstall-pak.in 2008-04-03 11:15:43.000000000 +0200 @@ -10,6 +10,81 @@ chmod a+rw ${BARTLBY_HOME}/etc/bartlby.cfg +function install_portier { + + echo "------------------------------------------------------"; + echo "Installing Bartlby-Portier (Port: 9031)"; + echo "------------------------------------------------------"; + + echo "registering service (bartlbyp 9031)"; + grep -sqe "^bartlbyp" /etc/services + EX=$?; + + if [ $EX = 1 ]; + then + echo "bartlbyp 9031/tcp #Bartlby Portier" >> /etc/services + echo "DONE"; + else + echo "Already existing!"; + fi; + + echo "------------------------------------------------------"; + echo ""; + echo ""; + + + echo "------------------------------------------------------"; + + if [ -f /etc/inetd.conf ]; + then + echo "Checking service in inetd.conf"; + grep -sqe "^bartlbyp" /etc/inetd.conf + EX=$?; + if [ $EX = 1 ]; + then + echo "bartlbyp stream tcp nowait.500 bartlby ${BARTLBY_HOME}/bin/bartlby_portier ${BARTLBY_HOME}/etc/bartlby.cfg" >> /etc/inetd.conf + echo "DONE ... restarting inetd"; + if [ -f /etc/init.d/openbsd-inetd ]; + then + echo "detected openbsd-inetd"; + echo "....restarting openbsd-inetd" + /etc/init.d/openbsd-inetd restart + else + /etc/init.d/inetd restart + fi; + else + echo "Already existing"; + fi; + + else + echo "Checking service in /etc/xinetd.d/"; + if [ ! -f /etc/xinetd.d/bartlbyp ]; + then + + echo "service bartlbyp" > /etc/xinetd.d/bartlbyp + echo "{" >> /etc/xinetd.d/bartlbyp + echo " disable = no" >> /etc/xinetd.d/bartlbyp + echo " port = 9030" >> /etc/xinetd.d/bartlbyp + echo " socket_type = stream" >> /etc/xinetd.d/bartlbyp + echo " protocol = tcp" >> /etc/xinetd.d/bartlbyp + echo " wait = no" >> /etc/xinetd.d/bartlbyp + echo " user = root" >> /etc/xinetd.d/bartlbyp + echo " server = ${BARTLBY_HOME}/bin/bartlby_portier" >> /etc/xinetd.d/bartlbyp + echo " server_args = ${BARTLBY_HOME}/etc/bartlby.cfg" >> /etc/xinetd.d/bartlbyp + echo "}" >> /etc/xinetd.d/bartlbyp + echo "DONE ... restarting xinetd"; + /etc/init.d/xinetd restart + + else + echo "already existing"; + fi; + fi; + + + + +} + function start_it_up { $BARTLBY_HOME/etc/bartlby.startup stop 2>&1 >> /dev/null $BARTLBY_HOME/etc/bartlby.startup remove 2>&1 >> /dev/null @@ -21,6 +96,9 @@ echo ""; echo ""; + install_portier; + + echo "####################################################"; echo "####################################################"; echo "### DONE ###"; @@ -152,7 +230,7 @@ MYSQL_COMMAND="$MY_MYSQL -u $MYSQL_USER --password=$MYSQL_PASSWORD -h $MYSQL_HOST"; cat << MYSQL_SCRIPT | $MYSQL_COMMAND; -use test; +select 1; MYSQL_SCRIPT MYSQL_OK=$?; @@ -175,7 +253,7 @@ fi; cat << MYSQL | $MYSQL_COMMAND -D $MYSQL_DB - use test; + select 1; MYSQL EX=$?; diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/ack.c bartlby-core/src/ack.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/ack.c 2007-02-15 17:25:32.000000000 +0100 +++ bartlby-core/src/ack.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: ack.c,v 1.2 2007/02/15 16:25:32 hjanuschka Exp $ */ +/* $Id: ack.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,19 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.2 $ -$Source: /cvsroot/bartlby/bartlby-core/src/ack.c,v $ - - -$Log: ack.c,v $ -Revision 1.2 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.1 2006/02/10 23:54:46 hjanuschka -SIRENE mode added - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/ack.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ #include @@ -75,6 +71,12 @@ //sprintf(svc.client_ip, "0.0.0.0"); //sprintf(svc.server_name, "CORE"); svc.srv=malloc(sizeof(struct server)); + if(svc.srv == NULL) { + _log("malloc failed in bartlby_check_sirene()"); + return; + } + + sprintf(svc.srv->client_ip, "0.0.0.0"); sprintf(svc.srv->server_name, "CORE"); @@ -85,7 +87,7 @@ svc.last_state=STATE_SIRENE; _log("!!! System is in sirene Mode !!!!"); - bartlby_trigger(&svc,configfile, bartlby_address, 0); + bartlby_trigger(&svc,configfile, bartlby_address, 0, 0); diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/bartlby.c bartlby-core/src/bartlby.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/bartlby.c 2007-07-28 00:54:04.000000000 +0200 +++ bartlby-core/src/bartlby.c 2008-04-16 10:21:18.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: bartlby.c,v 1.43 2007/07/27 22:54:04 hjanuschka Exp $ */ +/* $Id: bartlby.c 36 2008-04-16 08:21:18Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,165 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.43 $ -$Source: /cvsroot/bartlby/bartlby-core/src/bartlby.c,v $ - - -$Log: bartlby.c,v $ -Revision 1.43 2007/07/27 22:54:04 hjanuschka -int to long changing - -Revision 1.42 2007/02/15 20:46:38 hjanuschka -auto commit - -Revision 1.41 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.40 2007/01/05 01:49:00 hjanuschka -auto commit - -Revision 1.38 2006/11/28 03:30:42 hjanuschka -auto commit - -Revision 1.37 2006/10/05 23:19:37 hjanuschka -auto commit - -Revision 1.36 2006/09/09 19:38:34 hjanuschka -auto commit - -Revision 1.35 2006/09/03 22:19:47 hjanuschka -auto commit - -Revision 1.34 2006/08/03 20:29:13 hjanuschka -auto commit - -Revision 1.33 2006/07/25 21:42:03 hjanuschka -auto commit - -Revision 1.32 2006/06/04 23:55:28 hjanuschka -core: SSL_connect (timeout issue's solved , at least i hope :)) -core: when perfhandlers_enabled == false, you now can enable single services -core: plugin_arguments supports $MACROS -core: config variables try now to cache themselfe to minimize I/O activity -core: .so extensions support added - -Revision 1.31 2006/05/28 16:18:27 hjanuschka -commit before release - -Revision 1.30 2006/05/24 19:18:35 hjanuschka -version bump - -Revision 1.29 2006/05/21 21:18:10 hjanuschka -commit before workweek - -Revision 1.28 2006/05/20 20:52:18 hjanuschka -set core dump limit in deamon mode -snmp minimal fixes -announce if SNMP is compiled in on startup - -Revision 1.27 2006/04/24 22:20:00 hjanuschka -core: event queue - -Revision 1.26 2006/04/23 18:07:43 hjanuschka -core/ui/php: checks can now be forced -ui: remote xml special_addon support -core: svc perf MS -core: round perf MS -php: svcmap, get_service perf MS -ui: perf MS - -Revision 1.25 2006/02/25 18:53:22 hjanuschka -setuid too late, pid file was created by root -makefile: copy mysql.shema to $BASEDIR - -Revision 1.24 2006/02/25 02:02:46 hjanuschka -core: configure/ --with-user= -core: configure/ install all files and directories with chown $BARTLBY_USER -core: lib/mysql [worker|service|server]_by_id returns negative value if not found - -Revision 1.23 2006/02/10 23:54:46 hjanuschka -SIRENE mode added - -Revision 1.22 2006/02/05 21:49:47 hjanuschka -*** empty log message *** - -Revision 1.21 2006/01/19 23:30:22 hjanuschka -introducing downtime's - -Revision 1.20 2006/01/09 23:53:10 hjanuschka -minor changes - -Revision 1.19 2006/01/08 16:17:24 hjanuschka -mysql shema^ - -Revision 1.18 2005/12/13 23:17:53 hjanuschka -setuid before creating shm segment - -Revision 1.17 2005/11/16 23:51:29 hjanuschka -version bump 0.9.9a (Exusiai) -replication tests minor fixes - -Revision 1.16 2005/10/25 20:36:32 hjanuschka -startup time is'nt reset on cfg reload now - -Revision 1.15 2005/09/30 23:58:02 hjanuschka -*** empty log message *** - -Revision 1.14 2005/09/28 21:46:30 hjanuschka -converted files to unix -jabber.sh -> disabled core dumps -> jabblibs segfaults - will try to patch it later - -Revision 1.13 2005/09/18 11:28:12 hjanuschka -replication now works :-) -core: can run as slave and load data from a file instead of data_lib -ui: displays a warning if in slave mode to not add/modify servers/services -portier: recieves and writes shm dump to disk -so hot stand by should be possible ;-) -slave also does service checking - -Revision 1.12 2005/09/18 05:05:43 hjanuschka -compile warnings - -Revision 1.11 2005/09/18 04:04:52 hjanuschka -replication interface (currently just a try out) -one instance can now replicate itself to another using portier as a transport way -FIXME: need to sort out a binary write() problem - -Revision 1.10 2005/09/13 19:43:31 hjanuschka -human readable release code name REL_NAME -fixed printf() in shutdown daemon *fg* - -Revision 1.9 2005/09/13 19:29:18 hjanuschka -daemon: pidfile, remove pidfile at end -mysql.c: fixed 2 segfaults under _MALLOC_CHECK=2 - -Revision 1.8 2005/09/06 20:59:12 hjanuschka -performance tests fixes addition's - -Revision 1.7 2005/09/05 19:53:12 hjanuschka -2 day uptime without a single sigsegv ;-) -added daemon function ;-) - new cfg vars daemon=[true|false], basedir, logfile - -Revision 1.6 2005/09/03 23:01:13 hjanuschka -datalib api refined -moved to version 0.9.7 -reload via SHM - -Revision 1.5 2005/09/03 20:11:22 hjanuschka -fixups - -added addworker, deleteworker, modifyworker, getworkerbyid - -Revision 1.4 2005/08/28 18:00:22 hjanuschka -data_lib api extended, service/add/delete/update - -Revision 1.3 2005/08/28 15:59:47 hjanuschka -CVS header ;-) - +$Revision: 36 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/bartlby.c $ +$Date: 2008-04-16 10:21:18 +0200 (Mi, 16 Apr 2008) $ +$Author: hjanuschka $ */ @@ -396,8 +246,15 @@ if(ui == NULL) { _log("User: %s not found cannot setuid running as %d", cfg_user, getuid()); } else { - setuid(ui->pw_uid); - setgid(ui->pw_gid); + if(setuid(ui->pw_uid) < 0) { + _log("setuid() failed: %s", ui->pw_name); + exit(2); + } + if(setgid(ui->pw_gid) < 0) { + _log("setgid() failed: %d '%s`", ui->pw_gid, strerror(errno)); + // exit(2); + + } _log("User: %s/%d", ui->pw_name, ui->pw_gid); } @@ -444,14 +301,17 @@ } int bartlby_populate_shm(char * cfgfile) { - + int shm_got_reused=0; + gshm_id = shmget(ftok(gShmtok, 32), gSHMSize,IPC_CREAT | IPC_EXCL | 0777); if(gshm_id < 0 && gReuseSHM == 1) { _log("trying to reuse SHM"); gshm_id = shmget(ftok(gShmtok, 32), gSHMSize,IPC_CREAT | 0777); + shm_got_reused=1; } + if(gshm_id != -1) { gBartlby_address=shmat(gshm_id,NULL,0); @@ -493,7 +353,7 @@ gshm_hdr->do_reload=0; gshm_hdr->last_replication=-1; //shm_hdr->startup_time=time(NULL); - if(gReuseSHM != 1) { + if(shm_got_reused != 1) { gshm_hdr->startup_time=global_startup_time; } @@ -508,12 +368,21 @@ if(gshm_hdr->wrkcount <= 0) { _log("Found workers are below zero (%ld) maybe your datalib config isnt OK or you havent completed the setup", gshm_hdr->wrkcount); - shmdt(gBartlby_address); + + if(shmdt(gBartlby_address) < 0) { + _log("shmdt() failed '%s`", strerror(errno)); + } + gshm_id = shmget(ftok(gShmtok, 32), 0, 0600); - shmctl(gshm_id, IPC_RMID, &gshm_desc); + + if(shmctl(gshm_id, IPC_RMID, &gshm_desc) < 0) { + _log("shmctl() failed '%s`", strerror(errno)); + } + return -1; } + bartlby_SHM_link_services_servers(gBartlby_address, cfgfile); @@ -545,12 +414,19 @@ //write back all services sched_write_back_all(cfgfile, gBartlby_address, gSOHandle); - shmdt(gBartlby_address); + + if(shmdt(gBartlby_address) < 0) { + _log("shmdt() failed '%s`", strerror(errno)); + } + gshm_id = shmget(ftok(gShmtok, 32), 0, 0600); - shmctl(gshm_id, IPC_RMID, &gshm_desc); + if(shmctl(gshm_id, IPC_RMID, &gshm_desc) < 0) { + _log("shmctl() failed '%s`", strerror(errno)); + } + if(exi_code != 1) { - //re populate SHM called reload *fg* + //re populate SHM bartlby_shm_fits(gCfgfile); if(bartlby_populate_shm(gCfgfile) < 0) { //in case of zero workers @@ -624,11 +500,17 @@ } //start it - bartlby_go(gCfgfile); + if(bartlby_go(gCfgfile) < 0) { + _log("bartlby_go() failed"); + } free(gShmtok); - dlclose(gSOHandle); + + if(dlclose(gSOHandle) < 0) { + _log("dlclose() failed '%s`", strerror(errno)); + } + _log("%s Ended(Daemon: %s)", PROGNAME, daemon_mode); bartlby_end_clean(gCfgfile); diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_active.c bartlby-core/src/check_active.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_active.c 2007-02-15 17:25:32.000000000 +0100 +++ bartlby-core/src/check_active.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: check_active.c,v 1.3 2007/02/15 16:25:32 hjanuschka Exp $ */ +/* $Id: check_active.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,23 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.3 $ -$Source: /cvsroot/bartlby/bartlby-core/src/check_active.c,v $ - - -$Log: check_active.c,v $ -Revision 1.3 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.2 2007/01/27 19:52:13 hjanuschka -auto commit - -Revision 1.1 2006/11/25 01:16:00 hjanuschka -auto commit - - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/check_active.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ #include #include @@ -41,11 +33,12 @@ #include #include #include +#include #include -static int connection_timed_out=0; +static sig_atomic_t connection_timed_out=0; static void bartlby_conn_timeout(int signo) { connection_timed_out = 1; @@ -106,7 +99,18 @@ } act1.sa_handler = bartlby_conn_timeout; - sigemptyset(&act1.sa_mask); + + + if(sigemptyset(&act1.sa_mask) < 0) { + + sprintf(svc->new_server_text, "%s", ALARM_ERROR); + svc->current_state=STATE_CRITICAL; + + return; + + + } + act1.sa_flags=0; #ifdef SA_INTERRUPT act1.sa_flags |= SA_INTERRUPT; @@ -128,7 +132,10 @@ if(connection_timed_out == 1 || client_connect_retval == -1) { sprintf(svc->new_server_text, "%s", CONN_ERROR); svc->current_state=STATE_CRITICAL; - close(client_socket); + + if(close(client_socket) < 0) { + _log("close() in check_active failed! '%s`", strerror(errno)); + } return; } diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_active_v2.c bartlby-core/src/check_active_v2.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_active_v2.c 2007-02-15 17:25:32.000000000 +0100 +++ bartlby-core/src/check_active_v2.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: check_active_v2.c,v 1.8 2007/02/15 16:25:32 hjanuschka Exp $ */ +/* $Id: check_active_v2.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,38 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -based on Ethan gelstad's nrpe: http://nagios.cvs.sourceforge.net/nagios/nrpe/src/check_nrpe.c?view=log -$Revision: 1.8 $ -$Source: /cvsroot/bartlby/bartlby-core/src/check_active_v2.c,v $ - - -$Log: check_active_v2.c,v $ -Revision 1.8 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.7 2006/12/20 21:28:56 hjanuschka -performance on large - -Revision 1.6 2006/12/05 03:47:12 hjanuschka -auto commit - -Revision 1.5 2006/11/28 21:37:25 hjanuschka -auto commit - -Revision 1.3 2006/11/28 03:30:42 hjanuschka -auto commit - -Revision 1.2 2006/11/27 21:16:28 hjanuschka -auto commit - -Revision 1.1 2006/11/25 22:04:40 hjanuschka -*** empty log message *** - -Revision 1.1 2006/11/25 00:54:23 hjanuschka -auto commit - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/check_active_v2.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ @@ -71,7 +48,7 @@ -static int conn_timedout = 0; +static sig_atomic_t conn_timedout = 0; static unsigned long crc32_table[256]; @@ -266,7 +243,7 @@ svc->current_state=STATE_CRITICAL; return; }else if(bytes_to_recvnew_server_text, "AgentV2: Receive underflow - only %d bytes received (%ld expected).\n",bytes_to_recv,sizeof(receive_packet)); + sprintf(svc->new_server_text, "AgentV2: Receive underflow - only %d bytes received (%ld expected).\n",bytes_to_recv,(unsigned long)sizeof(receive_packet)); svc->current_state=STATE_CRITICAL; return; } diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check.c bartlby-core/src/check.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check.c 2007-07-28 00:54:04.000000000 +0200 +++ bartlby-core/src/check.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,496 +1,277 @@ -/* $Id: check.c,v 1.69 2007/07/27 22:54:04 hjanuschka Exp $ */ -/* ----------------------------------------------------------------------- * - * - * Copyright 2005 Helmut Januschka - All Rights Reserved - * - * 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, Inc., 675 Mass Ave, Cambridge MA 02139, - * USA; either version 2 of the License, or (at your option) any later - * version; incorporated herein by reference. - * - * ----------------------------------------------------------------------- */ -/* -$Revision: 1.69 $ -$Source: /cvsroot/bartlby/bartlby-core/src/check.c,v $ - - -$Log: check.c,v $ -Revision 1.69 2007/07/27 22:54:04 hjanuschka -int to long changing - -Revision 1.68 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.67 2006/12/20 21:28:56 hjanuschka -performance on large - -Revision 1.65 2006/12/08 23:52:20 hjanuschka -*** empty log message *** - -Revision 1.63 2006/11/27 21:16:28 hjanuschka -auto commit - -Revision 1.62 2006/11/26 20:52:20 hjanuschka -auto commit - -Revision 1.61 2006/11/25 01:16:00 hjanuschka -auto commit - -Revision 1.60 2006/11/25 00:54:23 hjanuschka -auto commit - -Revision 1.59 2006/09/30 17:48:11 hjanuschka -auto commit - -Revision 1.58 2006/09/11 21:22:06 hjanuschka -auto commit - -Revision 1.57 2006/09/03 22:19:47 hjanuschka -auto commit - -Revision 1.56 2006/08/25 20:10:10 hjanuschka -auto commit - -Revision 1.55 2006/08/19 00:07:29 hjanuschka -version bump 1.2.3 (August) -core: passive services get critical after timeout*2 - -Revision 1.54 2006/08/12 17:44:34 hjanuschka -auto commit - -Revision 1.53 2006/08/03 20:52:57 hjanuschka -*** empty log message *** - -Revision 1.52 2006/07/28 21:17:44 hjanuschka -auto commit - -Revision 1.48 2006/07/18 21:38:23 hjanuschka -core: a major BUG has been discoverd in the first production envorioments - when a worker has only selected OK and CRITICAL notifications - he always got notified about a change from (unselected) WARNING back to OK - this had produce ALOT of unserious OK notifications - -- 18-07-06 fixed :-) - -core: perfhandlers have been re-worked to only collect data - -Revision 1.47 2006/06/21 11:34:30 hjanuschka -fixing trigger bug - -Revision 1.46 2006/06/14 22:44:50 hjanuschka -fixing stdout bug on early mysql errors -fixing miss behavior of the extension interface in various code pieces - -Revision 1.45 2006/06/04 23:55:28 hjanuschka -core: SSL_connect (timeout issue's solved , at least i hope :)) -core: when perfhandlers_enabled == false, you now can enable single services -core: plugin_arguments supports $MACROS -core: config variables try now to cache themselfe to minimize I/O activity -core: .so extensions support added - -Revision 1.44 2006/05/24 13:07:39 hjanuschka -NRPE support (--enable-nrpe) - -Revision 1.43 2006/05/20 20:26:09 hjanuschka -ui: add/modify server page rebrush (should be user-friendlier) -core: snmp INTEGER greater, lower (warning,critical) (--enable-snmp=yes) -core/lib mysql: SNMP functionality -ui: add/modify_service SNMP -php: SNMP functions - -Revision 1.42 2006/05/20 18:29:16 hjanuschka -snmp implented - -Revision 1.41 2006/05/12 23:38:02 hjanuschka -*** empty log message *** - -Revision 1.40 2006/05/06 23:32:02 hjanuschka -*** empty log message *** - -Revision 1.39 2006/05/01 22:11:30 hjanuschka -some sched fixes -and event push immediatly when status change - -Revision 1.38 2006/04/24 22:20:00 hjanuschka -core: event queue - -Revision 1.37 2006/03/29 16:55:46 hjanuschka -mysql sheme fix -> forgott to add service_retain -check: notify + retain FIXed - -Revision 1.36 2006/03/18 01:54:46 hjanuschka -perf: distribute RRDs correspodening to the perf handler -core: sched_timeout refined -core: service_retain -core: lib/mysql service_retain -php: service_retain -ui: service_retain -ui: add perf defaults to package -ui: catch un-existing objects, server|service|worker -ui: exit if either built in nor shared bartlby extension was found (discovered during php upgrade ) -ui: addons got own config file (ui-extra.conf) -php: E_WARNING on unexisting config file - -Revision 1.35 2006/02/17 20:06:19 hjanuschka - acknowledgeable services - -Revision 1.34 2006/02/12 00:15:34 hjanuschka -Makefile.conf added -Local checks implemented -minor active check fixes and clean ups for re-use with local checks - -Revision 1.33 2006/02/10 23:54:46 hjanuschka -SIRENE mode added - -Revision 1.32 2006/02/09 00:14:50 hjanuschka -datalib: mysql/ catch failed logins -core: fixed some setuid problems with datalib -core: zero worker detected and logged -core: network code re-worked, much faster and cleaner now -core: encode/decode removed -php: encode/decode removed -ui: topology map manager added -ui: nicer menu (flap) -ui: server_detail (added) -startup sh: pre-start check if logfile is writeable - -Revision 1.31 2006/01/16 20:51:41 hjanuschka -performance stuff moved to perf.c -timeing information on perf handler - -Revision 1.30 2006/01/09 23:53:10 hjanuschka -minor changes - -Revision 1.29 2006/01/08 16:17:24 hjanuschka -mysql shema^ - -Revision 1.28 2005/12/31 00:29:44 hjanuschka -some more perf fixes during high load test - -Revision 1.27 2005/12/27 22:00:14 hjanuschka -*** empty log message *** - -Revision 1.26 2005/12/25 23:01:16 hjanuschka -stress testing with RRD -perf fixes - -Revision 1.25 2005/12/25 12:55:45 hjanuschka -service_check_timeout is dynamic now - -Revision 1.24 2005/12/25 00:38:04 hjanuschka -perf_trigger: BARTLBY_CONFIG env set - sample (bartlby_load) RRD+graph sample performance trigger - -Revision 1.23 2005/12/25 00:30:08 hjanuschka -perf trigger: envs, BARTLBY_CURR_HOST, BARTLBY_CURR_SERVICE, BARTLBY_CURR_PLUGIN set right before trigger is executed - -Revision 1.22 2005/12/24 17:53:41 hjanuschka -performance interface i.e: for adding RRD tools or something like that - -Revision 1.21 2005/11/27 02:04:42 hjanuschka -setuid/setgid for security and web ui - -Revision 1.20 2005/11/16 23:51:29 hjanuschka -version bump 0.9.9a (Exusiai) -replication tests minor fixes - -Revision 1.19 2005/10/25 20:36:32 hjanuschka -startup time is'nt reset on cfg reload now - -Revision 1.18 2005/10/13 22:13:14 hjanuschka -logging improved, check fixup - -Revision 1.17 2005/10/09 14:44:09 hjanuschka -agent announces OS and version - -Revision 1.16 2005/09/28 21:46:30 hjanuschka -converted files to unix -jabber.sh -> disabled core dumps -> jabblibs segfaults - will try to patch it later - -Revision 1.15 2005/09/25 13:30:18 hjanuschka -cfg: jabber variables -daemon: setenv BARTLBY_HOME (for triggers) -sched: wait_open timeout -mail.sh: sendmail trigger -trigger: $1 == email -$2 == icq -$3 == name -$4 == msg - -Revision 1.14 2005/09/24 10:34:11 hjanuschka -deadlock sched_wait_open fixed - -Revision 1.13 2005/09/23 18:21:18 hjanuschka -if check times out curren_running gets in negative integer fixed -default check timeout 15 seconds - -Revision 1.12 2005/09/22 02:55:03 hjanuschka -agent: def timeout 15 -check: strreplace ' " - -Revision 1.11 2005/09/14 22:01:41 hjanuschka -debug in data_lib added and removed -agent: off by two :-) *fG* malloc error producing magic char's (fixed) - -Revision 1.10 2005/09/11 21:42:24 hjanuschka -log files are now archived by Y.M.d - -Revision 1.9 2005/09/11 09:20:58 hjanuschka -logging issue ;-) -ui now can display log in a nice layout ;-) - -Revision 1.8 2005/09/07 22:36:56 hjanuschka -portier: added err code -4 svc not found -check: group check fixed , runnaway strtok :-) - -Revision 1.7 2005/09/07 21:51:40 hjanuschka -fixed passive check_fin bug -added bartlby_portier passive results may now be deliverd from remote - -Revision 1.6 2005/09/05 19:53:12 hjanuschka -2 day uptime without a single sigsegv ;-) -added daemon function ;-) - new cfg vars daemon=[true|false], basedir, logfile - -Revision 1.5 2005/09/03 20:11:22 hjanuschka -fixups - -added addworker, deleteworker, modifyworker, getworkerbyid - -Revision 1.4 2005/08/28 16:02:59 hjanuschka -CVS Header - - -*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - - -void bartlby_check_grep_perf_line(char * l, struct service * svc, char * cfgfile) { - char * tmp_line; - int x; - int lf_found=0; - int n_orig=0; - int p_line=0; - char * pl; - - - - - if(strncmp(l, "PERF: ", 6) == 0) { - tmp_line = strdup(l); - pl=strdup(l); - - for(x=0; xcurrent_state != svc->last_state) { - svc->service_retain_current=0; - svc->last_state=svc->current_state; - - _log("@LOG@%ld|%d|%s:%d/%s|%s", svc->service_id, svc->current_state, svc->srv->server_name, svc->srv->client_port, svc->service_name, svc->new_server_text); - bartlby_push_event(EVENT_STATUS_CHANGED, "Service-Changed;%d;%s:%d/%s;%d;%s", svc->service_id, svc->srv->server_name, svc->srv->client_port, svc->service_name, svc->current_state, svc->new_server_text); - bartlby_callback(EXTENSION_CALLBACK_STATE_CHANGED, svc); - } - if(svc->service_retain_current == svc->service_retain && svc->current_state != svc->notify_last_state) { - - bartlby_push_event(EVENT_TRIGGER_PUSHED, "Service-Changed;%d;%s:%d/%s;%d;%s", svc->service_id, svc->srv->server_name, svc->srv->client_port, svc->service_name, svc->current_state, svc->new_server_text); - - if(svc->current_state == STATE_CRITICAL && svc->recovery_outstanding == RECOVERY_DONE) { - svc->recovery_outstanding = RECOVERY_OUTSTANDING; - } - - bartlby_trigger(svc, cfgfile, shm_addr, 1); - svc->notify_last_state=svc->current_state; - - if(svc->current_state == STATE_OK && svc->recovery_outstanding == RECOVERY_OUTSTANDING) { - svc->recovery_outstanding=RECOVERY_DONE; - - } - - if(svc->service_ack == ACK_NEEDED && svc->current_state == STATE_CRITICAL) { - svc->service_ack=ACK_OUTSTANDING; - } - - - - } - - - - bartlby_callback(EXTENSION_CALLBACK_POST_CHECK, svc); - - svc->service_retain_current++; - - - - cfg_instant_wb = getConfigValue("instant_write_back", cfgfile); - if(cfg_instant_wb == NULL) { - cfg_instant_wb=strdup("true"); - } - - if(strcmp(cfg_instant_wb, "true") == 0) { - LOAD_SYMBOL(doUpdate,SOHandle, "doUpdate"); - doUpdate(svc,cfgfile); - } - - free(cfg_instant_wb); - - - -} - -void bartlby_check_service(struct service * svc, void * shm_addr, void * SOHandle, char * cfgfile) { - //_log("check service"); - int ctime, pdiff; - //_log("<%d/%d -- CHECK >: %s",svc->current_state,svc->last_state, svc->service_name); - - setenv("BARTLBY_CONFIG", cfgfile,1); - setenv("BARTLBY_CURR_PLUGIN", svc->plugin,1); - setenv("BARTLBY_CURR_HOST", svc->srv->server_name,1); - setenv("BARTLBY_CURR_SERVICE", svc->service_name,1); - - if(bartlby_callback(EXTENSION_CALLBACK_PRE_CHECK, svc) != EXTENSION_OK) { - /* - a extension canceld the check - */ - return; - } - if(svc->service_type == SVC_TYPE_GROUP) { - bartlby_check_group(svc, shm_addr); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_PASSIVE) { - ctime=time(NULL); - pdiff=ctime-svc->last_check; - - if(svc->service_passive_timeout > 0 && pdiff >= svc->service_passive_timeout) { - - sprintf(svc->new_server_text, "%s", PASSIVE_TIMEOUT); - if(pdiff >= svc->service_passive_timeout * 2) { - svc->current_state=STATE_CRITICAL; - } else { - svc->current_state=STATE_WARNING; - } - - - } - //_log("PASSIVE_CHECK %d->%d", svc->service_passive_timeout, svc->service_id); - bartlby_check_grep_perf_line(svc->new_server_text, svc, cfgfile); - - bartlby_fin_service(svc, SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_ACTIVE) { - bartlby_check_active(svc,cfgfile); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_LOCAL) { - bartlby_check_local(svc,cfgfile); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_SNMP) { - - bartlby_check_snmp(svc,cfgfile); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_NRPE) { - bartlby_check_nrpe(svc, cfgfile, 0); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_NRPE_SSL) { - bartlby_check_nrpe(svc, cfgfile, 1); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - - } - if(svc->service_type == SVC_TYPE_V2) { - bartlby_check_v2(svc, cfgfile, 1); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - if(svc->service_type == SVC_TYPE_V2_NO_SSL) { - bartlby_check_v2(svc, cfgfile, 0); - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } - // - if(bartlby_callback(EXTENSION_CALLBACK_UNKOWN_CHECK_TYPE, svc) != EXTENSION_OK) { - bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); - return; - } else { - _log("Undefined service check type: %d", svc->service_type); - sprintf(svc->new_server_text, "undefined service type (%d)", svc->service_type); - svc->current_state=STATE_CRITICAL; - } - - return; -} +/* $Id: check.c 16 2008-04-07 19:20:34Z hjanuschka $ */ +/* ----------------------------------------------------------------------- * + * + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * + * + * 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, Inc., 675 Mass Ave, Cambridge MA 02139, + * USA; either version 2 of the License, or (at your option) any later + * version; incorporated herein by reference. + * + * visit: www.bartlby.org for support + * ----------------------------------------------------------------------- */ +/* +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/check.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +void bartlby_check_grep_perf_line(char * l, struct service * svc, char * cfgfile) { + char * tmp_line; + int x; + int lf_found=0; + int n_orig=0; + int p_line=0; + char * pl; + + + + + if(strncmp(l, "PERF: ", 6) == 0) { + tmp_line = strdup(l); + pl=strdup(l); + + for(x=0; xcurrent_state != svc->last_state) { + svc->service_retain_current=0; + svc->last_state=svc->current_state; + + _log("@LOG@%ld|%d|%s:%d/%s|%s", svc->service_id, svc->current_state, svc->srv->server_name, svc->srv->client_port, svc->service_name, svc->new_server_text); + bartlby_push_event(EVENT_STATUS_CHANGED, "Service-Changed;%d;%s:%d/%s;%d;%s", svc->service_id, svc->srv->server_name, svc->srv->client_port, svc->service_name, svc->current_state, svc->new_server_text); + bartlby_callback(EXTENSION_CALLBACK_STATE_CHANGED, svc); + } + if(svc->service_retain_current == svc->service_retain && svc->current_state != svc->notify_last_state) { + + bartlby_push_event(EVENT_TRIGGER_PUSHED, "Service-Changed;%d;%s:%d/%s;%d;%s", svc->service_id, svc->srv->server_name, svc->srv->client_port, svc->service_name, svc->current_state, svc->new_server_text); + + if(svc->current_state == STATE_CRITICAL && svc->recovery_outstanding == RECOVERY_DONE) { + svc->recovery_outstanding = RECOVERY_OUTSTANDING; + } + + bartlby_trigger(svc, cfgfile, shm_addr, 1, 0); + svc->notify_last_state=svc->current_state; + + if(svc->current_state == STATE_OK && svc->recovery_outstanding == RECOVERY_OUTSTANDING) { + svc->recovery_outstanding=RECOVERY_DONE; + + } + + if(svc->service_ack == ACK_NEEDED && svc->current_state == STATE_CRITICAL) { + svc->service_ack=ACK_OUTSTANDING; + } + + + + } + /* Check if we need to re-notify */ + /* when retain in reached */ + /* current state is critical*/ + /* re-notify interval reached (seen from last_notify) */ + + //if ( (svc->service_retain_current >= svc->service_retain) && ( svc->current_state == STATE_CRITICAL ) && ( svc->renotify_interval > 0 ) && ( (time(NULL)-svc->last_notify_send) >= svc->renotify_interval ) ) { + if ( (svc->service_retain_current >= svc->service_retain) && ( svc->current_state == STATE_CRITICAL ) && ( svc->renotify_interval > 0 ) && ( svc->service_retain_current % svc->renotify_interval == 0 ) ) { + _log("re-notify for %s:%d/%s", svc->srv->server_name,svc->srv->client_port, svc->service_name); + bartlby_trigger(svc, cfgfile, shm_addr, 1, 0); + svc->notify_last_state=svc->current_state; + + } + /* Check if we need to escalate and enable standby workers */ + /* when retain in reached */ + /* current state is critical*/ + /* retain_current >= escalate_value */ + + if ( (svc->service_retain_current >= svc->service_retain) && ( svc->current_state == STATE_CRITICAL ) && ( svc->escalate_divisor > 0 ) && ( svc->service_retain_current % svc->escalate_divisor == 0 ) ) { + _log("escalate to standby workers for %s:%d/%s", svc->srv->server_name,svc->srv->client_port, svc->service_name); + bartlby_trigger(svc, cfgfile, shm_addr, 1, 1); + + + } + + + + + + bartlby_callback(EXTENSION_CALLBACK_POST_CHECK, svc); + + svc->service_retain_current++; + + + + cfg_instant_wb = getConfigValue("instant_write_back", cfgfile); + if(cfg_instant_wb == NULL) { + cfg_instant_wb=strdup("true"); + } + + if(strcmp(cfg_instant_wb, "true") == 0) { + LOAD_SYMBOL(doUpdate,SOHandle, "doUpdate"); + doUpdate(svc,cfgfile); + } + + free(cfg_instant_wb); + + + +} + +void bartlby_check_service(struct service * svc, void * shm_addr, void * SOHandle, char * cfgfile) { + //_log("check service"); + int ctime, pdiff; + //_log("<%d/%d -- CHECK >: %s",svc->current_state,svc->last_state, svc->service_name); + + setenv("BARTLBY_CONFIG", cfgfile,1); + setenv("BARTLBY_CURR_PLUGIN", svc->plugin,1); + setenv("BARTLBY_CURR_HOST", svc->srv->server_name,1); + setenv("BARTLBY_CURR_SERVICE", svc->service_name,1); + + if(bartlby_callback(EXTENSION_CALLBACK_PRE_CHECK, svc) != EXTENSION_OK) { + /* + a extension canceld the check + */ + return; + } + if(svc->service_type == SVC_TYPE_GROUP) { + bartlby_check_group(svc, shm_addr); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_PASSIVE) { + ctime=time(NULL); + pdiff=ctime-svc->last_check; + + if(svc->service_passive_timeout > 0 && pdiff >= svc->service_passive_timeout) { + + sprintf(svc->new_server_text, "%s", PASSIVE_TIMEOUT); + if(pdiff >= svc->service_passive_timeout * 2) { + svc->current_state=STATE_CRITICAL; + } else { + svc->current_state=STATE_WARNING; + } + + + } + //_log("PASSIVE_CHECK %d->%d", svc->service_passive_timeout, svc->service_id); + bartlby_check_grep_perf_line(svc->new_server_text, svc, cfgfile); + + bartlby_fin_service(svc, SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_ACTIVE) { + bartlby_check_active(svc,cfgfile); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_LOCAL) { + bartlby_check_local(svc,cfgfile); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_SNMP) { + + bartlby_check_snmp(svc,cfgfile); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_NRPE) { + bartlby_check_nrpe(svc, cfgfile, 0); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_NRPE_SSL) { + bartlby_check_nrpe(svc, cfgfile, 1); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + + } + if(svc->service_type == SVC_TYPE_V2) { + bartlby_check_v2(svc, cfgfile, 1); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + if(svc->service_type == SVC_TYPE_V2_NO_SSL) { + bartlby_check_v2(svc, cfgfile, 0); + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } + // + if(bartlby_callback(EXTENSION_CALLBACK_UNKOWN_CHECK_TYPE, svc) != EXTENSION_OK) { + bartlby_fin_service(svc,SOHandle,shm_addr,cfgfile); + return; + } else { + _log("Undefined service check type: %d", svc->service_type); + sprintf(svc->new_server_text, "undefined service type (%d)", svc->service_type); + svc->current_state=STATE_CRITICAL; + } + + return; +} diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_group.c bartlby-core/src/check_group.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_group.c 2007-02-15 17:25:32.000000000 +0100 +++ bartlby-core/src/check_group.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: check_group.c,v 1.2 2007/02/15 16:25:32 hjanuschka Exp $ */ +/* $Id: check_group.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,21 +11,15 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.2 $ -$Source: /cvsroot/bartlby/bartlby-core/src/check_group.c,v $ - - -$Log: check_group.c,v $ -Revision 1.2 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.1 2006/11/25 01:16:00 hjanuschka -auto commit - - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/check_group.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ + #include #include #include @@ -89,7 +85,7 @@ return; } - if(svg->current_state == state) { + if(bartlby_is_in_downtime(shm_addr, svg) > 0 && svg->current_state == state) { //_log("Service: is not %d\n", svg->current_state ); sprintf(svc->new_server_text, "%s %s:%d/%s - %d", GROUP_CRITICAL, svg->srv->server_name, svg->srv->client_port, svg->service_name, state); svc->current_state=STATE_CRITICAL; diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_local.c bartlby-core/src/check_local.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_local.c 2006-11-25 02:16:00.000000000 +0100 +++ bartlby-core/src/check_local.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: check_local.c,v 1.1 2006/11/25 01:16:00 hjanuschka Exp $ */ +/* $Id: check_local.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,17 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.1 $ -$Source: /cvsroot/bartlby/bartlby-core/src/check_local.c,v $ - - -$Log: check_local.c,v $ -Revision 1.1 2006/11/25 01:16:00 hjanuschka -auto commit - - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/check_local.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ #include #include @@ -39,7 +37,7 @@ #include -static int connection_timed_out=0; +static sig_atomic_t connection_timed_out=0; static void bartlby_conn_timeout(int signo) { connection_timed_out = 1; diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_nrpe.c bartlby-core/src/check_nrpe.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/check_nrpe.c 2007-02-15 17:25:32.000000000 +0100 +++ bartlby-core/src/check_nrpe.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,4 +1,24 @@ -/* $Id: check_nrpe.c,v 1.3 2007/02/15 16:25:32 hjanuschka Exp $ */ +/* $Id: check_nrpe.c 16 2008-04-07 19:20:34Z hjanuschka $ */ +/* ----------------------------------------------------------------------- * + * + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * + * + * 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, Inc., 675 Mass Ave, Cambridge MA 02139, + * USA; either version 2 of the License, or (at your option) any later + * version; incorporated herein by reference. + * + * visit: www.bartlby.org for support + * ----------------------------------------------------------------------- */ +/* +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/check_nrpe.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ +*/ /* ----------------------------------------------------------------------- * * BASED upon the original source of CHECK_NRPE package from nagios: ***************************************************************************************** @@ -23,64 +43,8 @@ * is one level below alpha!! :) you explicit have to enable NRP feature(s) * in the ./configure of bartlby-core (--enable-nrpe=yes) * - * Copyright 2005 Helmut Januschka - All Rights Reserved - * - * 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, Inc., 675 Mass Ave, Cambridge MA 02139, - * USA; either version 2 of the License, or (at your option) any later - * version; incorporated herein by reference. - * * ----------------------------------------------------------------------- */ -/* -$Revision: 1.3 $ -$Source: /cvsroot/bartlby/bartlby-core/src/check_nrpe.c,v $ - - -$Log: check_nrpe.c,v $ -Revision 1.3 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.2 2006/11/27 21:16:28 hjanuschka -auto commit - -Revision 1.1 2006/11/25 01:16:00 hjanuschka -auto commit - -Revision 1.11 2006/11/25 00:54:23 hjanuschka -auto commit - -Revision 1.10 2006/11/13 16:58:55 hjanuschka -auto commit - -Revision 1.9 2006/09/23 22:38:46 hjanuschka -auto commit -Revision 1.8 2006/07/15 10:28:39 hjanuschka -nrpe FIXME solved - -Revision 1.7 2006/05/30 21:41:18 hjanuschka -nrpe ssl timeout - -Revision 1.6 2006/05/28 20:38:27 hjanuschka -cbr - -Revision 1.5 2006/05/28 16:18:27 hjanuschka -commit before release - -Revision 1.4 2006/05/24 19:18:35 hjanuschka -version bump - -Revision 1.3 2006/05/24 13:22:45 hjanuschka -*** empty log message *** - -Revision 1.2 2006/05/24 13:12:51 hjanuschka -nrpe: ARG1 fix - -Revision 1.1 2006/05/24 13:07:39 hjanuschka -NRPE support (--enable-nrpe) - -*/ #include @@ -115,7 +79,7 @@ #else -static int conn_timedout = 0; +static sig_atomic_t conn_timedout = 0; static unsigned long crc32_table[256]; @@ -377,7 +341,7 @@ svc->current_state=STATE_CRITICAL; return; }else if(bytes_to_recvnew_server_text, "CHECK_NRPE: Receive underflow - only %d bytes received (%ld expected).\n",bytes_to_recv,sizeof(receive_packet)); + sprintf(svc->new_server_text, "CHECK_NRPE: Receive underflow - only %d bytes received (%ld expected).\n",bytes_to_recv,(unsigned long)sizeof(receive_packet)); svc->current_state=STATE_CRITICAL; return; } diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/config.c bartlby-core/src/config.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/config.c 2007-02-15 17:25:32.000000000 +0100 +++ bartlby-core/src/config.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: config.c,v 1.11 2007/02/15 16:25:32 hjanuschka Exp $ */ +/* $Id: config.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,55 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.11 $ -$Source: /cvsroot/bartlby/bartlby-core/src/config.c,v $ - - -$Log: config.c,v $ -Revision 1.11 2007/02/15 16:25:32 hjanuschka -auto commit - -Revision 1.10 2007/01/05 01:49:00 hjanuschka -auto commit - -Revision 1.9 2006/06/05 21:06:06 hjanuschka -*** empty log message *** - -Revision 1.8 2006/06/04 23:55:28 hjanuschka -core: SSL_connect (timeout issue's solved , at least i hope :)) -core: when perfhandlers_enabled == false, you now can enable single services -core: plugin_arguments supports $MACROS -core: config variables try now to cache themselfe to minimize I/O activity -core: .so extensions support added - -Revision 1.7 2005/09/28 21:46:30 hjanuschka -converted files to unix -jabber.sh -> disabled core dumps -> jabblibs segfaults - will try to patch it later - -Revision 1.6 2005/09/25 13:30:18 hjanuschka -cfg: jabber variables -daemon: setenv BARTLBY_HOME (for triggers) -sched: wait_open timeout -mail.sh: sendmail trigger -trigger: $1 == email -$2 == icq -$3 == name -$4 == msg - -Revision 1.5 2005/09/05 20:00:54 hjanuschka -stupid configfile issue fixed - -Revision 1.4 2005/08/28 22:57:14 hjanuschka -config.c: fixed fclose BUG (too many open files ) missing fclose -service_active is now set by data_lib and acutally used by scheduler - -Revision 1.3 2005/08/28 16:02:59 hjanuschka -CVS Header - - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/config.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ #include @@ -70,8 +30,8 @@ struct cfg_cache { - char key[1024]; - char value[2048]; + char key[MAX_CCACHE_KEY]; + char value[MAX_CCACHE_VALUE]; } ccf; @@ -84,8 +44,8 @@ void cfg_init_cache(void) { int x; for(x=0; x= MAX_CCACHE) { cur_el=0; } else { @@ -135,7 +95,7 @@ return getConfigValue_ex(key, fname, 1); } -char * getConfigValue_ex(char * key, char * fname, int cache) { +char * getConfigValue_ex(const char * key, const char * fname, int cache) { FILE * fp; char str[1024]; char * val; diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/daemon.c bartlby-core/src/daemon.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/daemon.c 2006-09-09 21:38:34.000000000 +0200 +++ bartlby-core/src/daemon.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: daemon.c,v 1.11 2006/09/09 19:38:34 hjanuschka Exp $ */ +/* $Id: daemon.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,72 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.11 $ -$Source: /cvsroot/bartlby/bartlby-core/src/daemon.c,v $ - - -$Log: daemon.c,v $ -Revision 1.11 2006/09/09 19:38:34 hjanuschka -auto commit - -Revision 1.10 2006/06/04 23:55:28 hjanuschka -core: SSL_connect (timeout issue's solved , at least i hope :)) -core: when perfhandlers_enabled == false, you now can enable single services -core: plugin_arguments supports $MACROS -core: config variables try now to cache themselfe to minimize I/O activity -core: .so extensions support added - -Revision 1.9 2006/05/21 21:18:10 hjanuschka -commit before workweek - -Revision 1.8 2006/05/20 20:52:18 hjanuschka -set core dump limit in deamon mode -snmp minimal fixes -announce if SNMP is compiled in on startup - -Revision 1.7 2005/12/13 23:17:53 hjanuschka -setuid before creating shm segment - -Revision 1.6 2005/11/27 02:04:42 hjanuschka -setuid/setgid for security and web ui - -Revision 1.5 2005/09/28 21:46:30 hjanuschka -converted files to unix -jabber.sh -> disabled core dumps -> jabblibs segfaults - will try to patch it later - -Revision 1.4 2005/09/25 13:30:18 hjanuschka -cfg: jabber variables -daemon: setenv BARTLBY_HOME (for triggers) -sched: wait_open timeout -mail.sh: sendmail trigger -trigger: $1 == email -$2 == icq -$3 == name -$4 == msg - -Revision 1.3 2005/09/13 19:43:31 hjanuschka -human readable release code name REL_NAME -fixed printf() in shutdown daemon *fg* - -Revision 1.2 2005/09/13 19:29:18 hjanuschka -daemon: pidfile, remove pidfile at end -mysql.c: fixed 2 segfaults under _MALLOC_CHECK=2 - -Revision 1.1 2005/09/05 19:53:57 hjanuschka -daemon maybe safe shutdown by SIGINT SIGUSR1 - -Revision 1.5 2005/09/03 20:11:22 hjanuschka -fixups - -added addworker, deleteworker, modifyworker, getworkerbyid - -Revision 1.4 2005/08/28 16:02:59 hjanuschka -CVS Header - - +$Revision: 16 $ +$HeadURL: https://bartlby.svn.sourceforge.net/svnroot/bartlby/trunk/bartlby-core/src/daemon.c $ +$Date: 2008-04-07 21:20:34 +0200 (Mo, 07 Apr 2008) $ +$Author: hjanuschka $ */ #include #include @@ -226,8 +169,14 @@ bartlby_set_limits(); - chdir(base_dir); - _log("basedir set to:%s", base_dir); + if(chdir(base_dir) < 0) { + _log("basedir setting failed :%s (%s)", base_dir,strerror(errno)); + exit(1); + } else { + _log("basedir set to:%s", base_dir); + } + + /* out of manpage: This system call always succeeds and the previous value of the mask is returned.*/ umask(0); @@ -238,9 +187,16 @@ } else { sprintf(pidstr, "%d", getpid()); - fwrite(pidstr, sizeof(char), strlen(pidstr), pidfile); - fclose(pidfile); - _log("pidfile is at: '%s'", pidfname); + if(fwrite(pidstr, sizeof(char), strlen(pidstr), pidfile) <= 0) { + _log("pidfile creation failed"); + } else { + if(fclose(pidfile) == EOF) { + _log("fclose() failed for pidfile!!"); + exit(1); + } + _log("pidfile is at: '%s'", pidfname); + } + } if(setenv("BARTLBY_HOME", base_dir,1) == 0) { @@ -276,8 +232,12 @@ pid_def_name=strdup(base_dir); } sprintf(pidfname, "%s/bartlby.pid", pid_def_name); - unlink(pidfname); - _log("%s Pid file removed", pidfname); + + if(unlink(pidfname) == 0) { + _log("%s Pid file removed", pidfname); + } else { + _log("%s Pid file remove failed", pidfname); + } free(base_dir); free(pid_def_name); @@ -286,6 +246,7 @@ void bartlby_get_daemon(char * cfgfile) { pid_t pid; + if ((pid = fork ()) != 0) { //_log("Fork failed"); @@ -302,4 +263,6 @@ + return; + } diff -Nur /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/downtime.c bartlby-core/src/downtime.c --- /var/www/htdocs/bartlby.januschka.com/cvs/last_full//bartlby-core/src/downtime.c 2006-01-20 00:30:22.000000000 +0100 +++ bartlby-core/src/downtime.c 2008-04-07 21:20:34.000000000 +0200 @@ -1,7 +1,9 @@ -/* $Id: downtime.c,v 1.1 2006/01/19 23:30:22 hjanuschka Exp $ */ +/* $Id: downtime.c 16 2008-04-07 19:20:34Z hjanuschka $ */ /* ----------------------------------------------------------------------- * * - * Copyright 2005 Helmut Januschka - All Rights Reserved + * Copyright 2005-2008 Helmut Januschka - All Rights Reserved + * Contact: , + * * * 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 @@ -9,23 +11,13 @@ * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * + * visit: www.bartlby.org for support * ----------------------------------------------------------------------- */ /* -$Revision: 1.1 $ -$Source: /cvsroot/bartlby/bartlby-core/src/downtime.c,v $ - - -$Log: downtime.c,v $ -Revision 1.1 2006/01/19 23:30:22 hjanuschka -introducing