Detailed description of SNMP and rrdtool

Source: Internet
Author: User
Tags rrd rrdtool snmpwalk snmpv3

Snmp is short for simple network manage protocol. snmp can use simple commands to obtain the service status on a remote host to monitor remote services. Snmp has gone through three versions: snmpv1, snmpv2, and snmpv3. The simple working principle of snmp is that a host on the monitoring end sends commands to a host on the monitoring end, the host on which the prosecution instance is installed can identify the commands sent from the host on the monitoring instance and provide feedback. Due to the limitations of this monitoring, it is ensured that the monitored host only recognizes the monitoring information sent from the specified host. Both parties need to establish the recognition information, which is the role of communite. In snmpv1, three communite methods are provided: read-only, read-write, and trap. Read-only means that the monitoring end can only receive information sent from the monitored end; read-write means that the monitoring end can directly operate the monitored host, such as shutdown; trap means that the monitored end can send information to inform the monitoring end to monitor itself. Compared with v1, snmpv2 has made powerful functional changes, but its basic functions have not changed. Snmpv3 provides more security measures for authentication and greatly enhances data transmission security. However, snmpv1 is the most widely used version.

Snmp has a very important concept: MIB (management infromation base), the full name of the management information library. It is the standard for network management data, which specifies the data items and data types that must be stored by the network proxy device, and allows operations in each data project. All data is stored in a tree structure. The second version of MIB is widely used, called MIB-II. Any host provides a MIB-II.

NMS = Network Management System: Network Management System. Is the control end in SNMP and the initiator of network management. Agent, which provides SNMP capabilities for managed devices and is responsible for communication between devices and NMS.

There are two snmp software packages. One is net-snmp and the other is net-snmp-utils. The one above is the tool required by the monitoring end, and the other is the command used by the monitoring end. However, if the monitoring end needs to use the trap function, it also needs to install the net-snmp package on the monitoring end. The following functions are all described on the local machine. Therefore, we directly mount all these two packages on the local machine. Yum install net-snmp-utils. You can use rpm-ql net-snmp to view all files installed during snmp installation. Using netstat-tunpl | grep snmp, you can find that the snmp listening is on tcp ports 199 and udp ports 161. If the monitoring end needs to enable the trap function, it also needs to start the snmptrapd server. Service snmptrapd start. Snmptrapd listens to udp port 162 by default. You can use snmpwalk-v 2c-c public localhost to obtain the resource status on the server for resources on a host. Snmpwalk supports many commands and parameters, and many resource conditions can be obtained.

The default configuration file of snmp is in the/etc/snmp/snmpd. conf file. This file contains the following information to change the host and community of the specified Monitoring:

# Sec. name source community

Com2sec notConfigUser default public

By default, all hosts are allowed to monitor on our hosts through this public interface. This shows that this is an insecure approach. Because the local machine monitors itself, you can change it:

Com2sec notConfigUser 127.0.0.1 qiguopublic, and all mibs databases are placed under the/usr/share/snmp/mibs/directory.

RRDtool refers to the Round Robin Database tool (ring Database ). Round robin is a technology used to process quantitative data and current element pointers. Imagine a circle with vertices around it. These vertices are the location of time storage. Draw an arrow from the center of the circle to a point in the circumference. This is the pointer. Just as we are on a ring, you can keep walking without starting or ending points. After a period of time, all available locations will be used, and the cycle process will automatically reuse the original location. In this way, the dataset does not increase and maintenance is not required. We use RRDtool to process RRD databases. It is used to store and extract data to the RRD database. You can plot the RRDtool to monitor the traffic chart.
Rrdtool is not provided in linux and needs to be manually installed. Here we use the source code package to install rrdtool. The software package is rrdtool-1.4.5.tar.gz. Start the installation process as follows:
Tar xf rrdtool-1.4.5.tar.gz
Cd rrdtool-1.4.5
./Configure -- prefix =/usr/local/rrdtool
Make & make install
For use. Add/usr/local/rrdtool/bin to environment variables such as path.
Vi ~ /. Bash_profile
Add PATH = $ PATH: $ HOME/bin:/usr/local/rrdtool/bin
Source. bash_profile re-read the configuration file

The following are some common options for using RRDtool. You can use these options to generate a drawing.

1. Use rrdtool to create RRD ring databases of various types and features
Rrdtool create filename [-- start |-B start time] [-- step |-s step] [DS: ds-name: DST: dst arguments] [RRA: CF: cf arguments]
This syntax is used to create an initialized rrdtool database file; filename is the name of the file to be created; -- start time sets the time when the rrd database is added to the first data, the default value is 10 seconds ago. -- step time span, which indicates the amount of time at which a data source is received. DS specifies a data source that can be aggregated multiple times. RRA specifies how to perform aggregation, archived.
DS: ds-name: DST: dst arguments:
DS fixed format, indicating the data source;
The name of the ds-name data source, which must be unique and can contain a maximum of 19 characters
The type of the DST data source. The data source types include 5 parameters: GAUGE, COUNTER, DERIVE, ABSOLUTE, and compute.
GAUGE indicates the initial A value. It stores the original value of A data without any changes.
COUNTER indicates the relative value, which is usually the value relative to the previous data and must be greater than the value of the previous data.
DERIVE is the same as COUNTER, but there is no counter limit.
ABSOLUTE obtains a relative value based on the original value.
COMPUTE is used to store the formula calculation results for other data sources in RRD.
Dst arguments data source type parameters. The default value is "heartbeat", "min", and "max ".
Heartbeat indicates the maximum amount of time the data is considered to be in the corresponding slot when the data arrives.
Min indicates the minimum value of the stored data. If you do not know the minimum value, you can use U by default.
Max indicates the maximum value of the stored incoming data. If you do not know the maximum value, you can use U by default.

RRA: CF: cf arguments:
RRA keyword
CF aggregate function, which has four aggregation types: AVERAGE, MIN, MAX, and LAST. Mean, minimum, maximum, current, respectively.
The parameter of the cf arguments aggregate function. The default format is xff: steps: rows.
Xff indicates that when the ratio of specified unknown is large, it is defined as unkown.
Steps indicates that the aggregate function performs one aggregation on several PDP instances.
Rows indicates how many aggregate results are saved
Example:
Rrdtool create test. rrd -- step 5 DS: qiguo: GAUGE: 8: u rra: AVERAGE: 0.5: 1: 17280 RRA: AVERAGE: 0.5: 10: 3456 RRA: AVERAGE: 0.5: 100: 1210
In the preceding example, an rrd named test. RRD is set to receive a random value every five seconds. If no data is provided within 8 seconds, the value is * UNKNOWN *. It can accept any value. In this example, several archiving areas are also defined. The first RRA archive area stores a random value (17280*5) within one day ). The average value of the second RRA storage within two days (3456*10*5), and the average value of the third storage within one week (100*5*1210)
Rrdtool info test. rrd can view the specific content of test. rrd.
2. provide data for rrd ring database:
Rrdtool {update | updatev} filename [-- template |-t ds-name [: ds-name]...] N | timestamp: value [: value...] at-timestamp @ value [: value...] [timestamp: value [: value...]
Filename is the name of the RRD database to be updated.
-- Template |-t ds-name [: ds-name]...:-t ds-name to update the name of the data source in the RRD Database
N | timestamp: value [: value...]: Time: value to be updated...

Example:
While true; done
Rrdtool update test. rrd N: $ RANDOM
Sleep (5 );
Done
Rrdtool fetch-r 5 test. rrd AVERAGE allows you to view the data generated for the rrd ring database.
-R indicates the time when data is generated.
3. Draw the data collected in rrd Environment Database
Rrdtool graph filename [option...] [data definition...] [data calculation...] [variable definition...]
[Graph element...] [print element...]
Name of the image to be drawn using filename
Time range
[-S | -- start time] start time
[-E | -- end time] end time
[-S | -- step seconds] step Size
[-T | -- title string] image title
[-V | -- vertical-label string] Y axis description
[-W | -- width pixels] display area width
[-H | -- height pixels] height of the display area
[-J | -- only-graph] only draws an image.
[-U | -- upper-limit value] maximum value of the Y axis positive value
[-L | -- lower-limit value] minimum value of negative values in Y axis
[-R | -- rigid] fixed the value of the Y axis without scaling
[-A | -- alt-autoscale] auto Scaling
[-J | -- alt-autoscale-min] Only auto scaling min
[-M | -- alt-autoscale-max] Only auto scaling max
[-N | -- no-gridfit] grid lines are not displayed.
[Data definition...] data and variables:
DEF: vname = rrdfile: ds-name: CF [: step = step] [: start = time] [: end = time]
Vname defines a variable to save data
Rrdfile is the previously generated rrd file.
Ds-name indicates the name of the data source.
CF is an aggregate function.
Step indicates how long data is obtained
LINE [width]: value [# color] [: [legend]
LINE: Specifies the LINE chart. By default, LINE1 is used.
Value indicates that the vname variable defined by DEF is used as the value for drawing.
Color indicates the color of the image.
Legend indicates the text information in the corresponding graph.
Example:
Rrdtool graph qiguo.png-s 1400129745-t Test-v YTest DEF: mytest = test. rrd: qiguo: AVERAGE: step = 5 LINE1: mytest # FF0000: testline
Note: Here, 1400129745 is the timestamp number generated by the above rrdtool fetch based on observation.
The above example generates a line chart named qiguo.png starting from timestamp. The image is as follows:

However, an image has only one piece of information. How can we draw two different lines on an image?
You only need to generate one more drawing data and drawing function when drawing:
Rrdtool graph qiguo2.png-s 1400130895-t Test-v YTest DEF: mytest = test. rrd: qiguo: AVERAGE: step = 5 DEF: mytest2 = test. rrd: qiguo: AVERAGE: step = 50 LINE1: mytest # FF0000: testline LINE2: mytest2 #00FF00: test2line
The image is as follows:

However, when we observe the official site of rrdtool, many figures have the maximum value, minimum value, and current value. Then, you need to use another function, GPRS Int. Default format: uplint: vname: CF: format

Vname indicates the value corresponding to the variable. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + Q0bKx77bus + Serial/serial + CsD9OiA8YnI + Serial + CiAgICDQtNK7uPa9xbG + d2hpbGUuc2ijrMjDy/serial + Serial "http://www.2cto.com/uploadfile/Collfiles/20140516/2014051608532228.jpg" alt = "">



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.