Search Exchange

Search All Sites

Nagios Log Server Now Available - Download Now

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

check_file_content

Bookmark and Share

Current Version
1.2
Last Release Date
2013-06-18
Compatible With
  • Nagios 3.x
E-mail
License
GPL
Hits
30890
Files:
FileDescription
check_file_content.plnagios plugin
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