Page 2 of 2
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Fri Apr 16, 2021 9:56 am
nmap results
Code: Select all
Starting Nmap 6.47 ( http://nmap.org ) at 2021-04-16 10:55 EDT
Nmap scan report for 70h1x50k6t63.statuspage.io (18.234.32.149)
Host is up (0.025s latency).
rDNS record for 18.234.32.149: ec2-18-234-32-149.compute-1.amazonaws.com
PORT STATE SERVICE
80/tcp open http
443/tcp open https
Will add the timeout and report.
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Fri Apr 16, 2021 10:21 am
No change after adding the timeout.
check_wss.py
check_wss.py
Usage:
Code: Select all
./check_wss.py -H 'https://70h1x50k6t63.statuspage.io/' -e 'unresolved' -c 'critical,major' -p -d
Code: Select all
./check_wss.py -H 'https://70h1x50k6t63.statuspage.io/' -e 'unresolved' -c 'degraded,partial,major' -p -d
-p : will add perfdata to output
-d : will output the debug log to "/usr/local/nagios/var/check_wss.log"
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Fri Apr 16, 2021 10:22 am
by vtrac
Hi,
Great!! .... looks like your XI machine can connect to "70h1x50k6t63.statuspage.io (18.234.32.149)".
Yes, please try adding "timeout" and also the "while" loop.
Regards,
Vinh
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Fri Apr 16, 2021 11:24 am
by vtrac
Hi,
I tested your script and it was successful!!
However, I used python 2.7 on my test VM.
I used pip to install the followings:
Code: Select all
pip install requests
pip install requests['security']
Here's the chech_wss.log:
Code: Select all
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="197"; message="meta-host="https://70h1x50k6t63.statuspage.io" meta-endpoint="unresolved" meta-critical="degraded,partial,major" meta-perfdata="True" meta-debug="True"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="212"; message="uir="<Response [200]>"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="217"; message="uir_json="{u'incidents': [], u'page': {u'url': u'https://wss.status.broadcom.com', u'time_zone': u'Etc/UTC', u'id': u'70h1x50k6t63', u'updated_at': u'2021-04-16T02:24:21.722Z', u'name': u'Symantec Web Security Service'}}"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="223"; message="pageName="Symantec Web Security Service"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="228"; message="pageID="70h1x50k6t63"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="234"; message="incidents="[]"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="248"; message="incCount="0" critCount="0"";
[2021-04-16T11:09:35] pid=17727; level="DEBUG"; name="check_wss"; function="<module>"; line="265"; message="output-msg="OK: There are (0) unresolved degraded,partial,major severity incidents for Symantec Web Security Service| incident_total=0; degraded,partial,major=0;"";
Please see attached pictures:
F1.png
F2.png
F3.png
Regards,
Vinh
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Fri Apr 16, 2021 3:47 pm
by dchurch
What's the output from the following command?
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Mon Apr 19, 2021 8:20 am
Code: Select all
drwxr-xr-x 7 nagios nagios 4096 Apr 19 09:18 .
drwxr-xr-x 9 root root 4096 Aug 20 2020 ..
drwxrwxr-x 2 nagios nagios 16384 Apr 18 23:59 archives
-rw-rw-r-- 1 nagios nagios 1641903 Apr 19 09:15 check_wss.log
-rw-r--r-- 1 nagios nagios 5249 Oct 19 06:26 host-perfdata
-rw-r--r-- 1 nagios nagios 3256233 Apr 19 09:18 nagios.log
-rw------- 1 nagios nagios 8192 Dec 27 23:32 nagios.tmp0AYwRN
-rw------- 1 nagios nagios 40960 Jan 18 23:30 nagios.tmp0sGdgk
-rw------- 1 nagios nagios 57344 Sep 22 2020 nagios.tmp1VO0SG
-rw------- 1 nagios nagios 176128 Feb 1 12:32 nagios.tmp26Ky0s
-rw------- 1 nagios nagios 61440 Oct 6 2020 nagios.tmp26PPRT
-rw------- 1 nagios nagios 12288 Oct 6 2020 nagios.tmp2ah0dw
-rw------- 1 nagios nagios 28672 Oct 5 2020 nagios.tmp2qiEyA
-rw------- 1 nagios nagios 0 Sep 30 2020 nagios.tmp3wbIKI
-rw------- 1 nagios nagios 20480 Jan 27 12:50 nagios.tmp49VLcV
-rw------- 1 nagios nagios 86016 Feb 6 01:00 nagios.tmp4Ef9a1
-rw------- 1 nagios nagios 0 Dec 21 23:32 nagios.tmp4xHLm3
-rw------- 1 nagios nagios 0 Dec 30 23:32 nagios.tmp5FxfBr
-rw------- 1 nagios nagios 12288 Sep 22 2020 nagios.tmp7JMYJi
-rw------- 1 nagios nagios 24576 Oct 19 20:42 nagios.tmp7MPnaP
-rw------- 1 nagios nagios 16384 Dec 24 23:31 nagios.tmp7nOMy7
-rw------- 1 nagios nagios 28672 Jan 15 23:30 nagios.tmp7TO7vk
-rw------- 1 nagios nagios 16384 Oct 5 2020 nagios.tmp7Wuvsx
-rw------- 1 nagios nagios 110592 Oct 5 2020 nagios.tmp7zE1VC
-rw------- 1 nagios nagios 147456 Sep 22 2020 nagios.tmp8FMtiG
-rw------- 1 nagios nagios 16384 Oct 6 2020 nagios.tmp8KZVRQ
-rw------- 1 nagios nagios 57344 Sep 22 2020 nagios.tmp948JiW
-rw------- 1 nagios nagios 0 Sep 22 2020 nagios.tmp9rjLuP
-rw------- 1 nagios nagios 0 Oct 6 2020 nagios.tmp9xJm34
-rw------- 1 nagios nagios 49152 Sep 21 2020 nagios.tmpAQP016
-rw------- 1 nagios nagios 114688 Feb 12 13:05 nagios.tmpBJ71TD
-rw------- 1 nagios nagios 12288 Jan 28 23:31 nagios.tmpBJjWC6
-rw------- 1 nagios nagios 45056 Jan 14 01:00 nagios.tmpBUJPnR
-rw------- 1 nagios nagios 241664 Oct 6 2020 nagios.tmpcAOnAC
-rw------- 1 nagios nagios 36864 Jan 4 23:31 nagios.tmpCewenO
-rw------- 1 nagios nagios 12288 Jan 28 03:25 nagios.tmpcLHRby
-rw------- 1 nagios nagios 32768 Jan 14 23:31 nagios.tmpCvev5s
-rw------- 1 nagios nagios 28672 Feb 2 01:00 nagios.tmpD1yZhz
-rw------- 1 nagios nagios 65536 Feb 5 16:55 nagios.tmpD5ctZ5
-rw------- 1 nagios nagios 0 Aug 26 2020 nagios.tmpd9QhCs
-rw-rw-r-- 1 nagios nagios 2706052 Feb 16 14:42 nagios.tmpDgDIFG
-rw------- 1 nagios nagios 0 Sep 21 2020 nagios.tmpdiyA25
-rw------- 1 nagios nagios 24576 Oct 6 2020 nagios.tmpDoRgT9
-rw------- 1 nagios nagios 0 Nov 17 23:31 nagios.tmpdPU74Y
-rw------- 1 nagios nagios 36864 Oct 19 21:19 nagios.tmpdTaM1H
-rw------- 1 nagios nagios 4096 Jan 26 14:18 nagios.tmpe6pqLk
-rw------- 1 nagios nagios 20480 Oct 24 17:22 nagios.tmpeJGkfl
-rw------- 1 nagios nagios 28672 Sep 23 2020 nagios.tmpeZ5Zjy
-rw------- 1 nagios nagios 32768 Jan 26 15:05 nagios.tmpezMxZV
-rw------- 1 nagios nagios 4096 Jan 12 07:43 nagios.tmpf0xi5e
-rw------- 1 nagios nagios 40960 Feb 5 13:59 nagios.tmpf7pcVl
-rw------- 1 nagios nagios 102400 Sep 22 2020 nagios.tmpFghVng
-rw------- 1 nagios nagios 24576 Jan 26 14:35 nagios.tmpFn3Zl3
-rw------- 1 nagios nagios 4096 Oct 6 2020 nagios.tmpGcuIYg
-rw------- 1 nagios nagios 65536 Jan 25 11:01 nagios.tmpGFpWsr
-rw------- 1 nagios nagios 45056 Oct 6 2020 nagios.tmpgfWZvf
-rw------- 1 nagios nagios 32768 Jan 28 15:49 nagios.tmpGlAHba
-rw------- 1 nagios nagios 53248 Sep 22 2020 nagios.tmpgPxvMY
-rw------- 1 nagios nagios 4096 Aug 26 2020 nagios.tmpgrbIAj
-rw------- 1 nagios nagios 4096 Oct 15 2020 nagios.tmpGsEcgA
-rw------- 1 nagios nagios 57344 Sep 21 2020 nagios.tmphcqbuQ
-rw------- 1 nagios nagios 8192 Jan 24 01:00 nagios.tmphd3YJM
-rw------- 1 nagios nagios 20480 Feb 16 14:40 nagios.tmphXmZ4E
-rw------- 1 nagios nagios 20480 Oct 24 17:33 nagios.tmphZfW1i
-rw------- 1 nagios nagios 4096 Jan 29 15:43 nagios.tmpibutB4
-rw------- 1 nagios nagios 32768 Oct 6 2020 nagios.tmpiSCvLF
-rw------- 1 nagios nagios 69632 Jan 15 10:25 nagios.tmpITv7k9
-rw------- 1 nagios nagios 290816 Jan 26 14:10 nagios.tmpjJzGTx
-rw------- 1 nagios nagios 49152 Sep 21 2020 nagios.tmpJLqoWw
-rw------- 1 nagios nagios 0 Jan 6 23:30 nagios.tmpk84H1T
-rw------- 1 nagios nagios 90112 Sep 30 2020 nagios.tmpklWjJX
-rw------- 1 nagios nagios 32768 Jan 20 15:31 nagios.tmpkr6nqw
-rw------- 1 nagios nagios 81920 Jan 19 23:32 nagios.tmpKrCkSs
-rw------- 1 nagios nagios 86016 Dec 15 23:32 nagios.tmpKTyS12
-rw------- 1 nagios nagios 28672 Feb 12 01:00 nagios.tmpkYHY9E
-rw------- 1 nagios nagios 24576 Oct 6 2020 nagios.tmpKZHuWZ
-rw------- 1 nagios nagios 94208 Jan 11 23:31 nagios.tmplMWiWW
-rw------- 1 nagios nagios 32768 Jan 15 10:37 nagios.tmplt0STP
-rw------- 1 nagios nagios 0 Feb 12 12:58 nagios.tmpMcLQEG
-rw------- 1 nagios nagios 0 Feb 2 23:31 nagios.tmpmrPuPe
-rw------- 1 nagios nagios 8192 Jan 26 09:54 nagios.tmpMTTDD2
-rw------- 1 nagios nagios 32768 Feb 16 01:00 nagios.tmpMTzzra
-rw------- 1 nagios nagios 24576 Oct 6 2020 nagios.tmpMYwPNO
-rw------- 1 nagios nagios 8192 Jan 17 23:31 nagios.tmpN0ALjs
-rw------- 1 nagios nagios 61440 Jan 16 01:00 nagios.tmpnjBGpp
-rw------- 1 nagios nagios 40960 Feb 16 14:15 nagios.tmpNKXbGM
-rw------- 1 nagios nagios 0 Sep 15 2020 nagios.tmpNwD1NJ
-rw------- 1 nagios nagios 73728 Sep 23 2020 nagios.tmpo6kiCq
-rw------- 1 nagios nagios 94208 Jan 19 13:15 nagios.tmpORYlfH
-rw------- 1 nagios nagios 8192 Jan 11 14:46 nagios.tmpP9DZaY
-rw------- 1 nagios nagios 61440 Sep 23 2020 nagios.tmpPAPPBv
-rw------- 1 nagios nagios 0 Aug 25 2020 nagios.tmppkFzvt
-rw------- 1 nagios nagios 4096 Jan 24 23:32 nagios.tmpPmlcTa
-rw------- 1 nagios nagios 24576 Jan 19 13:40 nagios.tmpPO1qe0
-rw------- 1 nagios nagios 90112 Jan 20 13:27 nagios.tmppsbYoV
-rw------- 1 nagios nagios 28672 Dec 15 23:30 nagios.tmpPUPODd
-rw------- 1 nagios nagios 20480 Feb 5 15:01 nagios.tmpPykkeN
-rw------- 1 nagios nagios 0 Jan 30 23:32 nagios.tmpQC5kKE
-rw------- 1 nagios nagios 12288 Jan 25 23:30 nagios.tmpriIWCG
-rw------- 1 nagios nagios 12288 Feb 6 23:30 nagios.tmpRQ42VW
-rw------- 1 nagios nagios 28672 Feb 1 15:18 nagios.tmpRQIfrm
-rw------- 1 nagios nagios 28672 Oct 6 2020 nagios.tmprR4Cib
-rw------- 1 nagios nagios 0 Jan 22 23:30 nagios.tmprrpNMS
-rw------- 1 nagios nagios 20480 Sep 21 2020 nagios.tmpskqPxh
-rw------- 1 nagios nagios 49152 Jan 17 01:00 nagios.tmpSlIVfX
-rw------- 1 nagios nagios 40960 Jan 25 09:03 nagios.tmpt493Qh
-rw------- 1 nagios nagios 40960 Nov 30 14:58 nagios.tmpT65Gjo
-rw------- 1 nagios nagios 53248 Jan 26 15:15 nagios.tmpTBzqes
-rw------- 1 nagios nagios 16384 Jan 20 23:31 nagios.tmpTkbLj2
-rw------- 1 nagios nagios 12288 Sep 22 2020 nagios.tmpTLBSrj
-rw------- 1 nagios nagios 8192 Sep 22 2020 nagios.tmpTLTEHl
-rw------- 1 nagios nagios 0 Feb 10 23:31 nagios.tmpTOxMUc
-rw------- 1 nagios nagios 8192 Oct 24 17:30 nagios.tmpTroEM8
-rw------- 1 nagios nagios 0 Feb 9 23:32 nagios.tmpUcsCKs
-rw------- 1 nagios nagios 28672 Sep 23 2020 nagios.tmpuNG9U1
-rw------- 1 nagios nagios 598016 Sep 22 2020 nagios.tmpUPhEoN
-rw------- 1 nagios nagios 24576 Jan 30 01:00 nagios.tmpUWkC2z
-rw------- 1 nagios nagios 57344 Oct 20 07:55 nagios.tmpUZqEku
-rw------- 1 nagios nagios 4235264 Sep 21 2020 nagios.tmpvFMkTK
-rw------- 1 nagios nagios 28672 Dec 29 23:31 nagios.tmpvLnOhV
-rw------- 1 nagios nagios 98304 Sep 22 2020 nagios.tmpvm3W1Q
-rw------- 1 nagios nagios 12288 Oct 6 2020 nagios.tmpvXwaHP
-rw------- 1 nagios nagios 94208 Jan 20 12:21 nagios.tmpw2klMR
-rw------- 1 nagios nagios 61440 Feb 8 01:00 nagios.tmpw47zql
-rw------- 1 nagios nagios 24576 Jan 17 23:32 nagios.tmpWRJeJL
-rw------- 1 nagios nagios 0 Oct 6 2020 nagios.tmpxmLJ5B
-rw------- 1 nagios nagios 24576 Oct 20 14:15 nagios.tmpxN7nOa
-rw------- 1 nagios nagios 0 Sep 22 2020 nagios.tmpXp2wt4
-rw------- 1 nagios nagios 20480 Oct 20 15:20 nagios.tmpYinEtM
-rw------- 1 nagios nagios 294912 Oct 6 2020 nagios.tmpylkZi4
-rw------- 1 nagios nagios 28672 Dec 11 23:30 nagios.tmpYP7qb2
-rw------- 1 nagios nagios 49152 Oct 6 2020 nagios.tmpZbUHlr
-rw------- 1 nagios nagios 143360 Sep 22 2020 nagios.tmpzcluyg
-rw------- 1 nagios nagios 12288 Jan 15 10:04 nagios.tmpzeAysa
-rw-r--r-- 1 nagios nagios 785623 Mar 15 19:02 npcd.log
-rw-r--r-- 1 nagios nagios 1111765 Oct 19 06:26 objects.cache
-rw------- 1 nagios nagios 3092617 Apr 19 09:00 retention.dat
drwxrwsr-x 2 nagios nagcmd 4096 Apr 19 01:00 rw
-rw-rw-r-- 1 nagios nagios 874542 Apr 5 19:01 ServiceNowRest.log
-rw-r--r-- 1 nagios nagios 18930 Oct 19 06:26 service-perfdata
drwxr-xr-x 5 nagios nagios 4096 Aug 6 2020 spool
drwxrwxr-x 8 nagios nagios 4096 Oct 24 17:54 ssolib
drwxr-xr-x 2 nagios nagios 4096 Apr 19 09:18 stats
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Mon Apr 19, 2021 6:49 pm
by ssax
Do you have selinux enabled on your system?
Or have any security software on the system or in the path that could be blocking it?
Usually when I see connection reset by peer it's something in between (web gateway/IPS device/FW) or on the remote system that is interfering with the connection.
I labbed this up on mine and it's working for me too, please check the security devices/software on the XI server, in the network path, and on the remote device as there could be something it's detecting as a threat when it's run through the backend.
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Tue Apr 20, 2021 9:54 am
I finally have this working in my DEV environment as expected.
1. Script executes on CLI
2. Configured command executes as expected within CCM
3. NagiosXI UI now reflects normal operations
Working-MASH.PNG
While this does not explain the original disparity observed in Works CLI-> Works CCM -> Fails XI UI functionality it does get me past the immediate blocker.
System Changes
Upgrade to XI 5.8.3 (Was 5.8.1)
Install python3 requests['security'] via Pip3
Code Changes
Add 0.02 pause/sleep to function prior to get call
Add 2.50 second timeout to the function for get call
Add Retry loop (max 3) to within function for get call
(I have only seen possibly two occurrences of this going past 1, I need to work the debug logging to capture the count to confirm)
Re: Custom Python Check Returns "UNKNOWN" exit state only in
Posted: Tue Apr 20, 2021 3:42 pm
by vtrac
AWESOME!! .... very happy that this script is now working for you ....
