Linux SNMP protocol instance (1)

Source: Internet
Author: User
Tags rrdtool snmp snmpget snmpwalk

For Linux SNMP protocol applications, this article will give you an example of a specific example to help you master this part of the content. For this complex process, we have introduced the update command in the previous article: it uses one or more parameters in the format ::. if you know that you can use N to represent the current time, you will be happy. Or you can use the time function in Perl to specify the time: perl-e 'print time, "\ n" 'Shell: date + % s how to run a program at a fixed interval varies with operating systems 。

However, the pseudo code can be used for representation:-Get the value and put it in variable "$ speed"-rrdtool update speed. rrd N: $ speed is just like this. The above script is run every five minutes. When you want to know what the image looks like, run the preceding example. You can put them into a script. Run this script and view the graph we just created 。

Knowledge about Linux SNMP protocol

I can imagine that only a few people can read real data from their cars every 5 minutes. Others have to Clear Counters of other types. You can measure the number of pages printed by the printer, the number of coffee cups made by the coffee maker and the current used for calculation can all be used 。

Incremental counters can be monitored, and use the methods you have learned to draw images. Later we will be able to monitor values like thermometers. Most people interested in RRDtool will use a method that tracks the amount of data transmitted by network devices. counter. In this way, we will proceed to this step. We will begin by explaining how to collect data 。

Some may say that some tools can help you collect data. They are right! However, I feel that it is not essential to understand these tools. When you can determine why something went wrong, you need to know how they work. The tools used in this example have been briefly mentioned earlier in this document, it is called Linux SNMP. It is used to talk to a networked device. The tool used below is Linux SNMPget. The following describes how it works:

For Linux SNMPget device password OID or Linux SNMPget-v [version]-c [password] device OID, replace it with the device name or IP address. For password, you need to replace it with a comunity read string in the Linux SNMP field 。

For some devices, the default public can work, but this setting may be disabled, adjust or be protected for security and confidentiality reasons. Please read the document of your device or program. Next there is a parameter called OID, which is used to represent the object identifier 。

It seems confusing when I first learned the Linux SNMP protocol. It is not that difficult when you see the MIB Management Information Base. MIB is the inverted tree used to describe data, it has only one root node, and multiple branches start from the root node. These branches end with another node, and they continue to go down to the branch 。

Therefore, each branch has a name that forms a path that we can follow. All the branches we follow are named iso, org, dod, internet, mgmt and mib-2. these names can also be recorded in numbers, like 1 3 6 1 2 1 。

Iso.org. dod. internet. mgmt. mib-2 (1.3.6.1.2.1) Some programs use leading points ., this is confusing. There is no leading point in an OID. To show the differences between the OID contraction method and the complete OID recording method (usually agreed) use the leading point when using the complete recording of the OID 。

Normally, these programs will omit the missing part when returning data to you. These programs have several default prefixes, which will make things worse. OK, lets continue to the start of our OID: we had 1.3.6.1.2.1 From there, we are especially interested in the branch interfaces which has number 2 (e.g ., 1.3.6.1.2.1.2 or 1.3.6.1.2.1.interfaces ).

Now, let's continue with the preliminary study of OID: we have an OID of 1.3.6.1.2.1, which we are particularly interested in (below) the interface branch. Its number is 2 (for example: 1.3.6.1.2.1.2 or 1.3.6.1.2.1.interface )。

First, we need to have several Linux SNMP protocol programs. First, check whether your OS platform has compiled software packages. This is the most convenient way, you have to download the source code and compile it. source code and programs are everywhere on the Internet. You can use any method you like and search engines to find relevant information 。

Suppose you already have these programs. First, try to collect data from most systems. Remember: The trees that interest us, the above section has a brief name. Here I will give an example available on the Fedora Core 3 operating system. If your operating system is unavailable, please check the Linux SNMP manual and make corresponding adjustments so that it can run 。

Linux SNMPget-v2c-c public myrouter system. sysDescr.0 the device should respond to its own description, which may be empty. Only after you get a response from a device, you may need to use different passwords or devices 。

Linux SNMPget-v2c-c public myrouter interfaces. ifNumber.0 you 'd better get a number. If so, you can continue and try another program named Linux SNMPwalk. Linux SNMPwalk-v2c-c public myrouter interfaces. ifTable. ifEntry. ifDescr if the command returns a series of interfaces, this is correct. The following is an example of the returned results of the command:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.