Processing all messages with NEB

Andreas Ericsson ae at op5.se
Sun Oct 23 16:25:00 CEST 2005


Mohr James wrote:
> Hi All!
> 
> What I need to do is to catch all service messages/text that are sent
> to Nagios, whether done via an active or passive check (i.e.
> send_nsca). I am using the helloworld.c example  and I have finally
> figured out how to get pull most of the data. I have a fuction like
> this that usually does what I want:
> 
> int helloworld_handle_status(int event_type, void *data){ char
> temp_buffer[1024]; service * tmp_service; 
> nebstruct_service_status_data * service_status_data; if(
> (service_status_data=(nebstruct_service_status_data *)data) ){ 
> tmp_service = (service *) service_status_data->object_ptr; 
> snprintf(temp_buffer,sizeof(temp_buffer)-1,"EVENT: %d MESSAGE:
> %s",event_type,tmp_service->plugin_output); } 
> write_to_all_logs(temp_buffer,NSLOG_INFO_MESSAGE); /*
> write_to_all_logs("inside:
> helloworld_handle_status",NSLOG_INFO_MESSAGE); */ }
> 
> However, when use tmp_service->plugin_output, it says "structure has
> no member named `plugin_output'". Inside of ../include/ojects.h,
> there is the definition of the service_struct, which shows me
> 
> char    *plugin_output;
> 
> However, this is within an the block #ifdef NSCORE.

Which is correct. All NEB-modules must #define NSCORE, since that's 
where they'll be running. #ifndef NSCORE is for the cgi's.

> Moving the line
> outside of the block, it will compile but when I send something to a
> service with send_nsca  the value of plugin_output ends up being
> null. So, I am at a loss how to get the text of the plugin_output.
> 

This is because you're fetching it from 
service_status_data->object_ptr->plugin_output which isn't filled in by 
the time you get the data.

You need to reference service_status_data->output instead.

Please keep in mind that the neb-code is to be considered fairly 
volatile. It's possible (and quite likely) that some of the variables of 
the nebstruct_*_data structs will disappear in the next overhaul.

> I have looked at th code for the mysql inserter module. However, I
> get stuck here as well.One thing that is unclear is whether **all**
> messages get sent through here or just the status changes. I need all
> of the messages and not just the status changes.
> 

All results of all checks are passed through the modules. Once before 
the plugin is executed and once after.

> An additional goal is to be able to process and change the messages
> before being sent to the GUI. For example, the text contains a code
> number which tells the system to change the text to a specific URL so
> all you need to do is click on the message text to  get instructions
> on what to do in a specific case. However, I have not yet figured out
> how to change the message that appears in the GUI.
> 

You can rewrite it with a module. Make sure you take care not to leak 
any memory.

> Any help would be greatly appreaciated.
> 

You're on your own when it comes to writing new code. I'll gladly answer 
neb-module questions though, so it at least gets documented somewhere.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list