sensucronic 0.1.0 → 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/README.md +29 -10
- data/lib/sensucronic.rb +15 -1
- data/lib/sensucronic/version.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: 9e01cc5d1c42a8bd017202854743c02ce9f898d8
|
4
|
+
data.tar.gz: 3391b35378ab5cb3af477a40ae9c71b10274e9fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a92ee79252c5e4dec6b1fe7587db98d4ed5cb7b0fe1fe896ae95789b5f571cd7af53933c220011b95905a68e6b84bf757fcf51d2d1b187330a3a200bb291e95
|
7
|
+
data.tar.gz: d56e75d329047d178d736861c29675a297d737dc385f8d5da9db113db53bafd2c58034b9b695e040dfc630f3b84210059e6013d495a4d4ad2bdf57f307b04732
|
data/README.md
CHANGED
@@ -8,8 +8,6 @@ sensu ecosystem
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
TODO: release gem so this works.
|
12
|
-
|
13
11
|
Add this line to your application's Gemfile:
|
14
12
|
|
15
13
|
```ruby
|
@@ -36,6 +34,19 @@ sensucronic [ OPTIONS ] [ -- ] 'COMMAND [ ARGS ]'
|
|
36
34
|
sensucronic runs COMMAND with ARGS it generates a json report and submits
|
37
35
|
it to the sensu-client input socket
|
38
36
|
|
37
|
+
use --help to view options
|
38
|
+
```
|
39
|
+
prompt% sensucronic --help
|
40
|
+
s@otfess-3-1645% bundle exec exe/sensucronic --help
|
41
|
+
Usage: sensucronic (options)
|
42
|
+
-d, --dry-run output result to stdout only
|
43
|
+
-f, --field "key: value" add a field to the json report
|
44
|
+
-h, --help print this message
|
45
|
+
-p, --port PORT the port number for the sensu client input socket
|
46
|
+
-s, --source SOURCE set the source attribute on the sensu result
|
47
|
+
|
48
|
+
```
|
49
|
+
|
39
50
|
the OPTION --dryrun causes sensucronic to issue it's report to stdout
|
40
51
|
instead of the sensu client input socket.
|
41
52
|
|
@@ -92,19 +103,27 @@ prompt% sensucronic --dry-run 'exit 3'
|
|
92
103
|
|
93
104
|
```
|
94
105
|
|
95
|
-
|
106
|
+
the option --field allows you to add arbitrary attributes to the json
|
107
|
+
report. you can repeat it as often as you need. note that you can't override the built in fields.
|
108
|
+
|
96
109
|
```
|
97
|
-
prompt% sensucronic --
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
110
|
+
prompt% sensucronic --field 'team: blah' --field foo:bar --field output:blah --dry-run 'echo hi; exit 20'
|
111
|
+
{
|
112
|
+
"command": "echo\\ hi\\;\\ exit\\ 20",
|
113
|
+
"output": "hi\n",
|
114
|
+
"status": 3,
|
115
|
+
"exitcode": 20,
|
116
|
+
"agent": "sensucronic",
|
117
|
+
"team": "blah",
|
118
|
+
"foo": "bar"
|
119
|
+
}
|
103
120
|
```
|
104
121
|
|
122
|
+
|
105
123
|
## TODO
|
106
|
-
- accept options to add extra fields to the output
|
107
124
|
- accept options to configure the status in response to the exitcodes. (always warn, always crit )
|
125
|
+
- allow specifying alternate host, currently the sensu agent must be running on the local box.
|
126
|
+
- maybe submit via http to client http api on another host
|
108
127
|
|
109
128
|
## Development
|
110
129
|
|
data/lib/sensucronic.rb
CHANGED
@@ -15,6 +15,13 @@ class Sensucronic
|
|
15
15
|
:default => false,
|
16
16
|
:description => 'output result to stdout only'
|
17
17
|
|
18
|
+
option :field,
|
19
|
+
:short => '-f "key: value"',
|
20
|
+
:long => '--field "key: value"',
|
21
|
+
:default => [],
|
22
|
+
:proc => proc { |f,cur| cur << f },
|
23
|
+
:description => 'add a field to the json report'
|
24
|
+
|
18
25
|
option :port,
|
19
26
|
:short => '-p PORT',
|
20
27
|
:long => '--port PORT',
|
@@ -115,16 +122,23 @@ class Sensucronic
|
|
115
122
|
end
|
116
123
|
end
|
117
124
|
|
125
|
+
def fields
|
126
|
+
config[:field]
|
127
|
+
.map { |f| f.split(/:\s*/,2) }
|
128
|
+
.each_with_object({}) { |(k,v), h| h[k.to_sym] = v }
|
129
|
+
end
|
130
|
+
|
118
131
|
def report
|
119
132
|
{
|
120
133
|
command: Shellwords.shelljoin(cli_arguments),
|
121
134
|
output: output,
|
122
135
|
status: sensu_status,
|
123
136
|
exitcode: exitcode,
|
124
|
-
agent: self.class.to_s.downcase
|
137
|
+
agent: self.class.to_s.downcase,
|
125
138
|
}.tap do |r|
|
126
139
|
r[:exitsignal] = status.termsig if status.termsig
|
127
140
|
r[:source] = config[:source] if config[:source]
|
141
|
+
r.update(fields) { |k,o,n| o }
|
128
142
|
end
|
129
143
|
end
|
130
144
|
|
data/lib/sensucronic/version.rb
CHANGED