alerty 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37200c7df937b8b93002b2ef0e988b49f0704482
4
- data.tar.gz: 02a87bf6ae0a11ad405f2a9e9c518cdaa3b613d8
3
+ metadata.gz: 3aebfe7ba5184735ab0d413628384502ce41b3a1
4
+ data.tar.gz: 47c6100062890783cd3c95cd2a1bb3ea9554396b
5
5
  SHA512:
6
- metadata.gz: 3970c46b9de3142aa6d459de8657a8ffc86c3d1e5bd9219d47700e8918e27b1b3252a5ade20b149217b047fb81ea3fea5d2f15eb5ae75a18ec625c7ef0e688f3
7
- data.tar.gz: 6c90bdd66aa9714bfbc48cc80c7d54750e7666b4d2df64942225aa6600e15664db6e29dde59f34149e9ed9f25732f4afb05f4da929f060092b3f6d9b2d46a411
6
+ metadata.gz: 427b8bca35c0e644daf46e7dd23cbb0d0bb2d3430dd25aae3608bc1e0780817840d4716b77b04a2441441509631a74fa4c44fc9383204dac829e770394e860dc
7
+ data.tar.gz: 05f4cf1c8cd05d20926d58943f06fa7464c1197679b41fb77710c8adfefe528ded0ea0762073c3d120e43cad282f2f5748a73ed97669cf90688672697233a48a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- # 0.0.3 (2015/08/14)
1
+ # 0.0.5 (2015/08/14)
2
+
3
+ Changes:
4
+
5
+ * Change default conf path from /etc/sysconfig/alerty to /etc/alerty/alerty.yml
6
+
7
+ # 0.0.4 (2015/08/14)
2
8
 
3
9
  Enchancements:
4
10
 
data/README.md CHANGED
@@ -7,7 +7,7 @@ A CLI utility to send an alert if a given command failed.
7
7
  I use `alerty` to run commands in cron to send alerts if cron commands fail.
8
8
 
9
9
  ```
10
- 0 * * * * alerty -c /etc/sysconfig/alerty -- /path/to/script --foo FOO --bar
10
+ 0 * * * * alerty -c /etc/alerty/alerty.yml -- /path/to/script --foo FOO --bar
11
11
  ```
12
12
 
13
13
  ## Installation
@@ -18,7 +18,7 @@ gem install alerty
18
18
 
19
19
  ## Configuration
20
20
 
21
- You can write a configuration file located at `/etc/sysconfig/alerty` (You can configure this path by `ALERTY_CONFIG_FILE` environment variable, or `-c` option):
21
+ You can write a configuration file located at `/etc/alerty/alerty.yml` (You can configure this path by `ALERTY_CONFIG_FILE` environment variable, or `-c` option):
22
22
 
23
23
  ```
24
24
  log_path: STDOUT
@@ -29,7 +29,7 @@ plugins:
29
29
  - type: stdout
30
30
  ```
31
31
 
32
- [example/alerty.yml](./example/alerty.yml)
32
+ [example.yml](./example.yml)
33
33
 
34
34
  ### CLI Example
35
35
 
@@ -41,7 +41,7 @@ $ alerty -c example.yml -- ls -l /something_not_exist
41
41
 
42
42
  ```
43
43
  $ bin/alerty -h
44
- -c, --config CONFIG_FILE config file path (default: /etc/sysconfig/alerty)
44
+ -c, --config CONFIG_FILE config file path (default: /etc/alerty/alerty.yml)
45
45
  --log LOG_FILE log file path (default: STDOUT)
46
46
  --log-level LOG_LEVEL log level (default: warn
47
47
  -t, --timeout SECONDS timeout the command (default: no timeout)
@@ -56,6 +56,66 @@ Following plugins are available:
56
56
  * [file](./lib/alerty/plugin/file.rb)
57
57
  * [exec](./lib/alerty/plugin/exec.rb)
58
58
  * [alerty-plugin-ikachan](https://github.com/sonots/alerty-plugin-ikachan)
59
+ * [alerty-plugin-amazon_sns](https://github.com/sonots/alerty-plugin-amazon_sns)
60
+
61
+ ## Plugin Architecture
62
+
63
+ ### Naming Convention
64
+
65
+ You must follow the below naming conventions:
66
+
67
+ * gem name: alerty-plugin-xxx (xxx_yyy)
68
+ * file name: lib/alerty/plugin/xxx.rb (xxx_yyy.rb)
69
+ * class name: Alerty::Plugin:Xxx (XxxYyy)
70
+
71
+ ### Interface
72
+
73
+ What you have to implement is `#initialize` and `#alert` methods. Here is an example of `file` plugin:
74
+
75
+ ```ruby
76
+ require 'json'
77
+
78
+ class Alerty
79
+ class Plugin
80
+ class File
81
+ def initialize(config)
82
+ raise ConfigError.new('file: path is not configured') unless config.path
83
+ @path = config.path
84
+ end
85
+
86
+ def alert(record)
87
+ ::File.open(@path, 'a') do |io|
88
+ io.puts record.to_json
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ ```
95
+
96
+ ### config
97
+
98
+ `config` is created from the configuration file:
99
+
100
+ ```
101
+ plugins:
102
+ - type: foobar
103
+ key1: val1
104
+ key2: val2
105
+ ```
106
+
107
+ `config.key1` and `config.key2` are availabe in the above config.
108
+
109
+ ### record
110
+
111
+ `record` is a hash whose keys are
112
+
113
+ * hostname: hostname
114
+ * command: the executed command
115
+ * exitstatus: the exit status of the executed command
116
+ * output: the output of the exectued command
117
+ * started_at: the time when command executed in epoch time.
118
+ * duration: the duration which the command execution has taken in seconds.
59
119
 
60
120
  ## ChangeLog
61
121
 
data/alerty.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "alerty"
3
- gem.version = '0.0.4'
3
+ gem.version = '0.0.5'
4
4
  gem.author = ['Naotoshi Seo']
5
5
  gem.email = ['sonots@gmail.com']
6
6
  gem.homepage = 'https://github.com/sonots/alerty'
data/lib/alerty/cli.rb CHANGED
@@ -16,7 +16,7 @@ class Alerty
16
16
  end
17
17
 
18
18
  opts = {}
19
- op.on('-c', '--config CONFIG_FILE', "config file path (default: /etc/sysconfig/alerty)") {|v|
19
+ op.on('-c', '--config CONFIG_FILE', "config file path (default: /etc/alerty/alerty.yml)") {|v|
20
20
  opts[:config_path] = v
21
21
  }
22
22
  op.on('--log LOG_FILE', "log file path (default: STDOUT)") {|v|
data/lib/alerty/config.rb CHANGED
@@ -11,7 +11,7 @@ class Alerty
11
11
  end
12
12
 
13
13
  def config_path
14
- @config_path ||= opts[:config_path] || ENV['ALERTY_CONFIG_PATH'] || '/etc/sysconfig/alerty'
14
+ @config_path ||= opts[:config_path] || ENV['ALERTY_CONFIG_PATH'] || '/etc/alerty/alerty.yml'
15
15
  end
16
16
 
17
17
  def config
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alerty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo