[Nagios-db-checkins] nagios-db/neb/postgres inserter.c,1.10,1.11
Status: Beta
Brought to you by:
bench23
From: Bench <be...@us...> - 2005-11-25 21:13:07
|
Update of /cvsroot/nagios-db/nagios-db/neb/postgres In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12862 Modified Files: inserter.c Log Message: - better debugging - fixed some buffer counting issues in initialization - upgraded NEB api to work with newer versions of Nagios Index: inserter.c =================================================================== RCS file: /cvsroot/nagios-db/nagios-db/neb/postgres/inserter.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- inserter.c 7 Apr 2005 21:31:40 -0000 1.10 +++ inserter.c 25 Nov 2005 21:12:58 -0000 1.11 @@ -52,6 +52,9 @@ static int processStatus(int, void *); static int processCheck(int, void *); +/* handle for callbacks*/ +void *inserter_module_handle = 0; + char * pullValue(char* in) { @@ -89,6 +92,9 @@ g_thread_init(0); + /* we'll want the handle saved for later */ + inserter_module_handle = handle; + write_to_all_logs("initializing nagios-db postgres inserter...",NSLOG_INFO_MESSAGE); /* Parse our arg string. @@ -99,12 +105,14 @@ write_to_all_logs("nagios-db postgres inserter failed to find postgres host in arguement string",NSLOG_INFO_MESSAGE); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... reading db host argument",NSLOG_INFO_MESSAGE); if(!(host = pullValue(tok+5))) { /* well, this isn't going to fly. */ write_to_all_logs("nagios-db postgres inserter failed to find valid postgres host in arguement string",NSLOG_INFO_MESSAGE); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... found valid db host",NSLOG_INFO_MESSAGE); if(!(tok = strstr(args,"db="))) { @@ -113,6 +121,7 @@ free(host); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... reading db name argument",NSLOG_INFO_MESSAGE); if(!(db = pullValue(tok+3))) { /* well, this isn't going to fly. */ @@ -120,6 +129,7 @@ free(host); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... found valid db name",NSLOG_INFO_MESSAGE); if(!(tok = strstr(args,"timeout="))) { @@ -129,6 +139,7 @@ free(db); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... reading timeout value argument",NSLOG_INFO_MESSAGE); if(!(val = pullValue(tok+8))) { /* well, this isn't going to fly. */ @@ -137,6 +148,7 @@ free(db); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... found valid timeout value",NSLOG_INFO_MESSAGE); timeout = atol(val); free(val); val=0; @@ -149,7 +161,8 @@ free(db); return 0; } - if(!(val = pullValue(tok+8))) + write_to_all_logs("initializing nagios-db postgres inserter... reading vacation value argument",NSLOG_INFO_MESSAGE); + if(!(val = pullValue(tok+9))) { /* well, this isn't going to fly. */ write_to_all_logs("nagios-db postgres inserter failed to find valid wrapper vacation value in arguement string",NSLOG_INFO_MESSAGE); @@ -157,6 +170,7 @@ free(db); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... found valid timeout value",NSLOG_INFO_MESSAGE); vacation = atol(val); free(val); val=0; @@ -169,7 +183,8 @@ free(db); return 0; } - if(!(val = pullValue(tok+8))) + write_to_all_logs("initializing nagios-db postgres inserter... reading write limit argument",NSLOG_INFO_MESSAGE); + if(!(val = pullValue(tok+7))) { /* well, this isn't going to fly. */ write_to_all_logs("nagios-db postgres inserter failed to find valid wrapper write limit in arguement string",NSLOG_INFO_MESSAGE); @@ -177,6 +192,7 @@ free(db); return 0; } + write_to_all_logs("initializing nagios-db postgres inserter... found valid write limit",NSLOG_INFO_MESSAGE); writes = atol(val); free(val); val=0; @@ -250,7 +266,7 @@ write_to_all_logs("nagios-db postgres inserter locked into db",NSLOG_INFO_MESSAGE); - neb_register_callback(NEBCALLBACK_TIMED_EVENT_DATA, 0, processStart); + neb_register_callback(NEBCALLBACK_TIMED_EVENT_DATA, inserter_module_handle, 0, processStart); return 0; } @@ -579,10 +595,10 @@ write_to_all_logs("nagios-db: configuration complete. Registering for status notifications...",NSLOG_INFO_MESSAGE); neb_deregister_callback(NEBCALLBACK_TIMED_EVENT_DATA, processStart); - neb_register_callback(NEBCALLBACK_HOST_STATUS_DATA, 0, processStatus); - neb_register_callback(NEBCALLBACK_SERVICE_STATUS_DATA, 0, processStatus); - neb_register_callback(NEBCALLBACK_HOST_CHECK_DATA, 0, processCheck); - neb_register_callback(NEBCALLBACK_SERVICE_CHECK_DATA, 0, processCheck); + neb_register_callback(NEBCALLBACK_HOST_STATUS_DATA, inserter_module_handle, 0, processStatus); + neb_register_callback(NEBCALLBACK_SERVICE_STATUS_DATA, inserter_module_handle, 0, processStatus); + neb_register_callback(NEBCALLBACK_HOST_CHECK_DATA, inserter_module_handle, 0, processCheck); + neb_register_callback(NEBCALLBACK_SERVICE_CHECK_DATA, inserter_module_handle, 0, processCheck); return 0; } |