access object data inside of nebmodule_init()

Don Byington Donald.Byington at synopsys.com
Sat Jan 12 00:07:09 CET 2008


I'm working on a NEB module and would like to access host and service
objects during the module init. This is an attempt to build a list of
all hosts and associated services from the start, rather than waiting
for the EB to send object information as things happen.

To start with I'm using the filesystem status interface example in David
Josephsen's book. I want to create all of the host directories and
service files first, then update them with status when it becomes
available.

I've tried to use;

extern host *host_list;
extern service *service_list;
extern char *config_file;
read_all_object_data(config_file);

Which will allow me to use;
for (temp_host=host_list ; temp_host!=NULL ; temp_host=temp_host->next)
{
<read in host code>
for (temp_service=service_list ; temp_service!=NULL ;
temp_service=temp_service->next) {
<read in services for host code>
}
}

However once I do this it apparently messes up the data already read in
by Nagios on start up so I get errors like;

[1199996860] Done.
[1199996860] Event broker module '/opt/nagios/bin/statechange_neb.o'
initialized successfully.
[1199996860] Error: Timeperiod '24x7' has already been defined
[1199996860] Error: Could not register timeperiod (config file
'/opt/nagios/etc/timeperiods.cfg'
, starting on line 7)
[1199996860] Bailing out due to one or more errors encountered in the
configuration files. Run
Nagios from the command line with the -v option to verify your config
before restarting. (PID=32
539)
[1199996860] Unloading STATECHANGE Module...
[1199996860] Event broker module '/opt/nagios/bin/statechange_neb.o'
deinitialized successfully.

How can I get to the host_list and service_list structs without messing
with the variables?

Thanks,
Don

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace




More information about the Developers mailing list