Linux SNMP commands and application instances (1)

Source: Internet
Author: User
Tags rrd rrdtool snmp snmpget snmpwalk

In the continuous learning of Linux SNMP, some of its command settings have always been the focus of our emphasis. So let's review some related command programs. Today we will introduce how to solve the Linux SNMP problem RRD database update instance. Update command: it uses one or more parameters in the format of:. If you know that you can use one N to represent the current time, you will be happy. Alternatively, you can use the time function in Perl to specify the time: perl-e 'print time, "\ n" 'Shell: how to run a program on different operating systems at a fixed interval of date + % s. However, the pseudo code can be used for representation:-Get the value and put it in variable "$ speed"-rrdtool update speed. rrd N: $ speed. Run the above script every five minutes. Run the above example when you want to know what the image looks like. You can put them in a script. Run this script to view the graph we just created.

Knowledge about Linux SNMP

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.

An incremental counter can be monitored and drawn into an image using the methods you have learned. Later we will be able to monitor values like thermometers. Most people interested in RRDtool use a counter that tracks the data volume transmitted by network devices. In this way, we will do this next step. We will start by explaining how to collect data.

Some may say that some tools can help you collect data. They are right! However, I feel that these tools are not essential. When you can determine why something went wrong, you need to know how they work. The tool used in this example is short mentioned earlier in this document. It is called Linux SNMP. It is used to communicate with connected devices. 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, adjusted, or protected for security and confidentiality reasons. Read your device or program documentation. Next, a parameter called OID is used to represent the object identifier.

It seems confusing when I first started learning Linux SNMP. When you see the MIB management information base, it is not that difficult. MIB is an inverted tree used to describe data. It has only one root-knot point and has multiple branches starting 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, which forms a path that we can follow down. The branches we are following 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 .., which 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, it is usually agreed that the leading point is used when the complete OID recording method is used.

Usually, when these programs return data to you, they will omit the missing part. These programs have several default prefixes, which makes 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.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) 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 programs. First, check whether your OS platform has compiled software packages. This is the most convenient way. If not, 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: For the trees that interest us, the above section has a simple name. Here I will provide an example available on the Fedora Core 3 operating system. If your operating system is unavailable, check the Linux SNMP manual and make corresponding adjustments to make it run.

Linux SNMPget-v2c-c public myrouter system. sysDescr.0 the device should respond to its own description, which may be empty. You can continue 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. In this case, 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 result returned by the command:

[User @ host/home/alex] $ Linux SNMPwalk-v2c-c public cisco 2.2.1.2 interfaces. ifTable. ifEntry. ifDescr.1 = "BRI0: B-Channel 1" interfaces. ifTable. ifEntry. ifDescr.2 = "BRI0: B-Channel 2" interfaces. ifTable. ifEntry. ifDescr.3 = "BRI0" Hex: 42 52 49 30 interfaces. ifTable. ifEntry. ifDescr.4 = "Ethernet0" interfaces. ifTable. ifEntry. ifDescr.5 = "Loopback0" for cisco devices, I want to monitor the 'ethernet0' interface. From the output above, I can see that the interface number is 4.

Run the following command: [user @ host/home/alex] $ Linux SNMPget-v2c-c public cisco 2.2.1.10.4 2.2.1.16.4

Interfaces. ifTable. ifEntry. ifInOctets.4 = 2290729126 interfaces. ifTable. ifEntry. ifOutOctets.4 = 1256486519 so that I have two OID to monitor. They use the complete recording method this time): 1.3.6.1.2.1.2.2.1.10 and 1.3.6.1.2.1.2.2.1.16 both OID have interface number 4.

Don't be fooled. I just did it once. I spent some data to figure out what these numbers mean. It is helpful to convert these numbers into descriptive text... At least when you talk about MIB and OID, you know what they are. Do not forget the interface number. If it is not a subsidiary interface, it is 0). If Linux SNMPget does not receive a response, try Linux SNMPwalk.


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.