sensu-plugins-snmp 0.0.4 → 0.1.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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +6 -0
- data/README.md +3 -2
- data/bin/check-snmp-disk.rb +130 -0
- data/bin/metrics-snmp-bulk.rb +1 -1
- data/bin/metrics-snmp-if.rb +1 -1
- data/lib/sensu-plugins-snmp/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +10 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f7350b0daf73bd6077d7407eedcc0fcd8c996b0
|
4
|
+
data.tar.gz: 60155093f565f86579df5fb82819a12b36517107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b793699f8c01672a2fee7572737a5037ed8472676016d77e9898d7849534f54a9d2c942e3113578c4b8950eafb8ba15e5fe46523b15a94d57600c5afb499818a
|
7
|
+
data.tar.gz: 80311ba562bf6c80dc7464555d558d98d7fcb9bbe555972cfa570c1a533f4d46c156acbba4e1f0660d70d00388e8eb45dea0ccc6aea06364ffd26c3bdfe51b00
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
|
+
## Unreleased
|
7
|
+
|
8
|
+
## [0.1.0] - 2015-11-13
|
9
|
+
### Added
|
10
|
+
- Added a script check-snmp-disk, that checks disk utilization using SNMP
|
11
|
+
|
6
12
|
## [0.0.4] - 2015-07-22
|
7
13
|
### Fixed
|
8
14
|
- Fixed graphite output when using a prefix in metrics-snmp-bulk.rb
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## Sensu-Plugins-snmp
|
2
2
|
|
3
|
-
[
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-snmp)
|
4
4
|
[](http://badge.fury.io/rb/sensu-plugins-snmp)
|
5
5
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-snmp)
|
6
6
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-snmp)
|
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
## Files
|
13
13
|
* bin/check-snmp.rb
|
14
|
+
* bin/check-snmp-disk.rb
|
14
15
|
* bin/metrics-snmp-bulk.rb
|
15
16
|
* bin/metrics-snmp-if.rb
|
16
17
|
* bin/metrics-snmp.rb
|
@@ -19,6 +20,6 @@
|
|
19
20
|
|
20
21
|
## Installation
|
21
22
|
|
22
|
-
[Installation and Setup](
|
23
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
23
24
|
|
24
25
|
## Notes
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-snmp-disk
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# This is a simple SNMP check disk script for Sensu,
|
8
|
+
# The tool get a mount point as a regex and search for it in the device description SNMP table
|
9
|
+
# and return the utilization status based on warning and critical thresholds
|
10
|
+
#
|
11
|
+
# OUTPUT:
|
12
|
+
# plain text
|
13
|
+
#
|
14
|
+
# PLATFORMS:
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: SNMP
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
# check-snmp -h host -C public -m /mnt -w 75 -c 85
|
22
|
+
#
|
23
|
+
# if you want to search for specific device and not regex add a comma to the pattern:
|
24
|
+
# check-snmp -h host -C public -m /,
|
25
|
+
#
|
26
|
+
# NOTES:
|
27
|
+
# To search for device description in your server or applicance run the following command:
|
28
|
+
# snmpwalk -v2c -c public host 1.3.6.1.2.1.25.2.3.1.3
|
29
|
+
#
|
30
|
+
# LICENSE:
|
31
|
+
# Yossi Nachum <nachum234@gmail.com>
|
32
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
33
|
+
# for details.
|
34
|
+
#
|
35
|
+
|
36
|
+
require 'sensu-plugin/check/cli'
|
37
|
+
require 'snmp'
|
38
|
+
|
39
|
+
class CheckSNMP < Sensu::Plugin::Check::CLI
|
40
|
+
option :host,
|
41
|
+
short: '-h host',
|
42
|
+
default: '127.0.0.1',
|
43
|
+
description: 'SNMP hostname'
|
44
|
+
|
45
|
+
option :community,
|
46
|
+
short: '-C snmp community',
|
47
|
+
default: 'public',
|
48
|
+
description: 'SNMP community'
|
49
|
+
|
50
|
+
option :mount_point,
|
51
|
+
short: '-m mount point',
|
52
|
+
default: '/',
|
53
|
+
description: 'Disk mount point'
|
54
|
+
|
55
|
+
option :ignoremnt,
|
56
|
+
short: '-i MNT[,MNT]',
|
57
|
+
description: 'Ignore mount point(s)',
|
58
|
+
proc: proc { |a| a.split(',') }
|
59
|
+
|
60
|
+
option :warning,
|
61
|
+
short: '-w warning',
|
62
|
+
proc: proc(&:to_i),
|
63
|
+
default: 80,
|
64
|
+
description: 'Warning threshold in precentage'
|
65
|
+
|
66
|
+
option :critical,
|
67
|
+
short: '-c critical',
|
68
|
+
proc: proc(&:to_i),
|
69
|
+
default: 90,
|
70
|
+
description: 'Critical threshold in precentage'
|
71
|
+
|
72
|
+
option :snmp_version,
|
73
|
+
short: '-v version',
|
74
|
+
description: 'SNMP version to use (SNMPv1, SNMPv2c (default))',
|
75
|
+
default: 'SNMPv2c'
|
76
|
+
|
77
|
+
option :timeout,
|
78
|
+
short: '-t timeout (seconds)',
|
79
|
+
default: '1',
|
80
|
+
description: 'SNMP timeout'
|
81
|
+
|
82
|
+
def initialize
|
83
|
+
super
|
84
|
+
@crit_mnt = []
|
85
|
+
@warn_mnt = []
|
86
|
+
end
|
87
|
+
|
88
|
+
def usage_summary
|
89
|
+
(@crit_mnt + @warn_mnt).join(', ')
|
90
|
+
end
|
91
|
+
|
92
|
+
def run
|
93
|
+
base_oid = '1.3.6.1.2.1.25.2.3.1'
|
94
|
+
dev_desc_oid = base_oid + '.3'
|
95
|
+
dev_size_oid = base_oid + '.5'
|
96
|
+
dev_used_oid = base_oid + '.6'
|
97
|
+
begin
|
98
|
+
manager = SNMP::Manager.new(host: "#{config[:host]}",
|
99
|
+
community: "#{config[:community]}",
|
100
|
+
version: config[:snmp_version].to_sym,
|
101
|
+
timeout: config[:timeout].to_i)
|
102
|
+
response = manager.get_bulk(0, 200, [dev_desc_oid])
|
103
|
+
dev_indexes = []
|
104
|
+
response.each_varbind do |var|
|
105
|
+
next if config[:ignoremnt] && config[:ignoremnt].include?(var.value.to_s.split(',')[0])
|
106
|
+
if var.value.to_s =~ /#{config[:mount_point]}/
|
107
|
+
dev_indexes.push(var.name[-1])
|
108
|
+
end
|
109
|
+
end
|
110
|
+
dev_indexes.each do |dev_index|
|
111
|
+
response = manager.get(["#{dev_desc_oid}.#{dev_index}", "#{dev_size_oid}.#{dev_index}", "#{dev_used_oid}.#{dev_index}"])
|
112
|
+
dev_desc, dev_size, dev_used = response.varbind_list
|
113
|
+
perc = dev_used.value.to_f / dev_size.value.to_f * 100
|
114
|
+
if perc > config[:critical]
|
115
|
+
@crit_mnt << "#{dev_desc.value} = #{perc.round(2)}%"
|
116
|
+
elsif perc > config[:warning]
|
117
|
+
@warn_mnt << "#{dev_desc.value} = #{perc.round(2)}%"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
rescue SNMP::RequestTimeout
|
121
|
+
unknown "#{config[:host]} not responding"
|
122
|
+
rescue => e
|
123
|
+
unknown "An unknown error occured: #{e.inspect}"
|
124
|
+
end
|
125
|
+
critical usage_summary unless @crit_mnt.empty?
|
126
|
+
warning usage_summary unless @warn_mnt.empty?
|
127
|
+
ok "All disk usage under #{config[:warning]}%"
|
128
|
+
manager.close
|
129
|
+
end
|
130
|
+
end
|
data/bin/metrics-snmp-bulk.rb
CHANGED
@@ -110,7 +110,7 @@ class SNMPGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
110
110
|
metric_string += ".#{config[:suffix]}" if config[:suffix]
|
111
111
|
metric_string += ".#{name}"
|
112
112
|
output metric_string, vb.value.to_f
|
113
|
-
rescue NameError # rubocop:disable
|
113
|
+
rescue NameError # rubocop:disable Lint/HandleExceptions
|
114
114
|
# Rescue as some values may fail to cast to float
|
115
115
|
end
|
116
116
|
end
|
data/bin/metrics-snmp-if.rb
CHANGED
@@ -118,7 +118,7 @@ class SNMPIfStatsGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
118
118
|
default: false,
|
119
119
|
description: 'Use low capacity counters'
|
120
120
|
|
121
|
-
def run # rubocop:disable
|
121
|
+
def run # rubocop:disable Metrics/AbcSize
|
122
122
|
if_table_HC_columns = %w(
|
123
123
|
ifHCInOctets ifHCOutOctets
|
124
124
|
ifHCInUcastPkts ifHCOutUcastPkts
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-snmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
31
|
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sensu-plugin
|
@@ -186,19 +186,25 @@ dependencies:
|
|
186
186
|
- - "~>"
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0.10'
|
189
|
-
description:
|
189
|
+
description: |-
|
190
|
+
This plugin provides native SNMP instrumentation
|
191
|
+
for monitoring and metrics collection, including:
|
192
|
+
generic OID single/bulk query for status and
|
193
|
+
metrics, and ifTable metrics
|
190
194
|
email: "<sensu-users@googlegroups.com>"
|
191
195
|
executables:
|
192
196
|
- metrics-snmp.rb
|
193
197
|
- metrics-snmp-if.rb
|
194
198
|
- metrics-snmp-bulk.rb
|
195
199
|
- check-snmp.rb
|
200
|
+
- check-snmp-disk.rb
|
196
201
|
extensions: []
|
197
202
|
extra_rdoc_files: []
|
198
203
|
files:
|
199
204
|
- CHANGELOG.md
|
200
205
|
- LICENSE
|
201
206
|
- README.md
|
207
|
+
- bin/check-snmp-disk.rb
|
202
208
|
- bin/check-snmp.rb
|
203
209
|
- bin/metrics-snmp-bulk.rb
|
204
210
|
- bin/metrics-snmp-if.rb
|
@@ -231,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
237
|
version: '0'
|
232
238
|
requirements: []
|
233
239
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.4.
|
240
|
+
rubygems_version: 2.4.8
|
235
241
|
signing_key:
|
236
242
|
specification_version: 4
|
237
243
|
summary: Sensu plugins for SNMP
|
metadata.gz.sig
CHANGED
Binary file
|