sensu-plugins-json-mutator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 84175624864453c65ec0f511e94cdcfc19c6c360
4
+ data.tar.gz: 235b149a1a3dbbf7b682cebf366f973ec41556fa
5
+ SHA512:
6
+ metadata.gz: a3eb9db8f3889ef8e7e7cd79566a49e9f9550a44617bd242f712c6c8885ca207c3fd5874b027cb703b4acde990a5acb9feeea05d7643d4232615195a84531b52
7
+ data.tar.gz: 6533c92d23fde011ecf8518d98d780ba801217407d1ee39a90cf6d060ea02778c3649b8cb140496a237ab2e611af08b59479ac63c75d59d95f6aff3faf27de75
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Yuri Artemev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ ## Sensu-Plugins-json-mutator
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-json-mutator.svg)](http://badge.fury.io/rb/sensu-plugins-json-mutator)
4
+
5
+ ## Functionality
6
+
7
+ **mutator-json** accepts Graphite or Statsd output and transforms it to json format.
8
+
9
+ ## Files
10
+ * bin/mutator-json.rb
11
+
12
+ ## Usage
13
+
14
+ ## Installation
15
+
16
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
17
+
18
+ ## Notes
@@ -0,0 +1,40 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # mutator-json
5
+ #
6
+ # DESCRIPTION:
7
+ # Accepts Graphite or Statsd output and transforms it to json format
8
+ #
9
+ # OUTPUT:
10
+ # json
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+
18
+ require 'json'
19
+
20
+ GRAPHITE = /([\w\.]+)\s(.+).*/ # sample.key 42.13 1462521982
21
+ STATSD = /([\w\.]+):(.*)\|.*/ # sample.key:42.13|kv
22
+
23
+ def parse_lines(lines, regexp)
24
+ kv = {}
25
+
26
+ lines.each do |line|
27
+ result = line.match(regexp)
28
+ kv[result[1]] = result[2].to_f if result
29
+ end
30
+
31
+ kv
32
+ end
33
+
34
+ event = JSON.parse(STDIN.read)
35
+ lines = event['check']['output'].lines
36
+
37
+ event['check']['output'] = parse_lines(lines, GRAPHITE) if lines.first =~ GRAPHITE
38
+ event['check']['output'] = parse_lines(lines, STATSD) if lines.first =~ STATSD
39
+
40
+ puts JSON.dump(event)
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-json-mutator/version'
@@ -0,0 +1,3 @@
1
+ module SensuPluginsJSONMutator
2
+ VERSION = '0.1.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-json-mutator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ - Yuri Artemev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-05-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sensu-plugin
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.7'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.7'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.1'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.1'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.37'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.37'
84
+ description:
85
+ email: i@artemeff.com
86
+ executables:
87
+ - mutator-json.rb
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - LICENSE
92
+ - README.md
93
+ - bin/mutator-json.rb
94
+ - lib/sensu-plugins-json-mutator.rb
95
+ - lib/sensu-plugins-json-mutator/version.rb
96
+ homepage: https://github.com/artemeff/sensu-plugins-json-mutator
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ maintainer: "@artemeff"
101
+ development_status: active
102
+ production_status: unstable - testing recommended
103
+ release_draft: 'false'
104
+ release_prerelease: 'false'
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: 1.9.3
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Sensu plugin for mutating Graphite and Statsd output
125
+ test_files: []