Home Directory Plugins System Metrics File System Check if files are periodically updated on a windows share

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check if files are periodically updated on a windows share

Rating
4 votes
Favoured:
0
Compatible With
  • Nagios 3.x
Owner
License
GPL
Hits
69833
Files:
FileDescription
share-file-check.shshare-file-check.sh
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
This plugin is a bash script which will check a windows share using the smbclient command. It will alert critical if the files matching a pattern are older then a specified amount of time or are not found. It can also warn if the files are not bigger then the specified limit.
Command Usage:

share-file-check.sh -u USERNAME -p PASSWORD -W WORKGROUP -s SMBSHARE -f FILEPATH -c FILEMAXTIME -w FILESIZEMIN [-d]


Example:

$ ./share-file-check.sh -u nagios -p $PASS -W domain.com -s //fileserver/share -f '/backups/*' -c 900 -w 80000000 -d
daily-backup-2012_06_07.zip - 81847979 bytes, 7537 min
daily-backup-2012_06_08.zip - 81889345 bytes, 7537 min
daily-backup-2012_06_09.zip - 81895321 bytes, 6726 min
daily-backup-2012_06_10.zip - 81895385 bytes, 5286 min
daily-backup-2012_06_11.zip - 81895501 bytes, 3846 min
daily-backup-2012_06_12.zip - 81927794 bytes, 2406 min
daily-backup-2012_06_13.zip - 81967408 bytes, 966 min
No files found newer than 900 minutes!


Nagios config:

define command{
command_name check_backup
command_line $USER1$/share-file-check.sh -u $ARG1$ -p $ARG2$ -W $ARG3$ -s $ARG4$ -f $ARG5$ -c $ARG6$ -w $ARG7$
}

define service {
service_description backup-check
use generic-service
host_name someserver
notification_options w,c,r
contact_groups just_mail
#Ensure newer files are found then 3d (4320m) and are bigger then 47mb (50000000 bytes).
check_command check_backup!nagios!SeCrEt!domain.com!//fileserver/share!/backups/*!4320!50000000
}

Reviews (2)
bygasp72, November 10, 2012
The error is related to NEWC variable
Try to modify line 64 with this code

[[ $TDIFm -lt $FMXT ]] && CRIT="no" && ((NEWC++))
byBenj, September 20, 2012
1 of 1 people found this review helpful
./check_file.sh: line 64: 0: command not found

when the result of the script should give me the ok result (files are newer and bigger than the arguments)...

What's the problem with this case ?

[[ $TDIFm -lt $FMXT ]] && $((NEWC++)) && CRIT='no'
[[ $SIZE -lt $FSZM ]] && WARN='yes'