arborist-snmp 0.6.0 → 0.6.1
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/lib/arborist/monitor/snmp/ups.rb +1 -1
- data/lib/arborist/monitor/snmp/ups/battery.rb +25 -21
- data/lib/arborist/snmp.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2018a5dacf04f2cd6b821c5438fe71b2950d512f4c3f8e1f398c6cba4ca7f52
|
4
|
+
data.tar.gz: '084f3b0db42917d34889931ca62a7f45830975024d410b35b715f64d87be1566'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174317ae1282ceadba0660f528e51147395801a3f26956acc950e44159f53567f4393d1f171e1378067ef441f2aac340b196b0902ff0a455f61dc0eed20a68c6
|
7
|
+
data.tar.gz: 2e23e9e51ba7b583396f6b35d522e6d855dec586c619ba11c4e6004a6e53590ecd404c8d9cc222abbdf4defdc27d5675ae1e00e8dc3964e886cb3a06cd8d6567
|
@@ -3,6 +3,10 @@
|
|
3
3
|
|
4
4
|
require 'arborist/monitor/snmp/ups' unless defined?( Arborist::Monitor::SNMP::UPS )
|
5
5
|
|
6
|
+
# Checks for UPS battery health.
|
7
|
+
#
|
8
|
+
# Checks the available battery percentage, if the UPS is on battery,
|
9
|
+
# and the temperature of the battery.
|
6
10
|
#
|
7
11
|
class Arborist::Monitor::SNMP::UPS::Battery
|
8
12
|
include Arborist::Monitor::SNMP
|
@@ -13,13 +17,13 @@ class Arborist::Monitor::SNMP::UPS::Battery
|
|
13
17
|
# OIDS for discovering ups status.
|
14
18
|
#
|
15
19
|
OIDS = {
|
16
|
-
battery_status:
|
17
|
-
seconds_on_battery:
|
18
|
-
est_minutes_remaining:
|
19
|
-
est_charge_remaining:
|
20
|
-
battery_voltage:
|
21
|
-
battery_current:
|
22
|
-
battery_temperature:
|
20
|
+
battery_status: '.1.3.6.1.2.1.33.1.2.1.0', # 1 - unk, 2 - normal, 3 - low, 4 - depleted
|
21
|
+
seconds_on_battery: '.1.3.6.1.2.1.33.1.2.2.0',
|
22
|
+
est_minutes_remaining: '.1.3.6.1.2.1.33.1.2.3.0',
|
23
|
+
est_charge_remaining: '.1.3.6.1.2.1.33.1.2.4.0', # in percent
|
24
|
+
battery_voltage: '.1.3.6.1.2.1.33.1.2.5.0', # in 0.1v DC
|
25
|
+
battery_current: '.1.3.6.1.2.1.33.1.2.6.0', # in 0.1a DC
|
26
|
+
battery_temperature: '.1.3.6.1.2.1.33.1.2.7.0' # in Celcius
|
23
27
|
}
|
24
28
|
|
25
29
|
# Human-readable translations for battery status OID.
|
@@ -76,23 +80,23 @@ class Arborist::Monitor::SNMP::UPS::Battery
|
|
76
80
|
|
77
81
|
# basic info that's always available
|
78
82
|
info[ :status ] = snmp.get( oid: OIDS[:battery_status] )
|
79
|
-
info[ :capacity ] = snmp.get( oid: OIDS[:est_charge_remaining] )
|
80
|
-
info[ :temperature ] = snmp.get( oid: OIDS[:battery_temperature] )
|
81
|
-
info[ :minutes_remaining ] = snmp.get( oid: OIDS[:est_minutes_remaining] )
|
83
|
+
info[ :capacity ] = snmp.get( oid: OIDS[:est_charge_remaining] ) rescue nil
|
84
|
+
info[ :temperature ] = snmp.get( oid: OIDS[:battery_temperature] ) rescue nil
|
85
|
+
info[ :minutes_remaining ] = snmp.get( oid: OIDS[:est_minutes_remaining] ) rescue nil
|
82
86
|
|
83
87
|
# don't report voltage if the UPS doesn't
|
84
88
|
voltage = snmp.get( oid: OIDS[:battery_voltage] ) rescue nil
|
85
|
-
info[ :voltage ] = voltage / 10
|
89
|
+
info[ :voltage ] = voltage / 10 if voltage
|
86
90
|
|
87
91
|
# don't report current if the UPS doesn't
|
88
92
|
current = snmp.get( oid: OIDS[:battery_current] ) rescue nil
|
89
|
-
info[ :current ] = current/10
|
93
|
+
info[ :current ] = current/10 if current
|
90
94
|
|
91
95
|
# see if we are on battery
|
92
96
|
info[ :seconds_on_battery ] = snmp.get( oid: OIDS[:seconds_on_battery] ) rescue 0
|
93
97
|
info[ :in_use ] = ( info[ :seconds_on_battery ] != 0 )
|
94
98
|
|
95
|
-
return { battery: info }
|
99
|
+
return { battery: info.compact }
|
96
100
|
end
|
97
101
|
|
98
102
|
### Parse SNMP-provided information and alert based on thresholds.
|
@@ -100,28 +104,28 @@ class Arborist::Monitor::SNMP::UPS::Battery
|
|
100
104
|
def check_battery( host, snmp )
|
101
105
|
info = self.format_battery( snmp )
|
102
106
|
|
103
|
-
config
|
104
|
-
cap_warn
|
107
|
+
config = identifiers[ host ].last || {}
|
108
|
+
cap_warn = config[ 'capacity_warn_at' ] || self.class.capacity_warn_at
|
105
109
|
temp_warn = config[ 'temperature_warn_at' ] || self.class.temperature_warn_at
|
106
110
|
|
107
|
-
in_use
|
108
|
-
status
|
109
|
-
capacity
|
111
|
+
in_use = info.dig( :battery, :in_use )
|
112
|
+
status = info.dig( :battery, :status )
|
113
|
+
capacity = info.dig( :battery, :capacity )
|
110
114
|
temperature = info.dig( :battery, :temperature )
|
111
115
|
warnings = []
|
112
116
|
|
113
117
|
if in_use
|
114
|
-
mins = info.dig( :battery, :minutes_remaining )
|
118
|
+
mins = info.dig( :battery, :minutes_remaining ) || "(unknown)"
|
115
119
|
warnings << "UPS on battery - %s minute(s) remaning." % [ mins ]
|
116
120
|
end
|
117
121
|
|
118
122
|
warnings << BATTERY_STATUS[ status ] if status != 2
|
119
123
|
|
120
124
|
warnings << "Battery remaining capacity %0.1f%% less than %0.1f percent" %
|
121
|
-
[ capacity, cap_warn ] if capacity <= cap_warn
|
125
|
+
[ capacity, cap_warn ] if capacity && capacity <= cap_warn
|
122
126
|
|
123
127
|
warnings << "Battery temperature %dC greater than %dC" %
|
124
|
-
[ temperature, temp_warn ] if temperature >= temp_warn
|
128
|
+
[ temperature, temp_warn ] if temperature && temperature >= temp_warn
|
125
129
|
|
126
130
|
info[ :warning ] = warnings.join( "\n" ) unless warnings.empty?
|
127
131
|
self.results[ host ] = info
|
data/lib/arborist/snmp.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arborist-snmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mahlon E. Smith <mahlon@martini.nu>
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-04-
|
12
|
+
date: 2019-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arborist
|