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_pattern

Current Version
1
Last Release Date
2013-10-21
Compatible With
  • Nagios 3.x
Owner
License
GPL
Hits
33718
Files:
FileDescription
check_pattern.pycheck file for pattern
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 file for pattern
Written in Python 2.6
check_pattern is used to scan the lines of a file for expressions used in python.
It allow to schedule check on several time and send matched result to file or mail to recipient

Usage: check_pattern.py [options]

Options:
-h, --help show this help message and exit
-p, --showpattern show pattern help
-n NAME, --name=NAME name your search (Ex: errors, monster... one at time)
-f FILE, --file=FILE file location
-s TIMES, --schedule=TIMES
STARTTIME-ENDTIME (Ex: 07:00-17:45,19:00-20:00)
default: 00:00-23:59
-o OFFDAY, --off=OFFDAY
exclude days (Ex: Sunday,Saturday)
default: None
-e ERRORS, --error=ERRORS
error patterns to search (Ex: "error|caused by" OR
"^server" OR etc.)
-i, --ignorecase ignore case sensitive
-q, --quite do not print matched search
--line=LINE number of last lines to check. Default: entire file
--outfile=OUTFILE output result to FILE
--mailto=OUTMAIL send result to RECIPIENT (use "mail" command)
Reviews (1)
--line= number of last lines to check. Default: entire file

For this function to work and have the script check the last lines of the file instead of the first lines of the file.

Replace:
for i in reversed(range(0, opts.line)):#search for pattern

With:
for i in reversed(range((len(out)-int(opts.line)), len(out))):#search for pattern