log_checker 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/README.md +156 -0
- data/Rakefile +1 -0
- data/lib/log_checker/version.rb +3 -0
- data/log_checker.gemspec +26 -0
- metadata +50 -0
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
# log file checker
|
2
|
+
|
3
|
+
## 基本方針
|
4
|
+
|
5
|
+
* 1.8.7〜2.0.0対応
|
6
|
+
* 前回最終確認ポイントの保持
|
7
|
+
* ファイルサイズが前回最終確認ポイントより小さい場合、ファイルがローテートされたと判断、はじめから実行する
|
8
|
+
* 条件には「文字列」「正規表現」の二つが使える
|
9
|
+
* 条件は可変で複数設定可能
|
10
|
+
* メソッドを同一名で複数回コールするのもOK
|
11
|
+
|
12
|
+
## オプション
|
13
|
+
|
14
|
+
```
|
15
|
+
-t --test 各ファイル 先頭から1Mをパースする(前回実行ポインタを動かさない、出力は強制で標準出力になる)
|
16
|
+
-a --all すべてのデータをパースする(前回実行ポインタを動かさない、出力は強制で標準出力になる)
|
17
|
+
--no-email 上記オプションと対で使う。email設定していても送信しない
|
18
|
+
```
|
19
|
+
|
20
|
+
## 機能
|
21
|
+
|
22
|
+
### 問題行レポート
|
23
|
+
|
24
|
+
基本はホワイトリスト。下記のアルゴリズムで抽出された行をまとめてレポート
|
25
|
+
|
26
|
+
* white(*args) : ホワイトリストを設定する。条件ヒットした行は抽出されない
|
27
|
+
* black(*args) : ブラックリスト。もしその条件がヒットした場合はホワイトリスト条件によって抽出対象外となっていたとしても抽出される
|
28
|
+
* 抽出行がない場合は「(no problem lines)」、 そもそも対象データがない(ファイルサイズが増えてない等)は「(file not changed)」
|
29
|
+
|
30
|
+
### サマリーレポート
|
31
|
+
|
32
|
+
条件を作成してそれにヒットしたもののカウント、合計等を出力する
|
33
|
+
|
34
|
+
* count(:name,*args) : 条件にヒットした回数をカウントする(同一行で複数回ヒットした場合は1回扱い)
|
35
|
+
* sum(:name, *args) : 条件にヒットしたものの$1を数字として合計する(同一行に複数回同一パターンが出てきた場合は頭のみ)
|
36
|
+
* gcount(:name,*args) : countの同一行複数回バージョン
|
37
|
+
* gsum(:name, *args) : sumの同一行複数回バージョン
|
38
|
+
|
39
|
+
|
40
|
+
## 設定ファイル(DSL)
|
41
|
+
|
42
|
+
```
|
43
|
+
# メールでレポートを送信する
|
44
|
+
email do
|
45
|
+
# 送信先
|
46
|
+
to "paco.jp@gmail.com", "someone@example.com"
|
47
|
+
|
48
|
+
# 送信元
|
49
|
+
from "report@examplecom"
|
50
|
+
|
51
|
+
# メールの件名(レポートの一行目) 置換文字列が使える
|
52
|
+
# 下記だと%all_sizeで全ログ中の問題行の行数を置換する
|
53
|
+
subject "logfile report(error:%all_size)"
|
54
|
+
end
|
55
|
+
|
56
|
+
# 最終確認状況の保持ファイルのパス設定
|
57
|
+
# 未設定の場合は「実行DSLファイル名 - 拡張子 + .dat」
|
58
|
+
datfile "/tmp/logcheck_points.dat"
|
59
|
+
|
60
|
+
# 結果出力
|
61
|
+
# 未設定の場合は標準出力
|
62
|
+
# out "/tmp/logcheck_points.log"
|
63
|
+
|
64
|
+
# fileブロックで対象ファイルを設定します
|
65
|
+
# 問題行レポートのみサンプル
|
66
|
+
file "/tmp/batch.log" do
|
67
|
+
name "batch log"
|
68
|
+
white /\[INFO.*?\]/
|
69
|
+
while 'NO_PROBLEM'
|
70
|
+
black 'ERR','CRITICAL' # 可変引数
|
71
|
+
black 'FATAL'
|
72
|
+
end
|
73
|
+
|
74
|
+
# 問題行レポートはいらないサンプル
|
75
|
+
file "/tmp/report.log" do
|
76
|
+
name "report log"
|
77
|
+
gcount "yes count", "YES"
|
78
|
+
end
|
79
|
+
|
80
|
+
# まぜまぜサンプル
|
81
|
+
file "/tmp/money_api.log" do
|
82
|
+
name "api log"
|
83
|
+
|
84
|
+
# whiteを指定すると問題行リポートが作成されます
|
85
|
+
white /\[INFO.*?\]/, 'NO_PROBLEM'
|
86
|
+
black 'ERR','CRITICAL'
|
87
|
+
black 'FATAL' # 複数行に分けてもOK
|
88
|
+
|
89
|
+
# 実行回数と成功回数をとっておく
|
90
|
+
count "process count", 'start subscribe with'
|
91
|
+
count "succeeded count", /\[\d+\] succeeded/
|
92
|
+
|
93
|
+
# 入金レコードをカウント&サマリーしておく
|
94
|
+
count "paid count", /paid:\d+\.\d+/
|
95
|
+
sum "paid summary", /paid:(\d+\.\d+)/
|
96
|
+
end
|
97
|
+
|
98
|
+
=begin
|
99
|
+
|
100
|
+
# 件名で使用可能な置換文字列例
|
101
|
+
|
102
|
+
# 問題行リポートのトータル行数(ログが複数あれば総計)(予約置換文字列)
|
103
|
+
%all_size
|
104
|
+
|
105
|
+
# filenameで指定したログファイルの問題行リポートのトータル行数 "%size_" + name
|
106
|
+
%size_api_log
|
107
|
+
|
108
|
+
# 上で設定したcount:"process count" "%count_" + name
|
109
|
+
%count_process_count
|
110
|
+
|
111
|
+
# 上で設定したsum:"paid summary" "%sum_" + name
|
112
|
+
%sum_paid_summary
|
113
|
+
|
114
|
+
# 上で設定したsum:"yes count" "%gcount_" + name
|
115
|
+
%gcount_yes_count
|
116
|
+
|
117
|
+
=end
|
118
|
+
|
119
|
+
```
|
120
|
+
|
121
|
+
レポートサンプル
|
122
|
+
|
123
|
+
```
|
124
|
+
logfile report(error:5)
|
125
|
+
|
126
|
+
############################################################
|
127
|
+
#### /tmp/batch.log ####
|
128
|
+
############################################################
|
129
|
+
file: /tmp/batch.log
|
130
|
+
--------- lines you need to check ---------
|
131
|
+
(no problem lines)
|
132
|
+
|
133
|
+
############################################################
|
134
|
+
#### report log ####
|
135
|
+
############################################################
|
136
|
+
name: report log
|
137
|
+
file: /tmp/report.log
|
138
|
+
yes_count: 14
|
139
|
+
|
140
|
+
############################################################
|
141
|
+
#### api log ####
|
142
|
+
############################################################
|
143
|
+
name: api log
|
144
|
+
file: /tmp/money_api.log)
|
145
|
+
process count: 100
|
146
|
+
succeeded count: 120
|
147
|
+
paid count: 13
|
148
|
+
paid summary: 2460.23
|
149
|
+
--------- lines you need to check ---------
|
150
|
+
some line you have to check hogehogehogehogehogehogehogehoge hogehogehogehogehogehogehogehoge
|
151
|
+
some line you have to check hogehogehogehogehogehogehogehoge hogehogehogehogehogehogehogehoge
|
152
|
+
some line you have to check hogehogehogehogehogehogehogehoge hogehogehogehogehogehogehogehoge
|
153
|
+
some line you have to check hogehogehogehogehogehogehogehoge hogehogehogehogehogehogehogehoge
|
154
|
+
some line you have to check hogehogehogehogehogehogehogehoge hogehogehogehogehogehogehogehoge
|
155
|
+
|
156
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/log_checker.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "log_checker/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "log_checker"
|
7
|
+
s.version = LogChecker::VERSION
|
8
|
+
s.authors = ["pacojp"]
|
9
|
+
s.email = ["paco.jp@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{ckeck logfile with white list(and more)}
|
12
|
+
s.description = %q{check logfile with white list(and more)}
|
13
|
+
s.rubyforge_project = "log_checker"
|
14
|
+
|
15
|
+
#s.add_dependency "batchbase",["0.0.4"]
|
16
|
+
#s.add_dependency "net-scp"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# s.add_development_dependency "rspec"
|
25
|
+
# s.add_runtime_dependency "rest-client"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: log_checker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- pacojp
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: check logfile with white list(and more)
|
15
|
+
email:
|
16
|
+
- paco.jp@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- lib/log_checker/version.rb
|
25
|
+
- log_checker.gemspec
|
26
|
+
homepage: ''
|
27
|
+
licenses: []
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project: log_checker
|
46
|
+
rubygems_version: 1.8.23
|
47
|
+
signing_key:
|
48
|
+
specification_version: 3
|
49
|
+
summary: ckeck logfile with white list(and more)
|
50
|
+
test_files: []
|