2012/08/09

Check on Nagios the latest files in folder with NSClient++ 0.3.9

CURRENT CONFIGURATION: Linux OpenSuSe, Nagios 3.2.3, NRPE; Windows 2003R2 x64 server, NSClient++ 0.3.9.330 2011-09-02
OBJECTIVE: Monitor MSSQL backup, IIS logs replication with Nagios. Check FOLDER with files (MSSQL backup, IIS logs, S3 logs, etc.). Send WARNING if files are older than some hours.
SOLUTION:
NRPE has to work on Nagios server and on Windows client computer with NSClient++.
Nagios server command.cfg file:
define command{
  command_name    check_nrpe_files_written
  command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c CheckFiles -a "path=$ARG1$" "pattern=$ARG2$" "filter=written gt -$ARG3$" truncate=4096 "master-syntax=files: %total%" max-dir-depth=$ARG4$ MinWarn=0
}

define command{
  command_name    check_nrpe_files_creation
  command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c CheckFiles -a "path=$ARG1$" "pattern=$ARG2$" "filter=creation gt -$ARG3$" truncate=4096 "master-syntax=files: %total%" max-dir-depth=$ARG4$ MinWarn=0
}

Nagios server somename.cfg file examples:


define service{
...
  check_command           check_nrpe_files_creation!F:\\Backup\\SERVER01\\mssql\\backup\\default\\full!*.bkz!30h!0
  normal_check_interval   720
}
define service{
...
  check_command           check_nrpe_files_creation!F:\\Backup\\SERVER06\\ServiceDesk\\backup!*.data!30h!0
  normal_check_interval   720
}
define service{
...
  check_command           check_nrpe_files_creation!F:\\backup\\SERVER01!*-exchange_1_storage_group.bkf!8d!0
  normal_check_interval   1440
}
define service{
...
  check_command           check_nrpe_files_written!D:\\Logs\\IISLogs!*WEB01*.log!6h!4
  normal_check_interval   180
}
define service{
...
  check_command           check_nrpe_files_written!D:\\Replica\\UploadCopy\\s3!LastReplication.log!30h!0
  normal_check_interval   720
}

NSClient++ NSC.ini file:

[modules]
NRPEListener.dll
[NRPE]
allow_arguments=1
allow_nasty_meta_chars=1
Big thanks to NSClient++ author for program and excellent support.

6 комментариев:

Анонимный комментирует...

Hello, I was reading your articles Check on Nagios the latest files in folder with NSClient++, and that's what I need to do with Ospview, but when I try to make a test using the command with nrpe I receive "UNKNOWN: No handler for that command".
I want to know if I need to made modifications to NSC.ini in order to define new NRPE handlers or NSClient++ checks with inject option.

I appreciate your kindly response

Luis

Vadim Zenin комментирует...

Hi Luis,

My NSC.ini NRPE and modules sections are next:
[NRPE]
port=5666
command_timeout=120
allow_arguments=1
allow_nasty_meta_chars=1
script_dir=scripts\

[modules]
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
CheckHelpers.dll
CheckWMI.dll
CheckExternalScripts.dll
NSCAAgent.dll

Regards,
Vadim

González, Luis Rolando комментирует...

Thank you for your response Vadim.
I check my NSC.ini and add the modules that you recommend but I have a question:
How you define CheckFiles in your command_line
CheckFiles is not present as module or NRPE Handler or NSClient++ check

How CheckFiles works?

thank you,

Luis

Vadim Zenin комментирует...

Luis,

Could you see text under "Nagios server command.cfg file:" line in article?

González, Luis Rolando комментирует...

Hello Vadim,
Yes, I can see the text reference by you.
I want to know how can I define CheckFiles in my config.
I need to define it in mi NSC.ini?
Is required another configuration in the NSClient++?
I missing something here.

Thank you for your kindly response.

Luis

Vadim Zenin комментирует...

Hi Luis,

>I need to define it in mi NSC.ini?
No, only on Nagios server.
>Is required another configuration in the NSClient++?
I am not sure...
Please try command on Nagios server with real IP and arguments:
check_nrpe -H $HOSTADDRESS$ -c CheckFiles -a "path=$ARG1$" "pattern=$ARG2$" "filter=written gt -$ARG3$" truncate=4096 "master-syntax=files: %total%" max-dir-depth=$ARG4$ MinWarn=0

http://nsclient.org/nscp/wiki/CheckDisk/CheckFiles