Dont work notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Dont work notifications

Post by Ravil »

Hi! I use nagios 4.0.2, ndoutil 2.0 and snmptt 1.4 on CentOS 6.5 and I have a problem. Dont work notifications on a critical events.
This is /var/log/messages

Code: Select all

Dec 16 16:38:29 mon-27 nagios: SERVICE ALERT: cluster260node1;TRAP;CRITICAL;HARD;1;This is test message
Dec 16 16:39:13 mon-27 nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;cluster260node1;TRAP;0;OK|
Dec 16 16:39:13 mon-27 nagios: PASSIVE SERVICE CHECK: cluster260node1;TRAP;0;OK
Dec 16 16:39:13 mon-27 nagios: SERVICE ALERT: cluster260node1;TRAP;OK;HARD;1;OK
Dec 16 16:48:05 mon-27 nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;192.168.30.145;TRAP;2;This is test message
Dec 16 16:48:05 mon-27 nagios: PASSIVE SERVICE CHECK: cluster260node2;TRAP;2;This is test message
Dec 16 16:48:05 mon-27 nagios: SERVICE ALERT: cluster260node2;TRAP;CRITICAL;HARD;1;This is test message
Dec 16 16:48:41 mon-27 nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;cluster260node2;TRAP;0;Pending|
Dec 16 16:48:41 mon-27 nagios: PASSIVE SERVICE CHECK: cluster260node2;TRAP;0;Pending
Dec 16 16:48:41 mon-27 nagios: SERVICE ALERT: cluster260node2;TRAP;OK;HARD;1;Pending
You can see that nagios does not even try to call notification.

Code: Select all

[root@mon-27 snmp]# ls -la /usr/local/nagios/sbin/
итого 4976
drwxrwxr-x. 2 nagios nagios   4096 Дек  9 11:58 .
drwxr-xr-x. 9 root   root     4096 Дек  9 17:13 ..
-rwxrwxr-x. 1 nagios nagios 307936 Дек  9 11:58 archivejson.cgi
-rwxrwxr-x. 1 nagios nagios 292040 Дек  9 11:58 avail.cgi
-rwxrwxr-x. 1 nagios nagios 288424 Дек  9 11:58 cmd.cgi
-rwxrwxr-x. 1 nagios nagios 259240 Дек  9 11:58 config.cgi
-rwxrwxr-x. 1 nagios nagios 300424 Дек  9 11:58 extinfo.cgi
-rwxrwxr-x. 1 nagios nagios 255368 Дек  9 11:58 histogram.cgi
-rwxrwxr-x. 1 nagios nagios 234664 Дек  9 11:58 history.cgi
-rwxrwxr-x. 1 nagios nagios 234664 Дек  9 11:58 notifications.cgi
-rwxrwxr-x. 1 nagios nagios 308704 Дек  9 11:58 objectjson.cgi
-rwxrwxr-x. 1 nagios nagios 226440 Дек  9 11:58 outages.cgi
-rwxrwxr-x. 1 nagios nagios 230824 Дек  9 11:58 showlog.cgi
-rwxrwxr-x. 1 nagios nagios 300232 Дек  9 11:58 status.cgi
-rwxrwxr-x. 1 nagios nagios 306560 Дек  9 11:58 statusjson.cgi
-rwxrwxr-x. 1 nagios nagios 251368 Дек  9 11:58 statusmap.cgi
-rwxrwxr-x. 1 nagios nagios 246984 Дек  9 11:58 statuswml.cgi
-rwxrwxr-x. 1 nagios nagios 230728 Дек  9 11:58 statuswrl.cgi
-rwxrwxr-x. 1 nagios nagios 255208 Дек  9 11:58 summary.cgi
-rwxrwxr-x. 1 nagios nagios 242920 Дек  9 11:58 tac.cgi
-rwxrwxr-x. 1 nagios nagios 263592 Дек  9 11:58 trends.cgi

Code: Select all

[root@mon-27 snmp]# grep nag /etc/group
nagios:x:500:snmptt,nagios,apache
nagcmd:x:501:nagios,apache,snmptt
On another OS I have nagios 3.5.1 and this nagios dont have such problem. What could be the reason? Why nagios 4 dont sent notification?

P.S. Sorry for dirty english
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Dont work notifications

Post by tmcdonald »

Do you have the "c" option for notification_options on that service? What about service_notification_options for the contact associated with that service? Without these two configured you would not receive critical alerts.
Former Nagios employee
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Dont work notifications

Post by Ravil »

I solved this problem. I delete group admins from templates and it begun work. But now I have another problev. Notifications works for email and perl sendxmpp scripts but doens't work for script xsend.py (script on python). If I run this script from terminal, it works, I see message. But if I run it from nagios I see exception in /var/log/messages:

Code: Select all

Dec 17 11:38:38 mon-27 nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;192.168.50.16;TRAP;2;Test message
Dec 17 11:38:38 mon-27 nagios: PASSIVE SERVICE CHECK: test-Misha;TRAP;2;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE ALERT: test-Misha;TRAP;CRITICAL;HARD;1;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: Bayburin Ravil;test-Misha;TRAP;CRITICAL;mc-ravil-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: Bayburin Ravil;test-Misha;TRAP;CRITICAL;Bayburin-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: Bayburin Ravil;test-Misha;TRAP;CRITICAL;notify-service-by-email;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;mc-misha-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;operator4-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;operator3-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;operator2-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;operator1-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;plazma2-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;plazma1-service;Test message
Dec 17 11:38:38 mon-27 nagios: SERVICE NOTIFICATION: main-contact;test-Misha;TRAP;CRITICAL;main-plazma-service;Test message
Dec 17 11:38:44 mon-27 abrt: detected unhandled Python exception in '/usr/local/nagios/libexec/xsend.py'
Dec 17 11:38:44 mon-27 abrtd: New client connected
Dec 17 11:38:44 mon-27 abrt-server[22556]: Saved Python crash dump of pid 22524 to /var/spool/abrt/pyhook-2014-12-17-11:38:44-22524
Dec 17 11:38:44 mon-27 abrtd: Directory 'pyhook-2014-12-17-11:38:44-22524' creation detected
Dec 17 11:38:44 mon-27 nagios: wproc: NOTIFY job 14 from worker Core Worker 22415 is a non-check helper but exited with return code 1
Dec 17 11:38:44 mon-27 nagios: wproc:   host=test-Misha; service=TRAP; contact=main-contact
Dec 17 11:38:44 mon-27 nagios: wproc:   early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 01: /usr/lib/python2.6/site-packages/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 02:   import sha,base64,random,dispatcher,re
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 03: /usr/lib/python2.6/site-packages/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 04:   import md5
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 05: /usr/lib/python2.6/site-packages/xmpp/transports.py:315: DeprecationWarning: socket.ssl() is deprecated.  Use ssl.wrap_socket() instead.
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 06:   tcpsock._sslObj    = socket.ssl(tcpsock._sock, None, None)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 07: Traceback (most recent call last):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 08:   File "/usr/local/nagios/libexec/xsend.py", line 32, in <module>
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 09:     auth=cl.auth(jid.getNode(),'password',resource=jid.getResource())
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 10:   File "/usr/lib/python2.6/site-packages/xmpp/client.py", line 229, in auth
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 11:     if self.Bind.Bind(resource):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 12:   File "/usr/lib/python2.6/site-packages/xmpp/auth.py", line 252, in Bind
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 13:     resp=self._owner.SendAndWaitForResponse(Protocol('iq',typ='set',payload=[Node('session',attrs={'xmlns':NS_SESSION})]))
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 14:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 337, in SendAndWaitForResponse
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 15:     return self.WaitForResponse(self.send(stanza),timeout)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 16:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 321, in WaitForResponse
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 17:     if not self.Process(0.04):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 18:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 303, in dispatch
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 19:     handler['func'](session,stanza)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 20:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 215, in streamErrorHandler
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 21:     raise exc((name,text))
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 22: xmpp.protocol.Conflict: (u'conflict', '')
Dec 17 11:38:44 mon-27 abrtd: Executable '/usr/local/nagios/libexec/xsend.py' doesn't belong to any package and ProcessUnpackaged is set to 'no'
Dec 17 11:38:44 mon-27 abrtd: 'post-create' on '/var/spool/abrt/pyhook-2014-12-17-11:38:44-22524' exited with 1
Dec 17 11:38:44 mon-27 abrtd: Deleting problem directory '/var/spool/abrt/pyhook-2014-12-17-11:38:44-22524'
Dec 17 11:38:44 mon-27 abrt: detected unhandled Python exception in '/usr/local/nagios/libexec/xsend.py'
Dec 17 11:38:44 mon-27 abrtd: New client connected
Dec 17 11:38:44 mon-27 abrt-server[22559]: Not saving repeating crash in '/usr/local/nagios/libexec/xsend.py'
Dec 17 11:38:44 mon-27 nagios: wproc: NOTIFY job 15 from worker Core Worker 22415 is a non-check helper but exited with return code 1
Dec 17 11:38:44 mon-27 nagios: wproc:   host=test-Misha; service=TRAP; contact=main-contact
Dec 17 11:38:44 mon-27 nagios: wproc:   early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 01: /usr/lib/python2.6/site-packages/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 02:   import sha,base64,random,dispatcher,re
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 03: /usr/lib/python2.6/site-packages/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 04:   import md5
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 05: /usr/lib/python2.6/site-packages/xmpp/transports.py:315: DeprecationWarning: socket.ssl() is deprecated.  Use ssl.wrap_socket() instead.
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 06:   tcpsock._sslObj    = socket.ssl(tcpsock._sock, None, None)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 07: Traceback (most recent call last):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 08:   File "/usr/local/nagios/libexec/xsend.py", line 32, in <module>
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 09:     auth=cl.auth(jid.getNode(),'password',resource=jid.getResource())
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 10:   File "/usr/lib/python2.6/site-packages/xmpp/client.py", line 229, in auth
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 11:     if self.Bind.Bind(resource):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 12:   File "/usr/lib/python2.6/site-packages/xmpp/auth.py", line 252, in Bind
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 13:     resp=self._owner.SendAndWaitForResponse(Protocol('iq',typ='set',payload=[Node('session',attrs={'xmlns':NS_SESSION})]))
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 14:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 337, in SendAndWaitForResponse
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 15:     return self.WaitForResponse(self.send(stanza),timeout)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 16:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 321, in WaitForResponse
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 17:     if not self.Process(0.04):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 18:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 303, in dispatch
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 19:     handler['func'](session,stanza)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 20:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 215, in streamErrorHandler
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 21:     raise exc((name,text))
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 22: xmpp.protocol.Conflict: (u'conflict', '')
Dec 17 11:38:44 mon-27 abrt: detected unhandled Python exception in '/usr/local/nagios/libexec/xsend.py'
Dec 17 11:38:44 mon-27 abrtd: New client connected
Dec 17 11:38:44 mon-27 abrt-server[22560]: Not saving repeating crash in '/usr/local/nagios/libexec/xsend.py'
Dec 17 11:38:44 mon-27 nagios: wproc: NOTIFY job 14 from worker Core Worker 22413 is a non-check helper but exited with return code 1
Dec 17 11:38:44 mon-27 nagios: wproc:   host=test-Misha; service=TRAP; contact=main-contact
Dec 17 11:38:44 mon-27 nagios: wproc:   early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 01: /usr/lib/python2.6/site-packages/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 02:   import sha,base64,random,dispatcher,re
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 03: /usr/lib/python2.6/site-packages/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 04:   import md5
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 05: /usr/lib/python2.6/site-packages/xmpp/transports.py:315: DeprecationWarning: socket.ssl() is deprecated.  Use ssl.wrap_socket() instead.
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 06:   tcpsock._sslObj    = socket.ssl(tcpsock._sock, None, None)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 07: Traceback (most recent call last):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 08:   File "/usr/local/nagios/libexec/xsend.py", line 32, in <module>
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 09:     auth=cl.auth(jid.getNode(),'password',resource=jid.getResource())
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 10:   File "/usr/lib/python2.6/site-packages/xmpp/client.py", line 229, in auth
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 11:     if self.Bind.Bind(resource):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 12:   File "/usr/lib/python2.6/site-packages/xmpp/auth.py", line 252, in Bind
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 13:     resp=self._owner.SendAndWaitForResponse(Protocol('iq',typ='set',payload=[Node('session',attrs={'xmlns':NS_SESSION})]))
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 14:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 337, in SendAndWaitForResponse
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 15:     return self.WaitForResponse(self.send(stanza),timeout)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 16:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 321, in WaitForResponse
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 17:     if not self.Process(0.04):
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 18:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 303, in dispatch
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 19:     handler['func'](session,stanza)
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 20:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 215, in streamErrorHandler
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 21:     raise exc((name,text))
Dec 17 11:38:44 mon-27 nagios: wproc:   stderr line 22: xmpp.protocol.Conflict: (u'conflict', '')
And every time it work for different notification receiver. For example, in first time it work for main-plazma-service, operator3-service and mc-ravil-service. Second time it work for only Bayburin-service and mc-misha-service.
In nagios 3.5 I dont see this exception and everythink work fine.
Also I see this message:

Code: Select all

Dec 17 15:18:55 mon-27 nagios: Warning: Notifying contact 'main-plazma' of service 'TRAP' on host 'test-Misha' by command '/usr/local/nagios/libexec/xsend.py test@xmpp "PROBLEM ,^! test-Misha ,^! 1-1 ,^! TRAP ,^! CRITICAL ,^! Test message "' timed out after 0.00 seconds
What is timed out after 0.00 seconds? Why time out?

Code: Select all

[root@mon-27 snmp]# ls -l /usr/local/nagios/libexec/xsend.py 
-rwxr-xr-x. 1 nagios nagios 1377 Дек 17 11:27 /usr/local/nagios/libexec/xsend.py
Once again, that the script works from the terminal.

Code: Select all

[nagios@mon-27 libexec]$./xsend.py user1@xmpp "Test message"
/usr/lib/python2.6/site-packages/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha,base64,random,dispatcher,re
/usr/lib/python2.6/site-packages/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
/usr/lib/python2.6/site-packages/xmpp/transports.py:315: DeprecationWarning: socket.ssl() is deprecated.  Use ssl.wrap_socket() instead.
  tcpsock._sslObj    = socket.ssl(tcpsock._sock, None, None)
This is only warning and it is normal state. After ./xsend.py user1@xmpp "Test message" command I see "Test message" in xmpp-server. And I cant undesrand, why it doesnt work on nagios 4.0.2. On nagios 3.5.1 it work fine and notifications is work and there aren't these exception.

Help, please. Why notifications doesn't work?
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Dont work notifications

Post by Ravil »

I noticed the following. In Nagios 3 interval between sending notification previous and next recipient about 3 seconds. In all 4 Nagios alerts appear immediately, at one point, and after the fire exception. May be a problem with that?
emislivec
Posts: 52
Joined: Tue Feb 25, 2014 10:06 am

Re: Dont work notifications

Post by emislivec »

This is a common problem with xmpppy since Python 2.6 was released.

Are you using this xsend.py: http://xmpppy.sourceforge.net/examples/xsend.py or a script like it?

You can try this workaround until a fixed version of xmpp is available. In xsend.py add this before the "import sys,os,xmpp,time" statements:

Code: Select all

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import sys,os,xmpp,time
If that doesn't work, try importing the md5 and sha modules earlier:

Code: Select all

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import md5, sha
import sys,os,xmpp,time
I've also seen this suggested:

Code: Select all

import warnings
with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=DeprecationWarning)
    import md5, sha
import sys,os,xmpp,time
Nagios 4 runs commands differently than Nagios 3. This may be why the script fails in Nagios 4.
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Dont work notifications

Post by Ravil »

This is doesnt resolve problem.
I added this string into xsend.py.

Code: Select all

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import sys,os,xmpp,time
This disabled warnings.

Code: Select all

[nagios@host libexec]#./xsend.py user1@xmpp "Test message"
[nagios@host libexec]#
But when nagios run notification you can see this:

Code: Select all

Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Bayburin Ravil;test-Misha;TRAP;CRITICAL;mc-ravil-service;Test message
Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Bayburin Ravil;test-Misha;TRAP;CRITICAL;Bayburin-service;Test message
Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Bayburin Ravil;test-Misha;TRAP;CRITICAL;notify-service-by-email;Test message
Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Karpilenko Mihail;test-Misha;TRAP;CRITICAL;mc-misha-service;Test message
Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Averyanov Denis;test-Misha;TRAP;CRITICAL;mc-denis-service;Test message
Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Averyanov Denis;test-Misha;TRAP;CRITICAL;Averyanov-service;Test message
Dec 18 08:25:09 mon-27 nagios: SERVICE NOTIFICATION: Averyanov Denis;test-Misha;TRAP;CRITICAL;notify-service-by-email;Test message
Dec 18 08:25:12 mon-27 abrt: detected unhandled Python exception in '/usr/local/nagios/libexec/xsend.py'
Dec 18 08:25:12 mon-27 abrtd: New client connected
Dec 18 08:25:12 mon-27 abrtd: Directory 'pyhook-2014-12-18-08:25:12-23563' creation detected
Dec 18 08:25:12 mon-27 abrt-server[23579]: Saved Python crash dump of pid 23563 to /var/spool/abrt/pyhook-2014-12-18-08:25:12-23563
Dec 18 08:25:12 mon-27 nagios: wproc: NOTIFY job 10138 from worker Core Worker 12173 is a non-check helper but exited with return code 1
Dec 18 08:25:12 mon-27 nagios: wproc:   host=test-Misha; service=TRAP; contact=Averyanov Denis
Dec 18 08:25:12 mon-27 nagios: wproc:   early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 01: Traceback (most recent call last):
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 02:   File "/usr/local/nagios/libexec/xsend.py", line 35, in <module>
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 03:     auth=cl.auth(jid.getNode(),'$n@giosXmPppswd',resource=jid.getResource())
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 04:   File "/usr/lib/python2.6/site-packages/xmpp/client.py", line 229, in auth
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 05:     if self.Bind.Bind(resource):
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 06:   File "/usr/lib/python2.6/site-packages/xmpp/auth.py", line 245, in Bind
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 07:     resp=self._owner.SendAndWaitForResponse(Protocol('iq',typ='set',payload=[Node('bind',attrs={'xmlns':NS_BIND},payload=resource)]))
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 08:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 337, in SendAndWaitForResponse
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 09:     return self.WaitForResponse(self.send(stanza),timeout)
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 10:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 321, in WaitForResponse
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 11:     if not self.Process(0.04):
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 12:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 303, in dispatch
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 13:     handler['func'](session,stanza)
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 14:   File "/usr/lib/python2.6/site-packages/xmpp/dispatcher.py", line 215, in streamErrorHandler
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 15:     raise exc((name,text))
Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 16: xmpp.protocol.Conflict: (u'conflict', '')
Dec 18 08:25:12 mon-27 abrtd: Executable '/usr/local/nagios/libexec/xsend.py' doesn't belong to any package and ProcessUnpackaged is set to 'no'
Dec 18 08:25:12 mon-27 abrtd: 'post-create' on '/var/spool/abrt/pyhook-2014-12-18-08:25:12-23563' exited with 1
Dec 18 08:25:12 mon-27 abrtd: Deleting problem directory '/var/spool/abrt/pyhook-2014-12-18-08:25:12-23563'
Dec 18 08:25:13 mon-27 nagios: wproc: NOTIFY job 10138 from worker Core Worker 12179 is a non-check helper but exited with return code 1
Dec 18 08:25:13 mon-27 nagios: wproc:   host=test-Misha; service=TRAP; contact=Bayburin Ravil
Dec 18 08:25:13 mon-27 nagios: wproc:   early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
Dec 18 08:25:13 mon-27 nagios: wproc:   stderr line 01: Use of uninitialized value $ENV{"HOME"} in concatenation (.) or string at /usr/local/nagios/libexec/sendxmpp line 210.
Dec 18 08:25:13 mon-27 nagios: wproc:   stderr line 02: Use of uninitialized value in string eq at /usr/local/nagios/libexec/sendxmpp line 369.
Dec 18 08:25:13 mon-27 nagios: wproc:   stderr line 03: Error 'AuthSend': [?]
Warnings was disable, but run exception (Traceback (most recent call last)).
Also you can see that the last three lines are sendxmpp. If I run sendxmpp from terminal, I dont have this problem.
!!!Sendxmpp and xsend work if I run it from terminal!!!
So I think this is problem whit nagios. Its run all scripts for all notification in one time and this is generate exception.
emislivec
Posts: 52
Joined: Tue Feb 25, 2014 10:06 am

Re: Dont work notifications

Post by emislivec »

Ravil wrote:!!!Sendxmpp and xsend work if I run it from terminal!!!
Have you tried running them as the nagios user?

Code: Select all

sudo -u nagios /usr/local/nagios/libexec/xsend.py user1@xmpp "Test message"
This is to be sure user account differences don't confuse things.

Can you post the service_notification_command command_line for the contacts? The warning message you posted earlier had a command line for xsend.py

Code: Select all

/usr/local/nagios/libexec/xsend.py test@xmpp "PROBLEM ,^! test-Misha ,^! 1-1 ,^! TRAP ,^! CRITICAL ,^! Test message "
What does your sendxmpp command_line look like?
Ravil wrote:So I think this is problem whit nagios. Its run all scripts for all notification in one time and this is generate exception.
You may be right. The xsend.py errors are a protocol conflict

Code: Select all

Dec 18 08:25:12 mon-27 nagios: wproc:   stderr line 16: xmpp.protocol.Conflict: (u'conflict', '')
The conflict can happen when trying to connect with a handle already in use. Do any of your contacts use the same handle? Core 4 does run notifications in parallel, Core 3 did not (I need to double check this). There needs to be a way to make Nagios not run more than one notification for the same XMPP contact at the same time.
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Dont work notifications

Post by Ravil »

Yes, it works.

Code: Select all

sudo -u nagios /usr/local/nagios/libexec/xsend.py user1@xmpp "Test message"
commands.cfg:

Code: Select all

# 'user1-host' command definition
define command{
        command_name    user1-host
        command_line    $USER1$/xsend.py user1@xmpp "Host '$HOSTNAME$' ,^! $HOSTALIAS$ ,^! is $HOSTSTATE$ ,^! $_HOSTPERSON1$ ,^! $_HOSTPERSON2$"
        }

# 'user1-service' command definition
define command{
        command_name    user1-service
        command_line    $USER1$/xsend.py user1@xmpp "$NOTIFICATIONTYPE$ ,^! $HOSTNAME$ ,^! $HOSTALIAS$ ,^! $SERVICEDESC$ ,^! $SERVICESTATE$ ,^! $SERVICEOUTPUT$ ,^! $_HOSTPERSON1$ ,^! $_HOSTPERSON2$"
        }
contacts.cfg:

Code: Select all

define contact{
        contact_name                    User1
        use                             generic-contact
        alias                           User1
        host_notification_options       d,r
        service_notification_options    c,r
        host_notifications_enabled      1
        service_notifications_enabled   1
        host_notification_commands      user1-host
        service_notification_commands   user1-service
}
There needs to be a way to make Nagios not run more than one notification for the same XMPP contact at the same time.
I was looking for how to do this, but couldn't find. Can you say, how do this?
emislivec
Posts: 52
Joined: Tue Feb 25, 2014 10:06 am

Re: Dont work notifications

Post by emislivec »

There isn't a simple way to force Nagios 4 to only run one notification at a time right now. I think it would be nice if xsend.py and sendxmpp did this since it seems to be an issue with the XMPP protocol.

Could a XMPP bot like this one work: http://nagibot.sourceforge.net/ http://nagibot.sourceforge.net/nagibot.html ? It connects once and stays connected so you shouldn't see the conflict errors. I haven't used it myself, so there may be problems with it.
Locked