Page 1 of 1

[Nagios-devel] Event broker module - querying host/service/hostgroup...SIGSEVs

Posted: Thu Jan 12, 2006 7:42 pm
by Guest
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:

=20
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:
=20
/* Get current hostgroup_list from configuration */
for(groupcount=3D0, hg =3D hostgroup_list; hg; hg =3D hg->next)
{
/* update this service */
char *groupName, *groupAlias, *hostName;
groupName=3Dhg->group_name;
groupAlias=3Dhg->alias;

/* insert this hostgroup */
=20
snprintf(temp_buffer,sizeof(temp_buffer)-1,"nagiosdb-efm: found
group %s with alias %s",groupName,groupAlias);
temp_buffer[sizeof(temp_buffer)-1]=3D'\x0';
write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE);

if(groupAlias) free(groupAlias);

for(hgm =3D hg->members; hgm; hgm =3D hgm->next)
{
/* add this host to the hostgroup */
hostName =3D hgm->host_name;

=20
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]=3D'\x0';
=20
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]=3D'\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=3D0, hl =3D host_list; hl; hl =3D 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]=3D'\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]=3D'\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). =20

Anyhow, appreciate any leads which can help me...


Here's the log file:

[1136982099] Nagios 2.0rc2 starting... (PID=3D5542)
[1136982099] LOG VERSION: 2.0
[1136982099] nagios-EFM: Copyright (c) 2006 Frank Macha=20
[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=3D5543)
[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

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]