Page 1 of 2
Check_file_age returns error
Posted: Fri Oct 26, 2018 8:41 am
by BrunoLosse1
Hello all,
I finally got my nagios core running for the first time thanks to the help of someone here, but I still have a small problem:
I'm monitoring an interface server that copies files to another and the command I'm running is to verify the age of a file.
If the folder is empty it means everything is fine, but the check_file_age returns an error.
I know that there is a way to ignore the "file missing" using -i but I can't seem to make it work.
my command is as follows:
Code: Select all
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description FIATCONECTOR
check_command check_nt! FILEAGE -l "d:\\Interfaces\FIATCONECTOR\saida\*.txt"! -w 600 -c 1800
}
And the status at the Web Interface is: "NSClient - ERROR: Invalid return from command: check_files "
If I try check_nt! FILEAGE -l "d:\\Interfaces\FIATCONECTOR\saida\*.txt"! -w 600 -c 1800 -i it doesn't work either.
Re: Check_file_age returns error
Posted: Fri Oct 26, 2018 1:17 pm
by npolovenko
@BrunoLosse1, I suggest using the NRPE portion of the NSCLient for the file age check. Here's the manual.
https://support.nagios.com/kb/article/f ... e_modified
If you're having trouble getting the nrpe module to work please upload your nsclient.ini file.
Re: Check_file_age returns error
Posted: Fri Oct 26, 2018 3:01 pm
by BrunoLosse1
The module is working but I don't understand where to put the command.
I'm monitoring another folder at the same server and it works fine, even when there are no files there.
here's how it is set up, the last service is the one returning an error:
Code: Select all
###############################################################################
# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE
#
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Nagios quickstart guide.
#
###############################################################################
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use windows-server ; Inherit default values from a template
host_name GEWL3BMSRPAS03 ; The name we're giving to this host
alias Thunderbird ; A longer name associated with the host
address 10.63.248.105 ; IP address of the host
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################
# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group
define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
}
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above
#define service{
# use generic-service
# host_name winserver
# service_description NSClient++ Version
# check_command check_nt!CLIENTVERSION
# }
# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description Uptime
check_command check_nt!UPTIME
}
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above
#define service{
# use generic-service
# host_name GEWL3BMSRPAS03
# service_description W3SVC
# check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
# }
# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above
#define service{
# use generic-service
# host_name GEWL3BMSRPAS03
# service_description Explorer
# check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
# }
# Conferir data de alteracao de arquivo
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description Thunderbird Fase 1 - Descompactar arquivos
check_command check_nt! FILEAGE -l "d:\\Interfaces\ARQUIVOS-XML\*.xml"! -w 600 -c 1800
}
#Conferir data de alteração fase 2 teste
#define service{
# use generic-service
# host_name GEWL3BMSRPAS03
# service_description Thunderbird Fase 2 - Carregar PROTHEUS
# check_command check_nt! FILEAGE -l "gewl3bclnpmst01\\xml-recebida-cte\inbox\*.xml"! -w 600 -c 1800 -i
# }
#Conferir data de alteração fase 2 teste
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description FIATCONECTOR
check_command check_nt! FILEAGE -l "d:\\Interfaces\FIATCONECTOR\saida\*.txt"! -w 600 -c 1800
}
Re: Check_file_age returns error
Posted: Fri Oct 26, 2018 4:01 pm
by scottwilkerson
BrunoLosse1 wrote:I'm monitoring another folder at the same server and it works fine, even when there are no files there.
Do you have the same version of NSClient++ on both servers?
Are your configurations the same?
Re: Check_file_age returns error
Posted: Fri Oct 26, 2018 4:30 pm
by cdienger
The check_files module can accept additional options that control and filter the output. It sounds like one server may have had its nsclient.ini file edited to behave better when there are not results to return. I would check out and compare these files. Feel free to post or PM copies as well if needed -- make sure to redact any sensitive info that may be in them.
Re: Check_file_age returns error
Posted: Mon Oct 29, 2018 8:59 am
by BrunoLosse1
scottwilkerson wrote:BrunoLosse1 wrote:I'm monitoring another folder at the same server and it works fine, even when there are no files there.
Do you have the same version of NSClient++ on both servers?
Are your configurations the same?
It's the same server.
Re: Check_file_age returns error
Posted: Mon Oct 29, 2018 9:04 am
by BrunoLosse1
cdienger wrote:The check_files module can accept additional options that control and filter the output. It sounds like one server may have had its nsclient.ini file edited to behave better when there are not results to return. I would check out and compare these files. Feel free to post or PM copies as well if needed -- make sure to redact any sensitive info that may be in them.
I didn't change anything at the nsclient.ini
Here's the file:
Code: Select all
# If you want to fill this file with all avalible options run the following command:
# nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
# nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help
; Undocumented section
[/settings/default]
; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 10.63.248.131
; Undocumented section
[/settings/NRPE/server]
; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket. default-workarounds Various workarounds for what I understand to be broken ssl implementations no-sslv2 Do not use the SSLv2 protocol. no-sslv3 Do not use the SSLv3 protocol. no-tlsv1 Do not use the TLSv1 protocol. single-dh-use Always create a new key when using temporary/ephemeral DH parameters. This option must be used to prevent small subgroup attacks, when the DH parameters were not generated using "strong" primes (e.g. when using DSA-parameters).
ssl options = no-sslv2,no-sslv3
; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket. none The server will not send a client certificate request to the client, so the client will not send a certificate. peer The server sends a client certificate request to the client and the certificate returned (if any) is checked. fail-if-no-cert if the client did not return a certificate, the TLS/SSL handshake is immediately terminated. This flag must be used together with peer. peer-cert Alias for peer and fail-if-no-cert. workarounds Various bug workarounds. single Always create a new key when using tmp_dh parameters. client-once Only request a client certificate on the initial TLS/SSL handshake. This flag must be used together with verify-peer
verify mode = peer-cert
; ALLOW INSECURE CHIPHERS and ENCRYPTION - Only enable this if you are using legacy check_nrpe client.
insecure = false
; Undocumented section
[/modules]
; NRPEServer - A server that listens for incoming NRPE connection and processes incoming requests.
NRPEServer = 1
; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1
; NSClientServer - A server that listens for incoming check_nt connection and processes incoming requests.
NSClientServer = 1
; CheckExternalScripts - Execute external scripts
CheckExternalScripts = 1
; CheckHelpers - Various helper function to extend other checks.
CheckHelpers = 1
; CheckEventLog - Check for errors and warnings in the event log.
CheckEventLog = 1
; CheckNSCP - Use this module to check the healt and status of NSClient++ it self
CheckNSCP = 1
; CheckDisk - CheckDisk can check various file and disk related things.
CheckDisk = 1
; A list of templates for wrapped scripts.
%SCRIPT% will be replaced by the actual script an %ARGS% will be replaced by any given arguments.
[/settings/external scripts/wrappings]
; POWERSHELL WRAPPING -
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
; BATCH FILE WRAPPING -
bat = scripts\\%SCRIPT% %ARGS%
; VISUAL BASIC WRAPPING -
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
; A list of aliases available.
An alias is an internal command that has been predefined to provide a single command without arguments. Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
[/settings/external scripts/alias]
; alias_volumes_loose - Alias for alias_volumes_loose. To configure this item add a section called: /settings/external scripts/alias/alias_volumes_loose
alias_volumes_loose = check_drivesize
; alias_volumes - Alias for alias_volumes. To configure this item add a section called: /settings/external scripts/alias/alias_volumes
alias_volumes = check_drivesize
; alias_up - Alias for alias_up. To configure this item add a section called: /settings/external scripts/alias/alias_up
alias_up = check_uptime
; alias_sched_all - Alias for alias_sched_all. To configure this item add a section called: /settings/external scripts/alias/alias_sched_all
alias_sched_all = check_tasksched show-all "syntax=${title}: ${exit_code}" "crit=exit_code ne 0"
; alias_process_stopped - Alias for alias_process_stopped. To configure this item add a section called: /settings/external scripts/alias/alias_process_stopped
alias_process_stopped = check_process "process=$ARG1$" "crit=state != 'stopped'"
; alias_service - Alias for alias_service. To configure this item add a section called: /settings/external scripts/alias/alias_service
alias_service = check_service
; alias_process_hung - Alias for alias_process_hung. To configure this item add a section called: /settings/external scripts/alias/alias_process_hung
alias_process_hung = check_process "filter=is_hung" "crit=count>0"
; alias_process_count - Alias for alias_process_count. To configure this item add a section called: /settings/external scripts/alias/alias_process_count
alias_process_count = check_process "process=$ARG1$" "warn=count > $ARG2$" "crit=count > $ARG3$"
; alias_process - Alias for alias_process. To configure this item add a section called: /settings/external scripts/alias/alias_process
alias_process = check_process "process=$ARG1$" "crit=state != 'started'"
; alias_mem - Alias for alias_mem. To configure this item add a section called: /settings/external scripts/alias/alias_mem
alias_mem = check_memory
; alias_file_size - Alias for alias_file_size. To configure this item add a section called: /settings/external scripts/alias/alias_file_size
alias_file_size = check_files "path=$ARG1$" "crit=size > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${size}" max-dir-depth=10
; alias_disk - Alias for alias_disk. To configure this item add a section called: /settings/external scripts/alias/alias_disk
alias_disk = check_drivesize
; alias_cpu_ex - Alias for alias_cpu_ex. To configure this item add a section called: /settings/external scripts/alias/alias_cpu_ex
alias_cpu_ex = check_cpu "warn=load > $ARG1$" "crit=load > $ARG2$" time=5m time=1m time=30s
; alias_file_age - Alias for alias_file_age. To configure this item add a section called: /settings/external scripts/alias/alias_file_age
alias_file_age = check_files "path=$ARG1$" "crit=written > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${written}" max-dir-depth=10
; alias_cpu - Alias for alias_cpu. To configure this item add a section called: /settings/external scripts/alias/alias_cpu
alias_cpu = check_cpu
; alias_event_log - Alias for alias_event_log. To configure this item add a section called: /settings/external scripts/alias/alias_event_log
alias_event_log = check_eventlog
; alias_service_ex - Alias for alias_service_ex. To configure this item add a section called: /settings/external scripts/alias/alias_service_ex
alias_service_ex = check_service "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc
; alias_disk_loose - Alias for alias_disk_loose. To configure this item add a section called: /settings/external scripts/alias/alias_disk_loose
alias_disk_loose = check_drivesize
; alias_sched_task - Alias for alias_sched_task. To configure this item add a section called: /settings/external scripts/alias/alias_sched_task
alias_sched_task = check_tasksched show-all "filter=title eq '$ARG1$'" "detail-syntax=${title} (${exit_code})" "crit=exit_code ne 0"
; alias_sched_long - Alias for alias_sched_long. To configure this item add a section called: /settings/external scripts/alias/alias_sched_long
alias_sched_long = check_tasksched "filter=status = 'running'" "detail-syntax=${title} (${most_recent_run_time})" "crit=most_recent_run_time < -$ARG1$"
Re: Check_file_age returns error
Posted: Mon Oct 29, 2018 2:05 pm
by cdienger
Can you share the working command and it's output so we can compare it to the non-working? It's not clear why it would behave differently but perhaps there's a character in there that is causing it to escape.
Re: Check_file_age returns error
Posted: Mon Oct 29, 2018 2:29 pm
by BrunoLosse1
At the windows.cfg file, here's the one that works:
Code: Select all
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description Thunderbird Fase 1 - Descompactar arquivos
check_command check_nt! FILEAGE -l "d:\\Interfaces\ARQUIVOS-XML\*.xml"! -w 600 -c 1800
}
The output at the web interface is Status: "ok" Status Information:"33181067405936000173550020004117741291520250.xml 2018-Oct-29 19:17:23 "
The one that does not work that I literally copied from the one that works.
And I have verified that the path is correct.
Code: Select all
define service{
use generic-service
host_name GEWL3BMSRPAS03
service_description FIATCONECTOR
check_command check_nt! FILEAGE -l "d:\\Interfaces\FIATCONECTOR\saida\*.txt"! -w 600 -c 1800
}
The output is Status: "Unknown" Status Information: "NSClient - ERROR: Invalid return from command: check_files"
Re: Check_file_age returns error
Posted: Tue Oct 30, 2018 3:44 pm
by ssax
Try adding this to your nsclient.ini and then restart the NSClient++ service:
Code: Select all
[/settings/log]
; LOG LEVEL - Log level to use. Available levels are error,warning,info,debug,trace
level = debug
; FILENAME - The file to write log data to. Set this to none to disable log to file.
file name = nsclient.log
; DATEMASK - The size of the buffer to use when getting messages this affects the speed and maximum size of messages you can recieve.
date format = %Y-%m-%d %H:%M:%S
[/settings/log/file]
; MAXIMUM FILE SIZE - When file size reaches this it will be truncated to 50% if set to 0 (default) truncation will be disabled
max size = 2048000
Then run the command that fails again and then post your nsclient.log file errors. I'm wondering if it may be a permissions issue.
Once it's done you can change the log settings to info or remove the sections and restart the NSClient++ service again so it doesn't affect performance.