Method and system for monitoring hardware through snmptrapd
By configuring the snmptrapd image and container combination, the problems of snmptrapd server stability and monitoring difficulty are solved, real-time monitoring of hardware devices and automatic node migration are realized, and management and ease of use are improved.
Patent Information
- Application Number
- CN202210223017.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-07
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-03-07
AI Technical Summary
The existing snmptrapd server has insufficient stability, which affects the normal reception and monitoring of hardware devices through snmp trap messages, resulting in increased management difficulty and low ease of use and manageability.
By configuring the snmptrapd image, setting pod affinity and host network, defining container combinations, using prometheus to access monitoring data, and implementing node drift detection and automatic restart through the curl container, ensuring the stability of the snmptrapd server and real-time query of monitoring data.
It achieves the stability of the snmptrapd server and the ease of use and manageability of hardware device monitoring, simplifies configuration, supports automatic sensing and migration during node migration, avoids the manual migration process, and improves the monitoring function of the production environment.
Smart Images

Figure CN114598585B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing, and in particular to a method and system for monitoring hardware through snmptrapd. Background Art
[0002] Snmptrapd is an SNMP application that receives and records trap and inform messages sent by devices that support the SNMP protocol. Current network devices and servers all support SNMP, and the snmptrapd server information is configured through the management interface. SNMP trap is a process in which the managed device actively sends abnormal conditions to the management server, so it is a process in which the management server passively receives messages. Therefore, if you need to monitor hardware through snmptrapd, you need to consider the stable operation of the management server, otherwise you cannot normally receive the SNMP trap messages sent by the hardware device.
[0003] How to ensure the stability of the snmptrapd server and improve the usability and manageability of hardware monitoring through snmptrapd are technical issues that need to be solved. Summary of the invention
[0004] The technical task of the present invention is to address the above shortcomings and provide a method and system for monitoring hardware through snmptrapd to solve the technical problem of how to ensure the stability of the snmptrapd server and improve the usability and manageability of monitoring hardware through snmptrapd.
[0005] In a first aspect, the method for monitoring hardware by snmptrapd of the present invention comprises the following steps:
[0006] Configure an image that can run snmptrapd according to the type of hardware being monitored;
[0007] Set pod affinity in the snmptrapd deployment to ensure that the generated pod and the vip pod are on the same node, and set the host network to ensure that the port is exposed on the vip and can receive trap messages sent by the hardware to be monitored;
[0008] Define the containers that need to run in the snmptrapd pod;
[0009] Use prometheus to connect to the interface exposed by the snmptrapd pod to pull the indicator data reported by snmptrapd in real time;
[0010] Configure snmptrapd information on the hardware device to be monitored. The trap information sent by the hardware device through snmptrap is received by the snmptrapd pod and converted into monitoring indicators, so that the monitoring data can be queried in real time in prometheus.
[0011] Preferably, an image capable of running snmptrapd is configured according to the type of hardware to be monitored, dependency packages are installed, mib files of the hardware to be monitored are collected and stored in the image, and the pod started according to the image can identify trap messages sent by the hardware to be monitored.
[0012] Preferably, define the containers that need to run in the snmptrapd pod, including:
[0013] Add four containers to the deployment of snmptrapd, namely: snmptrapd container, fluentd container, logrotate container and curl container. The snmptrapd container uses the created image to configure the port exposed by the service; the fluentd container uses an open source image to configure the prometheus port exposed by the configuration service; the logrotate container uses an open source image to configure the storage of snmp trp messages; the curl container uses an open source image to configure the startup command to run the script;
[0014] Configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that can be identified by prometheus based on the trap messages sent by the hardware to be monitored, and expose the metrics port to wait for the service address of smmptrapd and the port exposed by fluentd to access;
[0015] Write a script used by the curl container, and periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located.
[0016] Preferably, configure the service address of smmptrapd in prometheus, access it through the service address of smmptrapd and the port exposed by fluentd, and after successful access, you can query the monitoring data in real time.
[0017] Preferably, the configured snmptrapd information includes server IP, port, community word and event level; the server IP configures the IP address carried by the vip pod, the port configures the default port 162 used by the snmptrapd server, the community word configures the field agreed with snmptrapd, and the event level is controlled according to business needs.
[0018] In a second aspect, a system for monitoring hardware through snmptrapd of the present invention monitors hardware devices in a container cluster environment through a method for monitoring hardware through snmptrapd as described in any one of the first aspects, and the system includes:
[0019] An image configuration module, the image configuration module is used to configure an image capable of running snmptrapd according to the type of hardware being monitored;
[0020] Snmptrapd configuration module, which is used to set pod affinity in the snmptrapd deployment to ensure that the generated pod and the vip's pod are on the same node, and to set the host network to ensure that the port is exposed on the vip and can receive the trap message sent by the hardware to be monitored;
[0021] A container definition module, which is used to define the container that needs to be run in the snmptrapd pod;
[0022] An access module, which is used to use prometheus to connect to the interface exposed by the snmptrapd pod to pull the indicator data reported by snmptrapd in real time;
[0023] An information configuration module is used to configure snmptrapd information on the hardware device to be monitored. The trap information sent by the hardware device through snmptrap is received by the snmptrapd pod and converted into monitoring indicators, so that the monitoring data can be queried in real time in prometheus.
[0024] Preferably, the image configuration module is used to configure an image that can run snmptrapd according to the type of monitored hardware, install dependent packages, collect mib files of the hardware to be monitored and organize and store them in the image, and the pod started according to the image can identify the trap messages sent by the hardware to be monitored.
[0025] Preferably, the Snmptrapd configuration module is used to define the containers that need to run in the snmptrapd pod, including:
[0026] Add four containers to the deployment of snmptrapd, namely: snmptrapd container, fluentd container, logrotate container and curl container. The snmptrapd container uses the created image to configure the port exposed by the service; the fluentd container uses an open source image to configure the prometheus port exposed by the configuration service; the logrotate container uses an open source image to configure the storage of snmp trp messages; the curl container uses an open source image to configure the startup command to run the script;
[0027] Configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that can be identified by prometheus based on the trap messages sent by the hardware to be monitored, and expose the metrics port to wait for the service address of smmptrapd and the port exposed by fluentd to access;
[0028] Write a script used by the curl container, and periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located.
[0029] Preferably, the access module is used to configure the service address of smmptrapd in prometheus, and access is performed through the service address of smmptrapd and the port exposed by fluentd. After successful access, monitoring data can be queried in real time.
[0030] Preferably, the configured snmptrapd information includes server IP, port, community word and event level; the server IP configures the IP address carried by the vip pod, the port configures the default port 162 used by the snmptrapd server, the community word configures the field agreed with snmptrapd, and the event level is controlled according to business needs.
[0031] The method and system for monitoring hardware through snmptrapd of the present invention have the following advantages:
[0032] 1. The container cluster environment monitors the hardware through snmptrapd. The Pod running snmptrapd includes snmptrapd receiving hardware trap messages, fluentd parsing logs, and logrotate cleaning up expired logs.
[0033] 2. At the same time, a container is added to periodically check whether the vip's Pod has node drift, which not only simplifies the configuration but also ensures the stability of the function. It supports the real-time perception of the snmptrapd pod when the vip's pod node migrates and migrates it to the same node in time, realizing the function of monitoring hardware through snmptrapd in the production environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] The present invention is further described below in conjunction with the accompanying drawings.
[0036] Figure 1 This is a flowchart of a method for monitoring hardware through snmptrapd in Example 1;
[0037] Figure 2 In the method for monitoring hardware through snmptrapd in Example 1, the snmptrapd service is run to receive trap messages and generate a monitoring indicator graph. DETAILED DESCRIPTION
[0038] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
[0039] The embodiment of the present invention provides a method and system for monitoring hardware through snmptrapd, which are used to solve the technical problem of how to ensure the stability of the snmptrapd server and improve the usability and manageability of monitoring hardware through snmptrapd.
[0040] Embodiment 1:
[0041] The method for monitoring hardware by snmptrapd of the present invention comprises the following steps:
[0042] S100, configure the image that can run snmptrapd according to the type of hardware to be monitored;
[0043] S200, set pod affinity in the deployment of snmptrapd to ensure that the generated pod and the VIP pod are on the same node, and set the host network to ensure that the port is exposed on the VIP and can receive the trap message sent by the hardware to be monitored;
[0044] S300, define the containers that need to be run in the snmptrapd pod;
[0045] S400, use prometheus to connect to the interface exposed by the snmptrapd pod to pull the indicator data reported by snmptrapd in real time;
[0046] S500. Configure snmptrapd information on the hardware device to be monitored. The trap information sent by the hardware device through snmptrap is received by the snmptrapd pod and converted into monitoring indicators, so that the monitoring data can be queried in real time in prometheus.
[0047] Step S100 makes a snmptrapd image. As a specific implementation, in this step, ubuntu is selected as the basic image, snmptrapd and dependent packages are installed, the hardware device configuration community word is configured to the configuration file required by snmptrapd and copied to the image, the type of hardware device to be monitored is collected and the mibs file supported by it is obtained, that is, snmptrapd supports capturing the snmp trap message type of the hardware device, these files are aggregated into a directory and copied to the image, and finally a startup script is written. Based on this, the snmptrapd image is built, so that the pod started according to the image can recognize the snmp trap message sent by the hardware.
[0048] Step S200 sets deployment parameters: the pod manager that runs snmptrapd uses deployment, first sets pod affinity (using requiredDuringSchedulingIgnoredDuringExecution in podAffinity) to schedule it to the same kuberntes node as the vip's pod; at the same time, sets the host network (hostNetwork) to ensure that the snmptrapd service port (162 / UDP) can be exposed to the vip, so that it can receive trap messages sent by the hardware; mounts a shared directory to provide shared logs for the snmptrapd container and the fluentd container, and mounts two configmaps including scripts used by fluentd to parse the configuration and the check container.
[0049] Step S300 defines the containers that need to be run in the snmptrapd pod. In this process, first, a deployment container is set. The four containers run by the snmptrapd deployment are snmptrapd, fluentd, logrotate, and curl. The snmptrapd container uses the image created in step S100, configures the port (162 / UDP) exposed by the service, uses a command to check whether the port is normal for health check, and mounts the directory / var / log to provide snmp trap logs for fluentd container parsing and logrotate container regular cleaning; the fluentd container uses an open source image, configures the prometheus port (24231 / TCP) exposed by the service, uses a built-in method to check whether the port is normal for health check, mounts the directory / var / log to read the snmp trap log, and mounts the directory / etc / fluent / config.d to load the configuration file; the logrorate container uses an open source image, mounts the directory / var / log as the cleaning object, configures the log directory ( / var / log) for storing snmp trp messages, the log truncation method (for example, by day), whether the storage is compressed and the storage time (for example, 7 days); the curl container uses an open source image, configures the startup command to run the script, configures the environment variables to read the name of the Pod, the node to which it belongs and the namespace, and mounts / tmp / init.sh to load the script.
[0050] Secondly, configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that prometheus can identify based on the trap messages sent by the hardware, and expose the metrics port to wait for access in step 6. As a specific implementation, enable the fluent-plugin-prometheus plug-in configuration, expose the metrics interface through the port, and provide prometheus with a pull interface to obtain monitoring indicators; configure the source block to read the snmp trap message received by the Pod and parse the field, configure the match block to distinguish the parsed field and add different labels to distinguish the device type, and configure the filter block of the prometheus type to assemble the label of the monitoring indicator according to the field. In this way, the process of extracting the indicators and labels of the monitoring data that prometheus can identify based on the trap messages sent by the hardware is completed, and finally the metrics port is exposed to wait for the configured snmptrapd information access.
[0051] Write the script used by the curl container again, and periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located. The overall architecture is an infinite loop, in which the container cluster API is periodically called to obtain the node where the vip pod is located. If the acquisition fails or the Pod status is wrong, the error is printed and the next loop continues; if the acquisition is successful and the Pod status is normal, determine whether the node is consistent with the current node of the snmptrapd pod. If it is inconsistent, call the container cluster API to restart the snmptrapd pod. When the Pod is rebuilt, it will be rescheduled to the node where the vip pod is located because of the configuration in the deployment parameters.
[0052] Step S400 configures the service address of smmptrapd in prometheus, accesses through the service address of smmptrapd and the port exposed by fluentd, and after successful access, the monitoring data can be queried in real time.
[0053] Step S500 configures snmptrapd information on the hardware to be monitored. All hardware to be monitored configure snmptrap including server IP, port, community word, event level, etc.; the server IP configures the vip pod bearer IP address, the port configures the snmptrapd server port (162 / UDP), the community word configures the fields agreed in (1), and the event level is controlled according to business needs.
[0054] This step also includes configuring smmptrapd in prometheus. Add the snmptrapd service address and the exposed port (24231 / TCP) of the fluentd container in the prometheus configuration, and check whether the target in the prometheus interface is successfully connected to snmptrapd. If successful, the hardware to be monitored generates an error and successfully sends an SNMP trap message to snmptrapd. The relevant monitoring indicators can be queried in the prometheus interface, thus completing the hardware monitoring.
[0055] The method of this embodiment first prepares to make a snmptrapd image according to the type of hardware to be monitored, sets pod affinity and uses the host network in the deployment. Then define the containers that need to be run in the snmptrapd pod, including the snmptrapd container exposing ports to provide services, the fluentd container parsing the snmptrapd container receiving logs and exposing indicators, the logrorate container periodically cleaning up the expired logs received by the snmptrapd container, and the curl container periodically calling the container cluster API to check whether the vip pod has node drift. Then use prometheus to dock the interface exposed by the snmptrapd pod, and you can pull the indicator data reported by snmptrapd in real time. Finally, configure the snmptrapd information on the hardware device to be monitored. The hardware can be converted into monitoring indicators after the trap information sent by snmptrap is received by the snmptrapd pod, so that the monitoring data can be queried in real time in prometheus.
[0056] This method first relies on the container cluster environment to run vip through Pod, and then runs the snmptrapd Pod, where the containers include snmptrapd to collect logs, fluentd to parse logs, logrotate to clean up logs, curl calls the container cluster API to check the vip pod, and finally uses prometheus to connect to the metrics interface exposed by the snmptrapd fluentd container to receive the snmp trap messages sent by the reporting hardware in real time and display them in the form of indicators. On the one hand, the Pod affinity configuration of the container cluster enables the snmptrapd pod and the vip pod to be scheduled to the same node; at the same time, a curl container is added to the snmptrapd pod to periodically check whether the vip pod has node drift. If the drift triggers itself to be rescheduled to a new node, the stability of the snmptrapd server is guaranteed, and the need to manually migrate services when a node fails is avoided, which greatly improves the ease of use and manageability of monitoring hardware through snmptrapd.
[0057] Embodiment 2:
[0058] The present invention discloses a system for monitoring hardware through snmptrapd, comprising an image configuration module, a Snmptrapd configuration module, a container definition module, an access module and an information configuration module. The image configuration module is used to configure an image capable of running snmptrapd according to the type of hardware to be monitored; the snmptrapd configuration module is used to set pod affinity in the deployment of snmptrapd to ensure that the generated pod and the pod of a vip are on the same node, and to set the host network to ensure that the port is exposed on the vip and can receive the trap message sent by the hardware to be monitored; the container definition module is used to define the container to be run in the pod of the snmptrapd; the access module is used to use prometheus to dock the interface exposed by the pod of the snmptrapd to pull the index data reported by the snmptrapd in real time; the information configuration module is used to configure the snmptrapd information on the hardware device to be monitored, and the trap information sent by the hardware device through snmptrap is converted into the monitoring index after being received by the pod of the snmptrapd, so that the monitoring data can be queried in real time in prometheus.
[0059] Among them, the image configuration module is used to configure the image that can run snmptrapd according to the type of monitored hardware, install dependent packages, collect the mib files of the hardware to be monitored and organize and store them in the image. The pod started according to the image can identify the trap messages sent by the hardware to be monitored.
[0060] The Snmptrapd configuration module is used to define the containers that need to run in the snmptrapd pod, including:
[0061] (1) Add four containers to the deployment of snmptrapd, namely: snmptrapd container, fluentd container, logrotate container and curl container. The snmptrapd container uses the created image to configure the port exposed by the service; the fluentd container uses an open source image to configure the prometheus port exposed by the configuration service; the logrotate container uses an open source image to configure the storage of snmp trp messages; the curl container uses an open source image to configure the startup command to run the script;
[0062] (2) Configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that can be identified by prometheus based on the trap messages sent by the hardware to be monitored, and expose the metrics port to wait for the service address of smmptrapd and the port exposed by fluentd to access;
[0063] (3) Write a script used by the curl container to periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located.
[0064] In the specific real-time process, the workflow of this module consists of the following three steps.
[0065] Step 1: Set up the deployment container. The four containers that snmptrapd's deployment runs are snmptrapd, fluentd, logrotate, and curl. The snmptrapd container uses the image created in step S100, configures the port (162 / UDP) exposed by the service, uses a command to check whether the port is normal for health check, and mounts the directory / var / log to provide snmp trap logs for fluentd container parsing and logrotate container regular cleaning; the fluentd container uses an open source image, configures the prometheus port (24231 / TCP) exposed by the service, uses a built-in method to check whether the port is normal for health check, mounts the directory / var / log to read the snmp trap log, and mounts the directory / etc / fluent / config.d to load the configuration file; the logrorate container uses an open source image, mounts the directory / var / log as the cleaning object, configures the log directory ( / var / log) for storing snmp trp messages, the log truncation method (for example, by day), whether the storage is compressed and the storage time (for example, 7 days); the curl container uses an open source image, configures the startup command to run the script, configures the environment variables to read the name of the Pod, the node to which it belongs and the namespace, and mounts / tmp / init.sh to load the script.
[0066] Step 2: Configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that prometheus can identify based on the trap messages sent by the hardware, and expose the metrics port to wait for access in step 6. As a specific implementation, enable the fluent-plugin-prometheus plug-in configuration, expose the metrics interface through the port, and provide prometheus with a pull interface to obtain monitoring indicators; configure the source block to read the snmp trap message received by the Pod and parse the field, configure the match block to distinguish the parsed field and add different labels to distinguish the device type, and configure the filter block of the prometheus type to assemble the label of the monitoring indicator according to the field. This completes the process of extracting the indicators and labels of the monitoring data that prometheus can identify based on the trap messages sent by the hardware, and finally exposes the metrics port to wait for the configured snmptrapd information access.
[0067] Step 3, write a script used by the curl container, and periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located. The overall architecture is an infinite loop, in which the container cluster API is periodically called to obtain the node where the vip pod is located. If the acquisition fails or the Pod status is wrong, the error is printed and the next loop continues; if the acquisition is successful and the Pod status is normal, determine whether the node is consistent with the current node of the snmptrapd pod. If it is inconsistent, call the container cluster API to restart the snmptrapd pod. When the Pod is rebuilt, it will be rescheduled to the node where the vip pod is located because of the configuration in the deployment parameters.
[0068] The access module is used to configure the service address of smmptrapd in prometheus, and access is performed through the service address of smmptrapd and the port exposed by fluentd. After successful access, monitoring data can be queried in real time.
[0069] The snmptrapd information configured by the information configuration module includes server IP, port, community word, and event level; the server IP is configured with the IP address of the pod hosted by the vip, the port is configured with the default port 162 used by the snmptrapd server, the community word is configured with the field agreed with snmptrapd, and the event level is controlled according to business needs.
[0070] The information configuration module configures smmptrapd in prometheus. Add the snmptrapd service address and the exposed port (24231 / TCP) of the fluentd container in the prometheus configuration, and check whether the target in the prometheus interface is successfully connected to snmptrapd. If successful, the hardware to be monitored generates an error and successfully sends an SNMP trap message to snmptrapd. The relevant monitoring indicators can be queried in the prometheus interface, thereby completing the hardware monitoring.
[0071] The system of this embodiment can execute the method disclosed in Embodiment 1.
[0072] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. The method of monitoring hardware through snmptrapd is characterized by The steps include: Configure an image that can run snmptrapd according to the type of hardware to be monitored; Set pod affinity in the snmptrapd deployment to ensure that the generated pod and the vip pod are on the same node, and set the host network to ensure that the port is exposed on the vip and can receive trap messages sent by the hardware to be monitored; Define the containers that need to run in the snmptrapd pod; Use prometheus to connect to the interface exposed by the snmptrapd pod to pull the indicator data reported by snmptrapd in real time; Configure snmptrapd information on the hardware to be monitored. The trap information sent by the hardware device through snmptrap is received by the snmptrapd pod and converted into monitoring indicators, so that the monitoring data can be queried in real time in Prometheus. Define the containers that need to run in the snmptrapd pod, including: Add four containers to the deployment of snmptrapd, namely: snmptrapd container, fluentd container, logrotate container and curl container. The snmptrapd container uses the created image to configure the port exposed by the service; the fluentd container uses an open source image to configure the prometheus port exposed by the configuration service; the logrotate container uses an open source image to configure the storage of snmp trp messages; the curl container uses an open source image to configure the startup command to run the script; Configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that can be identified by prometheus based on the trap messages sent by the hardware to be monitored, and expose the metrics port to wait for the service address of snmptrapd and the port exposed by fluentd to access; Write a script used by the curl container, and periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located.
2. The method for monitoring hardware by snmptrapd according to claim 1, characterized in that Configure an image that can run snmptrapd according to the type of hardware to be monitored, install dependent packages, collect the mib files of the hardware to be monitored and organize and store them in the image. The pod started according to the image can identify the trap messages sent by the hardware to be monitored.
3. The method for monitoring hardware by snmptrapd according to claim 1, characterized in that Configure the service address of snmptrapd in prometheus, access it through the service address of snmptrapd and the port exposed by fluentd. After successful access, you can query the monitoring data in real time.
4. The method for monitoring hardware by snmptrapd according to any one of claims 1 to 3, characterized in that The configured snmptrapd information includes server IP, port, community word, and event level. The server IP is configured with the IP address of the pod hosted by the vip, the port is configured with the default port 162 used by the snmptrapd server, the community word is configured with the field agreed with snmptrapd, and the event level is controlled according to business needs.
5. The system monitors the hardware through snmptrapd, which is characterized by In a container cluster environment, a method for monitoring hardware by using snmptrapd as described in any one of claims 1 to 4 is used to monitor hardware devices, and the system includes: An image configuration module, the image configuration module is used to configure an image capable of running snmptrapd according to the type of hardware being monitored; The snmptrapd configuration module is used to set the pod affinity in the snmptrapd deployment to ensure that the generated pod and the vip's pod are on the same node, and to set the host network to ensure that the port is exposed on the vip and can receive the trap message sent by the hardware to be monitored; A container definition module, which is used to define the container that needs to be run in the snmptrapd pod; An access module, which is used to use prometheus to connect to the interface exposed by the snmptrapd pod to pull the indicator data reported by snmptrapd in real time; An information configuration module, which is used to configure snmptrapd information on the hardware device to be monitored. The trap information sent by the hardware device through snmptrap is received by the snmptrapd pod and converted into monitoring indicators, so that the monitoring data can be queried in real time in prometheus; The snmptrapd configuration module is used to define the containers that need to run in the snmptrapd pod, including: Add four containers to the deployment of snmptrapd, namely: snmptrapd container, fluentd container, logrotate container and curl container. The snmptrapd container uses the created image to configure the port exposed by the service; the fluentd container uses an open source image to configure the prometheus port exposed by the configuration service; the logrotate container uses an open source image to configure the storage of snmp trp messages; the curl container uses an open source image to configure the startup command to run the script; Configure the collection configuration of fluentd, extract the indicators and labels of the monitoring data that can be identified by prometheus based on the trap messages sent by the hardware to be monitored, and expose the metrics port to wait for the service address of snmptrapd and the port exposed by fluentd to access; Write a script used by the curl container, and periodically call the container cluster API to obtain the node where the vip pod is located. If the node is inconsistent with the current node of snmptrapd, call the container cluster API to restart the snmptrapd pod so that it can be rebuilt and rescheduled to the node where the vip pod is located.
6. The system for monitoring hardware through snmptrapd according to claim 5, characterized in that The image configuration module is used to configure an image that can run snmptrapd according to the type of hardware to be monitored, install dependent packages, collect mib files of the hardware to be monitored and organize and store them in the image. The pod started according to the image can identify the trap message sent by the hardware to be monitored.
7. The system for monitoring hardware through snmptrapd according to claim 5, characterized in that The access module is used to configure the service address of snmptrapd in prometheus, and access is performed through the service address of snmptrapd and the port exposed by fluentd. After successful access, monitoring data can be queried in real time.
8. The system for monitoring hardware through snmptrapd according to any one of claims 5 to 7, characterized in that The configured snmptrapd information includes server IP, port, community word, and event level. The server IP is configured with the IP address of the pod hosted by the vip, the port is configured with the default port 162 used by the snmptrapd server, the community word is configured with the field agreed with snmptrapd, and the event level is controlled according to business needs.
