A method and device for querying atomic capabilities based on equipment

By assigning unique codes to atomic capabilities in the network management platform and performing parameter verification and connection limit, combined with database, SNMP, and telnet command queries, the problem of frequent atomic capability calls on devices was solved, reducing development workload and improving operation and maintenance efficiency.

CN114201517BActive Publication Date: 2024-10-15CHINA UNITECHS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010972418.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-16
Publication Date
2024-10-15
Estimated Expiration
2040-09-16

AI Technical Summary

Technical Problem

In the network management platform, frequent calls to atomic capabilities put a load on the devices, and the large amount of new development required for each query request causes inconvenience to the platform's operation and maintenance personnel.

Method used

A device-based atomic capability query method is adopted. By defining a unique code for each atomic capability, parameter verification and connection limit are performed. Data queries are performed using database, SNMP, and telnet commands to reduce the actual query operations.

Benefits of technology

This effectively reduces the load on devices from frequent calls to atomic capabilities, decreases the amount of new development required for query requests, and provides convenience for platform operation and maintenance personnel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114201517B_ABST
    Figure CN114201517B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for querying atomic capabilities based on equipment, wherein the method includes: agreeing on a unique and readable code for each atomic capability; configuring the parameters that need to be verified for the atomic capability according to the atomic capability parameter configuration table; judging whether there is a corresponding record in the cache according to all the input parameters of the current query, if there is no cache record, judging whether it is necessary to telnet log in to the device, and if necessary, judging whether the device exceeds the upper limit of the number of logins within a certain period of time; according to the method of querying data in the atomic capability, it is divided into a database method, an SNMP method and a telnet command method; the atomic capability template: split according to the atomic capability code and the supported device model. The method and device can effectively reduce the load on the device caused by the frequent call of atomic capabilities, and also reduce the amount of new development for each query demand, providing convenience for platform operation and maintenance personnel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network management platforms, and in particular to a method and a device for querying atomic capabilities based on equipment. Background Art

[0002] In the network management platform, the information collection and analysis of network elements are the most common functions. In terms of providing external interfaces, the information query capability of network elements is indispensable, which leads to frequent calls of atomic capabilities, causing load on the equipment. At the same time, the amount of new development required for each query is large, which brings inconvenience to the platform operation and maintenance personnel. Summary of the invention

[0003] In order to overcome the above technical problems, the real-time and calling frequency of the atomic capability interface requirements are analyzed, and a method and device for querying atomic capabilities based on devices is provided in the present invention, which can effectively reduce the load on the device caused by frequent calls of atomic capabilities, and also reduce the amount of new development for each query requirement, thereby providing convenience for platform operation and maintenance personnel.

[0004] To achieve the above object, the present invention adopts the following technical solutions:

[0005] In one embodiment of the present invention, a method for querying atomic capabilities based on a device is proposed, the method comprising:

[0006] Atomic capability encoding: A unique and readable code is agreed upon for each atomic capability;

[0007] Parameter verification: At least one of the two device-related parameters, device name and device IP address, must be provided. If both are provided, the device information in the database will be searched based on the device name first. If the device-related parameters are missing or the device cannot be found based on the device input parameters, a corresponding error message will be returned. Configure the parameters that need to be verified for the atomic capability according to the atomic capability parameter configuration table.

[0008] Device connection number limit: After the parameter verification is passed, determine whether there is a corresponding record in the cache based on all the input parameters of the query. If there is, directly return the record in the cache without actually executing the query action; if there is no cache record, determine whether telnet login to the device is required based on the field value of "whether telnet login to the device" in the atomic capability parameter configuration table. If it is required, determine whether the device exceeds the upper limit of login times within a certain period of time. If it exceeds, directly return this query failure and give a prompt;

[0009] Data query method: According to the data query method in atomic capability, it is divided into database method, snmp method and telnet command method;

[0010] Atomic capability template: Split according to atomic capability coding and supported device models.

[0011] Furthermore, the database method refers to obtaining results by writing SQL queries in a relational database. Only one SQL statement is required for inputting parameters, and the returned results are stored in a two-layer structure of an outer array and an inner hash.

[0012] Furthermore, the snmp method refers to obtaining data by performing snmp collection on the device, which is divided into snmpget and snmpwalk. The input parameters are OID and index, and the obtained results are stored in the hash of the two-layer structure.

[0013] Furthermore, the telnet command method refers to executing commands to obtain data after logging into the device through telnet / ssh, and storing the returned results in a string variable.

[0014] Furthermore, the content of the atomic capability template is divided into:

[0015] Further verification of input parameters;

[0016] Call the common functions of different query methods as needed to execute the query action and obtain the corresponding query results;

[0017] Analyze the query results and obtain the required return information.

[0018] Furthermore, different query methods include: port status query, device port traffic query and device port real-time traffic query.

[0019] Furthermore, the port status query includes:

[0020] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0021] Connect to the database and execute SQL to query the index of the port stored in the port information table;

[0022] Connect to the device using snmp and query the fixed OID plus port index;

[0023] Determine the snmp result, a value of 1 indicates up, a value of 2 indicates down, and other logical conversions;

[0024] Spell returns the result and logs it.

[0025] Furthermore, device port traffic queries include:

[0026] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0027] Connect to the database and execute SQL to query the latest traffic data corresponding to the port;

[0028] The query results are converted into data, the returned results are spelled out and logged.

[0029] Furthermore, real-time traffic query of device ports includes:

[0030] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0031] Log in to the device through telnet / ssh and query the port traffic through command;

[0032] Parse the query results to obtain the required flow rate information;

[0033] If necessary, wait a few seconds and execute the command again to query, subtract the flow rate in the two results and divide it by the interval length to get the flow rate information;

[0034] Spell returns the result and logs it.

[0035] In one embodiment of the present invention, a device for querying atomic capabilities based on a device is also proposed, the device comprising:

[0036] Atomic capability encoding module, used to agree on a unique and readable code for each atomic capability;

[0037] The parameter verification module is used to provide at least one of the two device-related parameters, device name and device IP address. If both are provided, the device information in the database will be searched based on the device name first. If the device-related parameters are missing or the device cannot be found based on the device input parameters, a corresponding error message will be returned. The parameters that need to be verified for the atomic capability are configured according to the atomic capability parameter configuration table.

[0038] The device connection number limit module is used to determine whether there is a corresponding record in the cache based on all the input parameters of the query after the parameter verification is passed. If there is, the record in the cache is directly returned without actually executing the query action; if there is no cache record, whether telnet login to the device is required is determined based on the field value of whether telnet login to the device is required in the atomic capability parameter configuration table. If it is required, it is further determined whether the device exceeds the upper limit of login times within a certain period of time. If it exceeds, it directly returns that the query failed and gives a prompt;

[0039] The data query module is used to query data in the atomic capability in the following ways: database mode, snmp mode and telnet command mode;

[0040] Atomic capability template module, used to split according to atomic capability coding and supported device models.

[0041] Furthermore, the atomic capability parameter configuration table includes four fields, namely capability code, required parameters, some required parameters, and whether telnet login to the device is required.

[0042] Furthermore, the database method refers to obtaining results by writing SQL queries in a relational database. Only one SQL statement is required for inputting parameters, and the returned results are stored in a two-layer structure of an outer array and an inner hash.

[0043] Furthermore, the snmp method refers to obtaining data by performing snmp collection on the device, which is divided into snmpget and snmpwalk. The input parameters are OID and index, and the obtained results are stored in the hash of the two-layer structure.

[0044] Furthermore, the telnet command method refers to executing commands to obtain data after logging into the device through telnet / ssh, and storing the returned results in a string variable.

[0045] Furthermore, the content of the atomic capability template is divided into:

[0046] Further verification of input parameters;

[0047] Call the common functions of different query methods as needed to execute the query action and obtain the corresponding query results;

[0048] Analyze the query results and obtain the required return information.

[0049] Furthermore, different query methods include: port status query, device port traffic query and device port real-time traffic query.

[0050] Furthermore, the port status query includes:

[0051] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0052] Connect to the database and execute SQL to query the index of the port stored in the port information table;

[0053] Connect to the device using snmp and query the fixed OID plus port index;

[0054] Determine the snmp result, a value of 1 indicates up, a value of 2 indicates down, and other logical conversions;

[0055] Spell returns the result and logs it.

[0056] Furthermore, device port traffic queries include:

[0057] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0058] Connect to the database and execute SQL to query the latest traffic data corresponding to the port;

[0059] The query results are converted into data, the returned results are spelled out and logged.

[0060] Furthermore, real-time traffic query of device ports includes:

[0061] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0062] Log in to the device through telnet / ssh and query the port traffic through command;

[0063] Parse the query results to obtain the required flow rate information;

[0064] If necessary, wait a few seconds and execute the command again to query, subtract the flow rate in the two results and divide it by the interval length to get the flow rate information;

[0065] Spell returns the result and logs it.

[0066] In one embodiment of the present invention, a computer device is also proposed, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the aforementioned method of querying atomic capabilities based on the device is implemented.

[0067] In one embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program for executing the method for querying atomic capabilities based on a device.

[0068] Beneficial effects:

[0069] The present invention can effectively reduce the load on the device caused by the frequent invocation of atomic capabilities, and also reduce the amount of new development for each query demand, providing convenience for platform operation and maintenance personnel. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 This is a schematic diagram of a method flow chart of querying atomic capabilities based on a device according to an embodiment of the present invention;

[0071] Figure 2 It is a schematic diagram of the structure of a device for querying atomic capabilities based on a device according to an embodiment of the present invention;

[0072] Figure 3 It is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0073] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0074] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0075] The purpose of the device-based atomic query capability is to provide third-party platforms with relatively real-time device-related configuration data and performance data, and "atomic" means that each query item requires only a few information points to be returned. Under this premise, the query volume can be large or small, up to dozens of times per minute, and the demand is to reduce the impact of frequent queries on the device. Therefore, the following principles are summarized:

[0076] Indicators with smaller granularity and periodic collection have been done, and only the database is checked;

[0077] For indicators that require very high real-time performance and can be queried using SNMP, SNMP is preferred (because SNMP has less impact on the device than Telnet);

[0078] For indicators that can only be queried using the telnet command, in order to reduce the number of interactions with the device, the cache within 5 minutes (the duration can be set) is recorded. When the same query object and query item are queried repeatedly within 5 minutes, the data in the cache is directly returned. At the same time, the number of logins to the same device is controlled, and the number of logins is limited to a certain number of times within a certain number of seconds. If the limit is exceeded, the query failure is returned.

[0079] According to the implementation mode of the present invention, a method and apparatus for querying atomic capabilities based on a device are proposed. The implementation process is mainly divided into the steps of analyzing and verifying input parameters, executing corresponding query instructions as needed, and analyzing query results to obtain the required return parameters for synchronous return. Based on various actual query situations, the common processing parts are refined and a set of appropriate capability provision solutions are sorted out.

[0080] The principle and spirit of the present invention are explained in detail below with reference to several representative embodiments of the present invention.

[0081] Figure 1 FIG. 1 is a flow chart of a method for querying atomic capabilities based on a device according to an embodiment of the present invention. Figure 1As shown, the process is as follows:

[0082] At the beginning, check whether the parameters are verified. If the verification fails (capability encoding is not supported or device information is missing, etc.), it ends. If the verification passes, go to the next step;

[0083] Search for the device to see if it exists. If it does not exist, the process ends. If it does exist, proceed to the next step.

[0084] Whether there is a cached result, if there is a cache, then end, if there is no cache, then proceed to the next step;

[0085] Do you need to log in to the device? If you need to log in through telnet, the number of logins will be judged as exceeded. If it exceeds the limit, the process ends. If it does not exceed the limit, the parameter format and other precise checks will be performed. If the check fails, the process ends. If the check passes, the snmp query will be executed as needed, the results will be analyzed, the returned parameter values ​​will be spliced ​​and entered into the cache, the cache effective time will be set, and the process ends. If you do not need to log in to the device, the parameter format and other precise checks will also be performed. If the check fails, the process ends. If the check passes, the device will be logged in and the command query results will be executed, the results will be analyzed, the returned parameter values ​​will be spliced ​​and entered into the cache, the cache effective time will be set, and the process ends.

[0086] The following is a detailed explanation based on five key elements:

[0087] 1. Atomic Capability Coding

[0088] This technical solution is based on the use of the same interface for atomic capabilities queried by all devices. Because a unique code needs to be agreed upon for each atomic capability in the input parameter. This code corresponds to the query item, such as device status, port status, port traffic, port optical power, etc. It is recommended to have a certain degree of readability, for example, the device status can be agreed upon as DeviceStatus, the port status can be agreed upon as PortStatus, etc.

[0089] If an unsupported capability code is filled in when calling this interface, an error prompt will be returned immediately.

[0090] 2. Parameter verification

[0091] First of all, this technical solution is a method based on the query atomic capability of the device, so the input parameter must have device information and provide two device-related parameters, devicename (device name) and ipaddress (device IP address). If both are filled in, the device information in the database will be searched based on the device name first. If the device parameter is missing or the device cannot be found based on the device input parameter, a corresponding error prompt will be returned.

[0092] In addition, the query contents of each atomic capability are different, and their input parameters can be defined separately. Some are required, some are optional, and some parameters are related and cannot be empty. Based on this principle, the following Table 1 is compiled to configure the parameters that need to be verified for atomic capabilities:

[0093] Table 1 Atomic Capacity Parameter Configuration Table - CapacityParaCfg

[0094]

[0095] Configuration example:

[0096]

[0097] In the first example, the required parameter of the atomic capability PortStatus is port. You need to check whether the parameter port is empty. If it is empty, an error message will be displayed.

[0098] In the second example, in addition to the required parameter port, the atomic capability OnuOpticalPower also sets some required parameters "onuid,loid", which means that in addition to the parameter port, it is also necessary to check that onuid and loid cannot be empty at the same time, otherwise an error prompt will be reported.

[0099] Note: Parameter verification is placed at the beginning of the code to speed up the execution efficiency of atomic capabilities and reduce some unnecessary processing logic, such as avoiding releasing the device without doing anything after it is connected.

[0100] 3. Limitation on the number of device connections

[0101] Based on the principle of reducing the impact on the device, after the parameter verification is passed, first determine whether there is a corresponding record in the cache database based on all the input parameters of the current query. If there is, directly return the record in the cache without actually executing the query action.

[0102] If there is no cache record, determine whether telnet login is required based on the value of the needlogin field in CapacityParaCfg in Table 1 above. If required, determine whether the device has exceeded the upper limit of login times within a certain period of time. If it has exceeded the upper limit, the query fails and a prompt is given.

[0103] 4. Data query method

[0104] According to the way of querying data in atomic capabilities, it can be mainly divided into the following three cases. According to these three cases, functions can be encapsulated separately for subsequent on-demand calls to reduce duplicate code:

[0105] (1) Database method:

[0106] It refers to obtaining results by writing SQL (Structured Query Language) queries in a relational database. Only one SQL statement is required as the input parameter, and the returned results are stored in a two-layer structure of an outer array and an inner hash.

[0107] For example: There is a student information table (student) with 3 fields: student number (no), name (name), and gender (sex). Execute an SQL statement to query all records in the table:

[0108] select no,name,sex from student

[0109] Assume the first piece of data has a student number of N001, a name of Zhang San, and a gender of male

[0110] After storing the data into the array variable @SQL_RESULT, it means the same as:

[0111] $SQL_RESULT[0] = ('NO' => 'N001', 'NAME' => 'Zhang San', 'SEX' =>'male').

[0112] (2) SNMP method:

[0113] It refers to collecting data from devices through SNMP (Simple Network Management Protocol), which is divided into snmpget (retrieving the value of a specific OID) and snmpwalk (traversing OID values). The input parameters are OID (Object Identifiers) and index. The obtained results are stored in a hash with a two-layer structure.

[0114] For example: To query the port management status of a device, use the public MIB (Management Information Base) ifDescr (.1.3.6.1.2.1.2.2.1.2) and ifAdminStatus (.1.3.6.1.2.1.2.2.1.7) for the query, and associate them according to the index. The resulting storage format is as follows:

[0115] $OID_RESULT{'1.3.6.1.2.1.2.2.1.2'} = ('1' => 'Gi1 / 1', '2' => 'Gi1 / 2');

[0116] $OID_RESULT{'1.3.6.1.2.1.2.2.1.7'} = ('1' => '1', '2' => '2');

[0117] It means that there are two ports described as Gi1 / 1 and Gi1 / 2; the port management statuses are up and down respectively;

[0118] Note: The value obtained by ifAdminStatus(.1.3.6.1.2.1.2.2.1.7). 1 means up, 2 means down, and so on.

[0119] (3) Telnet command method:

[0120] It means to log in to the device through telnet / ssh and execute commands to obtain data. The returned results are stored in string variables. For example, execute the show clock command and get the device return result:

[0121] 13:59:27.179PRC Sat Aug 152020

[0122] 5. Atomic Capability Template

[0123] Atomic capability templates are split according to atomic capability codes and supported device models.

[0124] For example, the atomic capability of the port status (capability code: PortStatus) can be obtained by querying the two OIDs ifAdminStatus and ifOperStatus in snmp mode, which can be implemented in the same template, and the template name can be consistent with the code.

[0125] For another example, the atomic capability of the device online time (capability code: SysUpTime) needs to be queried through the telnet command. Since the query commands for different device models are different, the template can be split by model. The template name is composed of the capability code plus the device model code, such as SysUpTime_ZT9000.

[0126] The content of the atomic capability template is mainly divided into:

[0127] (1) Further verification of input parameters, for example, whether the port name format is normal and whether the VLAN value is a pure number;

[0128] (2) Calling common functions of different query modes as needed to execute query actions and obtain corresponding query results;

[0129] (3) Analyze the query results and obtain the required return information.

[0130] The above query method is illustrated by the following examples:

[0131] (1) Port status query:

[0132] Parameter verification: whether the port input parameter conforms to a certain format (multiple numbers are separated by slashes), for example, Gi1 / 1;

[0133] Connect to the database and execute SQL to query the index of the port stored in the port information table;

[0134] Connect to the device using snmp, query the fixed OID (ifAdminStatus and ifOperStatus) plus the port index;

[0135] Determine the snmp result, a value of 1 indicates up, a value of 2 indicates down, and other logical conversions;

[0136] Spell returns the result and logs it.

[0137] (2) Device port traffic query:

[0138] Parameter verification: whether the port input parameter conforms to a certain format (multiple numbers are separated by slashes), for example, Gi1 / 1;

[0139] Connect to the database and execute SQL to query the latest traffic data corresponding to the port;

[0140] The query results are converted into data, the returned results are spelled out and logged.

[0141] (3) Real-time traffic query of device ports:

[0142] Parameter verification: whether the port input parameter conforms to a certain format (multiple numbers are separated by slashes), for example, Gi1 / 1;

[0143] Log in to the device through telnet / ssh and query the port traffic through commands, such as display interface${portid} or show interface${portid}, where ${portid} indicates the port variable.

[0144] Parse the query results to obtain the required flow rate information;

[0145] If necessary, wait a few seconds and execute the command again to query, subtract the flow rate in the two results and divide it by the interval length to get the flow rate information;

[0146] Spell returns the result and logs it.

[0147] It should be noted that, although the operations of the method of the present invention are described in a specific order in the above embodiments and the accompanying drawings, this does not require or imply that the operations must be performed in the specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0148] In order to explain the above-mentioned device-based atomic capability query method more clearly, a specific embodiment is used for illustration below. However, it should be noted that this embodiment is only for better illustrating the present invention and does not constitute an improper limitation to the present invention.

[0149] The following is a specific example to further illustrate the method of querying atomic capabilities based on devices in more detail:

[0150] Example: (Configuration query based on SR device)

[0151] 1. Atomic Capability Interface Agreement

[0152] (1) The request parameters are as shown in Table 2:

[0153] Table 2 Request parameter table

[0154]

[0155]

[0156] (2) The response parameters are as shown in Table 3:

[0157] Table 3 Response parameter table

[0158]

[0159] 2. Atomic capability template content

[0160]

[0161]

[0162]

[0163]

[0164]

[0165]

[0166] Note: The execCmd function in this atomic capability template represents the command executed after telnet logs into the device. The content stored in the variable $CMD_RESULT is the return result obtained after each command is executed.

[0167] 3. Actual call of capabilities

[0168] Incoming message:

[0169] {"code":"get_srcfg","have80":"0","pointip":"","userip":"","devicename":"SH-SH-QPXXDL-MSE-1.MAN.M6000","sessionid":"DQ202008 30080958011274","cvlan":"2917","portid":"255 / 0 / 45","linkno":"EIP100191133","svlan":"0534","uprate":"1024","downrate":"1024"}

[0170] Output message:

[0171] {"deviceip":null,"return_desc":"The uplink rate is inconsistent (parameter uprate=1024, uprate=100M on the device); the downlink rate is inconsistent (parameter downrate=1024, downrate=100M on the device);","code":"get_srcfg","have80":"0","pointip":"","sessionid":"DQ20200830080958011274","portid":"255 / 0 / 45","cvlan":"2917","deviceid":"DEV122wx","returnData":null,"userip":"","devicename":"SH-SH-QPXXDL-MSE-1 .MAN.M6000","linkno":"EIP100191133","svlan":"0534","uprate":"1024","return_code":"101","downrate":"1024"}

[0172] Based on the same inventive concept, the present invention also proposes a device for querying atomic capabilities based on a device. The implementation of the device can refer to the implementation of the above method, and the repeated parts will not be repeated. The term "module" used below can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0173] Figure 2 FIG. 1 is a schematic diagram of a device structure for querying atomic capabilities based on a device according to an embodiment of the present invention. Figure 2 As shown, the device comprises:

[0174] Atomic capability encoding module 101, used to agree on a unique and readable code for each atomic capability;

[0175] The parameter verification module 102 is used to provide at least one of the two device-related parameters, device name and device IP address. When both are provided, the device information in the database is searched first according to the device name; if the device-related parameters are missing or the device cannot be found according to the device input parameters, a corresponding error message will be returned; the parameters that need to be verified for the atomic capability are configured according to the atomic capability parameter configuration table; wherein:

[0176] The atomic capability parameter configuration table includes four fields: capability code, required parameters, some required parameters, and whether telnet login is required.

[0177] The device connection number limiting module 103 is used to determine whether there is a corresponding record in the cache according to all the input parameters of the current query after the parameter verification is passed. If there is, the record in the cache is directly returned without actually executing the query action; if there is no cache record, it is determined whether telnet login to the device is required according to the field value of whether telnet login to the device is required in the atomic capability parameter configuration table. If it is required, it is determined whether the device exceeds the upper limit of the number of logins within a certain period of time. If it exceeds, it directly returns that the query fails and gives a prompt;

[0178] The data query module 104 is used to query data in the atomic capability in the form of a database, an SNMP method, and a telnet command method; wherein:

[0179] The database method is to get the result by writing SQL query in a relational database. Only one SQL statement is needed for inputting parameters, and the returned result is stored in a two-layer structure of outer array and inner hash.

[0180] The snmp method is to collect data from the device through snmp, which is divided into snmpget and snmpwalk. The input parameters are OID and index, and the obtained results are stored in the hash of the two-layer structure;

[0181] The telnet command method is to log in to the device through telnet / ssh and execute commands to obtain data, and store the returned results in a string variable;

[0182] The atomic capability template module 105 is used to split according to the atomic capability code and the supported device model; wherein:

[0183] The content of the atomic capability template is divided into:

[0184] Further verification of input parameters;

[0185] Call the common functions of different query methods as needed to execute the query action and obtain the corresponding query results;

[0186] Analyze the query results and obtain the required return information;

[0187] Different query methods include: port status query, device port traffic query and device port real-time traffic query; among them:

[0188] Port status query includes:

[0189] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0190] Connect to the database and execute SQL to query the index of the port stored in the port information table;

[0191] Connect to the device using snmp and query the fixed OID plus port index;

[0192] Determine the snmp result, a value of 1 indicates up, a value of 2 indicates down, and other logical conversions;

[0193] Spelling returns the result and records it in the log;

[0194] Device port traffic query includes:

[0195] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0196] Connect to the database and execute SQL to query the latest traffic data corresponding to the port;

[0197] The query results are converted into data, the returned results are spelled and logged;

[0198] The real-time traffic query of the device port includes:

[0199] Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes;

[0200] Log in to the device through telnet / ssh and query the port traffic through command;

[0201] Parse the query results to obtain the required flow rate information;

[0202] If necessary, wait a few seconds and execute the command again to query, subtract the flow rate in the two results and divide it by the interval length to get the flow rate information;

[0203] Spell returns the result and logs it.

[0204] It should be noted that although several modules of the device-based query atomic capability apparatus are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules described above can be concretized in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be concretized.

[0205] Based on the above invention concept, Figure 3 As shown, the present invention also proposes a computer device 200, including a memory 210, a processor 220, and a computer program 230 stored in the memory 210 and executable on the processor 220. When the processor 220 executes the computer program 230, the aforementioned method of querying atomic capabilities based on the device is implemented.

[0206] Based on the aforementioned inventive concept, the present invention further proposes a computer-readable storage medium, which stores a computer program for executing the aforementioned device-based atomic capability query method.

[0207] The method and apparatus for querying atomic capabilities based on a device proposed by the present invention have the following advantages:

[0208] (1) General Model

[0209] This model can be applied to all atomic capabilities related to device query. To add an atomic capability, you only need to configure parameter information and add a corresponding query template to quickly implement it.

[0210] (2) Unified management

[0211] With the unified entrance for device query capabilities, the number of connections to the same device can be managed to a certain extent, and log viewing and analysis can also be facilitated.

[0212] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements contained in the spirit and scope of the attached claims.

[0213] Regarding the limitation of the protection scope of the present invention, those skilled in the art should understand that, based on the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative work are still within the protection scope of the present invention.

Claims

1. A method for querying atomic capabilities based on a device, characterized in that: The method includes: Atomic capability encoding: A unique and readable code is agreed upon for each atomic capability; Parameter verification: At least one of the two device-related parameters, device name and device IP address, must be provided. If both are provided, the device information in the database will be searched based on the device name first. If the device-related parameters are missing or the device cannot be found based on the device input parameters, a corresponding error message will be returned. Configure the parameters that need to be verified for the atomic capability according to the atomic capability parameter configuration table. Device connection number limit: After the parameter verification is passed, determine whether there is a corresponding record in the cache based on all the input parameters of the query. If there is, directly return the record in the cache without actually executing the query action; if there is no cache record, determine whether telnet login to the device is required based on the field value of "whether telnet login to the device" in the atomic capability parameter configuration table. If it is required, determine whether the device exceeds the upper limit of login times within a certain period of time. If it exceeds, directly return this query failure and give a prompt; Data query method: According to the data query method in atomic capability, it is divided into database method, snmp method and telnet command method; Atomic capability template: Split according to atomic capability coding and supported device models.

2. The method for querying atomic capabilities based on a device according to claim 1, characterized in that: The atomic capability parameter configuration table includes four fields, namely capability code, required parameters, some required parameters, and whether telnet login to the device is required.

3. The method for querying atomic capabilities based on a device according to claim 1, characterized in that: The database method refers to obtaining results by writing SQL queries in a relational database. Only one SQL statement is required for inputting parameters, and the returned results are stored in a two-layer structure of an outer array and an inner hash.

4. The method for querying atomic capabilities based on a device according to claim 1, characterized in that: The snmp method refers to obtaining data by performing snmp collection on the device, which is divided into snmpget and snmpwalk. The input parameters are OID and index, and the obtained results are stored in the hash of the two-layer structure.

5. The method for querying atomic capabilities based on a device according to claim 1, characterized in that: The telnet command method refers to logging into the device through telnet / ssh and executing commands to obtain data, and the returned results are stored in a string variable.

6. The method for querying atomic capabilities based on a device according to claim 1, characterized in that: The content of the atomic capability template is composed of: Further verification of input parameters; Call the common functions of different query methods as needed to execute the query action and obtain the corresponding query results; Analyze the query results and obtain the required return information.

7. The method for querying atomic capabilities based on a device according to claim 6, characterized in that: The different query modes include: port status query, device port flow query and device port real-time flow query.

8. The method for querying atomic capabilities based on a device according to claim 7, characterized in that: The port status query includes: Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes; Connect to the database and execute SQL to query the index of the port stored in the port information table; Connect to the device using snmp and query the fixed OID plus port index; Determine the snmp result, a value of 1 indicates up, a value of 2 indicates down, and other logical conversions; Spell returns the result and logs it.

9. The method for querying atomic capabilities based on a device according to claim 7, characterized in that: The device port traffic query includes: Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes; Connect to the database and execute SQL to query the latest traffic data corresponding to the port; The query results are converted into data, the returned results are spelled out and logged.

10. The method for querying atomic capabilities based on a device according to claim 7, characterized in that: The device port real-time traffic query includes: Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes; Log in to the device through telnet / ssh and query the port traffic through command; Parse the query results to obtain the required flow rate information; If necessary, wait a few seconds and execute the command again to query, subtract the flow rate in the two results and divide it by the interval length to get the flow rate information; Spell returns the result and logs it.

11. A device for querying atomic capabilities based on a device, characterized in that: The device includes: Atomic capability encoding module, used to agree on a unique and readable code for each atomic capability; The parameter verification module is used to provide at least one of the two device-related parameters, device name and device IP address. If both are provided, the device information in the database will be searched based on the device name first. If the device-related parameters are missing or the device cannot be found based on the device input parameters, a corresponding error message will be returned. The parameters that need to be verified for the atomic capability are configured according to the atomic capability parameter configuration table. The device connection number limit module is used to determine whether there is a corresponding record in the cache based on all the input parameters of the query after the parameter verification is passed. If there is, the record in the cache is directly returned without actually executing the query action; if there is no cache record, whether telnet login to the device is required is determined based on the field value of whether telnet login to the device is required in the atomic capability parameter configuration table. If it is required, it is further determined whether the device exceeds the upper limit of login times within a certain period of time. If it exceeds, it directly returns that the query failed and gives a prompt; The data query module is used to query data in the atomic capability in the following ways: database mode, snmp mode and telnet command mode; Atomic capability template module, used to split according to atomic capability coding and supported device models.

12. The device for querying atomic capabilities based on a device according to claim 11, characterized in that: The atomic capability parameter configuration table includes four fields, namely capability code, required parameters, some required parameters, and whether telnet login to the device is required.

13. The device for querying atomic capabilities based on a device according to claim 11, characterized in that: The database method refers to obtaining results by writing SQL queries in a relational database. Only one SQL statement is required for inputting parameters, and the returned results are stored in a two-layer structure of an outer array and an inner hash.

14. The device for querying atomic capabilities based on a device according to claim 11, characterized in that: The snmp method refers to obtaining data by performing snmp collection on the device, which is divided into snmpget and snmpwalk. The input parameters are OID and index, and the obtained results are stored in the hash of the two-layer structure.

15. The device for querying atomic capabilities based on a device according to claim 11, characterized in that: The telnet command method refers to logging into the device through telnet / ssh and executing commands to obtain data, and the returned results are stored in a string variable.

16. The device for querying atomic capabilities based on a device according to claim 11, characterized in that: The content of the atomic capability template is composed of: Further verification of input parameters; Call the common functions of different query methods as needed to execute the query action and obtain the corresponding query results; Analyze the query results and obtain the required return information.

17. The device for querying atomic capabilities based on a device according to claim 16, characterized in that: The different query modes include: port status query, device port flow query and device port real-time flow query.

18. The device for querying atomic capabilities based on a device according to claim 17, characterized in that: The port status query includes: Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes; Connect to the database and execute SQL to query the index of the port stored in the port information table; Connect to the device using snmp and query the fixed OID plus port index; Determine the snmp result, a value of 1 indicates up, a value of 2 indicates down, and other logical conversions; Spell returns the result and logs it.

19. The device for querying atomic capabilities based on a device according to claim 17, characterized in that: The device port traffic query includes: Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes; Connect to the database and execute SQL to query the latest traffic data corresponding to the port; The query results are converted into data, the returned results are spelled out and logged.

20. The device for querying atomic capabilities based on a device according to claim 17, characterized in that: The device port real-time traffic query includes: Parameter verification: whether the port input parameter conforms to the format of multiple numbers separated by slashes; Log in to the device through telnet / ssh and query the port traffic through command; Parse the query results to obtain the required flow rate information; If necessary, wait a few seconds and execute the command again to query, subtract the flow rate in the two results and divide it by the interval length to get the flow rate information; Spell returns the result and logs it.

21. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 10 is implemented.

22. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 10.