Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
Searches log files for a patterns loaded from a pattern file. Usage check_in_logfiles.py :
Current Version
1.0
Last Release Date
2015-05-10
Owner
Imran Ahmed
License
GPL
Compatible With
Nagios plugin that searches log files for a patterns loaded from a pattern file. Usage check_in_logfiles.py : <patfile> <logfile> First argument PATTERNFILE is a text file containing lines of the form: SEVERITY:PATTERN Where *SEVERITY* is one of `IGNORE`, `WARNING`, `CRITICAL` and *PATTERN* is a regular expression. Second (and later) argument LOGFILE is the path to one (or more) log files. If a line is found that matches a *PATTERN* with *SEVERITY* `CRITICAL`, exit with CRITICAL status If a line is found that matches a *PATTERN* with *SEVERITY* `WARNING`, exit with WARNING status
Hi, Hope you don't mind. I modified the code a bit. Seemed that when everything was OK, Nagios failed display data. #!/usr/bin/env python # Check_log_files.py # Author: Imran Ahmed # Description: Nagios plugin that searches log files for a patterns loaded from a pattern file. # Usage check_in_logfiles.py : # First argument PATTERNFILE is a text file containing lines of the form: # SEVERITY:PATTERN # where *SEVERITY* is one of `IGNORE`, `WARNING`, `CRITICAL` and *PATTERN* is a # regular expression. # Second (and later) argument LOGFILE is the path to one (or more) log files. # if a line is found that matches a *PATTERN* with *SEVERITY* `CRITICAL`, # exit with CRITICAL status # if a line is found that matches a *PATTERN* with *SEVERITY* `WARNING`, # exit with WARNING status import sys, re def popLists(file): with open(file, 'r') as myPatFile: lines = myPatFile.readlines() critical = [] warning = [] ok = [] for line in lines: line = line.strip() words = line.split(":") if (words[0] =='CRITICAL'): critical.append(words[1]) elif (words[0] =='WARNING'): warning.append(words[1]) elif (words[0] =='OK'): ok.append(words[1]) else: print "Everything is cool!" return critical, warning, ok def main(): argc = len(sys.argv) if argc main()
You must be logged in to submit a review.
To:
From:
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!