Re: [Nagios-db-devel] Upgrade and rollback issues
Status: Beta
Brought to you by:
bench23
From: Ben <be...@si...> - 2005-03-11 06:54:15
|
Excellent, glad you find it useful. On Mar 10, 2005, at 10:51 PM, Robert Bilbrey wrote: > That was it, don't know how it ever worked in the first place. I > should be able to take it from here. Thanks for the help. This is the > relevant nagios.log entry: > [1110523507] Nagios 2.0b2 starting... (PID=9223) > [1110523507] LOG VERSION: 2.0 > [1110523507] initializing nagios-db postgres inserter... > [1110523507] nagios-db: inserter failed to establish postgres > connection (fe_sendauth: no password supplied > ) > [1110523507] Event broker module '/usr/local/nagios/bin/inserter.o' > initialized successfully. > > Ben wrote: >> Ok, so it turns out I apparently can't read documentation. I bet the >> problem is that you aren't successfully connecting to your database. >> Have you checked your permissions? Or, better yet, your postgres >> logs? >> I'm not in a place where I can try this out, so give it a shot. If it >> passes the compile test, then I'll check it in. If we're lucky, it >> might even tell you what's wrong. :) >> ---------------------------------------------------------------------- >> -- >> #ifndef NSCORE >> #define NSCORE >> #endif >> /* we need this for postgres support */ >> #include "libpq-fe.h" >> /* include the needed event broker header files */ >> #include "../include/nebmodules.h" >> #include "../include/nebcallbacks.h" >> #include "../include/nebstructs.h" >> #include "../include/broker.h" >> /* include some Nagios stuff as well */ >> #include "../include/config.h" >> #include "../include/common.h" >> #include "../include/nagios.h" >> #include "../include/objects.h" >> #include <sys/types.h> >> #include <string.h> >> #include <stdlib.h> >> #define UNIX_PATH_MAX 108 >> /* specify event broker API version (required) */ >> NEB_API_VERSION(CURRENT_NEB_API_VERSION); >> #define BUFFER_ALLOC_SIZE 1024 >> #define NULL_STRING(x) (x?:"null") >> #define BOOLIFY_STRING(x) (x?"TRUE":"FALSE") >> #define FIRST_COMMAND_NUM NEBCALLBACK_PROCESS_DATA >> char * querify(char * src); >> extern hostgroup *hostgroup_list; >> extern servicegroup *servicegroup_list; >> extern host *host_list; >> extern service *service_list; >> extern int enable_flap_detection; >> extern int enable_notifications; >> extern int enable_event_handlers; >> extern int execute_service_checks; >> extern int execute_host_checks; >> extern int accept_passive_service_checks; >> extern int accept_passive_host_checks; >> static int processStart(int, void *); >> static int processStatus(int, void *); >> static int processCheck(int, void *); >> PGconn * pgconn = 0; >> /* this function gets called when the module is loaded by the event >> broker */ >> int nebmodule_init(int flags, char *args, nebmodule *handle) >> { >> write_to_all_logs("initializing nagios-db postgres >> inserter...",NSLOG_INFO_MESSAGE); >> if(!(pgconn = PQconnectdb("host=meatshake port=5432 dbname=nag >> user=postgres"))) >> { >> /* couldn't connect; this will be useless. */ >> write_to_all_logs("nagios-db: inserter failed to allocate postgres >> connection",NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(CONNECTION_OK != PQstatus(pgconn)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: inserter failed to establish >> postgres connection (%s)",PQerrorMessage(pgconn)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> write_to_all_logs("nagios-db: inserter locked into >> db",NSLOG_INFO_MESSAGE); >> } >> neb_register_callback(NEBCALLBACK_TIMED_EVENT_DATA, 0, processStart); >> return 0; >> } >> /* this function gets called when the module is unoaded by the event >> broker */ >> int nebmodule_deinit(int flags, int reason) >> { >> /* log a message to the Nagios log file */ >> write_to_all_logs("nagios-db: inserter >> unloading...",NSLOG_INFO_MESSAGE); >> PQfinish(pgconn); >> neb_deregister_callback(NEBCALLBACK_HOST_STATUS_DATA, processStatus); >> neb_deregister_callback(NEBCALLBACK_SERVICE_STATUS_DATA, >> processStatus); >> neb_deregister_callback(NEBCALLBACK_HOST_CHECK_DATA, processCheck); >> neb_deregister_callback(NEBCALLBACK_SERVICE_CHECK_DATA, >> processCheck); >> pgconn = 0; >> return 0; >> } >> /* helper function to make a string ready for inclusion into a sql >> query */ >> char * >> querify(char * src) >> { >> char * ret = 0; >> if(src) >> { >> int size = 2*strlen(src) + 3; /* +3 because we want to surround >> strings with single quotes, and we still need a null */ >> int written = 0; >> if(!(ret = malloc(size))) >> { >> return 0; >> } >> ret[0] = '\''; >> written = PQescapeString(ret+1, src, strlen(src)); >> ret[written + 1] = '\''; >> ret[written + 2] = 0; >> } >> return ret; >> } >> /* when Nagios starts up, we'll want to replicate configuration data >> into the database */ >> static int processStart(int cmd, void * data) >> { >> host *hl = 0; >> service *sl = 0; >> hostgroup *hg = 0; >> PGresult *res = 0; >> int groupcount = 0; >> char q[2048]; >> /* verify that we're dealing with the right kind of message. */ >> if(cmd != NEBCALLBACK_TIMED_EVENT_DATA) return 0; >> /* verify that our config data has been initialized. */ >> if(((nebstruct_timed_event_data*)data)->type != >> NEBTYPE_TIMEDEVENT_ADD) return 0; >> /* Clear out the previous config info.... */ >> res = PQexec(pgconn,"select empty_config()"); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't clear config info >> (%s)", PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> PQclear(res); >> /* .... and insert new config info. Start with the hosts. */ >> for(groupcount=0, hl = host_list; hl; hl = hl->next) >> { >> /* update this host */ >> char *hostName = querify(hl->name); >> snprintf(q,sizeof(q),"select >> configure_host(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", >> NULL_STRING(hostName), >> BOOLIFY_STRING(hl->checks_enabled), >> BOOLIFY_STRING(hl->accept_passive_host_checks), >> BOOLIFY_STRING(hl->event_handler_enabled), >> BOOLIFY_STRING(hl->flap_detection_enabled), >> BOOLIFY_STRING(hl->notifications_enabled), >> BOOLIFY_STRING(hl->failure_prediction_enabled), >> BOOLIFY_STRING(hl->process_performance_data), >> BOOLIFY_STRING(hl->obsess_over_host), >> BOOLIFY_STRING(hl->should_be_scheduled)); >> if(hostName) free(hostName); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't configure host using >> '%s' (%s)", q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> PQclear(res); >> groupcount++; >> } >> snprintf(q,sizeof(q),"nagios-db: configured %d hosts", groupcount); >> write_to_all_logs(q,NSLOG_INFO_MESSAGE); >> /* add hostgroup membership */ >> for(groupcount=0, hg=hostgroup_list; hg ; hg = hg->next) >> { >> hostgroupmember *hgm = 0; >> char *groupName, *groupAlias, *hostName; >> unsigned long groupid = 0; >> /* insert this hostgroup */ >> groupName = querify(hg->group_name); >> groupAlias = querify(hg->alias); >> snprintf(q,sizeof(q),"select new_hostgroup(%s,%s)", >> NULL_STRING(groupName), NULL_STRING(groupAlias)); >> if(groupName) free(groupName); >> if(groupAlias) free(groupAlias); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't configure hostgroup >> using '%s' (%s)", q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> groupid = atol(PQgetvalue(res,0,0)); >> PQclear(res); >> for(hgm = hg->members; hgm; hgm = hgm->next) >> { >> /* add this host to the hostgroup */ >> hostName = querify(hgm->host_name); >> snprintf(q,sizeof(q),"select append_to_hostgroup(%lu,%s)", >> groupid, NULL_STRING(hostName)); >> if(hostName) free(hostName); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || >> PQresultStatus(res) == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't configure hostgroup >> membership using '%s' (%s)", q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> PQclear(res); >> } >> groupcount++; >> } >> snprintf(q,sizeof(q),"nagios-db: loaded %d hostgroups", groupcount); >> write_to_all_logs(q,NSLOG_INFO_MESSAGE); >> /* mark all the configured services as such */ >> for(groupcount=0, sl = service_list; sl; sl = sl->next) >> { >> /* update this service */ >> char *hostName = querify(sl->host_name); >> char *serviceDesc = querify(sl->description); >> snprintf(q,sizeof(q),"select >> configure_service(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", >> NULL_STRING(hostName), >> NULL_STRING(serviceDesc), >> BOOLIFY_STRING(sl->checks_enabled), >> BOOLIFY_STRING(sl->accept_passive_service_checks), >> BOOLIFY_STRING(sl->event_handler_enabled), >> BOOLIFY_STRING(sl->flap_detection_enabled), >> BOOLIFY_STRING(sl->notifications_enabled), >> BOOLIFY_STRING(sl->failure_prediction_enabled), >> BOOLIFY_STRING(sl->process_performance_data), >> BOOLIFY_STRING(sl->obsess_over_service), >> BOOLIFY_STRING(sl->should_be_scheduled)); >> if(hostName) free(hostName); >> if(serviceDesc) free(serviceDesc); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't configure service >> using '%s' (%s)", q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> PQclear(res); >> >> groupcount++; >> } >> snprintf(q,sizeof(q),"nagios-db: set configured flag on %d >> services", groupcount); >> write_to_all_logs(q,NSLOG_INFO_MESSAGE); >> /* also insert various config parameters that we might want */ >> snprintf(q,sizeof(q),"select >> replace_config_param('accept_passive_host_checks',%d)",accept_passive_ >> host_checks); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> snprintf(q,sizeof(q),"select >> replace_config_param('execute_host_checks',%d)",execute_host_checks); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> snprintf(q,sizeof(q),"select >> replace_config_param('accept_passive_service_checks',%d)",accept_passi >> ve_service_checks); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> snprintf(q,sizeof(q),"select >> replace_config_param('execute_service_checks',%d)",execute_service_che >> cks); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> snprintf(q,sizeof(q),"select >> replace_config_param('enable_flap_detection',%d)",enable_flap_detectio >> n); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> snprintf(q,sizeof(q),"select >> replace_config_param('enable_notifications',%d)",enable_notifications) >> ; >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> snprintf(q,sizeof(q),"select >> replace_config_param('enable_event_handlers',%d)",enable_event_handler >> s); >> res = PQexec(pgconn,q); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> q, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", q, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> 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); >> return 0; >> } >> static int processCheck(int cmd, void * data) { >> PGresult *res; >> char temp_buffer[1024]; >> bzero(temp_buffer, sizeof(temp_buffer)); >> switch(cmd) { >> case NEBCALLBACK_HOST_CHECK_DATA: >> { >> nebstruct_host_check_data * host_check_data = >> (nebstruct_host_check_data *) data; >> if(host_check_data->type != NEBTYPE_HOSTCHECK_PROCESSED) return 0; >> char *safeName = querify(host_check_data->host_name); >> snprintf(temp_buffer, sizeof(temp_buffer), "select >> host_checked(%s)",NULL_STRING(safeName)); >> if(safeName) free(safeName); >> } >> break; >> case NEBCALLBACK_SERVICE_CHECK_DATA: >> { >> nebstruct_service_check_data * service_check_data = >> (nebstruct_service_check_data *) data; >> if(service_check_data->type != NEBTYPE_SERVICECHECK_PROCESSED) >> return 0; >> char *safeName = querify(service_check_data->host_name); >> char *safeServiceDescription = >> querify(service_check_data->service_description); >> snprintf(temp_buffer, sizeof(temp_buffer), "select >> service_checked(%s,%s)", NULL_STRING(safeName), >> NULL_STRING(safeServiceDescription)); >> if(safeName) free(safeName); >> if(safeServiceDescription) free(safeServiceDescription); >> } >> break; >> default: >> snprintf(temp_buffer,sizeof(temp_buffer),"nagios-db: processCheck >> ignoring unknown NEB command %i",cmd); >> write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); >> return 0; >> break; >> } >> res = PQexec(pgconn,temp_buffer); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> temp_buffer, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", temp_buffer, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> return 0; >> } >> static int processStatus(int cmd, void * data) { >> PGresult *res; >> char temp_buffer[5120]; >> service *tmp_service; >> host *tmp_host; >> bzero(temp_buffer, sizeof(temp_buffer)); >> switch(cmd) { >> case NEBCALLBACK_HOST_STATUS_DATA: >> { >> nebstruct_host_status_data * host_status_data = >> (nebstruct_host_status_data *) data; >> tmp_host = (host *) host_status_data->object_ptr; >> char *safeName = querify(tmp_host->name); >> char *safeEventHandler = querify(tmp_host->event_handler); >> char *safePluginOutput = querify(tmp_host->plugin_output); >> char *safeHostCheckCommand = querify(tmp_host->host_check_command); >> char *safePerfData = querify(tmp_host->perf_data); >> snprintf(temp_buffer, sizeof(temp_buffer), "select >> update_host(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%lu,%s,%s,%s,%d,%d,%s,%d,%s, >> %f,%f,%lu,%lu,%d,%lu,%lu,%s,%s,%d)", >> NULL_STRING(safeName), >> BOOLIFY_STRING(tmp_host->checks_enabled), >> BOOLIFY_STRING(tmp_host->accept_passive_host_checks), >> BOOLIFY_STRING(tmp_host->event_handler_enabled), >> BOOLIFY_STRING(tmp_host->flap_detection_enabled), >> BOOLIFY_STRING(tmp_host->notifications_enabled), >> BOOLIFY_STRING(tmp_host->failure_prediction_enabled), >> BOOLIFY_STRING(tmp_host->process_performance_data), >> BOOLIFY_STRING(tmp_host->obsess_over_host), >> NULL_STRING(safeEventHandler), >> tmp_host->modified_attributes, >> BOOLIFY_STRING(tmp_host->has_been_checked), >> BOOLIFY_STRING(tmp_host->should_be_scheduled), >> BOOLIFY_STRING(tmp_host->is_flapping), >> tmp_host->current_state, >> tmp_host->last_hard_state, >> NULL_STRING(safePluginOutput), >> tmp_host->current_attempt, >> NULL_STRING(safeHostCheckCommand), >> tmp_host->execution_time, >> tmp_host->latency, >> tmp_host->last_check, >> tmp_host->next_check, >> tmp_host->max_attempts, >> tmp_host->last_host_notification, >> tmp_host->next_host_notification, >> BOOLIFY_STRING(tmp_host->no_more_notifications), >> NULL_STRING(safePerfData), >> tmp_host->check_type); >> if(safeName) free(safeName); >> if(safeEventHandler) free(safeEventHandler); >> if(safePluginOutput) free(safePluginOutput); >> if(safeHostCheckCommand) free(safeHostCheckCommand); >> if(safePerfData) free(safePerfData); >> } >> break; >> case NEBCALLBACK_SERVICE_STATUS_DATA: >> { >> nebstruct_service_status_data * service_status_data = >> (nebstruct_service_status_data *) data; >> tmp_service = (service *) service_status_data->object_ptr; >> char *safeName = querify(tmp_service->host_name); >> char *safeServiceDescription = querify(tmp_service->description); >> char *safeEventHandler = querify(tmp_service->event_handler); >> char *safePluginOutput = querify(tmp_service->plugin_output); >> char *safeServiceCheckCommand = >> querify(tmp_service->service_check_command); >> char *safePerfData = querify(tmp_service->perf_data); >> snprintf(temp_buffer, sizeof(temp_buffer), "select >> update_service(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%lu,%s,%s,%s,%d,%d,%s, >> %d,%s,%f,%f,%lu,%lu,%d,%lu,%lu,%s,%s,%d)", >> NULL_STRING(safeName), >> NULL_STRING(safeServiceDescription), >> BOOLIFY_STRING(tmp_service->checks_enabled), >> BOOLIFY_STRING(tmp_service- >> >accept_passive_service_checks), >> BOOLIFY_STRING(tmp_service->event_handler_enabled), >> BOOLIFY_STRING(tmp_service->flap_detection_enabled), >> BOOLIFY_STRING(tmp_service->notifications_enabled), >> BOOLIFY_STRING(tmp_service->failure_prediction_enabled), >> BOOLIFY_STRING(tmp_service->process_performance_data), >> BOOLIFY_STRING(tmp_service->obsess_over_service), >> NULL_STRING(safeEventHandler), >> tmp_service->modified_attributes, >> BOOLIFY_STRING(tmp_service->has_been_checked), >> BOOLIFY_STRING(tmp_service->should_be_scheduled), >> BOOLIFY_STRING(tmp_service->is_flapping), >> tmp_service->current_state, >> tmp_service->last_hard_state, >> NULL_STRING(safePluginOutput), >> tmp_service->current_attempt, >> NULL_STRING(safeServiceCheckCommand), >> tmp_service->execution_time, >> tmp_service->latency, >> tmp_service->last_check, >> tmp_service->next_check, >> tmp_service->max_attempts, >> tmp_service->last_notification, >> tmp_service->next_notification, >> BOOLIFY_STRING(tmp_service->no_more_notifications), >> NULL_STRING(safePerfData), >> tmp_service->check_type); >> if(safeName) free(safeName); >> if(safeServiceDescription) free(safeServiceDescription); >> if(safeEventHandler) free(safeEventHandler); >> if(safePluginOutput) free(safePluginOutput); >> if(safeServiceCheckCommand) free(safeServiceCheckCommand); >> if(safePerfData) free(safePerfData); >> } >> break; >> default: >> snprintf(temp_buffer,sizeof(temp_buffer),"nagios-db: processStatus >> ignoring unknown NEB command %i",cmd); >> write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); >> return 0; >> break; >> } >> res = PQexec(pgconn,temp_buffer); >> if(!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) >> == PGRES_TUPLES_OK)) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: couldn't execute '%s' (%s)", >> temp_buffer, PQresultErrorMessage(res)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> else >> { >> if(atoi(PQgetvalue(res,0,0)) < 0) >> { >> char str[2048]; >> snprintf(str,sizeof(str),"nagios-db: executed '%s' and got back >> %s", temp_buffer, PQgetvalue(res,0,0)); >> write_to_all_logs(str,NSLOG_INFO_MESSAGE); >> } >> } >> PQclear(res); >> return 0; >> } >> ---------------------------------------------------------------------- >> -- >> On Mar 10, 2005, at 8:57 PM, Robert Bilbrey wrote: >>> Hi Ben, upgraded Nagios back up to 2.0b2 and pulled the latest >>> nagios-db code from cvs. Still no joy (: >>> What would you suggest I do next ? >>> Thanks, Bob >>> >>> >>> postgresql version: >>> nagios=# select version(); >>> version >>> --------------------------------------------------------------------- >>> -- ----------------------------------- >>> PostgreSQL 7.4.6 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) >>> 3.2.3 20030502 (Red Hat Linux 3.2.3-42) >>> >>> my makefile: >>> gcc -Wall -g -O2 -o inserter.o inserter.c -shared >>> -I/usr/local/src/nagios-2.0b2/include -I/usr/local/pgsql/include >>> /usr/local/pgsql/lib/libpq.a >>> >>> nagios.log with latest nagios-db cvs pull: >>> >>> [1110516022] Nagios 2.0b2 starting... (PID=8772) >>> [1110516022] LOG VERSION: 2.0 >>> [1110516022] initializing nagios-db postgres inserter... >>> [1110516022] nagios-db: inserter locked into db >>> [1110516022] Event broker module '/usr/local/nagios/bin/inserter.o' >>> initialized successfully. >>> [1110516022] Warning: Host 'kcwebwt1' has no services associated >>> with it! >>> [1110516022] Warning: Contact 'brian' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'cheikh' is not a member of any >>> contact groups! >>> [1110516022] Warning: Contact 'dwain' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'eric' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'john' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'karen' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'liz' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'robert' is not a member of any >>> contact groups! >>> [1110516022] Warning: Contact 'russ' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'scott' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact 'van' is not a member of any contact >>> groups! >>> [1110516022] Warning: Contact group 'nagios-setup' is not used in >>> any hostgroup/service definitions or host/hostgroup/se >>> rvice escalations! >>> [1110516022] Finished daemonizing... (New PID=8774) >>> [1110516022] nagios-db: couldn't clear config info () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('OPX',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('clappwp1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('clbackw1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('clsqlwp1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('clwebwp1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('intranet',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcacct',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE >>> ,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcads',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE, >>> TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcadw1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE >>> ,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcmailfw1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,T >>> RUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcmailw1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcparadox',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,T >>> RUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcsecl1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRU >>> E,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcsqldb',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRU >>> E,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcsqlwd1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcsqlwp2',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcwebwd1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('kcwebwt1',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TR >>> UE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('pdoxtimer',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,T >>> RUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('sunflower-chi-gw',TRUE,TRUE,TRUE,TRUE,TRUE >>> ,TRUE,TRUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('sunflower-nor-gw',TRUE,TRUE,TRUE,TRUE,TRUE >>> ,TRUE,TRUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('sunflower-op-gw',TRUE,TRUE,TRUE,TRUE,TRUE, >>> TRUE,TRUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: couldn't configure host using 'select >>> configure_host('sunflowerKC',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE >>> ,TRUE,TRUE,FALSE)' () >>> [1110516022] nagios-db: configured 23 hosts >>> [1110516022] nagios-db: couldn't configure hostgroup using 'select >>> new_hostgroup('sunshine-colo','Sunshine Colo')' () >>> >>> Ben wrote: >>> >>>> First (and most important to you) I don't see anything in the code >>>> that make it obvious why you would get the "couldn't clear config >>>> info" message unless the command failed, but then you should have >>>> had some reason, and I don't see that. So that's still a mystery. >>>> Therefore, I'm going to blame the victim and ask what version of >>>> the postgres libs you have installed, and ask that you make sure >>>> you're really linking to them. Second, I recommend you use 2.0b2. >>>> It fixed problems I was having and didn't hurt anything. Given >>>> that you have the same problems on both versions, you might as >>>> well have them on the better one. :) >>>> Third, I just checked in a file that should fix the unhelpful >>>> "nagios-db: couldn't configure host using 'nagios-db: couldn't >>>> configure host using 'nagios-db: couldn't configure host us' ()" >>>> crap. That won't help your big >>>> issue, but it might help others in the future.... >>>> On Thu, 10 Mar 2005, Robert Bilbrey wrote: >>>> >>>>> I had nagios 2.0b1 working with nagios-db on RHEL3. I decided to >>>>> upgrade to 2.0b2 and pulled the latest nagios-db code from cvs. >>>>> Everything compiled fine, dropped the db and recreated the db with >>>>> the new schema, but nagios would not start with the neb module. >>>>> So then I pulled the 0.91 archive, same problem. After deciding >>>>> to roll back to 2.0b1 and the nagios-db cvs snapshot that I had >>>>> working previously, I am still throwing the same errors. If I >>>>> run the "select empty_config()" from a psql session I am returned >>>>> an empty recordset, which is what I would expect. The following >>>>> is from the nagios log. Does anyone have any thoughts, I really >>>>> need to get this back online. >>>>> Thanks, Bob >>>>> >>>>> [1110500709] Nagios 2.0b1 starting... (PID=5391) >>>>> [1110500709] LOG VERSION: 2.0 >>>>> [1110500709] initializing nagios-db postgres inserter... >>>>> [1110500709] nagios-db: inserter locked into db >>>>> [1110500709] Event broker module >>>>> '/usr/local/nagios/bin/inserter.o' initialized successfully. >>>>> [1110500709] Warning: Host 'kcwebwt1' has no services associated >>>>> with it! >>>>> [1110500709] Warning: Contact 'brian' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'cheikh' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'dwain' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'eric' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'john' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'karen' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'liz' is not a member of any contact >>>>> groups! >>>>> [1110500709] Warning: Contact 'robert' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'russ' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'scott' is not a member of any >>>>> contact groups! >>>>> [1110500709] Warning: Contact 'van' is not a member of any contact >>>>> groups! >>>>> [1110500709] Warning: Contact group 'nagios-setup' is not used in >>>>> any hostgroup/service definitions or host/hostgroup/service escala >>>>> tions! >>>>> [1110500709] Finished daemonizing... (New PID=5393) >>>>> [1110500709] nagios-db: couldn't clear config info () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure ho' ( >>>>> ) >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> ' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host' >>>>> () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> ' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> usi' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> usi' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> u' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> u' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> us' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> usi' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> using 'nag' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> using 'nag' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> using 'na' () >>>>> [1110500709] nagios-db: couldn't configure host using 'nagios-db: >>>>> couldn't configure host using 'nagios-db: couldn't configure host >>>>> using' () >>>>> [1110500709] nagios-db: configured 23 hosts >>>>> [1110500709] nagios-db: couldn't configure hostgroup using >>>>> 'nagios-db: couldn't configure hostgroup using 'nagios' () >>>>> [1110500709] Caught SIGSEGV, shutting down... >>>>> >>>>> >>>>> ------------------------------------------------------- >>>>> SF email is sponsored by - The IT Product Guide >>>>> Read honest & candid reviews on hundreds of IT Products from real >>>>> users. >>>>> Discover which products truly live up to the hype. Start reading >>>>> now. >>>>> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >>>>> _______________________________________________ >>>>> Nagios-db-devel mailing list >>>>> Nag...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/nagios-db-devel >>>>> >>>> ------------------------------------------------------- >>>> SF email is sponsored by - The IT Product Guide >>>> Read honest & candid reviews on hundreds of IT Products from real >>>> users. >>>> Discover which products truly live up to the hype. Start reading >>>> now. >>>> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >>>> _______________________________________________ >>>> Nagios-db-devel mailing list >>>> Nag...@li... >>>> https://lists.sourceforge.net/lists/listinfo/nagios-db-devel > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Nagios-db-devel mailing list > Nag...@li... > https://lists.sourceforge.net/lists/listinfo/nagios-db-devel |