Skip to main content

Hello community o7 ! 

I am struggling with how to correctly write logfile name, here’s the command I tried with : 
 

bash-5.1$ /usr/lib/centreon/plugins//centreon_nsclient_restapi.pl 
--plugin=apps::nsclient::restapi::plugin
--mode=query
--hostname='X.X.X.X'
--port='8443'
--proto='https'
--legacy-password='XXXX'
--ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"
--timeout=60
--command=check_logfiles
--arg='--logfile="C:/Program Files/Centreon NSClient++/nsclient.log"
--tag=""
--criticalpattern=""
--warningpattern="" '
--debug

I’ve tried with differents separators : /, \, //, \\, \/, /\ but everytime I get this error message : 
 

Failed to execute check_logfiles: 2: The specified file cannot be found.
======> request send
GET https://X.X.X.X:8443/query/check_logfiles?--logfile%3D%22C%3A%2FProgram%20Files%2FCentreon%20NSClient%2B%2B%2Fnsclient.log%22%20--tag%3D%22%22%20--criticalpattern%3D%22%22%20--warningpattern%3D%22%22%20

r...]

{"header":{"source_id":""},"payload":"{"command":"check_logfiles","lines":"{"message":"Failed to execute check_logfiles: 2: The specified file cannot be found."}],"result":"UNKNOWN"}]}

Do you have any idea of what i did wrong ? 

 

Thanks,

I continue looking for documentation then I found on some forum topics and NSClient documentation and there what i learned, :
To activate CheckLogFile you should use these command lines

nscp settings --activate-module CheckLogFile --add-defaults
nscp service --restart

Care to check weither [/settings/default] section doesn’t make error by overwriting ‘allowed hosts’ for NRPE/server and WEB/server parts.

Next, I found a way to check logfile by using check_cache through two lasts jolson’s answers on this topic (Real-time Log File from NSClient++ - Nagios Support Forum) : 

C:\Program Files\Centreon NSClient++>nscp settings --activate-module SimpleFileWriter --add-defaults

C:\Program Files\Centreon NSClient++>nscp settings --activate-module SimpleCache --add-defaults

C:\Program Files\Centreon NSClient++>nscp settings --activate-module NSCAClient --add-defaults

C:\Program Files\Centreon NSClient++>nscp service --restart

Do not forget to check [/settings/default] again.

Then on nsclient.ini, add theses sections :

; Real-time filtering - A set of options to configure the real time checks
[/settings/logfile/real-time]

; Real time - Spawns a background thread which waits for file changes.
enabled = true

[/settings/logfile/real-time/checks/logfile]
file = c:/temp/test.log
target=CACHE
filter = column1 like 'hallo'
critical = column2 like 'wurld'
column split=;

Now you can execute this command to check your files :

/usr/lib64/nagios/plugins/check_centreon_nrpe3 
-H X.X.X.X
-p 5666 -n -u -2 -P 8192
-c check_cache
-a key=logfile

c:/temp/test.log: 2 (ERROR, TYPE2, , ERROR, TYPE1, )

But I wasn’t really happy of the output and I don’t think we can use check_cache on Centreon. On my initial post, the error ‘Failed to execute check_logfiles: 2: The specified file cannot be found.’ wasn’t what i thought. On centreon when we look at how is built ‘check_logfile’ command its written with this parameter ‘--command=check_logfiles’ but it found that it is an syntax error, the correct way is without last ‘s’, so ‘--command=check_logfile’.

EDIT: argument --logfile is also incorrect when I should be --file=

With this syntax I got this output : 
 

/usr/lib/centreon/plugins//centreon_nsclient_restapi.pl 
--plugin=apps::nsclient::restapi::plugin
--mode=query
--hostname='X.X.X.X'
--port='8443'
--proto='https'
--legacy-password='XXX'
--ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"
--timeout=30
--command=check_logfile
--arg='--file="C:\fakelogfile.log"'

Failed to open file: "C:\fakelogfile.log"

Now I am sure that command prompt is correct but still on a syntax error or an other issue. I also tried with “/” “//” “\” “\\” nothing change still failed to open file.

Do you have some ideas of what can be the right way check_logfile ?


Reply