You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>If you want to write network management applications in Ruby, you're probably going to need an SNMP library. The goal of the Ruby SNMP project is to create an interface to SNMP that has the same intuitive, joyful feeling that the Ruby programming language does. With a crusty, old protocol like SNMP this is easier said than done, but we're working on it!</p>
91
+
92
+
<h2>Getting Started</h2>
93
+
94
+
<h3>Install</h3>
95
+
<p>If you already have <ahref="http://docs.rubygems.org/">RubyGems</a> all you need to do is:</p>
96
+
<p><code>gem install snmp</code></p>
97
+
<p>If you don't have RubyGems then <ahref="http://rubyforge.org/frs/?group_id=126">go get it</a>. Otherwise, you will need to <ahref="http://rubyforge.org/projects/snmplib/">download</a> the library from RubyForge, uncompress it, and run install.rb to install it.</p>
98
+
99
+
<h3>Import MIBs</h3>
100
+
<p>If you are using standard <ahref="http://www.ietf.org/">IETF</a> MIBs then you're ready to go. Most of the IETF MIBs have been included for you with Ruby SNMP. Just list the MIBs that you need when you open your SNMP session and you will have full symbolic access to all of the OIDs.</p>
101
+
102
+
<pre><code>
103
+
SNMP::Manager.open(:MibModules => ["DOCS-IF-MIB"]) do |snmp|
104
+
mac = ".0.224.111.203.106.116"
105
+
value = snmp.get_value("docsIfCmtsCmPtr" << mac)
106
+
end</code></pre>
107
+
108
+
<p>If you don't provide a MIB list then the default MIBs are loaded: SNMPv2-MIB, IF-MIB, IP-MIB, TCP-MIB, UDP-MIB</p>
109
+
110
+
<p>If you want to import custom MIBs, then have a look at the <ahref="doc/index.html">documentation</a> for the <code>SNMP::MIB</code> class. If you use the <code>import_module</code> method, you will need to install <ahref="http://www.ibr.cs.tu-bs.de/projects/libsmi/">libsmi</a> first, or create the required YAML file manually.</p>
111
+
112
+
<h3>Start Coding</h3>
113
+
114
+
<p>Have a look at the <ahref="doc/index.html">documentation</a> for the <code>SNMP::Manager</code> class. This class provides the main interface for sending and receiving SNMP PDUs.</p>
115
+
116
+
<p>Here's an example to get you started. You can find plenty more in the <ahref="doc/index.html">README</a> file</p>
SNMP::Manager.open(:Host => 'localhost') do |manager|
122
+
manager.walk(ifTable_columns) do |row|
123
+
row.each { |vb| print "\t#{vb.value}" }
124
+
puts
125
+
end
126
+
end</code></pre>
127
+
128
+
<h2>Useful SNMP Tools</h2>
129
+
130
+
<h3>libsmi</h3>
131
+
132
+
<p>The <ahref="http://www.ibr.cs.tu-bs.de/projects/libsmi/">libsmi</a> distribution includes some very useful tools for checking, analyzing, converting, and comparing MIBs. It also contains a complete archive of IETF and IANA MIBs which saves you from having to find and download them yourself.</p>
133
+
134
+
<h3>Net-SNMP</h3>
135
+
136
+
<p><ahref="http://net-snmp.sourceforge.net/">Net-SNMP</a> includes SNMP libraries for implementing SNMP agents and managers in C and a set of SNMP tools for setting and getting information from SNMP agents.</p>
<p>“I'd like to thank you for such a fantastic library.”</p>
145
+
<p>“This is excellent - better functionality than Perl's Net::SNMP
146
+
module.”</p>
147
+
<p>“Your work alone heightens my interest in Ruby quite a bit.”</p>
148
+
</div>
149
+
<p>Have feeback? Send it <ahref="http://rubyforge.org/sendmessage.php?touser=842">via RubyForge</a>.</p>
150
+
<h3>What is SNMP?</h3>
151
+
<p>SNMP is the Simple Network Management Protocol. This protocol provides the capability to monitor and manage switches, routers, printers, desktops, and other equipment in your network.</p>
152
+
153
+
<h3>What is Ruby?</h3>
154
+
<p>Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable.</p>
155
+
<p>Find out more at <ahref="http://www.ruby-lang.org/en/">www.ruby-lang.org</a>.</p>
0 commit comments