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 +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +64 -4
- data/alerty.gemspec +1 -1
- data/lib/alerty/cli.rb +1 -1
- data/lib/alerty/config.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aebfe7ba5184735ab0d413628384502ce41b3a1
|
4
|
+
data.tar.gz: 47c6100062890783cd3c95cd2a1bb3ea9554396b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427b8bca35c0e644daf46e7dd23cbb0d0bb2d3430dd25aae3608bc1e0780817840d4716b77b04a2441441509631a74fa4c44fc9383204dac829e770394e860dc
|
7
|
+
data.tar.gz: 05f4cf1c8cd05d20926d58943f06fa7464c1197679b41fb77710c8adfefe528ded0ea0762073c3d120e43cad282f2f5748a73ed97669cf90688672697233a48a
|
data/CHANGELOG.md
CHANGED
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/
|
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/
|
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
|
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/
|
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
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/
|
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