Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
Tests the existence/age/size/contents of a file/folder on a SMB share. It's a Perl script that uses the Filesys::SmbClient module to do all the work.
Current Version
0.5
Last Release Date
2012-12-16
Owner
Chad Sikorra
Website
https://github.com/ChadSikorra/nagios-check-smb-file
Download URL
https://raw.github.com/ChadSikorra/nagios-check-smb-file/master/check_smb_file.pl
License
GPL
Compatible With
Usage Switches... -H, --host <hostname> The hostname to check (required) -f, --filename <filename> The share and path to the file/directory (required) -F --filename-match <regex> Only check filenames matching this regex -D --mode-directory Treat the filename to check as a directory -w, --warning <value> Warning if file property exceeds value -c, --critical <value> Critical if file property exceeds value -m, --warning-match <regex> Warning if contents match regex -M, --critical-match <regex> Critical if contents match regex -t, --warning-files <value> Warning if the total files detected exceeds value -T, --critical-files <value> Critical if the total files detected exceeds value -p, --property <property> The property to test (Default: modified) -K, --kerberos Use Kerberos for authentication -U, --username <username> The username to connect with -P, --password <password> The password to authenticate with -W, --workgroup <workgroup> The workgroup the username is located in -K, --kerberos Use Kerberos for authentication -n, --no-data Do not collect performance data -d, --debug <0-10> Set the debug level for libsmbclient -V, --version Display the version of this script and exit -h, --help Display this usage screen and exit
Warning and Critical Values --------------------------- The returned value for a non-existent file/path is CRITICAL.
A warning or critical value can be a measure of time or size, with a suffix detailing the measure type. The below table is a list of possible measures.
Time | Size -------- --------------- seconds | KB (kilobytes) minutes | MB (megabytes) hours | GB (gigabytes) days |
You can test a few different properties of the file. The below table lists the valid properties.
Property | Description --------- ---------------------- modified | Last modified time accessed | Last accessed time size | Size of the file
File Paths ---------- File paths are checked with forward slashes. So a path to check should be entered with forward slashes and not back slashes, such as...
SomeShare/some_directory/some_file.txt
However, if you enter back slashes the script will attempt to convert them to forward slashes and check the resulting path. Also, you can check hidden and admin shares, such as the system drive, by using a double dollar sign in nagios commands...
C$$/some_directory/some_file.txt
Also note that file path checks are case-insensitive.
TODO/Limitations ---------- * This script does not yet test the size of a directory. * Performance data is a work-in-progress.
Love the script! Had and issues with accessing files in subdirectories so made the following changes to the script: 1. sub-directories in the share 2. added full path to commands used $ diff check_smb_file check_smb_file-orig 18c18 $PROGNAME -H -W -s -f -u -p -S -E 57,59d56 ";; 82c79 onErrorMessage="ERROR: File "//"$host""$sharePathToTest"$fileToTest" does not exists." 89c86 smbclient //"$host""$sharePathToTest" -U "$user"%"$password" -W "$workgroup" -c "get '$fileToTest' /tmp/"$fileToTest"" 92c89 rm -f /tmp/"$fileToTest"
I only changed this: $ diff check_smb_file.pl* 541a542 > next if $filename eq "." or $filename eq ".."; to exclude the local dir and the upper dir because it would report critical every time otherwise (yes, the modified timestamps on those are older, but I do not need to check those ;-) Thanks
You must be logged in to submit a review.
To:
From: