Event broker module - querying host/service/hostgroup...SIGSEVs (disregard)
Macha, Frank
frank.macha at atosorigin.com
Fri Jan 13 17:46:06 CET 2006
Guys,
My problem was with the free statements (argh)... nevermind.
Can someone point me to other event broker module work being done out
there for 2.x? I found a couple here and there, but no list per se...
TIA,
Frank
_____________________________________________
From: Macha, Frank
Sent: Thursday, January 12, 2006 9:42 PM
To: 'nagios-devel at lists.sourceforge.net'
Subject: Event broker module - querying host/service/hostgroup...SIGSEVs
Guys,
I've been playing with the helloworld module and the inserter modules
from the nagios-db code to try to get something functional. I've put
together a function registered via:
neb_register_callback(NEBCALLBACK_TIMED_EVENT_DATA,nagiosdb_module_handl
e,0,loadConfig);
The function starts off with the following initialization...
static int loadConfig(int cmd, void *data){
host *hl;
service *sl;
hostgroup *hg;
hostgroupmember *hgm;
int groupcount;
char temp_buffer[1024];
char q[1024];
.
.
.
I have for-loops which query the host_list, service_list and
hostgroup_list lists. My problem is that I am getting SIGSEVs when the
following code inside this function runs:
/* Get current hostgroup_list from configuration */
for(groupcount=0, hg = hostgroup_list; hg; hg = hg->next)
{
/* update this service */
char *groupName, *groupAlias, *hostName;
groupName=hg->group_name;
groupAlias=hg->alias;
/* insert this hostgroup */
snprintf(temp_buffer,sizeof(temp_buffer)-1,"nagiosdb-efm: found
group %s with alias %s",groupName,groupAlias);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE);
if(groupAlias) free(groupAlias);
for(hgm = hg->members; hgm; hgm = hgm->next)
{
/* add this host to the hostgroup */
hostName = hgm->host_name;
snprintf(temp_buffer,sizeof(temp_buffer)-1,"nagiosdb-efm
: found host %s belongs to group %s, with groupid
%d",hostName,groupName,groupco
unt);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE);
if(hostName) free(hostName);
}
if(groupName) free(groupName);
if(hgm) free(hgm);
groupcount++;
}
snprintf(temp_buffer,sizeof(temp_buffer)-1,"nagiosdb-efm:
configured %d
groups", groupcount);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE);
If I comment the above out, and run the other queries to the lists, no
SIGSEVs:
for(groupcount=0, hl = host_list; hl; hl = hl->next)
{
/* update this host */
snprintf(q,sizeof(q)-1,"nagiosdb-efm: Host %s found, has
followi
ng characteristics\n"
"checks_enabled %d, "
"accept_passive_host_checks %d, "
"event_handler_enabled %d, "
"flap_detection_enabled %d, "
"notifications_enabled %d, "
"failure_prediction_enabled %d, "
"process_performance_data %d, "
"obsess_over_host %d, "
"should_be_scheduled %d.",
hl->name,hl->checks_enabled,
hl->accept_passive_host_checks,
hl->event_handler_enabled,
hl->flap_detection_enabled,
hl->notifications_enabled,
hl->failure_prediction_enabled,
hl->process_performance_data,
hl->obsess_over_host,
hl->should_be_scheduled);
q[sizeof(q)-1]='\x0';
write_to_all_logs(q,NSLOG_INFO_MESSAGE);
groupcount++;
}
snprintf(temp_buffer,sizeof(temp_buffer)-1,"nagiosdb-efm:
configured %d
hosts", groupcount);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE);
What am I doing wrong with the hostgroup, hostgroupmember which causes
the SIGSEV?
My eventual goal is to dump this to a database, but right now I'm
dumping to the nagios.log file to make sure the data makes sense. The
destination database is an ODBC connected DB (MSSQL to be exact).
Anyhow, appreciate any leads which can help me...
Here's the log file:
[1136982099] Nagios 2.0rc2 starting... (PID=5542)
[1136982099] LOG VERSION: 2.0
[1136982099] nagios-EFM: Copyright (c) 2006 Frank Macha
[1136982099] nagios-EFM: Startup
[1136982099] nagiosdb-efm: Startup Complete
[1136982099] Event broker module
'/root/src/nagios-2.0rc2/module/frank5.o' initialized successfully.
[1136982099] Warning: Host 'localhost2' has no services associated with
it!
[1136982099] Finished daemonizing... (New PID=5543)
[1136982099] nagiosdb-efm: Host localhost1 found, has following
characteristics
checks_enabled 1, accept_passive_host_checks 1, event_handler_enabled 1,
flap_de
tection_enabled 1, notifications_enabled 1, failure_prediction_enabled
1, proces
s_performance_data 1, obsess_over_host 1, should_be_scheduled 0.
[1136982099] nagiosdb-efm: Host localhost2 found, has following
characteristics
checks_enabled 1, accept_passive_host_checks 1, event_handler_enabled 1,
flap_de
tection_enabled 1, notifications_enabled 1, failure_prediction_enabled
1, proces
s_performance_data 1, obsess_over_host 1, should_be_scheduled 0.
[1136982099] nagiosdb-efm: Host redhat1 found, has following
characteristics
checks_enabled 1, accept_passive_host_checks 1, event_handler_enabled 1,
flap_de
tection_enabled 1, notifications_enabled 1, failure_prediction_enabled
1, proces
s_performance_data 1, obsess_over_host 1, should_be_scheduled 0.
[1136982099] nagiosdb-efm: Host redhat2 found, has following
characteristics
checks_enabled 1, accept_passive_host_checks 1, event_handler_enabled 1,
flap_de
tection_enabled 1, notifications_enabled 1, failure_prediction_enabled
1, proces
s_performance_data 1, obsess_over_host 1, should_be_scheduled 0.
[1136982099] nagiosdb-efm: configured 4 hosts
[1136982099] nagiosdb-efm: found group test1 with alias Test Servers1
[1136982099] nagiosdb-efm: found host localhost1 belongs to group test1,
with groupid 0
[1136982099] nagiosdb-efm: found host redhat1 belongs to group test1,
with groupid 0
[1136982099] nagiosdb-efm: found group test2 with alias Test Servers2
[1136982099] nagiosdb-efm: found host localhost2 belongs to group test2,
with groupid 1
[1136982099] nagiosdb-efm: found host redhat2 belongs to group test2,
with groupid 1
[1136982099] nagiosdb-efm: configured 2 groups
[1136982099] nagiosdb-efm: Service Current Load found, has following
characteristics:
hostname localhost1, checks_enabled 1, accept_passive_service_checks 1,
event_ha
ndler_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_pred
iction_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Current Users found, has following
characteri
stics:
hostname localhost1, checks_enabled 1, accept_passive_service_checks 1,
event_ha
ndler_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_pred
iction_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service PING found, has following
characteristics:
hostname localhost1, checks_enabled 1, accept_passive_service_checks 1,
event_ha
ndler_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_pred
iction_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Root Partition found, has following
character
istics:
hostname localhost1, checks_enabled 1, accept_passive_service_checks 1,
event_ha
ndler_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_pred
iction_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Total Processes found, has following
characte
ristics:
hostname localhost1, checks_enabled 1, accept_passive_service_checks 1,
event_ha
ndler_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_pred
iction_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service PING found, has following
characteristics:
hostname redhat1, checks_enabled 1, accept_passive_service_checks 1,
event_handl
er_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_predict
ion_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Root Partition found, has following
character
istics:
hostname redhat1, checks_enabled 1, accept_passive_service_checks 1,
event_handl
er_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_predict
ion_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Current Load found, has following
characteris
tics:
hostname redhat2, checks_enabled 1, accept_passive_service_checks 1,
event_handl
er_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_predict
ion_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Current Users found, has following
characteri
stics:
hostname redhat2, checks_enabled 1, accept_passive_service_checks 1,
event_handl
er_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_predict
ion_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: Service Total Processes found, has following
characte
ristics:
hostname redhat2, checks_enabled 1, accept_passive_service_checks 1,
event_handl
er_enabled 1, flap_detection_enabled 1, notifications_enabled 1,
failure_predict
ion_enabled 1, process_performance_data 1, obsess_over_service 1.
[1136982099] nagiosdb-efm: configured 10 services
[1136982099] nagiosdb-efm: General config_params
accept_passive_host_checks 1,execute_host_checks
1,accept_passive_service_checks
1,execute_service_checks 1,enable_flap_detection 0,enable_notifications
1,enabl
e_event_handlers 1,
[1136982099] nagiosdb-efm: leaving loadConfig
[1136982099] nagiosdb-efm: entering generic_handle_function
[1136982099] nagiosdb-efm: event_type no 25.
[1136982099] nagiosdb-efm: entering generic_handle_function
[1136982099] nagiosdb-efm: event_type no 25.
[1136982109] Caught SIGSEGV, shutting down...
[1136982114] nagiosdb-efm: entering generic_handle_function
[1136982114] nagiosdb-efm: event_type no 25.
[1136982114] nagiosdb-efm: entering generic_handle_function
[1136982114] nagiosdb-efm: event_type no 25.
Thanks,
Eloy F. 'Frank' Macha
ERP Technology Services
AtosOrigin, Inc
Office: +1 817 264 8465
Cell: +1 972 814 4979
Fax: +1 817 264 8209
email: frank.macha at atosorigin.com
www.atosorigin.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
More information about the Developers
mailing list