Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_smb_file
0.5
2012-12-16
- Nagios 3.x
GPL
60730
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!
Usage Switches...
-H, --host The hostname to check (required)
-f, --filename The share and path to the file/directory (required)
-F --filename-match Only check filenames matching this regex
-D --mode-directory Treat the filename to check as a directory
-w, --warning Warning if file property exceeds value
-c, --critical Critical if file property exceeds value
-m, --warning-match Warning if contents match regex
-M, --critical-match Critical if contents match regex
-t, --warning-files Warning if the total files detected exceeds value
-T, --critical-files Critical if the total files detected exceeds value
-p, --property The property to test (Default: modified)
-K, --kerberos Use Kerberos for authentication
-U, --username The username to connect with
-P, --password The password to authenticate with
-W, --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.
-H, --host
-f, --filename
-F --filename-match
-D --mode-directory Treat the filename to check as a directory
-w, --warning
-c, --critical
-m, --warning-match
-M, --critical-match
-t, --warning-files
-T, --critical-files
-p, --property
-K, --kerberos Use Kerberos for authentication
-U, --username
-P, --password
-W, --workgroup
-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.
Reviews (2)
bycenovusjim, October 19, 2015
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"
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
$ 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