Having issue with plugin
Having issue with plugin
We are trying to use a custom plugin and are receiving the following error. Any assistance would be appreciated. # instead of the actual values.
[nagios@cxonainmorv0102 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H ######## -vvv -t '#######' -M 'plugins/check_filesize.pl' -q "args= -F S:\\cypress\\server\\db_prog.exe_collateral\\datafile000222.cdb -o -c 10 -w 10000000"
Connecting to: https://##############:####/api/plugins/check_filesize.pl/?token=&check=1&args=+-F+S%3A%5C%5Ccypress%5C%5Cserver%5C%5Cdb_prog.exe_collateral%5C%5Cdatafile000222.cdb+-o+-c+10+-w+10000000
An error occurred:
UNKNOWN: An error occured connecting to API. (Connection error: '[Errno -2] Name or service not known')
[nagios@cxonainmorv0102 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H ######## -vvv -t '#######' -M 'plugins/check_filesize.pl' -q "args= -F S:\\cypress\\server\\db_prog.exe_collateral\\datafile000222.cdb -o -c 10 -w 10000000"
Connecting to: https://##############:####/api/plugins/check_filesize.pl/?token=&check=1&args=+-F+S%3A%5C%5Ccypress%5C%5Cserver%5C%5Cdb_prog.exe_collateral%5C%5Cdatafile000222.cdb+-o+-c+10+-w+10000000
An error occurred:
UNKNOWN: An error occured connecting to API. (Connection error: '[Errno -2] Name or service not known')
Re: Having issue with plugin
Hello,
Name or service not known suggests it can not resolve the host. Are you using IP or hostname, can hostname be resolved by DNS ? Can you just ping hostname ?
Regards
Name or service not known suggests it can not resolve the host. Are you using IP or hostname, can hostname be resolved by DNS ? Can you just ping hostname ?
Regards
Re: Having issue with plugin
I found what I was doing wrong, had the wrong hostname. Running into another problem though. I have the plugin at D:\Program Files (x86)\Nagios\plugins
[nagios@cxonainmorv0102 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H ###### -vvv -t '#######' -M 'plugins/check_filesize.pl' -q "args= -F S:\\cypress\\server\\db_prog.exe_collateral\\datafile000222.cdb"
Connecting to: https://########:######/api/plugins/check_filesize.pl/?token=######&check=1&args=+-F+S%3A%5C%5Ccypress%5C%5Cserver%5C%5Cdb_prog.exe_collateral%5C%5Cdatafile000222.cdb
File returned contained:
{
"returncode": 3,
"stdout": "The plugin (check_filesize.pl) requested does not exist."
}
The plugin (check_filesize.pl) requested does not exist.
[nagios@cxonainmorv0102 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H ###### -vvv -t '#######' -M 'plugins/check_filesize.pl' -q "args= -F S:\\cypress\\server\\db_prog.exe_collateral\\datafile000222.cdb"
Connecting to: https://########:######/api/plugins/check_filesize.pl/?token=######&check=1&args=+-F+S%3A%5C%5Ccypress%5C%5Cserver%5C%5Cdb_prog.exe_collateral%5C%5Cdatafile000222.cdb
File returned contained:
{
"returncode": 3,
"stdout": "The plugin (check_filesize.pl) requested does not exist."
}
The plugin (check_filesize.pl) requested does not exist.
-
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Having issue with plugin
Hi @durga,
A few questions/information to help troubleshoot this error.
1. Did you install Perl on the Windows system. If so, which package. If you can use Powershell, that would be best as it does not require additional software.
This Powershell script may work: https://exchange.nagios.org/directory/P ... s1/details
2. Can you attach or PM a copy of the ncpa.cfg file and ncpa_listener.log.
Thanks!
Benjamin
A few questions/information to help troubleshoot this error.
1. Did you install Perl on the Windows system. If so, which package. If you can use Powershell, that would be best as it does not require additional software.
This Powershell script may work: https://exchange.nagios.org/directory/P ... s1/details
2. Can you attach or PM a copy of the ncpa.cfg file and ncpa_listener.log.
Thanks!
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Having issue with plugin
I tested the plugin you mentioned and get the same error. I have sent you a PM with the ncpa.cfg file you requested. I removed the token information, but it is correct.
Re: Having issue with plugin
Have you tried wrapping your arguments in single quotes?
Example:
Example:
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H ###### -vvv -t '#######' -M 'plugins/check_filesize.pl' -q 'args= -F S:\cypress\server\db_prog.exe_collateral\datafile000222.cdb'
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Having issue with plugin
Here is the code after using single quotes.
/usr/local/nagios/libexec/check_ncpa.py -H ######## -T 90 -t ##### -M 'plugins/check_windows_files.ps1' -q 'args= -checkPath C:\path\data -sizewarning 0'
The plugin (check_windows_files.ps1) requested does not exist.
/usr/local/nagios/libexec/check_ncpa.py -H ######## -T 90 -t ##### -M 'plugins/check_windows_files.ps1' -q 'args= -checkPath C:\path\data -sizewarning 0'
The plugin (check_windows_files.ps1) requested does not exist.
Re: Having issue with plugin
I tested the check_windows_files.ps1 plugin from the Nagios Exchange and it didn't work for me. Just want to mention that many of the plugins listed on the Nagios Exchange are 3rd party plugins, that are not tested by us (Nagios). There is no guarantee that they would work. If you can't find a suitable plugin that is going to fit your needs, you would need to write your own.
I am not a PS expert by no means, so the plugin I put together for you may need some improvements and/or fixes, but at least it will get you started.
check_file_size.ps1
The way you would use it is by running the plugin, and passing 3 arguments. The first argument would be the path to your file. The second one would be the warning threshold, and the third on - the critical threshold (in KB).
I placed the PS script in the NCPA plugins directory on the target machine, then ran my command from the Nagios XI server. I was checking the size of the "test.txt" file in the "C:\Temp" directory on my Windows workstation.
Examples:
You can modify the script to your liking. For example, you can pass different number of arguments, e.g. just warning or just critical thresholds, you can "hard-code" the path to your file, and/or threshold values in the check_file_size.ps1 script, etc.
Hope this helps.
I am not a PS expert by no means, so the plugin I put together for you may need some improvements and/or fixes, but at least it will get you started.
check_file_size.ps1
Code: Select all
$file = $args[0]
$Warning = $args[1]
$Critical = $args[2]
$size = ((Get-ChildItem -file $file) | % {[math]::ceiling($_.length / 1kb)})
if ($size -gt $Critical) {
echo "Critical: The size of the file is $size KB."
exit 2
} elseif ($size -lt $Warning) {
echo "OK: The size of the file is $size KB."
exit 0
} else {
echo "Warning: The size of the file is $size KB."
exit 1
}
I placed the PS script in the NCPA plugins directory on the target machine, then ran my command from the Nagios XI server. I was checking the size of the "test.txt" file in the "C:\Temp" directory on my Windows workstation.
Examples:
Code: Select all
[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=c:\Temp\test.txt 200 300'
OK: The size of the file is 136 KB.
[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=c:\Temp\test.txt 100 200'
Warning: The size of the file is 136 KB.
[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=c:\Temp\test.txt 10 20'
Critical: The size of the file is 136 KB.
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Having issue with plugin
I tested your script on the server and we are receiving the same error. That it cannot find the plugin. After we place the script on the server is there something specific that we need to do so the agent recognizes the script is now in the plugins folder?lmiltchev wrote:I tested the check_windows_files.ps1 plugin from the Nagios Exchange and it didn't work for me. Just want to mention that many of the plugins listed on the Nagios Exchange are 3rd party plugins, that are not tested by us (Nagios). There is no guarantee that they would work. If you can't find a suitable plugin that is going to fit your needs, you would need to write your own.
I am not a PS expert by no means, so the plugin I put together for you may need some improvements and/or fixes, but at least it will get you started.
check_file_size.ps1The way you would use it is by running the plugin, and passing 3 arguments. The first argument would be the path to your file. The second one would be the warning threshold, and the third on - the critical threshold (in KB).Code: Select all
$file = $args[0] $Warning = $args[1] $Critical = $args[2] $size = ((Get-ChildItem -file $file) | % {[math]::ceiling($_.length / 1kb)}) if ($size -gt $Critical) { echo "Critical: The size of the file is $size KB." exit 2 } elseif ($size -lt $Warning) { echo "OK: The size of the file is $size KB." exit 0 } else { echo "Warning: The size of the file is $size KB." exit 1 }
I placed the PS script in the NCPA plugins directory on the target machine, then ran my command from the Nagios XI server. I was checking the size of the "test.txt" file in the "C:\Temp" directory on my Windows workstation.
Examples:
You can modify the script to your liking. For example, you can pass different number of arguments, e.g. just warning or just critical thresholds, you can "hard-code" the path to your file, and/or threshold values in the check_file_size.ps1 script, etc.Code: Select all
[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=c:\Temp\test.txt 200 300' OK: The size of the file is 136 KB. [root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=c:\Temp\test.txt 100 200' Warning: The size of the file is 136 KB. [root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=c:\Temp\test.txt 10 20' Critical: The size of the file is 136 KB.
Hope this helps.
/usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -T 90 -t 'mytoken' -M 'plugins/check_file_size.ps1' -q 'args=C:\data\path\file.txt 200 300'
The plugin (check_file_size.ps1) requested does not exist.
Re: Having issue with plugin
Can you run the PS script locally on the Windows machine and show the output? Does it work for you?
Example: Please, post the ncpa.cfg and ncpa_listener.log from the Windows box on the forum.
Have you checked to see if your group policy allows you to run PS script on this machine?
Example: Please, post the ncpa.cfg and ncpa_listener.log from the Windows box on the forum.
Have you checked to see if your group policy allows you to run PS script on this machine?
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!