SNMPDevice 0.1.0 → 0.1.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/README.md +1 -1
- data/lib/SNMPDevice/device.rb +1 -1
- data/lib/SNMPDevice/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15d73addd0c6eca5dcdddfd25e5ffc86e56b50a
|
4
|
+
data.tar.gz: 52114385cb7cc05d1e60f52d8f51ba83921d9095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79eb0c4b3ae1e5db0bdd799e58aa1b2baa782481fd5560ff0a4109283c28c7cc7def5336c324a88f02a2a571bee2469f052a918e2364aa53eaa95be167f73224
|
7
|
+
data.tar.gz: bf24728232ab2d5bbaa73335622bf96ff51010ccf9053ae2205dcd8faeb124dbaa23b9f296f49325ff0e6b7ceb9504663ede0949ef991cd159f72a67924b49ad
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
include SNMPDevice
|
23
23
|
|
24
24
|
printer_a = Device.new('10.247.1.20')
|
25
|
-
printer_a.
|
25
|
+
printer_a.set_config({'toner' => {:name_of_toner => '1.2.3.4.5.6.7.351.2', :toner_level => '1.2.3.4.5.6.7.351.3'}})
|
26
26
|
printer_a.toner_info # => [["name_of_toner","toner_level"], ["Yellow", "50"], ["Cyan", "100"], ["Magenta". "10"], ["Black", "0"]]
|
27
27
|
|
28
28
|
Depending on the values in the hash or YAML config, you can call something like `paper_info` or `toner_info`. It uses Ruby's `method_missing` function to define names dynamically depending on the configuration values. The results of a function such as `toner_info` can then be used as needed in other ways, such as turning to `JSON` and outputting to Javascript to create a web application capable of monitoring various devices.
|
data/lib/SNMPDevice/device.rb
CHANGED
@@ -18,7 +18,6 @@ module SNMPDevice
|
|
18
18
|
private
|
19
19
|
attr_accessor :snmp_object
|
20
20
|
def method_missing(symbol, *args)
|
21
|
-
require_config
|
22
21
|
if symbol.id2name.end_with?('_info') and @config.has_key?(symbol.id2name.split('_info')[0])
|
23
22
|
snmp_lookup(symbol.id2name.split('_info')[0])
|
24
23
|
else
|
@@ -29,6 +28,7 @@ module SNMPDevice
|
|
29
28
|
@snmp_object = SNMP::Manager.new(:host => ip_address)
|
30
29
|
end
|
31
30
|
def snmp_lookup(name)
|
31
|
+
require_config
|
32
32
|
lookup_table = Array.new
|
33
33
|
output = [[]]
|
34
34
|
@config[name].each do |n|
|
data/lib/SNMPDevice/version.rb
CHANGED