This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### | |
| # Handles found errors/warnings/notices | |
| # - Grab all errors in the logged text | |
| # - Parse each pattern for fatals we monitor | |
| # - Shift matched pattern from error list | |
| # - Invoke callback for each match | |
| # - Send anything left over | |
| def parse(constraints, errors, type) | |
| constraints.each do |item, logic| | |
| pattern = logic.first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module LogMailer | |
| require 'fssm' | |
| DEBUG = true | |
| #DEBUG = false | |
| def debug(msg) | |
| DEBUG or return | |
| puts "DEBUG:: #{msg}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root@RHL081:/var/log/php# grep -iP "utf-?8" /var/log/php/*_error_log | |
| /var/log/php/api_error_log:[17-Feb-2011 07:34:52] PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in /opt/www/sites/api/www/ws2.php on line 29 | |
| /var/log/php/artists_error_log:[17-Feb-2011 10:25:35] PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in /opt/www/sites/artists/views/json/ViewGateway.php on line 73 | |
| /var/log/php/facebook_error_log:[17-Feb-2011 07:56:03] PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in /opt/www/sites/facebookSharesong/lib/Common.php on line 32 | |
| /var/log/php/lite_error_log:[17-Feb-2011 05:07:44] PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in /opt/www/sites/cowbell/lib/RPCServer.php on line 111 | |
| /var/log/php/lite_error_log:[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ^Cymek@zedd ~/development/projects/logmailer/bin $ ./lmd run | |
| logmailer.rb: process with pid 9426 started. | |
| DEBUG:: New Log Object: test.log | |
| DEBUG:: Reading from test.log | |
| DEBUG:: Have a frequency constraint... continue | |
| DEBUG:: Frequency not met 1 < 3 | |
| DEBUG:: Reading from test.log | |
| DEBUG:: Have a frequency constraint... continue | |
| DEBUG:: Frequency not met 2 < 3 | |
| DEBUG:: Reading from test.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def parse(constraints, matches) | |
| constraints.each do |constraint| | |
| (matches.find_all { |txt| txt =~ /.*?#{constraint.pattern}.*?/i }).each do |e| | |
| if constraint.frequency[:seconds] > 0 | |
| debug("Have a frequency constraint... continue") | |
| new_timestamp = Time.now.to_i | |
| if new_timestamp - constraint.timestamp >= constraint.frequency[:seconds] | |
| # Reset. Out of timestamp's range (keep the current error as 1 for the new range) | |
| constraint.count = 1 | |
| constraint.timestamp = new_timestamp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Thu Feb 24 13:21:52 2011] [error] [client 172.16.202.86] PHP Notice: Use of undefined constant APP_LIB_PATH - assumed 'APP_LIB_PATH' in /opt/www/sites/panda-cave/stdlib.php on line 54 | |
| [Thu Feb 24 13:21:52 2011] [error] [client 172.16.202.86] PHP Fatal error: Class 'DBex' not found in /opt/www/conf/production/cpool.php on line 18 | |
| [Thu Feb 24 13:21:52 2011] [error] [client 172.16.202.86] PHP Notice: Use of undefined constant APP_LIB_PATH - assumed 'APP_LIB_PATH' in /opt/www/sites/panda-cave/stdlib.php on line 54 | |
| [Thu Feb 24 13:21:52 2011] [error] [client 172.16.202.86] PHP Fatal error: Class 'DBex' not found in /opt/www/conf/production/cpool.php on line 18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # After the package is installed; | |
| # - set up the service | |
| # - set up the init script | |
| # - set up the configuration file | |
| # - (re)start the service | |
| (1..2).each do |i| | |
| template "/etc/init.d/mongos#{i}" do | |
| source "mongos.erb" | |
| mode 0644 | |
| owner 'root' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module LogMailer | |
| class Summary | |
| attr_accessor :logged | |
| def initialize() | |
| @enabled = false | |
| @logged = "" | |
| @error_count = 0 | |
| @frequency = { :seconds => 20, :amount => 30 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### | |
| # We can change C-style if-statements to something more legible in Ruby | |
| # though it's likely a few cycles less efficient | |
| ### | |
| # From this... | |
| if @project_name == 'cowbell' or @project_name == 'aquarium' or @project_name == 'weblib' or @project_name == 'tinysong' or @project_name == 'conf' or @project_name == 'html5' or @project_name == 'conf' | |
| # do something... | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $LOAD_PATH.unshift File.dirname(__FILE__) | |
| # | |
| # Debugging method and flag | |
| #DEBUG = false | |
| DEBUG = true | |
| def debug(msg) | |
| DEBUG or return | |
| puts "DEBUG:: #{msg}" | |
| end |