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_file_content

Current Version
1.2
Last Release Date
2013-06-18
Compatible With
  • Nagios 3.x
License
GPL
Hits
60120
Files:
FileDescription
check_file_content.plnagios plugin
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!
Check if a string or a chain provided by -s option is present in a file
which is critical when the number of founded line(s) is bigger than one provided by -c option.
It works with local file or with file on cifs sharing with smb protocol, in the futur, it would be on nfs, sftp, ftp etc ...
This plugin requires that perl, perl-Filesys-SmbClient package are installed on the system.
Under RHEL/CentOS or Fedora : yum --enablerepo=rpmforge install perl-Filesys-SmbClient
Exit 0 on success, providing some information
Exit 2 on failure.
Usage: ./check_file_content.pl -f -P [-u -p -d ] -s <"search_expression"> -t [-w -c ] -V
-h, --help
print this help message
-f, --filepath=PATHTOFILENAME
full path to file to analyze
-P, --protocol=PROTOCOL
protocol used to acess file :
LOCAL for local file (default),
SMB for CIFS file
-u, --user=USER
user to login
-p, --password=PASSWORD
password
-d, --domain=DOMAIN
domain name
-s, --search="EXPRESSION", expression to search in the specified file if check_type INCLUDE, if not, this is the expression to not find
-x, --exception="EXPRESSION", exception expression to search in the specified file if check_type INCLUDE, if not, this is the expression to not search
-t, --check_type=TYPE
Type of search :
INCLUDE for include at least the critical option, then the warning option
EXCLUDE for exclude with a maximum of founded expression smaller than critical option
-w, --warn=INTEGER
number that will cause a warning
-c, --critical=INTEGER
number that will cause an error (Default: 1)
-V, --version
prints version number
Note :
The script will return
* With warn and critical options:
OK if we are able to found expression and the count result respect and depending check_type,
WARNING if we are able to found expression and the count result unrespect and depending check_type,
CRITICAL if we are able to found expression and the count result unrespect and depending check_type,
UNKNOWN if we aren't able to read the file

Commands.cfg :

# 'check_file_content' command definition
define command{
command_name check_file_content
command_line $USER1$/check_file_content.pl -f $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$ -t $ARG6$ -s $ARG7$ -w $ARG8$ -c $ARG9$
}


# 'check_file_content_with_exception' command definition
define command{
command_name check_file_content_with_exception
command_line $USER1$/check_file_content.pl -f $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$ -t $ARG6$ -s $ARG7$ -x $ARG8$ -w $ARG9$ -c $ARG10$
}

Services.cfg :

define service{
use generic-service
host_name my_file_server
service_description Include at least 4 instances of "Provider : OK" in mytest.log
check_command check_file_content!smb://server/dir/file.log!SMB!user!password!domain!INCLUDE!"Provider : OK"!5!3
normal_check_interval 10
}

define service{
use generic-service
host_name my_file_server
service_description Include at least 4 instances of "Provider : OK" in mytest.log with an exception
check_command check_file_content_with_exception!smb://server/dir/file.log!SMB!user!password!domain!INCLUDE!"Provider : OK"!"Provider : OK but i m not sure"!5!3
normal_check_interval 10
}

For more informations : http://www.slobberbone.net/dotclear/index.php?pages/check_file_content
Reviews (3)
Where can i find: smb_file_contend?
bynens63, September 15, 2015
./check_smb_file_content -f smb://w.x.y.z/Directory/file.txt -P SMB -u login -p password -s search_expression -t INCLUDE -w 1 -c 10
bysvamberg, September 15, 2015
1 of 1 people found this review helpful
This plugin needs small patch:
--- check_file_content.pl.orig 2015-09-15 13:44:43.941945012 +0200
+++ check_file_content.pl 2015-09-15 13:42:31.572945415 +0200
@@ -56,7 +56,7 @@
my $o_user= undef; # user
my $o_password= undef; # password
my $o_domain= undef; # domain
-my @o_search= undef; # word or chain we search
+my @o_search= (); # word or chain we search
my @o_exception= undef; # exception word or chain we not search
my $o_check_type= undef; # check type
my $o_version= undef; # print version
@@ -288,7 +288,7 @@

# Should match
foreach (@o_search) {
- if ($line =~ m/@o_search/) {
+ if ($line =~ m/$_/) {
if ($exception==1) {
if ($line =~ m/@o_exception/) {
$found=0;