Article Title: Linux-based performance monitoring competition and implementation strategy. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Basic concepts of performance monitoring:
Today, enterprises are constantly demanding on key service efficiency and stability. Therefore, it is increasingly important to obtain comprehensive information on service operation in a scientific and accurate manner. Therefore, when deploying services, enterprises also use various methods and means to monitor services and their peripheral environment resources. In addition to the service itself, the Monitored Objects also include the basic environment in which the service runs, such as CPU, memory, I/O, storage space, and network throughput. By using different graphical analysis software for sorting and analyzing the data collected during the long-term monitoring, we can easily determine the current and long-term running status of the service, it also provides a reference for future performance tuning and system troubleshooting.
Basic Principles and types of performance monitoring based on Linux:
There are basically two methods used for performance monitoring on Linux:
First, it is implemented through snmp + data collection software:
By starting the snmp Simple Network Management Protocol on a Linux server to dynamically collect the running parameters of the server in software or hardware, the server becomes a monitored node. Some client software on other network management workstations can then collect snmp data and dynamically generate HTML information that can be accessed through Web pages, the other part of the client software itself integrates more powerful data collection and drawing functions, combined to generate more intuitive and specific web pages. The data format obtained by this type of monitoring is comprehensive and easy to configure. Therefore, it is a good solution from the perspective of comprehensive monitoring.
Second, write the script + data collection software through the performance monitoring command:
In some cases, the configuration of the snmp protocol is relatively cumbersome, but the system itself provides many performance monitoring commands, such as sar, iostat, and free, that can be periodically and periodically executed, this facilitates monitoring. These commands can be embedded into scripts to periodically generate the data required by the performance monitoring software. In the end, they can be used to generate an intuitive Statistical Chart. The information obtained by this type of monitoring is more flexible and accurate. It is quite handy for some users who are familiar with scripts programming.
In addition, command monitoring can be expanded without restrictions. Users can obtain and customize their own monitoring scripts through various pipelines. Therefore, the two monitoring schemes have their own advantages. Therefore, we will provide some cases for each of the two solutions in the following sections, from simple to complex. We will explain and explain the operation methods of each solution step by step.
In more cases, many enterprises tend to use SNMP to obtain various information about server running. Therefore, we will take some time to introduce the basic concepts and working principles of SNMP.
Simple Network Management Protocol (SNMP) is a network protocol widely used to monitor network devices (computers, routers) and other devices (such as UPS, it is also a specialized application layer protocol used to manage network nodes (including servers, workstations, routers, switches, and HUBS) in an IP network. SNMP enables network administrators to manage network performance, discover and solve network problems, and plan network growth. When SNMP is used to receive random messages (and event reports), the network management system will learn various network problems.
The Network Managed by SNMP has three main components: Managed Device, Agent, and Network Management system (NMS ).
A managed device is a network node that contains an ANMP proxy and is in a management network. It is also known as a network unit. It is used to collect and store network information, which can be obtained through SNMP and NMS. The managed devices may be routers, access servers, switches and bridges, HUBS, hosts, or printers.
The SNMP agent is a network management software module on the managed device. The SNMP agent has local management information and converts them to an SNMP-compatible format.
NMS runs applications to monitor managed devices. In addition, NMS provides a large number of processing programs and necessary storage resources for network management. Any managed network requires at least one or more NMS.
Currently, SNMP has three different versions: SNMPv1, SNMPv2, and SNMPv3. There is no big gap between version 1st and version 2nd, but SNMPv2 is an enhanced version that includes other protocol operations. The first two snmp protocols use the group name (community) method to authenticate access to the proxy by the network management workstation. Compared with the first two methods, SNMPv3 includes more security and remote configuration, in terms of authentication, users and passwords encrypted based on some symmetric and asymmetric encryption protocols can be used to implement access authentication for proxies by the network management workstation. To solve the incompatibility problem between different SNMP versions, RFC3584 defines a three-way coexistence policy.
In addition, the SNMP protocol includes four basic actions:
Get: if the network management system needs to obtain the information of the monitored device, the get action is executed.
GetNext: If you want to obtain information about a project that is one of multiple projects in the project list, the network management system executes getnext to obtain information about all the projects.
Set: the network management system uses the set command to change a value of the managed project.
Trap: If the managed device needs to notify the network management system of some information, it needs to execute the trap command.
Finally, the SNMP-related package in Red Hat provides MIB in the package. The information file is/usr/share/snmp/mibs. MIB is a Management Information Base for a device ). Each value of this device is represented by a unique Object Identifier (OID). The OID format includes available names, prefixes, and numbers.
If the net-snmp-utils package is installed in the system, the MIB and OID information in snmp can be displayed through the snmptranslate command, and the information of the entire MIB Tree and the OID on it, snmptranslate is used to convert the OID information displayed by text name or number ID and list the snmp MIB structure tree.