== Environment == The first task to be done is to install the nagios. Follow this [documentation | http://nagios.sourceforge.net/docs/3_0/quickstart.html] (Installation in CentOS is identical to that of Fedora). Once installed, to start / stop nagios use: /etc/init.d/nagios [start | stop | restart ] == Development == The plugin was made with two languages: C and Python. To compile the Python, you must install Python 2.6 ([http://www.python.org/download/]). You must also install the library of IPC for Python, found in [http://pypi.python.org/pypi/sysv_ipc/0.4.1]. To download the project from the SVN repository. == About nagios Event Broker == Communicating with nagios is made by the Nagios Event Broker (NEB). There is an example within the directory "module" of the source code that nagios is the best way to understand the NEB. The only documentation that explains the NEB is this [pdf | http://nagios.sourceforge.net/download/contrib/documentation/misc/NEB%202x%20Module%20API.pdf] that brings the main types of events available . There is also this article available in the Usenix [google cache | http://74.125.95.132/search?q=cache:HaK4XghsTzcJ:sagecertification.org/publications/login/2008-10/pdfs/josephsen.pdf+nagios+event+broker+event+type&cd=5&hl=pt-BR&ct=clnk&gl=br&client=firefox-a]. A NEB module should have three functions: one to initialize (init), another to be called when the event happens (handle) and one for finish execution (deinit). == How does the plugin works ? == === Subscriber - NEB module in C === The function "init" register the callbacks for the types of events to be processed by the function handle and creates a message queue in the operating system to communicate with the daemon in Python. The function "handle" identifies the type of event (NEBCALLBACK_SERVICE_CHECK or NEBCALLBACK_HOST_CHECK) and writes a struct containing the type of event (int) and a message (char *) in a simple format (some information separated by "^" to facilitate the parsing Python) in the message queue. === Publisher - daemon in Python === A daemon in Python has one thread that is reading the message queue, sending to the parser class that performs the conversion to the format expected by bus (ActiveMQ), and going to the main thread that maintains a Stomp connection with the bus along the transmission of messages. To support a new type of message, configure the file "topics.py". There are two topics archives, one in the "dev" folder the other in the "qa" folder. To configure a new service check, the service command name (available via C struct) must be the key to the dictionary and the properties must be configured with the regexps. In the case of host checks there are no command name and the configuration is fixed using "host" as a key and one regexp. === Testing === First make sure you have installed and started ActiveMQ. Compile the project to generate the neb2ipc "neb2ipc.o. Run "make" inside the directory "neb2ipc" To Nagios load the module you must add this line to the configuration line 246 of "/usr/local/nagios/etc/nagios.cfg: {{{ broker_module = /usr/local/nagios/bin/neb2ipc.o }}} The script "test.sh" copies "neb2ipc.o" generated for the bin directory of nagios, nagios restart the service and gives a tail in the nagios log to debug. To check whether the message queue was created there was a similar message appears in the log: {{{ [1242824262] neb2ipc: Created message queue 32768. }}} Another way is to run the command that lists the messages in queues operating system. This can be helpful to debug: {{{ sudo-u nagios ipcs -q }}} To start and stop the daemon in python use within "ipc2activemq/src" the script. neb2mq.sh start | stop The log of the daemon is being created in "/ usr / local / nagios / var / nebpublisher.log. You can view it with the command: {{{ tail-200f / usr / local / nagios / var / nebpublisher.log }}} To view the messages in activemq, visit [url this | http://localhost:8161/admin/browse.jsp?JMSDestination=events]