NTP Check on Windows Servers with NCPA agents
NTP Check on Windows Servers with NCPA agents
Hello
On the monitored windows 2012 Servers
The plugin check_ntp_time.c'is placed Under C:\Program Files (x86)\Nagios\NCPA\plugins
Then when testing from NagiosXI to see if we can get the offset time from NTP
/usr/local/nagios/libexec/check_ncpa.py -H remotehost -t code-P 5693 -M 'plugins/check_ntp_time.c' -a "-u '-H NTPServerIP -w 60 -c 120'"
Resulting this
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
Same result if executing
plugins/check_ntp_peer.c
or /check_time.c
Here is the listener log from the server hosting the NCPA agent
2020-03-07 02:38:42,243:ERROR:app:Exception on /api/agent/plugins/check_ntp_peer.c/-u/'-H NTPServerIP -w 60 -c 120' [GET]
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
File "C:\ncpa\agent\listener\server.py", line 154, in token_auth_decoration
File "C:\ncpa\agent\listener\server.py", line 931, in api
File "C:\ncpa\agent\listener\nodes.py", line 251, in run_check
File "C:\ncpa\agent\listener\pluginnodes.py", line 99, in execute_plugin
File "C:\Python27\lib\site-packages\gevent\subprocess.py", line 586, in __init__
File "C:\Python27\lib\site-packages\gevent\subprocess.py", line 555, in __init__
File "C:\Python27\lib\site-packages\gevent\subprocess.py", line 899, in _execute_child
WindowsError: [Error 193] %1 is not a valid Win32 application
Any suggestion on how to acceive the same goal in different way that can work?
On the monitored windows 2012 Servers
The plugin check_ntp_time.c'is placed Under C:\Program Files (x86)\Nagios\NCPA\plugins
Then when testing from NagiosXI to see if we can get the offset time from NTP
/usr/local/nagios/libexec/check_ncpa.py -H remotehost -t code-P 5693 -M 'plugins/check_ntp_time.c' -a "-u '-H NTPServerIP -w 60 -c 120'"
Resulting this
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
Same result if executing
plugins/check_ntp_peer.c
or /check_time.c
Here is the listener log from the server hosting the NCPA agent
2020-03-07 02:38:42,243:ERROR:app:Exception on /api/agent/plugins/check_ntp_peer.c/-u/'-H NTPServerIP -w 60 -c 120' [GET]
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
File "C:\ncpa\agent\listener\server.py", line 154, in token_auth_decoration
File "C:\ncpa\agent\listener\server.py", line 931, in api
File "C:\ncpa\agent\listener\nodes.py", line 251, in run_check
File "C:\ncpa\agent\listener\pluginnodes.py", line 99, in execute_plugin
File "C:\Python27\lib\site-packages\gevent\subprocess.py", line 586, in __init__
File "C:\Python27\lib\site-packages\gevent\subprocess.py", line 555, in __init__
File "C:\Python27\lib\site-packages\gevent\subprocess.py", line 899, in _execute_child
WindowsError: [Error 193] %1 is not a valid Win32 application
Any suggestion on how to acceive the same goal in different way that can work?
You do not have the required permissions to view the files attached to this post.
Re: NTP Check on Windows Servers with NCPA agents
This plugin is not a Windows application, so it is not going to work... I would recommend finding a plugin that would work on Windows. Here's one that I found on the Nagios Exchange:
https://exchange.nagios.org/directory/P ... 29/details
Testing the plugin from the command line on the Nagios XI server:
Hope this helps.
https://exchange.nagios.org/directory/P ... 29/details
Testing the plugin from the command line on the Nagios XI server:
Code: Select all
[root@main-nagios-xi libexec]# ./check_ncpa.py -H 192.168.x.x -t 'mytoken' -M 'plugins/check_windows_time.bat' -q 'args=0.us.pool.ntp.org,args=1,args=2'
OK: Time is -00.7324614s from 0.us.pool.ntp.org|'Offset'=00s;1;2;0Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: NTP Check on Windows Servers with NCPA agents
Thanks for sharing the right plugin
After placing the plugin on the target windows server
I am getting this when trying it on my end not sure what I am doing wrong. Can you idenify any wrong syntax?
[root@rdnagios libexec]# ./check_ncpa.py -H X.X.X.X -t Token -M 'plugins/check_windows_time.bat' -q 'args=1.1.1.1,args=60,args=120'
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" - Nagios plugin that checks time offset against a specified ntp server.
Usage: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" <timeserver> <warning threshold in seconds> <critical threshold in seconds>
Examples: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" pool.ntp.org 120 300
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" my-domain-controller.local 120 300
[root@rdnagios libexec]#
After placing the plugin on the target windows server
I am getting this when trying it on my end not sure what I am doing wrong. Can you idenify any wrong syntax?
[root@rdnagios libexec]# ./check_ncpa.py -H X.X.X.X -t Token -M 'plugins/check_windows_time.bat' -q 'args=1.1.1.1,args=60,args=120'
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" - Nagios plugin that checks time offset against a specified ntp server.
Usage: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" <timeserver> <warning threshold in seconds> <critical threshold in seconds>
Examples: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" pool.ntp.org 120 300
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" my-domain-controller.local 120 300
[root@rdnagios libexec]#
Re: NTP Check on Windows Servers with NCPA agents
Open the ncpa.cfg file in a text editor, change this line:
to this:
Save, exit, and restart ncpa_listener service on the Windows machine.
Next, try your check by adding "-v" at the end of your command for increased verbosity:
and show the output.
Also, post the entire ncpa_listener.log on the forum. It should be located in the "C:\Program Files (x86)\Nagios\NCPA\var\log" folder.
Code: Select all
loglevel = infoCode: Select all
loglevel = debugNext, try your check by adding "-v" at the end of your command for increased verbosity:
Code: Select all
./check_ncpa.py -H X.X.X.X -t Token -M 'plugins/check_windows_time.bat' -q 'args=1.1.1.1,args=60,args=120' -vAlso, post the entire ncpa_listener.log on the forum. It should be located in the "C:\Program Files (x86)\Nagios\NCPA\var\log" folder.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: NTP Check on Windows Servers with NCPA agents
The requested steps were done
Please find attached logs
Please find attached logs
You do not have the required permissions to view the files attached to this post.
Re: NTP Check on Windows Servers with NCPA agents
Thanks for the logs! What is the output of the command below?
Code: Select all
./check_ncpa.py -H X.X.X.X -t Token -M 'plugins/check_windows_time.bat' -q 'args=1.1.1.1,args=60,args=120' -vBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NTP Check on Windows Servers with NCPA agents
Connecting to: https://10.90.112.xx:5693/api/plugins/c ... 0&args=120
File returned contained:
{
"returncode": 3,
"stdout": "\"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" - Nagios plugin that checks time offset against a specified ntp server.\n\nUsage: \"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" <timeserver> <warning threshold in seconds> <critical threshold in seconds>\nExamples: \"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" pool.ntp.org 120 300\n \"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" my-domain-controller.local 120 300"
}
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" - Nagios plugin that checks time offset against a specified ntp server.
Usage: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" <timeserver> <warning threshold in seconds> <critical threshold in seconds>
Examples: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" pool.ntp.org 120 300
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" my-domain-controller.local 120 300
[root@rdnagios libexec]#
File returned contained:
{
"returncode": 3,
"stdout": "\"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" - Nagios plugin that checks time offset against a specified ntp server.\n\nUsage: \"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" <timeserver> <warning threshold in seconds> <critical threshold in seconds>\nExamples: \"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" pool.ntp.org 120 300\n \"C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_windows_time.bat\" my-domain-controller.local 120 300"
}
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" - Nagios plugin that checks time offset against a specified ntp server.
Usage: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" <timeserver> <warning threshold in seconds> <critical threshold in seconds>
Examples: "C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" pool.ntp.org 120 300
"C:\Program Files (x86)\Nagios\NCPA\plugins\check_windows_time.bat" my-domain-controller.local 120 300
[root@rdnagios libexec]#
Re: NTP Check on Windows Servers with NCPA agents
We haven't been able to recreate the issue in house. It seems like the plugin shows you the usage... it is almost like your arguments are not taken. I am not sure why this would be.
Have you modified the settings in the ncpa.cfg file from "defaults"? Can you post your ncpa.cfg file on the forum? Please hide/obfuscate sensitive info.
Have you tried running your check against a different NTP server? Can you try the command below and show the output?
Have you modified the settings in the ncpa.cfg file from "defaults"? Can you post your ncpa.cfg file on the forum? Please hide/obfuscate sensitive info.
Have you tried running your check against a different NTP server? Can you try the command below and show the output?
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -t 'token' -M 'plugins/check_windows_time.bat' -q 'args=pool.ntp.org,args=120,args=300' -vBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NTP Check on Windows Servers with NCPA agents
Please find the attached ncpa.cfg of the target server
You do not have the required permissions to view the files attached to this post.
Re: NTP Check on Windows Servers with NCPA agents
Do you get the same error when you run the command below?
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -t 'token' -M 'plugins/check_windows_time.bat' -q 'args=pool.ntp.org,args=120,args=300' -vBe sure to check out our Knowledgebase for helpful articles and solutions!