NET-SNMP-based variable management method

By defining SNMP variables and data source mappings through XML configuration files, constructing MIB data structures, and registering them with SNMP agents, the problem of cumbersome NET-SNMP extensions is solved, dynamic management of SNMP variables is realized, and operational efficiency and flexibility are improved.

CN121887602APending Publication Date: 2026-04-17BEIJING INST OF RADIO MEASUREMENT
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING INST OF RADIO MEASUREMENT
Filing Date
2025-12-15
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

The existing NET-SNMP extension mechanism in Linux systems is cumbersome and lengthy, and cannot dynamically adjust monitoring variables, resulting in low operation and maintenance efficiency and making it unsuitable for scenarios with frequent changes in monitoring requirements.

Method used

SNMP variables and data source mappings are defined through XML configuration files, a MIB data structure is built and registered with the SNMP agent to form a request entry point, process SNMP requests, and realize dynamic management of variables, avoiding compilation and restart steps.

Benefits of technology

It enables dynamic configuration and management of SNMP variables, lowers the deployment threshold, reduces manual coding errors, supports online maintenance, and takes effect without restarting the agent, thus improving management flexibility and ease of use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121887602A_ABST
    Figure CN121887602A_ABST
Patent Text Reader

Abstract

The invention discloses a variable management method based on NET-SNMP, and relates to the technical field of network communication and network management, and the method comprises the steps: obtaining first configuration information through configuring an XML configuration file and defining SNMP variables and data source mapping; based on the first configuration information, constructing an MIB data structure during operation; registering the MIB data structure to an SNMP agent to form a request entry; and processing the SNMP request according to the data source mapping through the request entry to obtain a variable result. According to the method, the technical threshold can be reduced, SNMP variable management can be realized only through configuration, configuration file modification can take effect without recompiling and restarting an SNMP proxy service, and seamless connection of services is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network communication and network management technology, and in particular to a variable management method based on NET-SNMP. Background Technology

[0002] Simple Network Management Protocol (SNMP) has become the de facto international standard protocol in the field of network management due to its simplicity, standardization, and strong scalability. It is widely used in the monitoring and management of routers, switches, servers, and even various IoT terminal devices. Its working principle is based on a manager and agent model: the manager is responsible for sending queries and control commands; the agent resides on the managed device, responsible for collecting local information, maintaining the Management Information Base (MIB), and responding to the manager's requests. The MIB is a hierarchical, structured collection of information, and each managed object is assigned a unique object identifier (OID).

[0003] However, despite its comprehensive functionality, NET-SNMP's extension mechanism in Linux systems has significant limitations. The standard extension process requires developers to first manually write MIB files conforming to SMI syntax; then, using the mib2c tool, a C code framework is generated, which only provides templates for the stub functions to be implemented; developers must then manually write the specific business logic based on this framework, requiring not only mastery of the complex NET-SNMP API but also the dual skills of an SNMP expert and a proficient C programmer; after completing the code, it must be compiled and linked to generate a dynamic shared library (.so file), and finally, the new library must be loaded by modifying the agent configuration file and the snmpd service restarted for the changes to take effect.

[0004] This process is cumbersome, lengthy, and prone to errors. Whether correcting a spelling mistake or adding a monitoring metric, the entire "coding-compiling-deploying-restarting" cycle must be repeated, severely hindering operational efficiency. Furthermore, the compilation-deployment method makes dynamically adjusting monitoring items virtually impossible, failing to adapt to scenarios requiring frequent changes in monitoring needs. Therefore, researching and designing a novel, more flexible SNMP variable management method, aiming to completely eliminate dependence on the compilation process and achieve "configurable" and "dynamic" management of monitoring items, has extremely important practical significance and application value. Summary of the Invention

[0005] The technical problem this invention aims to solve is to address the shortcomings of existing technologies, specifically the issues of traditional NET-SNMP extensions requiring repeated compilation and restarts and being unable to dynamically adjust variables. Specifically, this invention provides a NET-SNMP-based variable management method, as follows: 1) In a first aspect, the present invention provides a variable management method based on NET-SNMP, the specific technical solution of which is as follows: S1, by configuring the XML configuration file, defines SNMP variables and data source mappings to obtain the first configuration information; S2, Based on the first configuration information, construct the MIB data structure at runtime; S3, Register the MIB data structure to the SNMP agent to form a request entry point; S4. Through the request entry point, the SNMP request is processed according to the data source mapping to obtain the variable result.

[0006] The beneficial effects of the NET-SNMP-based variable management method provided by this invention are as follows: SNMP variables can be added, deleted, or modified by defining variables and data source mappings through XML configuration files, eliminating the need for writing C code and recompiling, thus lowering the deployment threshold. The MIB data structure is built at runtime and directly registered to the SNMP agent, omitting the steps of generating dynamic shared libraries and restarting snmpd, shortening the time for changes to take effect. SNMP read and write requests are handled according to data source mappings based on the same request entry point, ensuring that variable value retrieval and update logic remains consistent with the configuration, reducing manual coding errors. When the XML configuration file changes, the rebuild and registration process is repeated through hot updates, making new variables immediately visible without restarting the agent, enabling uninterrupted online maintenance.

[0007] Based on the above solution, the present invention can be further improved as follows.

[0008] Furthermore, the data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

[0009] Furthermore, the MIB data structure consists of a linked list of oid_node_t structures, with each oid_node_t storing the OID, data type, access permissions, and data source pointer within the same structure.

[0010] Furthermore, it also includes: S5. When the XML configuration file is changed, the second configuration information is obtained through hot update. Based on the second configuration information, S2-S4 are repeated to achieve the purpose of updating the MIB data structure and processing SNMP requests without restarting the SNMP agent.

[0011] 2) In a second aspect, the present invention also provides a variable management system based on NET-SNMP, the specific technical solution of which includes: a configuration definition module, a structure construction module, a registration entry module, and a request processing module; The configuration definition module is used to define SNMP variables and data source mappings by configuring an XML configuration file to obtain the first configuration information; The structure building module is used to build a MIB data structure at runtime based on the first configuration information; The registration entry module is used to register the MIB data structure to the SNMP agent, forming a request entry point; The request processing module is used to process SNMP requests through the request entry point and according to the data source mapping to obtain variable results.

[0012] Based on the above solution, the present invention can be further improved as follows.

[0013] Furthermore, the data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

[0014] Furthermore, the MIB data structure consists of a linked list of oid_node_t structures, with each oid_node_t storing the OID, data type, access permissions, and data source pointer within the same structure.

[0015] Furthermore, it also includes: a hot update module; The hot update module is used to obtain the second configuration information through hot update when the XML configuration file is changed, and repeat S2-S4 based on the second configuration information, so as to update the MIB data structure and process SNMP requests without restarting the SNMP agent.

[0016] 3) In a third aspect, the present invention also provides a computer device, the computer device including a processor coupled to a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to enable the computer device to implement any of the above methods.

[0017] 4) In a fourth aspect, the present invention also provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to enable a computer to perform any of the above methods.

[0018] It should be noted that the beneficial effects of the technical solutions of the second to fourth aspects of the present invention and their corresponding possible implementations can be found in the above description of the technical effects of the first aspect and its corresponding possible implementations, and will not be repeated here. Attached Figure Description

[0019] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a flowchart illustrating the steps of a variable management method based on NET-SNMP according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the XML Schema structure of a variable management method based on NET-SNMP according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the system architecture of a variable management method based on NET-SNMP according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the configuration parsing process of a variable management method based on NET-SNMP according to an embodiment of the present invention; Figure 5 This is a structural block diagram of a computer device according to the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0021] like Figure 1 As shown in the figure, a variable management method based on NET-SNMP according to an embodiment of the present invention includes the following steps: S1, by configuring the XML configuration file, defines SNMP variables and data source mappings to obtain the first configuration information; S2, based on the first configuration information, constructs the MIB data structure at runtime; S3 registers the MIB data structure with the SNMP agent, forming a request entry point; S4 processes the SNMP request through the request entry point, based on the data source mapping, and obtains the variable results.

[0022] The beneficial effects of the NET-SNMP-based variable management method provided by this invention are as follows: SNMP variables can be added, deleted, or modified by defining variables and data source mappings through XML configuration files, eliminating the need for writing C code and recompiling, thus lowering the deployment threshold. The MIB data structure is built at runtime and directly registered to the SNMP agent, omitting the steps of generating dynamic shared libraries and restarting snmpd, shortening the time for changes to take effect. SNMP read and write requests are handled according to data source mappings based on the same request entry point, ensuring that variable value retrieval and update logic remains consistent with the configuration, reducing manual coding errors. When the XML configuration file changes, the rebuild and registration process is repeated through hot updates, making new variables immediately visible without restarting the agent, enabling uninterrupted online maintenance.

[0023] It should be noted that, for ease of understanding, the technical terms used in this solution will be explained one by one, and will not be repeated hereafter: NET-SNMP: refers to an open-source SNMP protocol implementation suite, which includes the snmpd agent and development library, used to implement network management interfaces.

[0024] XML configuration files: These are text files written by users using predefined tags, declaring OIDs, data types, access permissions, and data source paths through tag attributes. In this example, it refers to configuration files written by users using XML syntax.

[0025] SNMP variable: refers to the MIB leaf object that can be Get / Set by the Manager, corresponding to an OID-value tuple.

[0026] Data source mapping refers to a set of rules describing "where the OID value is obtained"; the mapping target can be a constant, memory address, executable string, or file path. In this embodiment, data source mapping is used to bind OIDs to static values, memory variables, system commands, script files, or file content.

[0027] First configuration information / Second configuration information: These are shorthand for "Currently Effective XML" and "Modified XML," respectively. They differ only in time dimension and have no additional technical meaning; they are used only for differentiation.

[0028] Runtime: This refers to the stage where the agent process has started and is listening, as opposed to the compilation, linking, and restart processes. In this embodiment, it refers to the stage where snmpd has started and is processing requests.

[0029] MIB data structure: refers to a tree-like collection of nodes in memory. Each node stores an OID fragment, type, permissions, and a pointer to the data source for fast request matching. In this embodiment, the MIB data structure consists of a linked list of oid_node_t structures. Each oid_node_t stores the OID, data type, access permissions, and data source pointer within the same structure.

[0030] SNMP agent: refers to a daemon process residing on the managed device, responsible for receiving, verifying and responding to SNMP PDUs.

[0031] Request Entry Point: This refers to the head of the handler chain formed within the agent for the registered OID segment. External Get / Set requests first arrive at this point, which is the entry point for external administrators to send Get / Set requests.

[0032] Variable result: refers to the ASN.1 encoded value returned by the data source processor, which is finally encapsulated into a Response PDU and returned to the external administrator.

[0033] Static value: refers to a fixed string hard-coded in the configuration file, which is directly copied during GET and does not require external calls. In this embodiment, it refers to returning a preset fixed value.

[0034] Memory variables: refer to key-value pairs in a hash table maintained by a proxy; Get / Set operations operate only in memory, resulting in minimal latency. In this embodiment, it refers to maintaining variable values ​​through an internal hash table, supporting high-frequency read and write operations.

[0035] System commands: These refer to the shell command lines specified in the configuration. The agent executes them via popen() and captures stdout as a variable value. In this embodiment, it refers to executing external commands and capturing the output as a variable value.

[0036] Script file: refers to the path to the executable script, which supports parameter passing; the Set operation appends the new value to the command line before calling the script. In this embodiment, it refers to the script program to be executed, which supports parameter passing for the Set operation.

[0037] File content: refers to the path of a plain text file. When using `GET`, it reads the entire file or returns a specified line of content, suitable for one-time readings such as log lines and temperature values. In this embodiment, it refers to reading the content of a specified file as a variable value. Furthermore, in this embodiment, the data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

[0038] The `oid_node_t` structure refers to a node descriptor, containing an OID array, length, ASN.1 type, access mask, and a pointer to a data source union. The linked list fields form a tree structure. In this embodiment, it is used to represent a MIB node in memory, containing OID, type, permissions, and a data source pointer.

[0039] Hot update: refers to the process of triggering the parser to reload the XML and atomically replace the memory tree without stopping the snmpd process or recompiling the code, so that the newly added / deleted OIDs take effect immediately.

[0040] In another embodiment of this solution, S1 is specifically implemented as follows: Define a machine-readable and human-understandable structured data format (using XML) to declaratively describe all SNMP variables that need to be managed. This XML needs to precisely define the hierarchical structure of the OID tree and the attributes of each node (type, access permissions, description, etc.), i.e., define the SNMP variables. Most importantly, it needs to establish a dynamic mapping relationship between OID nodes and various data sources on the device (such as memory locations, system commands, script files, static values), thus forming a data source mapping. The configuration information in the XML file (i.e., the XML configuration file) is the first configuration information. It should be noted that this step only modifies the variables in the XML configuration file to obtain the first configuration information; the process of constructing the MIB data structure is described in S2 below.

[0041] The definitions include: Define the root node (\<snmp-config\> ): Define the base OID (base-oid) as the namespace prefix for all configuration nodes.

[0042] Define the node hierarchy (\<node\> MIB trees are constructed using a nested approach, with each node having a name and a numeric identifier (oid).

[0043] Define node attributes (\<properties\> ): Includes data types (\<type\> ), Access permissions (\)<access\> ), Description information (\<description\> ) and data source definition (\<source\> ).

[0044] In another embodiment of this solution, S2 is specifically implemented as follows: A lightweight runtime program is set up; in this embodiment, this runtime program can also be called a parser. Its core responsibility is to load and parse the aforementioned XML file, and dynamically construct a complete MIB subtree structure in memory based on the file content. The parser can be implemented in C language, and its core data structure is oid_node_t, which is used to represent SNMP nodes in memory, including fields such as OID, data type, access permissions, and data source pointer.

[0045] In another embodiment of this solution, S3 is specifically implemented as follows: The generic request handling function `generic_handler` serves as the unified request entry point for all SNMP requests. It locates the corresponding node based on the request OID, verifies permissions, and then calls the appropriate data source handler to execute the operation. Specifically, after the parser constructs the MIB tree in memory, it calls the NET-SNMP module registration API to register itself as a sub-agent module of snmpd. Then, starting from the root node, it performs a depth-first traversal of the entire MIB tree, calling `netsnmp_register_handler` or a similar API for each leaf `oid_node_t` node. This registers the node's complete OID, access permissions, and a uniformly written `generic_handler` function pointer into snmpd's handler chain. Simultaneously, it stores the node's own `oid_node_t` structure pointer in the handler registration structure field. After registration, all SNMP requests sent by external administrators to this OID segment will be routed by snmpd to this unique `generic_handler` entry point, thus forming the request entry point.

[0046] In another embodiment of this solution, S4 is specifically implemented as follows: When an external SNMP request arrives, the NET-SNMP agent calls the registered `generic_handler` function, passing the request PDU as a parameter. `generic_handler` first extracts the target OID from the PDU, then traverses the MIB tree root pointer `root_node` layer by layer for comparison. If the corresponding `oid_node_t` is not found, it returns the `noSuchName` error code. If found, it first checks if the node's access mask matches the PDU's operation type. If they don't match, it returns the `noAccess` error code. After successful verification, it enters a switch statement to determine `node->data_source->type`: if the type is `static`, it directly copies the `data_source.params.static_value` string to the `varbind` of the `Response` PDU and returns it; if the type is `memory`, it queries or updates the `uthash` hash table using `node->name` as the key. A `Get` operation retrieves the ASN.1 value and fills it into the `Response`, while a `Set` operation writes the new value to the hash table and returns a success code; if the type is `command`, it calls `popen` to execute `data_source.params.command` and uses the `stdout` content as the `OCTET`. STRING returns an error; if the type is script and it is a Set operation, the new value of the PDU is appended as a parameter to data_source.params.script and then the script is executed by calling system. The script's return code determines the error status; if the type is file, fopen is called to read the complete content of data_source.params.file_path as the variable value and return it. After all branches have been executed, generic_handler encapsulates the final ASN.1 encoded result or error code into a Response PDU and sends it back to the agent, which then forwards it to the manager. At this point, the variable result processing is complete.

[0047] Furthermore, data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

[0048] Furthermore, the MIB data structure consists of a linked list of oid_node_t structures, with each oid_node_t storing the OID, data type, access permissions, and data source pointer within the same structure.

[0049] Furthermore, it also includes: S5: When the XML configuration file changes, a second configuration information is obtained through hot update. Based on this second configuration information, S2-S4 are repeated, achieving the goal of updating the MIB data structure and processing SNMP requests without restarting the SNMP agent. In other words, after modifying the XML configuration file, a reload is triggered via a signal or command without needing to restart the SNMP agent service.

[0050] In another embodiment of the present invention, XML is used as the configuration language, and tests are conducted in the Kylin operating system and NET-SNMP 5.8 environment, as detailed below: XML configuration files: such as Figure 2 As shown, a hierarchical structure is logically used to define the tree-like organization and data attributes of the Management Information Base (MIB). Its architecture mainly includes three levels: The first level is the root configuration layer, which serves as the starting point for the entire MIB subtree and is used to declare a base object identifier (OID), which serves as the root of the unified namespace for all managed objects.

[0051] The second level is the node definition layer, which constructs the hierarchical structure of the MIB through nested node elements. Each node is identified by its name and relative OID, and by nesting child nodes within parent nodes, the base OID and the relative OIDs at each level are automatically combined to logically form a complete MIB tree.

[0052] The third level is the attribute rule layer, which is associated with specific nodes in the node definition layer and is used to define in detail the behavioral characteristics and data interface of the managed object. The defined attributes include at least: the data type of the object value (such as string type), its access control permissions (such as read and write), and the source of its value (for example, by specifying that it is dynamically obtained from system memory).

[0053] Architecture and Parser Implementation: The overall architecture of this invention is as follows Figure 3As shown, it mainly consists of three parts: configuration management, runtime data, and NET-SNMP integration. These parts work together to load, manage, and process configuration requests. The configuration parser, as the system's central hub, is responsible for reading and validating the XML configuration file, parsing it into an in-memory data structure, and driving the entire MIB registration process. The runtime data structure includes a configuration MIB data structure and an in-memory variable hash table: the configuration MIB data structure is a tree structure that fully maps the XML configuration definition in memory. Each node corresponds to an `oid_node_t` structure, storing attributes such as OID, type, access permissions, and data source, forming the basis for SNMP request routing and processing; the in-memory variable hash table is implemented based on libraries such as uthash, used to efficiently store and manage all variables defined as `type="memory"` and their current values, using the variable name as the key and the ASN.1 value as the value.

[0054] The NET-SNMP integration consists of a handler registrar and a generic request handling function: the registrar registers the system as a module of snmpd by calling the NET-SNMP API, traverses the configuration MIB tree and registers a unified generic request handling function for each leaf node; this function serves as the single entry point for all SNMP requests, finds the corresponding node based on the request OID, verifies permissions, and calls the corresponding handler to perform Get or Set operations according to the data source type.

[0055] The core workflow of the parser is as follows: Figure 4 As shown, it is developed in C and uses the libxml2 library to parse XML files. The core data structure consists of two interrelated internal data structures: The first is the data source description structure, used to characterize different ways of obtaining data. This structure contains a type field to distinguish the specific category of the data source; it also contains a parameter union, which can store different types of parameter information such as static values, executed commands, script paths, or file paths, depending on the value of the type field.

[0056] The second is the node description structure, which is used to fully represent the nodes of the MIB tree in memory. This structure contains the following fields: a character array to store the node name; an array to store the complete object identifier (OID) and its length; a field to record the data type; a field to record the access control rules; a pointer to the aforementioned data source description structure to associate the data retrieval method of the node; and pointers to its first child node and next sibling node, respectively. These two pointers are used to construct the complete tree hierarchy in memory.

[0057] Request processing flow: All SNMP requests are processed by the `generic_handler` function. 1. Locate the corresponding node in the memory MIB tree based on the requested OID; 2. Verify access permissions; 3. Invoke the appropriate handler based on the data source type; 4. Return the processing result or error message.

[0058] Taking memory variables as an example, the Get operation looks up the value from the hash table, and the Set operation updates the hash table and returns a success response. The handle_get_request and handle_set_request functions are the specific executors of the data source mapping mechanism. Their core logic is to use a switch-case statement to dispatch the request to the corresponding data source handler based on the value of node->data_source->type.

[0059] Performance Testing: To verify the effectiveness and performance of this invention, a controlled experimental environment was built for testing. Functional test results show that the system can correctly parse XML configuration and dynamically construct the MIB tree structure, and all SNMP operations are processed correctly. Table 1 shows the final performance results: Table 1 The results show that this invention achieves flexible SNMP variable management with acceptable performance overhead, and its performance meets the needs of most practical network management scenarios. As shown in Table 1, the average request latency increased by approximately 2.7ms, with a relative growth rate of 31.8%. This overhead mainly stems from the additional indirection layer and branch judgment in the request processing flow: unlike traditional methods that directly call pre-compiled and highly optimized C functions, this invention first uses a unified general processing function (generic_handler), then locates the corresponding node through a hash table, and finally dispatches the operation to the specific data source processor using a switch-case structure. Although this process inevitably introduces additional overhead, its absolute performance remains excellent. It is still sufficient to meet the needs of most network management scenarios, and administrators can hardly perceive the latency difference in actual high-frequency requests. The moderate sacrifice in performance results in a significant improvement in flexibility, which will be discussed in detail in the next section.

[0060] Test results also show that despite the introduction of a new indirect processing layer, the system's access to memory variables remains at a highly efficient level down to the microsecond level, indicating that its core routing and data processing logic itself is highly efficient. The performance bottleneck primarily stems from the necessary sacrifices made to achieve dynamic configuration capabilities, rather than significant flaws in the architecture design itself. This invention, through XML configuration and dynamic parsing technology, achieves declarative management and runtime registration of SNMP variables, significantly improving the flexibility and ease of use of NET-SNMP extensions. It is suitable for network management scenarios requiring high adaptability, such as equipment monitoring, cloud platforms, and the Internet of Things. This invention lowers the technical barrier: administrators do not need C programming skills or NET-SNMP API knowledge; they can manage SNMP variables simply through configuration. It enhances management flexibility: adding, deleting, modifying, and querying variables only requires modifying the configuration file to take effect, without recompiling or restarting the SNMP agent service, achieving seamless business integration. Performance is controllable: it meets the needs of most network management scenarios, achieving a good balance between flexibility and performance.

[0061] In the above embodiments, although the steps are numbered S1, S2, etc., they are only specific embodiments given by the present invention. Those skilled in the art can adjust the execution order of S1, S2, etc. according to the actual situation, and these situations are also within the protection scope of the present invention. It can be understood that in some embodiments, some or all of the above embodiments may be included.

[0062] The present invention also provides a variable management system based on NET-SNMP, the specific technical solution of which includes: a configuration definition module, a structure construction module, a registration entry module, and a request processing module; The configuration definition module is used to define SNMP variables and data source mappings through configuration XML configuration files to obtain the initial configuration information; The structure building module is used to build the MIB data structure at runtime based on the initial configuration information; The registration entry module is used to register the MIB data structure with the SNMP agent, forming a request entry point; The request processing module is used to process SNMP requests through the request entry point, based on the data source mapping, and obtain variable results.

[0063] Based on the above solution, the present invention can be further improved as follows.

[0064] Furthermore, data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

[0065] Furthermore, the MIB data structure consists of a linked list of oid_node_t structures, with each oid_node_t storing the OID, data type, access permissions, and data source pointer within the same structure.

[0066] Furthermore, it also includes: a hot update module; The hot update module is used to obtain the second configuration information through hot update when the XML configuration file changes. Based on the second configuration information, S2-S4 are repeated to achieve the purpose of updating the MIB data structure and processing SNMP requests without restarting the SNMP agent.

[0067] It should be noted that the beneficial effects of the NET-SNMP-based variable management system provided in the above embodiments are the same as those of the NET-SNMP-based variable management method described above, and will not be repeated here. Furthermore, the system provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the system can be divided into different functional modules according to the actual situation to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, and will not be repeated here.

[0068] like Figure 5 As shown, an embodiment of the present invention provides a computer device 300, which includes a processor 320 coupled to a memory 310. The memory 310 stores at least one computer program 330, which is loaded and executed by the processor 320 to enable the computer device 300 to implement any of the above-described methods. Specifically: The computer device 300 can vary considerably due to differences in configuration or performance. It may include one or more processors 320 (Central Processing Units, CPUs) and one or more memories 310. The one or more memories 310 store at least one computer program 330, which is loaded and executed by the one or more processors 320 to enable the computer device 300 to implement the NET-SNMP-based variable management method provided in the above embodiments. Of course, the computer device 300 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input / output. The computer device 300 may also include other components for implementing device functions, which will not be elaborated upon here.

[0069] An embodiment of the present invention provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to enable a computer to implement any of the above-described methods.

[0070] Alternatively, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, a floppy disk, and an optical data storage device, etc.

[0071] In an exemplary embodiment, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the NET-SNMP-based variable management methods described above.

[0072] It should be noted that the terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and represent a limitation on a specific order or sequence. Where appropriate, the order of use for similar objects can be interchanged so that the embodiments of this application described herein can be implemented in an order other than that shown or described.

[0073] Those skilled in the art will recognize that this invention can be implemented as a system, method, or computer program product. Therefore, this disclosure can be specifically implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.

[0074] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.

[0075] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A variable management method based on NET-SNMP, characterized in that, include: S1, by configuring the XML configuration file, defines SNMP variables and data source mappings to obtain the first configuration information; S2, Based on the first configuration information, construct the MIB data structure at runtime; S3, Register the MIB data structure to the SNMP agent to form a request entry point; S4. Through the request entry point, the SNMP request is processed according to the data source mapping to obtain the variable result.

2. The variable management method based on NET-SNMP according to claim 1, characterized in that, The data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

3. The variable management method based on NET-SNMP according to claim 1, characterized in that, The MIB data structure consists of a linked list of oid_node_t structures. Each oid_node_t stores the OID, data type, access permissions, and data source pointer within the same structure.

4. The variable management method based on NET-SNMP according to claim 1, characterized in that, Also includes: S5, when the XML configuration file is changed, the second configuration information is obtained through hot update, and S2-S4 are repeated based on the second configuration information, so as to achieve the purpose of updating the MIB data structure and processing SNMP requests without restarting the SNMP agent.

5. A variable management system based on NET-SNMP, characterized in that, include: Configuration definition module, structure construction module, registration entry module, and request processing module; The configuration definition module is used to define SNMP variables and data source mappings by configuring an XML configuration file to obtain the first configuration information; The structure building module is used to build a MIB data structure at runtime based on the first configuration information; The registration entry module is used to register the MIB data structure to the SNMP agent, forming a request entry point; The request processing module is used to process SNMP requests through the request entry point and according to the data source mapping to obtain variable results.

6. A variable management system based on NET-SNMP according to claim 5, characterized in that, The data source mapping includes at least one of five types: static values, memory variables, system commands, script files, and file content.

7. A variable management system based on NET-SNMP according to claim 5, characterized in that, The MIB data structure consists of a linked list of oid_node_t structures. Each oid_node_t stores the OID, data type, access permissions, and data source pointer within the same structure.

8. A variable management system based on NET-SNMP according to claim 5, characterized in that, Also includes: Hot update module; The hot update module is used to obtain second configuration information through hot update when the XML configuration file changes, and repeatedly execute the structure building module, the registration entry module and the request processing module based on the second configuration information, so as to update the MIB data structure and process SNMP requests without restarting the SNMP agent.

9. A computer device, characterized in that, The computer device includes a processor coupled to a memory storing at least one computer program, which is loaded and executed by the processor to enable the computer device to perform the method as claimed in any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to enable the computer to perform the method as described in any one of claims 1 to 4.