sensu-plugins-snmp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE +22 -0
- data/README.md +24 -0
- data/bin/check-snmp.rb +97 -0
- data/bin/metrics-snmp-bulk.rb +101 -0
- data/bin/metrics-snmp-if.rb +178 -0
- data/bin/metrics-snmp.rb +79 -0
- data/lib/sensu-plugins-snmp.rb +2 -0
- data/lib/sensu-plugins-snmp/version.rb +14 -0
- metadata +234 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0e2a38fa927448ef6e39b44a980851452c5cbf30
|
4
|
+
data.tar.gz: 1185f418997a954d57608696f7075876ebe45fc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7a4dd0207c72418a132216ecaa3323acd8e853ffb0d44fe5d7e264cc0cb630137cdd9b12db1a610f21aa8cc847432265638cd9ff1b1af1370f1521d6c095d20
|
7
|
+
data.tar.gz: 94621c0274d36ae0bd06016bba09baf40c340deae8bf1a337ea035a70788b25e0f0f012f11cdb1340e5ffec179b6cfbc938a2e9ffe249746001ffff414f5f0ed
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
|
+
|
6
|
+
## Unreleased][unreleased]
|
7
|
+
|
8
|
+
=======
|
9
|
+
## 0.0.1 - 2015-04-30
|
10
|
+
|
11
|
+
### Added
|
12
|
+
- initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
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,24 @@
|
|
1
|
+
## Sensu-Plugins-snmp
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-snmp.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-snmp)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-snmp.svg)](http://badge.fury.io/rb/sensu-plugins-snmp)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-snmp/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-snmp)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-snmp/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-snmp)
|
7
|
+
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-snmp.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-snmp)
|
8
|
+
[![Codeship Status for sensu-plugins/sensu-plugins-snmp](https://codeship.com/projects/c7145640-e8a4-0132-3bde-62885e5c211b/status?branch=master)](https://codeship.com/projects/82852)
|
9
|
+
|
10
|
+
## Functionality
|
11
|
+
|
12
|
+
## Files
|
13
|
+
* bin/check-snmp.rb
|
14
|
+
* bin/metrics-snmp-bulk.rb
|
15
|
+
* bin/metrics-snmp-if.rb
|
16
|
+
* bin/metrics-snmp.rb
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
[Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
|
23
|
+
|
24
|
+
## Notes
|
data/bin/check-snmp.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Check SNMP
|
3
|
+
# ===
|
4
|
+
#
|
5
|
+
# This is a simple SNMP check script for Sensu, We need to supply details like
|
6
|
+
# Server, port, SNMP community, and Limits
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# Requires SNMP gem
|
10
|
+
#
|
11
|
+
# USAGE:
|
12
|
+
#
|
13
|
+
# check-snmp -h host -C community -O oid -w warning -c critical
|
14
|
+
# check-snmp -h host -C community -O oid -m "(P|p)attern to match\.?"
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# Author Deepak Mohan Das <deepakmdass88@gmail.com>
|
18
|
+
#
|
19
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
20
|
+
# for details.
|
21
|
+
|
22
|
+
require 'sensu-plugin/check/cli'
|
23
|
+
require 'snmp'
|
24
|
+
|
25
|
+
class CheckSNMP < Sensu::Plugin::Check::CLI
|
26
|
+
option :host,
|
27
|
+
short: '-h host',
|
28
|
+
default: '127.0.0.1'
|
29
|
+
|
30
|
+
option :community,
|
31
|
+
short: '-C snmp community',
|
32
|
+
default: 'public'
|
33
|
+
|
34
|
+
option :objectid,
|
35
|
+
short: '-O OID',
|
36
|
+
default: '1.3.6.1.4.1.2021.10.1.3.1'
|
37
|
+
|
38
|
+
option :warning,
|
39
|
+
short: '-w warning',
|
40
|
+
default: '10'
|
41
|
+
|
42
|
+
option :critical,
|
43
|
+
short: '-c critical',
|
44
|
+
default: '20'
|
45
|
+
|
46
|
+
option :match,
|
47
|
+
short: '-m match',
|
48
|
+
description: 'Regex pattern to match against returned value'
|
49
|
+
|
50
|
+
option :snmp_version,
|
51
|
+
short: '-v version',
|
52
|
+
description: 'SNMP version to use (SNMPv1, SNMPv2c (default))',
|
53
|
+
default: 'SNMPv2c'
|
54
|
+
|
55
|
+
option :comparison,
|
56
|
+
short: '-o comparison operator',
|
57
|
+
description: 'Operator used to compare data with warning/critial values. Can be set to "le" (<=), "ge" (>=).',
|
58
|
+
default: 'ge'
|
59
|
+
|
60
|
+
option :timeout,
|
61
|
+
short: '-t timeout (seconds)',
|
62
|
+
default: '1'
|
63
|
+
|
64
|
+
def run
|
65
|
+
begin
|
66
|
+
manager = SNMP::Manager.new(host: "#{config[:host]}",
|
67
|
+
community: "#{config[:community]}",
|
68
|
+
version: config[:snmp_version].to_sym,
|
69
|
+
timeout: config[:timeout].to_i)
|
70
|
+
response = manager.get(["#{config[:objectid]}"])
|
71
|
+
rescue SNMP::RequestTimeout
|
72
|
+
unknown "#{config[:host]} not responding"
|
73
|
+
rescue => e
|
74
|
+
unknown "An unknown error occured: #{e.inspect}"
|
75
|
+
end
|
76
|
+
operators = { 'le' => :<=, 'ge' => :>= }
|
77
|
+
symbol = operators[config[:comparison]]
|
78
|
+
|
79
|
+
response.each_varbind do |vb|
|
80
|
+
if config[:match]
|
81
|
+
if vb.value.to_s =~ /#{config[:match]}/
|
82
|
+
ok
|
83
|
+
else
|
84
|
+
critical "Value: #{vb.value} failed to match Pattern: #{config[:match]}"
|
85
|
+
end
|
86
|
+
else
|
87
|
+
critical 'Critical state detected' if "#{vb.value}".to_i.send(symbol, "#{config[:critical]}".to_i)
|
88
|
+
# #YELLOW
|
89
|
+
warning 'Warning state detected' if ("#{vb.value}".to_i.send(symbol, "#{config[:warning]}".to_i)) && !("#{vb.value}".to_i.send(symbol, "#{config[:critical]}".to_i)) # rubocop:disable LineLength
|
90
|
+
unless "#{vb.value}".to_i.send(symbol, "#{config[:warning]}".to_i)
|
91
|
+
ok 'All is well!'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
manager.close
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# SNMP Bulk Metrics
|
3
|
+
# ===
|
4
|
+
#
|
5
|
+
# This is a script to 'bulk walk' an SNMP OID value, collecting metrics
|
6
|
+
#
|
7
|
+
#
|
8
|
+
# Requires SNMP gem
|
9
|
+
#
|
10
|
+
# USAGE:
|
11
|
+
#
|
12
|
+
# snmp-bulk-metrics -h host -C community -O oid1,oid2... -s suffix
|
13
|
+
#
|
14
|
+
# Copyright 2014 Matthew Richardson <m.richardson@ed.ac.uk>
|
15
|
+
# Based on snmp-metrics.rb by Double Negative Limited
|
16
|
+
#
|
17
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
18
|
+
# for details.
|
19
|
+
|
20
|
+
require 'sensu-plugin/metric/cli'
|
21
|
+
require 'snmp'
|
22
|
+
|
23
|
+
class SNMPGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
24
|
+
option :host,
|
25
|
+
short: '-h host',
|
26
|
+
boolean: true,
|
27
|
+
default: '127.0.0.1',
|
28
|
+
required: true
|
29
|
+
|
30
|
+
option :community,
|
31
|
+
short: '-C snmp community',
|
32
|
+
boolean: true,
|
33
|
+
default: 'public'
|
34
|
+
|
35
|
+
option :objectid,
|
36
|
+
short: '-O OID[,OID,OID...]',
|
37
|
+
description: 'comma separated list of OIDs to bulkwalk',
|
38
|
+
required: true
|
39
|
+
|
40
|
+
option :prefix,
|
41
|
+
short: '-p prefix',
|
42
|
+
description: 'prefix to attach to graphite path'
|
43
|
+
|
44
|
+
option :suffix,
|
45
|
+
short: '-s suffix',
|
46
|
+
description: 'suffix to attach to graphite path',
|
47
|
+
required: true
|
48
|
+
|
49
|
+
option :snmp_version,
|
50
|
+
short: '-v version',
|
51
|
+
description: 'SNMP version to use (SNMPv1, SNMPv2c (default))',
|
52
|
+
default: 'SNMPv2c'
|
53
|
+
|
54
|
+
option :graphite,
|
55
|
+
short: '-g',
|
56
|
+
description: 'Replace dots with underscores in hostname',
|
57
|
+
boolean: true
|
58
|
+
|
59
|
+
option :maxrepeat,
|
60
|
+
short: '-m maxrepeat',
|
61
|
+
description: 'Number of iterations to perform on repeating variables (defaults to 10)',
|
62
|
+
default: 10
|
63
|
+
|
64
|
+
option :nonrepeat,
|
65
|
+
short: '-n non-repeaters',
|
66
|
+
description: 'Number of supplied OIDs that should not be iterated over (defaults to 0)',
|
67
|
+
default: 0
|
68
|
+
|
69
|
+
option :timeout,
|
70
|
+
short: '-t timeout (seconds) (defaults to 5)',
|
71
|
+
default: 5
|
72
|
+
|
73
|
+
def run
|
74
|
+
oids = config[:objectid].split(',')
|
75
|
+
begin
|
76
|
+
manager = SNMP::Manager.new(host: "#{config[:host]}",
|
77
|
+
community: "#{config[:community]}",
|
78
|
+
version: config[:snmp_version].to_sym,
|
79
|
+
timeout: config[:timeout].to_i)
|
80
|
+
response = manager.get_bulk(config[:nonrepeat].to_i,
|
81
|
+
config[:maxrepeat].to_i,
|
82
|
+
oids)
|
83
|
+
rescue SNMP::RequestTimeout
|
84
|
+
unknown "#{config[:host]} not responding"
|
85
|
+
rescue => e
|
86
|
+
unknown "An unknown error occured: #{e.inspect}"
|
87
|
+
end
|
88
|
+
config[:host] = config[:host].gsub('.', '_') if config[:graphite]
|
89
|
+
response.each_varbind do |vb|
|
90
|
+
name = vb.oid
|
91
|
+
name = "#{name}".gsub('.', '_') if config[:graphite]
|
92
|
+
if config[:prefix]
|
93
|
+
output "#{config[:prefix]}.#{config[:host]}.#{config[:suffix]}.#{name}", vb.value.to_f
|
94
|
+
else
|
95
|
+
output "#{config[:host]}.#{config[:suffix]}.#{name}", vb.value.to_f
|
96
|
+
end
|
97
|
+
end
|
98
|
+
manager.close
|
99
|
+
ok
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# SNMP Interface Metrics
|
3
|
+
# ===
|
4
|
+
#
|
5
|
+
# Collect device network interface metrics using the IF-MIB (RFC 2863) interface.
|
6
|
+
#
|
7
|
+
# This script uses the 64-bit "HC" (high capacity) metrics which I am assuming most
|
8
|
+
# modern devices probably support. If there is no HC support, use --low-capacity
|
9
|
+
# flag.
|
10
|
+
#
|
11
|
+
# Example
|
12
|
+
# -------
|
13
|
+
#
|
14
|
+
# snmp-if-metrics.rb -C community -h host
|
15
|
+
#
|
16
|
+
# Only in/out octets are displayed by default to keep the number of metrics low. Additional
|
17
|
+
# Metrics can be generated:
|
18
|
+
#
|
19
|
+
# - `--include-down`: Output metrics for interfaces not marked up (ifOperStatus != 1).
|
20
|
+
# By default only metrics for interfaces in the up state are printed.
|
21
|
+
# - `--include-errors`: Output error metrics such as in/out errors, discards, etc.
|
22
|
+
# - `--include-name`: Include the interface name with the interface index number when generating
|
23
|
+
# the metric name. This can help identify interfaces in graphite when browsing.
|
24
|
+
# - `--include-packet-counts`: Output packet metrics.
|
25
|
+
# - `--include-speed`: Output a metric for the interface's speed. Useful when constructing
|
26
|
+
# a view of an interfaces capacity in graphite.
|
27
|
+
# - `--version`: Set SNMP protocol version (SNMPv2c or SNMPv1)
|
28
|
+
# - `--low-capacity`: Use low capacity counters
|
29
|
+
#
|
30
|
+
# Copyright (c) 2013 Joe Miller
|
31
|
+
#
|
32
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
33
|
+
# for details.
|
34
|
+
|
35
|
+
# #YELLOW
|
36
|
+
# rubocop:disable VariableName
|
37
|
+
require 'sensu-plugin/metric/cli'
|
38
|
+
require 'snmp'
|
39
|
+
|
40
|
+
def graphite_safe_name(name)
|
41
|
+
name.gsub(/\W/, '_')
|
42
|
+
end
|
43
|
+
|
44
|
+
class SNMPIfStatsGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
45
|
+
option :host,
|
46
|
+
short: '-h host',
|
47
|
+
boolean: true,
|
48
|
+
default: '127.0.0.1',
|
49
|
+
required: true
|
50
|
+
|
51
|
+
option :community,
|
52
|
+
short: '-C snmp community',
|
53
|
+
boolean: true,
|
54
|
+
default: 'public'
|
55
|
+
|
56
|
+
option :scheme,
|
57
|
+
short: '-s SCHEME',
|
58
|
+
long: '--scheme SCHEME',
|
59
|
+
default: 'snmp.interfaces',
|
60
|
+
description: 'prefix to attach to graphite path'
|
61
|
+
|
62
|
+
option :include_pkt_metrics,
|
63
|
+
short: '-k',
|
64
|
+
long: '--include-packet-counts',
|
65
|
+
boolean: true,
|
66
|
+
default: false,
|
67
|
+
description: 'Include packets metrics, eg: IfInUcastPkts, IfOutUcastPkts, IfInBroadcastPkts, etc'
|
68
|
+
|
69
|
+
option :include_speed,
|
70
|
+
short: '-s',
|
71
|
+
long: '--include-speed',
|
72
|
+
boolean: true,
|
73
|
+
default: false,
|
74
|
+
description: 'Output interface max speed (ifSpeed) metric'
|
75
|
+
|
76
|
+
option :include_name,
|
77
|
+
short: '-n',
|
78
|
+
long: '--include-name',
|
79
|
+
boolean: true,
|
80
|
+
default: false,
|
81
|
+
description: 'append ifName to ifIndex when generating metric name, eg: "1__OUTSIDE"'
|
82
|
+
|
83
|
+
option :include_error_metrics,
|
84
|
+
short: '-e',
|
85
|
+
long: '--include-errors',
|
86
|
+
boolean: true,
|
87
|
+
default: false,
|
88
|
+
description: 'Include error metrics in output'
|
89
|
+
|
90
|
+
option :include_down_interfaces,
|
91
|
+
short: '-d',
|
92
|
+
long: '--include-down',
|
93
|
+
boolean: true,
|
94
|
+
default: false,
|
95
|
+
description: 'output metrics for all interfaces including those marked down'
|
96
|
+
|
97
|
+
option :verbose,
|
98
|
+
short: '-v',
|
99
|
+
long: '--verbose',
|
100
|
+
boolean: true,
|
101
|
+
default: false,
|
102
|
+
description: 'verbose output for debugging'
|
103
|
+
|
104
|
+
option :version,
|
105
|
+
short: '-V VERSION',
|
106
|
+
long: '--version VERSION',
|
107
|
+
default: :SNMPv2c,
|
108
|
+
description: 'SNMP version (SNMPv1 or SNMPv2c)',
|
109
|
+
proc: proc(&:intern)
|
110
|
+
|
111
|
+
option :low_capacity,
|
112
|
+
long: '--low-capacity',
|
113
|
+
boolean: true,
|
114
|
+
default: false,
|
115
|
+
description: 'Use low capacity counters'
|
116
|
+
|
117
|
+
def run # rubocop:disable all
|
118
|
+
if_table_HC_columns = %w(
|
119
|
+
ifHCInOctets ifHCOutOctets
|
120
|
+
ifHCInUcastPkts ifHCOutUcastPkts
|
121
|
+
ifHCInMulticastPkts ifHCOutMulticastPkts
|
122
|
+
ifHCInBroadcastPkts ifHCOutBroadcastPkts
|
123
|
+
)
|
124
|
+
if_table_LC_columns = %w(
|
125
|
+
ifInOctets ifOutOctets
|
126
|
+
ifInUcastPkts ifOutUcastPkts
|
127
|
+
ifInMulticastPkts ifOutMulticastPkts
|
128
|
+
ifInBroadcastPkts ifOutBroadcastPkts
|
129
|
+
)
|
130
|
+
if_table_common_columns = %w(
|
131
|
+
ifIndex ifOperStatus ifName ifDescr
|
132
|
+
ifInErrors ifOutErrors ifInDiscards ifOutDiscards ifSpeed
|
133
|
+
)
|
134
|
+
if_table_columns = if_table_common_columns +
|
135
|
+
(config[:low_capacity] ? if_table_LC_columns : if_table_HC_columns)
|
136
|
+
|
137
|
+
SNMP::Manager.open(host: "#{config[:host]}", community: "#{config[:community]}", version: config[:version]) do |manager|
|
138
|
+
manager.walk(if_table_columns) do |row_array|
|
139
|
+
# turn row (an array) into a hash for eaiser access to the columns
|
140
|
+
row = Hash[*if_table_columns.zip(row_array).flatten]
|
141
|
+
puts row.inspect if config[:verbose]
|
142
|
+
if_name = config[:include_name] ? "#{row['ifIndex'].value}__#{graphite_safe_name(row['ifName'].value.to_s)}" : row['ifIndex'].value.to_s
|
143
|
+
|
144
|
+
next if row['ifOperStatus'].value != 1 && !config[:include_down_interfaces]
|
145
|
+
|
146
|
+
in_octets = config[:low_capacity] ? 'ifInOctets' : 'ifHCInOctets'
|
147
|
+
out_octets = config[:low_capacity] ? 'ifOutOctets' : 'ifHCOutOctets'
|
148
|
+
output "#{config[:scheme]}.#{if_name}.#{in_octets}", row[in_octets].value
|
149
|
+
output "#{config[:scheme]}.#{if_name}.#{out_octets}", row[out_octets].value
|
150
|
+
|
151
|
+
output "#{config[:scheme]}.#{if_name}.ifSpeed", row['ifSpeed'].value if config[:include_speed]
|
152
|
+
|
153
|
+
if config[:include_error_metrics]
|
154
|
+
output "#{config[:scheme]}.#{if_name}.ifInErrors", row['ifInErrors'].value
|
155
|
+
output "#{config[:scheme]}.#{if_name}.ifOutErrors", row['ifOutErrors'].value
|
156
|
+
output "#{config[:scheme]}.#{if_name}.ifInDiscards", row['ifInDiscards'].value
|
157
|
+
output "#{config[:scheme]}.#{if_name}.ifOutDiscards", row['ifOutDiscards'].value
|
158
|
+
end
|
159
|
+
|
160
|
+
if config[:include_pkt_metrics]
|
161
|
+
in_ucast_pkts = config[:low_capacity] ? 'ifInUcastPkts' : 'ifHCInUcastPkts'
|
162
|
+
out_ucast_pkts = config[:low_capacity] ? 'ifOutUcastPkts' : 'ifHCOutUcastPkts'
|
163
|
+
in_mcast_pkts = config[:low_capacity] ? 'ifInMulticastPkts' : 'ifHCInMulticastPkts'
|
164
|
+
out_mcast_pkts = config[:low_capacity] ? 'ifOutMulticastPkts' : 'ifHCOutMulticastPkts'
|
165
|
+
in_bcast_pkts = config[:low_capacity] ? 'ifInBroadcastPkts' : 'ifHCInBroadcastPkts'
|
166
|
+
out_bcast_pkts = config[:low_capacity] ? 'ifOutBroadcastPkts' : 'ifHCOutBroadcastPkts'
|
167
|
+
output "#{config[:scheme]}.#{if_name}.#{in_ucast_pkts}", row[in_ucast_pkts].value
|
168
|
+
output "#{config[:scheme]}.#{if_name}.#{out_ucast_pkts}", row[out_ucast_pkts].value
|
169
|
+
output "#{config[:scheme]}.#{if_name}.#{in_mcast_pkts}", row[in_mcast_pkts].value
|
170
|
+
output "#{config[:scheme]}.#{if_name}.#{out_mcast_pkts}", row[out_mcast_pkts].value
|
171
|
+
output "#{config[:scheme]}.#{if_name}.#{in_bcast_pkts}", row[in_bcast_pkts].value
|
172
|
+
output "#{config[:scheme]}.#{if_name}.#{out_bcast_pkts}", row[out_bcast_pkts].value
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
ok
|
177
|
+
end
|
178
|
+
end
|
data/bin/metrics-snmp.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# SNMP Metrics
|
3
|
+
# ===
|
4
|
+
#
|
5
|
+
# This is a simple script to collect metrics from a SNMP OID value
|
6
|
+
#
|
7
|
+
#
|
8
|
+
# Requires SNMP gem
|
9
|
+
#
|
10
|
+
# USAGE:
|
11
|
+
#
|
12
|
+
# check-snmp -h host -C community -O oid -p prefix -s suffix
|
13
|
+
#
|
14
|
+
# Copyright (c) 2013 Double Negative Limited
|
15
|
+
# Based on check-snmp.rb by Deepak Mohan Das <deepakmdass88@gmail.com>
|
16
|
+
#
|
17
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
18
|
+
# for details.
|
19
|
+
|
20
|
+
require 'sensu-plugin/metric/cli'
|
21
|
+
require 'snmp'
|
22
|
+
|
23
|
+
class SNMPGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
24
|
+
option :host,
|
25
|
+
short: '-h host',
|
26
|
+
boolean: true,
|
27
|
+
default: '127.0.0.1',
|
28
|
+
required: true
|
29
|
+
|
30
|
+
option :community,
|
31
|
+
short: '-C snmp community',
|
32
|
+
boolean: true,
|
33
|
+
default: 'public'
|
34
|
+
|
35
|
+
option :objectid,
|
36
|
+
short: '-O OID',
|
37
|
+
default: '1.3.6.1.4.1.2021.10.1.3.1',
|
38
|
+
required: true
|
39
|
+
|
40
|
+
option :prefix,
|
41
|
+
short: '-p prefix',
|
42
|
+
description: 'prefix to attach to graphite path'
|
43
|
+
|
44
|
+
option :suffix,
|
45
|
+
short: '-s suffix',
|
46
|
+
description: 'suffix to attach to graphite path',
|
47
|
+
required: true
|
48
|
+
|
49
|
+
option :snmp_version,
|
50
|
+
short: '-v version',
|
51
|
+
description: 'SNMP version to use (SNMPv1, SNMPv2c (default))',
|
52
|
+
default: 'SNMPv2c'
|
53
|
+
|
54
|
+
option :graphite,
|
55
|
+
short: '-g',
|
56
|
+
description: 'Replace dots with underscores in hostname',
|
57
|
+
boolean: true
|
58
|
+
|
59
|
+
def run
|
60
|
+
begin
|
61
|
+
manager = SNMP::Manager.new(host: "#{config[:host]}", community: "#{config[:community]}", version: config[:snmp_version].to_sym)
|
62
|
+
response = manager.get(["#{config[:objectid]}"])
|
63
|
+
rescue SNMP::RequestTimeout
|
64
|
+
unknown "#{config[:host]} not responding"
|
65
|
+
rescue => e
|
66
|
+
unknown "An unknown error occured: #{e.inspect}"
|
67
|
+
end
|
68
|
+
config[:host] = config[:host].gsub('.', '_') if config[:graphite]
|
69
|
+
response.each_varbind do |vb|
|
70
|
+
if config[:prefix]
|
71
|
+
output "#{config[:prefix]}.#{config[:host]}.#{config[:suffix]}", vb.value.to_f
|
72
|
+
else
|
73
|
+
output "#{config[:host]}.#{config[:suffix]}", vb.value.to_f
|
74
|
+
end
|
75
|
+
end
|
76
|
+
manager.close
|
77
|
+
ok
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-snmp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sensu-Plugins and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-05-31 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sensu-plugin
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.0
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: snmp
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.2.0
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.2.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: codeclimate-test-reporter
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.4'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.4'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rubocop
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.30'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0.30'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rspec
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.1'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.1'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: bundler
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.7'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.7'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rake
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '10.0'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '10.0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: github-markup
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '1.3'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '1.3'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: redcarpet
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.2'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '3.2'
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: yard
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0.8'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0.8'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: pry
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0.10'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0.10'
|
189
|
+
description: Sensu plugins for SNMP
|
190
|
+
email: "<sensu-users@googlegroups.com>"
|
191
|
+
executables: []
|
192
|
+
extensions: []
|
193
|
+
extra_rdoc_files: []
|
194
|
+
files:
|
195
|
+
- CHANGELOG.md
|
196
|
+
- LICENSE
|
197
|
+
- README.md
|
198
|
+
- bin/check-snmp.rb
|
199
|
+
- bin/metrics-snmp-bulk.rb
|
200
|
+
- bin/metrics-snmp-if.rb
|
201
|
+
- bin/metrics-snmp.rb
|
202
|
+
- lib/sensu-plugins-snmp.rb
|
203
|
+
- lib/sensu-plugins-snmp/version.rb
|
204
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-snmp
|
205
|
+
licenses:
|
206
|
+
- MIT
|
207
|
+
metadata:
|
208
|
+
maintainer: ''
|
209
|
+
development_status: active
|
210
|
+
production_status: unstable - testing recommended
|
211
|
+
release_draft: 'false'
|
212
|
+
release_prerelease: 'false'
|
213
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
214
|
+
in /etc/default/sensu
|
215
|
+
rdoc_options: []
|
216
|
+
require_paths:
|
217
|
+
- lib
|
218
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 1.9.3
|
223
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - ">="
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '0'
|
228
|
+
requirements: []
|
229
|
+
rubyforge_project:
|
230
|
+
rubygems_version: 2.4.6
|
231
|
+
signing_key:
|
232
|
+
specification_version: 4
|
233
|
+
summary: Sensu plugins for SNMP
|
234
|
+
test_files: []
|
metadata.gz.sig
ADDED