A cross-version Oracle monitoring system based on Python language
By designing a cross-version Oracle monitoring system, we solve the problems of low efficiency of traditional manual inspection and inconvenient information management, realize the automation of database operation and maintenance, improve the timeliness and comprehensiveness of monitoring information, and meet the needs of modern database systems for stability and Efficient requirements.
Patent Information
- Application Number
- CN202110988080.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-26
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-08-26
AI Technical Summary
Traditional manual database inspection efficiency is low, information cannot be archived, and macro control cannot be achieved. It cannot meet the stability and efficiency requirements of modern complex database systems.
Designed a cross-version Oracle monitoring system based on Python language, including Monitor Host, Monitor Proxy, Nginx, Monitor Server and Monitor Browse. Through these components, automatic collection, storage and query of monitoring information are realized, and cross-version database performance monitoring is provided. and alarm email function.
It realizes the automation of database operation and maintenance, improves the timeliness, accuracy and comprehensiveness of monitoring information, reduces the workload of operation and maintenance personnel, and meets the company's requirements for database stability and efficiency.
Smart Images

Figure CN113778795B
Abstract
Description
Technical Field
[0001] The present invention is a part of the database automatic operation and maintenance system, which is suitable for monitoring multiple versions of Oracle databases. Its main functions include automatic collection and display of information such as database performance, table space, user information, backup, etc., and automatic email alert of alarm information. Background Art
[0002] The Oracle database system (hereinafter referred to as the "database") is the key backend service for many of our company's application systems. The database's survival and performance fluctuations directly affect the use of a large number of front-end users.
[0003] As the business develops, the application architecture becomes increasingly complex and the scale becomes larger and larger. The application system needs to provide 7*24 services. The corresponding database nodes and architectures are also increasing, and currently there are hundreds of nodes, and the database versions are also different. The database runs in multiple environments such as IDC computer rooms, user-built computer rooms, and the cloud. The database failures caused by hardware, network, application, etc. are also increasing.
[0004] In order to ensure a good user experience, the company has basic requirements for the database: stability and efficiency, and prevention of problems before they occur.
[0005] This places higher demands on the operation and maintenance of the database, requiring multiple inspections every day. Traditional manual inspections generally involve logging into the database server to execute scripts, which can no longer meet the requirements when there are increasingly higher requirements for database stability and more and more nodes. The main problems with manual inspections are as follows:
[0006] (1) Low efficiency
[0007] Manually logging into the database server to run the monitoring script or executing the monitoring script on the database server regularly takes a long time when there are hundreds of nodes. Sometimes the problem occurs before the database server inspection is completed. Repetitive mechanical operations can easily cause fatigue and errors for the operation and maintenance personnel.
[0008] (2) Information cannot be archived
[0009] The text information collected by manual inspections is either stored on the database server or sent to the email addresses of operation and maintenance personnel. It is impossible to archive large amounts of information for a long time. The information is isolated and difficult to organize for vertical and horizontal comparison.
[0010] (3) Unable to control the macro
[0011] The text information collected by manual inspections is isolated from each other, and it is usually difficult to determine the overall status of the database operation from a macro perspective after collection. Summary of the invention
[0012] The goal of the present invention is to overcome the drawbacks of traditional manual inspections to achieve automatic inspections and meet the company's requirements for databases: stability and efficiency, and prevent problems before they occur. A cross-version Oracle monitoring system based on Python language is provided.
[0013] The technical solution adopted by the present invention to solve the technical problem is as follows:
[0014] The present invention includes five parts: Monitor Host, Monitor Proxy, nginx, Monitor Server and MonitorBrowse, which are as follows:
[0015] Monitor Host is responsible for collecting monitoring information on the database server;
[0016] Monitor proxy is responsible for forwarding monitoring information
[0017] Nginx is responsible for mapping the Monitor Server's intranet IP and port to the external network, and sending the information forwarded by the Monitor proxy to the interface defined by the Monitor Server;
[0018] Monitor Server is responsible for storing the information forwarded by nginx in the database and responding to query requests from Monitor Browse.
[0019] Monitor Browse provides monitoring information query function.
[0020] Furthermore, the Monitor Host is specifically implemented as follows:
[0021] 1-1 Configuration File
[0022] It mainly identifies the connection information of each database server and monitors the specific behavior parameters;
[0023] 1-1-1: Server connection information:
[0024] IP: IP address of the database server;
[0025] SERVICE_NAME: database Service_name;
[0026] SYSTEM_PASSWORD: system user password;
[0027] REGION = the ID of the computer room where the server is located;
[0028] 1-1-2: Key identification:
[0029] DB_VERSION: database version identifier;
[0030] 1-1-3: Main catalogue:
[0031] DATA_DIR: database data directory;
[0032] APP_DIR: database program directory;
[0033] SHELL_WORK_DIR: function script running directory;
[0034] DUMP_BACKUP_DIR: database logical backup directory;
[0035] RMAN_BACKUP_DIR: database rman backup directory;
[0036] 1-1-4: Frequency of information collection
[0037] GET_TABLESPACE_INTERVAL: Database tablespace collection frequency;
[0038] GET_OS_INTERVAL: frequency of collecting database operating system data;
[0039] GET_BACKUP_INTERVAL: frequency of collecting backup information;
[0040] GET_DB_INTERVAL: frequency of collecting database dynamic information;
[0041] GET_ERROR_INTERVAL: database alarm collection frequency;
[0042] 1-1-5: Monitor Proxy forwarding IP and port
[0043] IF_PROXIES: whether the information needs to be forwarded;
[0044] PROXIES: The IP and port where the Monitor Proxy program is located;
[0045] MONITOR_SERVER_URL: monitoring system forwarding interface IP and port when IF_PROXIES=1;
[0046] 1-2: Monitor Host class and method
[0047] 1-2-1class username_monitor
[0048] Username part of the architecture diagram: monitors the number of connections, profiles and expiration time of each user;
[0049] Method get_username main indicators are as follows:
[0050] Username: User name;
[0051] Account_status: user status;
[0052] Connections: number of connections per user;
[0053] Profile: the profile to which the user belongs;
[0054] Expiry_date: user expiration date;
[0055] Grace_day: lock grace days;
[0056] Lock_date: lock date;
[0057] Method Interface: defines the interface for sending information, main information:
[0058] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name);
[0059] 1-2-2: Class Server_Monitor
[0060] Architecture diagram OS part: The main method for obtaining operating system indicators:
[0061] get_disk: Get the space utilization and read / write io bytes of the disk where DATA_DIR APP_DIR in the configuration file on the database server is located;
[0062] get_cpu: Get the CPU utilization of the database server;
[0063] get_mem: Get the memory usage of the database server;
[0064] get_io: Get the number of bytes input and output by the database server network card;
[0065] Method Interface: defines the interface for sending information. The main attribute of the interface is Interface_url: the address of the message receiving interface (MONITOR_SERVER_URL + receiving method name);
[0066] 1-2-3: Class Oracle_Monitor
[0067] Architecture diagram DB part: database dynamic performance main class and method:
[0068] The indicators are obtained by running SQL statements, and the database version is specified according to DB_VERSION in the configuration file;
[0069] Method: get_db_status main indicators;
[0070] Commits_count: number of transaction commits;
[0071] Rollbacks_count: transaction rollback count;
[0072] Physical_read_count: physical readings;
[0073] Physical_write_count: physical write count;
[0074] Db_block_change_count: number of data block modifications;
[0075] Qps: qps per second;
[0076] TPS: tqs per second;
[0077] Session_count: number of users connected;
[0078] Session_active_count: number of active user connections;
[0079] Sga: sga size;
[0080] Method Interface: defines the interface for sending information, main properties:
[0081] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name)
[0082] 1-2-4class: tablespace_monitor
[0083] Tablespace part of the architecture diagram: monitor the usage of tablespace to prevent the exhaustion of hard disk space and tablespace database files;
[0084] Method get_tablespace main indicators are as follows:
[0085] Tablespace_name: tablespace name;
[0086] Contents: tablespace type;
[0087] file_name: database file;
[0088] extent_management: segment management type;
[0089] segment_space_management: segment space extension type;
[0090] Status: tablespace status;
[0091] tbs_file_total_m: upper limit of data file size;
[0092] tbs_file_used_m: actual used size of the data file;
[0093] file_used_pct: data file usage rate;
[0094] Method Interface: defines the interface for sending information, main properties:
[0095] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name)
[0096] 1-2-5 class alter_log_monitor
[0097] The alert_log part of the architecture diagram: collects alert logs;
[0098] Method get_alter_log main indicators:
[0099] Alert_log: alarm content;
[0100] Alter_log_date: alarm date;
[0101] Method Interface: defines the interface for sending information, main information:
[0102] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name);
[0103] 1-2-6class backup_monitor
[0104] Architecture diagram backup part: collect rman backup and expdp part information; Method get_backup main indicators are as follows:
[0105] Type: backup type;
[0106] Status: backup status;
[0107] Backup_name: backup file path;
[0108] Backup_size: backup size;
[0109] Disk_usage: backup disk usage;
[0110] Backup_complete: backup completion time;
[0111] Error: error message;
[0112] Method Interface: defines the interface for sending information, main information:
[0113] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name).
[0114] Furthermore, the Monitor Proxy is specifically implemented as follows:
[0115] 2-1: Monitoring information forwarding
[0116] The database servers deployed by the monitor host are distributed in the intranet of various environments. The monitor server is a unified interface, and the two cannot communicate directly. In actual business, the monitor server needs to receive monitoring information from the monitor host.
[0117] Monitor Proxy is responsible for forwarding the information collected by Monitor Host to the unified interface of Monitor Server, which is the interface specified by the parameter file MONITOR_SERVER_URL in step (1);
[0118] 2-2: Monitor Proxy method
[0119] Use Python twisted to forward the message generated in the Monitor host to the specified address of the interface in step (1) via HTTP;
[0120] Method defines the IP and port of the machine where the service is located, which can be accessed by the Monitor Host. It corresponds to the PROXIES parameter of the Monitor host in the configuration file.
[0121] Further, the nginx is specifically implemented as follows:
[0122] Nginx plays the role of HTTP and reverse proxy, as follows:
[0123] Reverse proxy: Maps the Monitor Server service to an external network address and provides an entry for Monitor Proxy to forward information;
[0124] http service: sends the received Monitor Proxy forwarding information to the specified interface of Monitor Server, i.e., the specified interface of the parameter file MONITOR_SERVER_URL in step (1).
[0125] Furthermore, the Monitor Server is specifically implemented as follows:
[0126] Monitor Server is a web application based on the python Flask architecture. Its main function is to store the messages generated by MonitorHost, Monitor proxy, and nginx into the MySQL database; and to return query information in response to query requirements.
[0127] 4-1 Data Storage
[0128] Monitor Host generates 6 types of information: os, db, alter_log, username, tablespace, and backup. Monitor Server has 6 corresponding methods to parse the messages sent from Monitor Host and store them in the MySQL database. The logic of the related classes and methods is the same. The specific implementation of the username message is as follows:
[0129] 4-1-1: method monitor_username_save
[0130] Parse the Monitor_host message forwarded by nginx and generate the SQL statement insert_username.sql according to the monitoring indicators;
[0131] 4-1-2: method execute_sql
[0132] Reference pythonpymysql, receive the above insert_username.sql, connect to the MySQL database to execute SQL statements, and store the OS monitoring data into the database;
[0133] 4-1-3: send_mail
[0134] Reference python email.utils to send an alarm email to the operation and maintenance personnel when the monitor_serverdata related indicators exceed the threshold.
[0135] Furthermore, the Monitor Browse is specifically implemented as follows:
[0136] Monitor Browse is used to respond to query requests and display them through HTML pages. Monitor Hos collects 6 aspects of monitoring information, and the front-end query and display are related to these 6 aspects of monitoring information. At the same time, in order to master the monitoring information at the global level, the specified parts of these 6 aspects of information are summarized to generate a summary information data dashboard: db_dash_board;
[0137] 5-1method server_monitor_data_list
[0138] Convert the query request into a select statement in the SQL statement: server_monitor_data_list, where the field range is within the monitoring information range collected by the OS in step (1);
[0139] 5-2method execute_sql
[0140] Reference python pymysql, receive the above server_monitor_data_list.sql, connect to the MySQL database to execute SQL statements, and return the query results to the front-end html page.
[0141] The beneficial effects of the present invention are as follows:
[0142] The Oracle database operation and maintenance of the present invention has been officially launched. Most of the time, the operation and maintenance personnel can accurately grasp the operation status of the database by checking the db_dash_board and the alarm email, which effectively improves the timeliness, accuracy and comprehensiveness of monitoring information acquisition. Compared with manual operation and maintenance, the information is more timely and accurate, which effectively reduces the repetitive workload of the operation and maintenance personnel and realizes the company's requirements for database operation and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0143] Figure 1 A schematic diagram showing the architecture of the present invention;
[0144] Figure 2 The db_dash_board of the present invention shows a schematic diagram;
[0145] Figure 3 Schematic diagram of OS monitoring display of the present invention;
[0146] Figure 4 Schematic diagram of db monitoring display of the present invention;
[0147] Figure 5 The alter_log monitoring display schematic diagram of the present invention;
[0148] Figure 6 The username monitoring display schematic diagram of the present invention;
[0149] Figure 7 The tablespace monitoring display schematic diagram of the present invention;
[0150] Figure 8 The backup monitoring display diagram of the present invention;
[0151] Fig. 9 It is a schematic diagram showing an example of the present invention; DETAILED DESCRIPTION
[0152] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0153] like Figure 1 As shown, the present invention includes 6 parts including Monitor Host, Monitor Proxy, nginx, Monitor Server and Monitor Browse.
[0154] Monitor Host is responsible for collecting monitoring information on the database server.
[0155] Monitor proxy is responsible for forwarding monitoring information
[0156] Nginx is responsible for mapping the Monitor Server's intranet IP and port to the external network, and sending the information forwarded by the Monitor proxy to the interface defined by the Monitor Server.
[0157] Monitor Server is responsible for storing the information forwarded by nginx in the database and responding to query requests from Monitor Browse.
[0158] Monitor Browse provides monitoring information query function.
[0159] The present invention has been officially launched in the practice of database operation and maintenance, effectively improving the timeliness, accuracy and comprehensiveness of monitoring information acquisition, while significantly reducing the workload of operation and maintenance personnel.
[0160] The architecture of the present invention includes five parts: Monitor Host, Monitor Proxy, nginx, Monitor Server, and MonitorBrowse, as follows:
[0161] Step (1). Monitor Host
[0162] The Monitor Host is a Python program that runs the operating system of each monitored database server.
[0163] The main modules and functions are as follows:
[0164] 1-1 Configuration File
[0165] It mainly identifies the connection information of each database server and monitors the specific behavior parameters.
[0166] 1-1-1: Server connection information:
[0167] IP: IP address of the database server;
[0168] SERVICE_NAME: database Service_name;
[0169] SYSTEM_PASSWORD: system user password;
[0170] REGION = the ID of the computer room where the server is located;
[0171] 1-1-2: Key identification:
[0172] DB_VERSION: database version identifier;
[0173] 1-1-3: Main catalogue:
[0174] DATA_DIR: database data directory;
[0175] APP_DIR: database program directory;
[0176] SHELL_WORK_DIR: function script running directory;
[0177] DUMP_BACKUP_DIR: database logical backup directory;
[0178] RMAN_BACKUP_DIR: database rman backup directory;
[0179] 1-1-4: Information collection frequency (in seconds)
[0180] GET_TABLESPACE_INTERVAL: Database tablespace collection frequency;
[0181] GET_OS_INTERVAL: frequency of collecting database operating system data;
[0182] GET_BACKUP_INTERVAL: frequency of collecting backup information;
[0183] GET_DB_INTERVAL: frequency of collecting database dynamic information;
[0184] GET_ERROR_INTERVAL: database alarm collection frequency;
[0185] 1-1-5: Monitor Proxy forwarding IP and port
[0186] IF_PROXIES: whether the information needs to be forwarded;
[0187] PROXIES: The IP and port where the Monitor Proxy program is located;
[0188] MONITOR_SERVER_URL: monitoring system forwarding interface IP and port when IF_PROXIES=1;
[0189] 1-2: Monitor Host class and method
[0190] 1-2-1class username_monitor
[0191] Username part of the architecture diagram: monitors the number of connections, profile, and expiration time of each user.
[0192] Method get_username main indicators are as follows:
[0193] Username: User name;
[0194] Account_status: user status;
[0195] Connections: number of connections per user;
[0196] Profile: the profile to which the user belongs;
[0197] Expiry_date: User expiration date;
[0198] Grace_day: Lock grace days;
[0199] Lock_date: Lock date;
[0200] Method Interface: Define the interface for sending information. Main information:
[0201] Interface_url: Message receiving interface address (MONITOR_SERVER_URL + receiving method name);
[0202] Message format: Here only the username_monitor message format is used as an example, and the message formats of other metrics are the same.
[0203] ['APPSTORE','176','DEFAULT','OPEN','2049-12-31 23:59:59','7'],
[0204] ['PASSPORT','50','DEFAULT','OPEN','2049-12-31 23:59:59','7'],
[0205] ['ESS','6','DEFAULT','OPEN','2049-12-31 23:59:59','7'],
[0206] ['SYSTEM','1','DEFAULT','OPEN','2049-12-31 23:59:59','7'],
[0207] ['BASE',”,'DEFAULT','EXPIRED(GRACE)','2021-07-27 15:14:25','7'],
[0208] ['ZUOYE',”,'DEFAULT','EXPIRED(GRACE)','2021-07-28 14:25:27','7'],
[0209] ['SYS',”,'DEFAULT','OPEN','2049-12-31 23:59:59','7'],['192.168.1.122','Micro-course Main 122','2021-08-16 15:14:10'].
[0210] 1-2-2: Class Server_Monitor
[0211] Architecture diagram OS part: The main method for obtaining operating system indicators:
[0212] get_disk: Gets the space utilization and read / write io byte count of the disk where DATA_DIR APP_DIR in the configuration file on the database server is located.
[0213] get_cpu: Get the CPU utilization of the database server;
[0214] get_mem: Get the memory usage of the database server;
[0215] get_io: Get the number of bytes input and output by the database server network card;
[0216] Method Interface: defines the interface for sending information. The main attribute of the interface is Interface_url: the address of the message receiving interface (MONITOR_SERVER_URL + receiving method name);
[0217] 1-2-3: Class Oracle_Monitor
[0218] Architecture diagram DB part: database dynamic performance main class and method:
[0219] The index is obtained by running SQL statements. At present, the database version is mainly divided into single db versions represented by 9i, 10g, and 11g, and multi-db versions represented by Pluggable Database (pluggable database) represented by 12c, 18c, and 19c. In the present invention, the multi-db version script runs under the Pluggable Database database, and the specific scripts are different. The version of the database is specified according to DB_VERSION in the configuration file.
[0220] Method: get_db_status main indicators;
[0221] Commits_count: number of transaction commits;
[0222] Rollbacks_count: transaction rollback count;
[0223] Physical_read_count: physical readings;
[0224] Physical_write_count: physical write count;
[0225] Db_block_change_count: number of data block modifications;
[0226] Qps: qps per second;
[0227] TPS: tqs per second;
[0228] Session_count: number of users connected;
[0229] Session_active_count: number of active user connections;
[0230] Sga: sga size;
[0231] Method Interface: defines the interface for sending information, main properties:
[0232] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name)
[0233] 1-2-4class: tablespace_monitor
[0234] Tablespace part of the architecture diagram: Monitor the usage of tablespace to prevent the exhaustion of hard disk space and tablespace database files.
[0235] Method get_tablespace main indicators are as follows:
[0236] Tablespace_name: tablespace name;
[0237] Contents: tablespace type;
[0238] file_name: database file;
[0239] extent_management: segment management type;
[0240] segment_space_management: segment space extension type;
[0241] Status: tablespace status;
[0242] tbs_file_total_m: upper limit of data file size;
[0243] tbs_file_used_m: actual size of the data file used;
[0244] file_used_pct: data file usage rate;
[0245] Method Interface: defines the interface for sending information, main properties:
[0246] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name)
[0247] 1-2-5 class alter_log_monitor
[0248] The alert_log part of the architecture diagram: collects alarm logs.
[0249] Method get_alter_log main indicators:
[0250] Alert_log: alarm content;
[0251] Alter_log_date: alarm date;
[0252] Method Interface: defines the interface for sending information, main information:
[0253] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name);
[0254] 1-2-6class backup_monitor
[0255] Architecture diagram backup part: collect rman backup and expdp part information. Method get_backup main indicators are as follows:
[0256] Type: backup type;
[0257] Status: backup status;
[0258] Backup_name: backup file path;
[0259] Backup_size: backup size;
[0260] Disk_usage: backup disk usage;
[0261] Backup_complete: backup completion time;
[0262] Error: error message;
[0263] Method Interface: defines the interface for sending information, main information:
[0264] Interface_url: message receiving interface address (MONITOR_SERVER_URL + receiving method name);
[0265] Step (2). Monitor Proxy
[0266] 2-1: Monitoring information forwarding
[0267] The database servers deployed on the Monitor host are distributed in the intranets of various environments. The Monitor server is a unified interface, and the two cannot communicate directly. In actual business, the Monitor server must receive monitoring information from the Monitorhost.
[0268] The requirement is achieved by finding a bastion host that can communicate with the external network in the environment where each application is located. This bastion host can communicate with the database server. This bastion host deploys the Monitor Proxy program, which is called the Monitor Proxy end. Monitor Proxy is responsible for forwarding the information collected by Monitor Host to the unified entrance of the Monitor Server interface (specified by the parameter file MONITOR_SERVER_URL in step (1)).
[0269] 2-2: Monitor Proxy method
[0270] Use the Python twisted module to forward the message generated in step (1) to the specified address of the interface in step (1) via HTTP.
[0271] Method defines the IP and port of the machine where the service is located, which can be accessed by the Monitor Host. It corresponds to the PROXIES parameter in step (1) of the configuration file.
[0272] Step (3).nginx
[0273] 3-1 The role of nginx
[0274] In the present invention, nginx plays the role of HTTP and reverse proxy.
[0275] Reverse proxy: Maps the Monitor Server service to an external network address and provides an entry for Monitor Proxy to forward information;
[0276] http service: sends the received Monitor Proxy forwarding information to the specific interface of Monitor Server (specified by the parameter file MONITOR_SERVER_URL in step (1))
[0277] Step (4) Monitor Server
[0278] Monitor Server is a web application based on the python Flask architecture. Its main function is to store the messages generated by steps (1), (2) and (3) into the MySQL database and return query information according to the corresponding query requirements.
[0279] 4-1 Data Storage
[0280] In step (1), six pieces of information, namely os, db, alter_log, username, tablespace, and backup, are generated, corresponding to Figure 3 , Figure 4 , Figure 5 , Figure 6 , Figure 7 and Figure 8 There are 6 corresponding methods on the Monitor Server to parse the message sent by the Monitor Host and store it in the MySQL database. The logic of the relevant classes and methods is the same, and the following uses the username message to illustrate:
[0281] 4-1-1: method monitor_username_save
[0282] Parse the Monitor_host message forwarded in step (3) and generate the SQL statement insert_username.sql according to the monitoring indicators. The example is as follows:
[0283] insert intooracle_username(ip,region,create_time,receive_time,username,connections,profile,account_status,expiry_date,p_limit)values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'; The sample display is as follows Fig. 9 shown.
[0284] 4-1-2: method execute_sql
[0285] Reference the python pymysql module, receive the insert_username.sql above, connect to the MySQL database to execute SQL statements, and store the OS monitoring data in the database.
[0286] 4-1-3: send_mail
[0287] Reference the python email.utils module to send an alarm email to the operation and maintenance personnel when the monitor_serverdata related indicators exceed the threshold. For example, when account_status = 'expire', an alarm email is sent to the operation and maintenance personnel.
[0288] Step (5) Monitor Browse
[0289] This module is used to respond to query requests and display them through HTML pages. In step (1), six aspects of monitoring information are collected. The front-end query and display are related to these six aspects of monitoring information. At the same time, in order to grasp the monitoring information at the global level, the most important parts of these six aspects of information are summarized to generate a summary information data dashboard: db_dash_board, such as Figure 2 The implementation logic of the related classes and methods is the same, and the following only uses the monitor_serverdata related information to illustrate.
[0290] 5-1method server_monitor_data_list
[0291] Convert the query request into a select statement in the SQL statement: server_monitor_data_list, where the field range is within the monitoring information collected by the OS in step (1).
[0292] 5-2method execute_sql
[0293] Reference the pythonpymysql module, receive the above server_monitor_data_list.sql, connect to the MySQL database to execute SQL statements, and return the query results to the front-end html page.
Claims
1. A cross-version Oracle monitoring system based on Python language, characterized by It includes five parts: Monitor Host, Monitor Proxy, nginx, Monitor Server and Monitor Browse, as follows: Monitor Host is responsible for collecting monitoring information on the database server; Monitor proxy is responsible for forwarding monitoring information Nginx is responsible for mapping the Monitor Server's intranet IP and port to the external network, and sending the information forwarded by the Monitor proxy to the interface defined by the Monitor Server; Monitor Server is responsible for storing the information forwarded by nginx in the database and responding to MonitorBrowse query requests; Monitor Browse provides monitoring information query function; Monitor Host is implemented as follows: 1-1 Configuration File Identify the connection information of each database server and the specific behavior parameters to be monitored; 1-1-1: Server connection information: IP: IP address of the database server; SERVICE_NAME: database Service_name; SYSTEM_PASSWORD: system user password; REGION = the ID of the computer room where the server is located; 1-1-2: Key identification: DB_VERSION: database version identifier; 1-1-3: Main catalogue: DATA_DIR: database data directory; APP_DIR: database program directory; SHELL_WORK_DIR: function script running directory; DUMP_BACKUP_DIR: database logical backup directory; RMAN_BACKUP_DIR: database rman backup directory; 1-1-4: Frequency of information collection GET_TABLESPACE_INTERVAL: Database tablespace collection frequency; GET_OS_INTERVAL: frequency of collecting database operating system data; GET_BACKUP_INTERVAL: frequency of collecting backup information; GET_DB_INTERVAL: frequency of collecting database dynamic information; GET_ERROR_INTERVAL: database alarm collection frequency; 1-1-5: Monitor Proxy forwarding IP and port IF_PROXIES: whether the information needs to be forwarded; PROXIES: The IP and port where the Monitor Proxy program is located; MONITOR_SERVER_URL: monitoring system forwarding interface IP and port when IF_PROXIES=1; 1-2: Monitor Host class and method 1-2-1class username_monitor Username part of the architecture diagram: monitors the number of connections, profiles and expiration time of each user; Method get_username indicators are as follows: Username: User name; Account_status: user status; Connections: number of connections per user; Profile: the profile to which the user belongs; Expiry_date: user expiration date; Grace_day: lock grace days; Lock_date: lock date; Method Interface: defines the interface for sending information, main information: Interface_url: the message receiving interface address, i.e., MONITOR_SERVER_URL + receiving method name; 1-2-2: Class Server_Monitor Architecture diagram os part: method to obtain operating system indicators: get_disk: Get the space utilization and read / write io bytes of the disk where DATA_DIR APP_DIR in the configuration file on the database server is located; get_cpu: Get the CPU utilization of the database server; get_mem: Get the database server memory usage; get_io: Get the number of bytes input and output by the database server network card; Method Interface: defines the interface for sending information and the main attributes of the interface; Interface_url: the message receiving interface address, i.e., MONITOR_SERVER_URL + receiving method name; 1-2-3: Class Oracle_Monitor Architecture diagram DB part: database dynamic performance main class and method: The indicators are obtained by running SQL statements, and the database version is specified according to DB_VERSION in the configuration file; Method: get_db_status indicator; Commits_count: number of transaction commits; Rollbacks_count: transaction rollback count; Physical_read_count: physical readings; Physical_write_count: physical write count; Db_block_change_count: number of data block modifications; Qps: qps per second; TPS: tqs per second; Session_count: number of users connected; Session_active_count: number of active user connections; Sga: sga size; Method Interface: defines the interface for sending information, main properties: Interface_url: the message receiving interface address, i.e., MONITOR_SERVER_URL + receiving method name; 1-2-4class: tablespace_monitor Tablespace part of the architecture diagram: monitor the usage of tablespace to prevent the exhaustion of hard disk space and tablespace database files; Method get_tablespace indicators are as follows: Tablespace_name: tablespace name; Contents: tablespace type; file_name: database file; extent_management: segment management type; segment_space_management: segment space extension type; Status: tablespace status; tbs_file_total_m: upper limit of data file size; tbs_file_used_m: actual used size of the data file; file_used_pct: data file usage rate; Method Interface: defines the interface for sending information, main properties: Interface_url: the message receiving interface address, i.e., MONITOR_SERVER_URL + receiving method name; 1-2-5 class alter_log_monitor The alert_log part of the architecture diagram: collects alert logs; Method get_alter_log indicator: Alert_log: alarm content; Alter_log_date: alarm date; Method Interface: defines the interface for sending information, main information: Interface_url: the message receiving interface address, i.e., MONITOR_SERVER_URL + receiving method name; 1-2-6class backup_monitor Architecture diagram backup part: collect rman backup and expdp part information; Method get_backup indicators are as follows: Type: backup type; Status: backup status; Backup_name: backup file path; Backup_size: backup size; Disk_usage: backup disk usage; Backup_complete: backup completion time; Error: error message; Method Interface: defines the interface for sending information, main information: Interface_url: The message receiving interface address is MONITOR_SERVER_URL + receiving method name.
2. According to the cross-version Oracle monitoring system based on Python language according to claim 1, it is characterized in that Monitor Proxy is implemented as follows: 2-1: Monitoring information forwarding The database servers deployed by the monitor host are distributed in the intranet of various environments. The monitor server is a unified interface, and the two cannot communicate directly. In actual business, the monitor server needs to receive monitoring information from the monitor host. Monitor Proxy is responsible for forwarding the information collected by Monitor Host to the unified interface of Monitor Server, that is, the interface specified by the Monitor Host parameter file MONITOR_SERVER_URL; 2-2: Monitor Proxy method Use python twisted to forward the messages generated in Monitor host to the specified address of MonitorHost interface via http; Method defines the IP and port of the machine where the service is located, which can be accessed by the Monitor Host. It corresponds to the PROXIES parameter of the Monitor host in the configuration file.
3. A Python-based cross-version Oracle monitoring system according to claim 2, characterized in that The specific implementation of nginx is as follows: Nginx plays the role of HTTP and reverse proxy, as follows: Reverse proxy: Maps the Monitor Server service to an external network address and provides an entry for Monitor Proxy to forward information; http service: sends the received Monitor Proxy forwarding information to the interface specified by Monitor Server, that is, the interface specified by the Monitor Host parameter file MONITOR_SERVER_URL.
4. A Python-based cross-version Oracle monitoring system according to claim 3, characterized in that Monitor Server is implemented as follows: Monitor Server is a web application based on the python Flask architecture. Its function is to store the messages generated by Monitor Host, Monitor proxy, and nginx into the MySQL database; and return the query information according to the query requirements. 4-1 Data Storage Monitor Host generates 6 types of information: os, db, alter_log, username, tablespace, and backup. Monitor Server has 6 corresponding methods to parse the messages sent from Monitor Host and store them in the MySQL database. The logic of the related classes and methods is the same. The specific implementation of the username message is as follows: 4-1-1: method monitor_username_save Parse the Monitor_host message forwarded by nginx and generate the SQL statement insert_username.sql according to the monitoring indicators; 4-1-2: method execute_sql Reference pythonpymysql, receive the above insert_username.sql, connect to the MySQL database to execute SQL statements, and store the OS monitoring data into the database; 4-1-3: send_mail Reference python email.utils to send an alarm email to the operation and maintenance personnel when the monitor_serverdata related indicators exceed the threshold.
5. A Python-based cross-version Oracle monitoring system according to claim 4, characterized in that Monitor Browse is implemented as follows: Monitor Browse is used to respond to query requests and display them through HTML pages. Monitor Hos collects 6 aspects of monitoring information, and the front-end query and display are related to these 6 aspects of monitoring information. At the same time, in order to master the monitoring information at the global level, the specified parts of these 6 aspects of information are summarized to generate a summary information data dashboard: db_dash_board; 5-1method server_monitor_data_list Convert the query request into a select statement in the SQL statement: server_monitor_data_list, where the field range is within the monitoring information collected by the OS in the Monitor Host; 5-2method execute_sql Reference python pymysql, receive the above server_monitor_data_list.sql, connect to the MySQL database to execute SQL statements, and return the query results to the front-end html page.
Citation Information
Patent Citations
Method and system for automatically operating, maintaining and monitoring oracle database
CN107656858A
A J2EE platform-based full-link monitoring method for supporting operation and maintenance of a service system
CN109901889A
MySQL monitoring system based on python language and implementation method
CN110515799A
Oracle monitoring system and method based on shell script
CN110515813A
Inspection method, device, electronic equipment and medium
CN112463612A
