riemann-sockstat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/LICENSE +21 -0
- data/README.md +4 -0
- data/bin/riemann-sockstat +41 -0
- data/riemann-sockstat.gemspec +22 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 10c29d538de8c1721903198c26fe05e8c2324a51
|
4
|
+
data.tar.gz: 456c1a61eba939345b2c2e514a1353a5fa9e388e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 976a61e43568fa99fdd8385e95c86e9cbe969194615451a785904da7c77d035aa4f832afb1b2c30619b4d7ac35fc8e1981b29f274f86beee1ce0350e739c9eef
|
7
|
+
data.tar.gz: 145b32a0da0f3a05224123d433c37cd1903b384c3eb8c0743da4b66be807247e294b3375542b5b1eabe8188736d7ef812eed9321200acf4a93164fda54451464
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2015 Fernando Alonso
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Riemann agent to collect sockstat metrics
|
4
|
+
|
5
|
+
require 'riemann/tools'
|
6
|
+
|
7
|
+
class Riemann::Tools::Sockstat
|
8
|
+
include Riemann::Tools
|
9
|
+
|
10
|
+
TCP_METRICS = %w{ inuse orphan tw alloc mem }.freeze
|
11
|
+
UDP_METRICS = %w{ inuse mem }.freeze
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@collect_tcp = true
|
15
|
+
end
|
16
|
+
|
17
|
+
def tick
|
18
|
+
raw_stats = `cat /proc/net/sockstat`
|
19
|
+
|
20
|
+
collect_tcp(raw_stats) if @collect_tcp
|
21
|
+
end
|
22
|
+
|
23
|
+
def collect_tcp(raw_stats)
|
24
|
+
stats = raw_stats.match(/TCP:\sinuse\s(\d+)\sorphan\s(\d+)\stw\s(\d+)\salloc\s(\d+)\smem\s(\d+)/).captures
|
25
|
+
report_stats('tcp', Hash[*TCP_METRICS.zip(stats).flatten])
|
26
|
+
end
|
27
|
+
|
28
|
+
def report_stats(sock_kind, stats)
|
29
|
+
stats.each_pair do |k, v|
|
30
|
+
report({
|
31
|
+
service: "#{sock_kind}_#{k}",
|
32
|
+
metric: v.to_i,
|
33
|
+
state: 'ok',
|
34
|
+
tags: ['sockstat'],
|
35
|
+
description: ''
|
36
|
+
})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Riemann::Tools::Sockstat.run
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "riemann-sockstat"
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["Fernando Alonso"]
|
9
|
+
spec.email = ["krakatoa1987@gmail.com"]
|
10
|
+
spec.summary = %q{Riemann agent to collect sockstat metrics}
|
11
|
+
spec.description = %q{Riemann agent to collect sockstat metrics}
|
12
|
+
spec.homepage = "https://github.com/krakatoa/riemann-sockstat"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "riemann-tools", "~> 0.2.6"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riemann-sockstat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fernando Alonso
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: riemann-tools
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
description: Riemann agent to collect sockstat metrics
|
42
|
+
email:
|
43
|
+
- krakatoa1987@gmail.com
|
44
|
+
executables:
|
45
|
+
- riemann-sockstat
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- bin/riemann-sockstat
|
53
|
+
- riemann-sockstat.gemspec
|
54
|
+
homepage: https://github.com/krakatoa/riemann-sockstat
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.4.8
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Riemann agent to collect sockstat metrics
|
78
|
+
test_files: []
|