macklog 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -3
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +26 -21
- data/lib/macklog.rb +2 -1
- data/lib/macklog/cli.rb +12 -8
- data/lib/macklog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22fe76b55d8c6450f3e716762e69f4c5b8636cf9
|
4
|
+
data.tar.gz: 0b995005bfaedede0731ff180d06ddc0c78cb6cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cea8c1711ad4402114474f59ed5f6134d0ebb481f73b9202996af51fd079b2e917b9cf3a420d090f952f60e07335c0b2e2b90ebe8bcdc9d09db7ce0a5a8a0c7
|
7
|
+
data.tar.gz: a2e6dfb20e815c3490142d7c8166194ac3f7933332581aa094768f08281db68942548b5d4d18a51f47aa2538dd2a9a829d376728b483df69ebaf3776a41566f7
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
mackerelのログ監視プラグインです。
|
8
|
-
|
8
|
+
指定したファイルに指定したワードが出力された場合、アラートを出力します。
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem
|
13
|
+
gem install macklog
|
14
14
|
```
|
15
15
|
|
16
16
|
## Usage
|
@@ -24,7 +24,8 @@ command = "macklog -f /var/log/httpd/error.log -w fatal -i"
|
|
24
24
|
### options
|
25
25
|
```
|
26
26
|
-f : 対象ファイル
|
27
|
-
-w :
|
27
|
+
-w : warningキーワード
|
28
|
+
-c : criticalキーワード
|
28
29
|
-i : 大文字小文字を区別しない
|
29
30
|
```
|
30
31
|
|
data/coverage/.last_run.json
CHANGED
data/coverage/.resultset.json
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
1,
|
12
12
|
1,
|
13
13
|
1,
|
14
|
+
1,
|
14
15
|
null
|
15
16
|
],
|
16
17
|
"/Users/yamashitakazuhiko/src/github.com/pyama86/macklog/lib/macklog/cli.rb": [
|
@@ -23,61 +24,65 @@
|
|
23
24
|
1,
|
24
25
|
1,
|
25
26
|
1,
|
27
|
+
1,
|
26
28
|
null,
|
27
29
|
null,
|
28
30
|
null,
|
29
31
|
null,
|
30
32
|
null,
|
31
33
|
null,
|
32
|
-
|
34
|
+
10,
|
33
35
|
null,
|
34
|
-
|
36
|
+
10,
|
35
37
|
1,
|
36
38
|
1,
|
37
39
|
null,
|
38
|
-
|
39
|
-
5,
|
40
|
-
null,
|
40
|
+
9,
|
41
41
|
5,
|
42
|
-
2,
|
43
|
-
null,
|
44
|
-
null,
|
45
42
|
null,
|
46
43
|
1,
|
47
44
|
1,
|
48
|
-
|
45
|
+
1,
|
46
|
+
11,
|
47
|
+
11,
|
49
48
|
null,
|
50
|
-
2,
|
51
49
|
null,
|
52
|
-
|
50
|
+
1,
|
51
|
+
11,
|
53
52
|
null,
|
54
53
|
5,
|
55
54
|
null,
|
55
|
+
6,
|
56
|
+
null,
|
57
|
+
11,
|
58
|
+
null,
|
56
59
|
null,
|
57
60
|
1,
|
58
|
-
|
59
|
-
|
61
|
+
6,
|
62
|
+
6,
|
60
63
|
null,
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
6,
|
65
|
+
6,
|
66
|
+
6,
|
64
67
|
null,
|
65
68
|
0,
|
66
69
|
null,
|
67
70
|
null,
|
68
71
|
null,
|
69
72
|
1,
|
70
|
-
|
71
|
-
|
73
|
+
6,
|
74
|
+
6,
|
72
75
|
null,
|
73
76
|
null,
|
74
77
|
null,
|
75
78
|
1,
|
76
|
-
|
77
|
-
|
79
|
+
7,
|
80
|
+
7,
|
78
81
|
null,
|
79
82
|
2,
|
80
83
|
null,
|
84
|
+
4,
|
85
|
+
null,
|
81
86
|
1,
|
82
87
|
null,
|
83
88
|
0,
|
@@ -91,6 +96,6 @@
|
|
91
96
|
null
|
92
97
|
]
|
93
98
|
},
|
94
|
-
"timestamp":
|
99
|
+
"timestamp": 1438087132
|
95
100
|
}
|
96
101
|
}
|
data/lib/macklog.rb
CHANGED
data/lib/macklog/cli.rb
CHANGED
@@ -4,7 +4,8 @@ module Macklog
|
|
4
4
|
class Cli < Thor
|
5
5
|
desc "check", "check log"
|
6
6
|
option :file, :type => :string , :required => true, :aliases => '-f'
|
7
|
-
option :
|
7
|
+
option :critical, :type => :string, :aliases => '-c'
|
8
|
+
option :warning, :type => :string, :aliases => '-w'
|
8
9
|
option :ignorecase , :type => :boolean, :aliases => '-i'
|
9
10
|
def check
|
10
11
|
# exit code
|
@@ -19,15 +20,16 @@ module Macklog
|
|
19
20
|
puts "#{file_path} not found!"
|
20
21
|
exit_status 3
|
21
22
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
if result && !notified?(file_path, result)
|
26
|
-
exit_status 2
|
27
|
-
end
|
23
|
+
check_log(file_path, options[:critical], 2, options[:ignorecase]) if options[:critical]
|
24
|
+
check_log(file_path, options[:warning], 1, options[:ignorecase]) if options[:warning]
|
28
25
|
end
|
29
26
|
default_task :check
|
30
27
|
no_tasks do
|
28
|
+
def check_log(file_path, word, status, ignore)
|
29
|
+
result = log_search(file_path, word, ignore)
|
30
|
+
exit_status status if result && !notified?(file_path, result)
|
31
|
+
end
|
32
|
+
|
31
33
|
def log_search(file_path, word, ignore=nil)
|
32
34
|
result = case
|
33
35
|
when ignore
|
@@ -59,8 +61,10 @@ module Macklog
|
|
59
61
|
def exit_status(status)
|
60
62
|
if ENV["MALTCH_TEST"]
|
61
63
|
case status
|
64
|
+
when 1
|
65
|
+
raise(Macklog::Warning)
|
62
66
|
when 2
|
63
|
-
raise(Macklog::
|
67
|
+
raise(Macklog::Critical)
|
64
68
|
when 3
|
65
69
|
raise(Macklog::FileNotFound)
|
66
70
|
else
|
data/lib/macklog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macklog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kazuhiko yamahsita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|