CN109840179B - RocktMQ thread number monitoring method and device, electronic equipment and storage medium - Google Patents

RocktMQ thread number monitoring method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109840179B
CN109840179B CN201811537813.9A CN201811537813A CN109840179B CN 109840179 B CN109840179 B CN 109840179B CN 201811537813 A CN201811537813 A CN 201811537813A CN 109840179 B CN109840179 B CN 109840179B
Authority
CN
China
Prior art keywords
thread number
rocktmq
pid
state data
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811537813.9A
Other languages
Chinese (zh)
Other versions
CN109840179A (en
Inventor
陈东杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201811537813.9A priority Critical patent/CN109840179B/en
Publication of CN109840179A publication Critical patent/CN109840179A/en
Application granted granted Critical
Publication of CN109840179B publication Critical patent/CN109840179B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method and a device for monitoring the number of threads of a RocktMQ, electronic equipment and a storage medium. The method for monitoring the number of the RocktMQ threads comprises the following steps: when a RocktMQ thread number monitoring instruction is received, detecting the running state of the RocktMQ; when the running state is the available state, a PS command is adopted, and a specified keyword is combined, so that the PID of the RocktetMQ process is obtained from all running processes; accessing state data in a file system process attribute information directory of the RocktMQ according to the PID; calling the current thread number of the RocktMQ from the state data by combining with a specified keyword; and saving and displaying the current thread number. According to the invention, related workers can find abnormality and respond in time, the operation and maintenance efficiency is further improved, the system blockage phenomenon is avoided, the system operation is slow, and the user experience is improved.

Description

RocktMQ thread number monitoring method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of operation and maintenance, in particular to a method and a device for monitoring the number of threads of a RocktMQ, electronic equipment and a storage medium.
Background
In the prior art, a standard Spring Boot product in the market usually does not monitor the rockmq thread number, the index is a core index concerned by application operation and maintenance, the rockmq thread number has an upper limit value, and if the rockmq thread number exceeds the upper limit value, an application request is blocked, so that a user feels that operation experience is slow and user experience is poor.
Disclosure of Invention
In view of the above, it is necessary to provide a method, an apparatus, an electronic device and a storage medium for monitoring rockmq thread number, so that relevant workers can find an abnormality in time and respond to the abnormality, thereby further improving operation and maintenance efficiency, and simultaneously avoiding a system blocking phenomenon, which results in slow system operation, and improving user experience.
A rockmq thread number monitoring method, the method comprising:
when a RocktMQ thread number monitoring instruction is received, detecting the running state of the RocktMQ;
when the running state is available, a PS command is adopted, and the specified keywords are combined, so that the PID of the RocktMQ process is obtained from all running processes;
accessing state data in a file system process attribute information directory of the RocktMQ according to the PID;
calling the current thread number of the RocktetMQ from the state data by combining the appointed key word;
and saving and displaying the current thread number.
According to the preferred embodiment of the present invention, the acquiring PID of the RocketMQ process from all running processes by using PS commands and combining with the specified keyword includes:
calling all process information of the RocktMQ from all running processes by adopting a PS command;
and acquiring the PID of the RocktMQ process from all process information by combining the specified keywords NamesrvStartup and BrokerStartup.
According to the preferred embodiment of the present invention, the file system process attribute information directory is a system file of the rockmq, and all state data is stored in the file system process attribute information directory;
wherein the status data comprises one or more of the following in combination:
process name, running state, PID, thread count.
According to a preferred embodiment of the present invention, said accessing the state data in the directory of file system process attribute information of the RocketMQ according to the PID comprises:
acquiring a configuration access command of the file system process attribute information directory;
generating a target path according to the PID and the configuration access command;
and accessing the state data in the file system process attribute information directory according to the target path.
According to the preferred embodiment of the present invention, said retrieving the current thread number of the RocketMQ from the state data in combination with the specified key comprises:
matching the specified keywords with all keywords in the state data to obtain matched keywords;
and acquiring a parameter value corresponding to the matched keyword from the state data as the current thread number.
According to a preferred embodiment of the invention, the method further comprises:
acquiring the configuration thread number of the RocktMQ;
calculating a first difference value between the configuration thread number and the current thread number;
calculating the ratio of the first difference value to the number of the configuration threads;
and when the ratio is greater than or equal to the first configuration value, an alarm is given.
According to a preferred embodiment of the invention, the method further comprises:
carrying out pressure test on the electronic equipment to obtain the simulation thread number of the RockettMQ;
calculating a second difference value between the current thread number and the simulation thread number;
and when the absolute value of the second difference is larger than a preset threshold value, giving an alarm.
A RocketMQ thread number monitoring device, the device comprising:
the detecting unit is used for detecting the running state of the RocktMQ when receiving the RocktMQ thread number monitoring instruction;
an obtaining unit, configured to obtain, when the running state is an available state, the PID of the rockmq process from all running processes by using a PS command and combining with a specified keyword;
the access unit is used for accessing the state data in the file system process attribute information directory of the RocketMQ according to the PID;
the calling unit is used for calling the current thread number of the RocktetMQ from the state data by combining the appointed key words;
and the display unit is used for storing and displaying the current thread number.
According to the preferred embodiment of the present invention, the acquiring unit acquires PIDs of the rockmq process from all running processes by using a PS command in combination with a specified keyword, including:
calling all process information of the RocketMQ from all running processes by adopting a PS command;
and acquiring the PID of the RockketMQ process from all the process information by combining the specified keywords NamesvStartup and BrokerStartup.
According to the preferred embodiment of the present invention, the file system process attribute information directory is a system file of the rockmq, and all state data is stored in the file system process attribute information directory;
wherein the status data comprises one or more of the following in combination:
process name, running state, PID, thread count.
According to a preferred embodiment of the present invention, the access unit is specifically configured to:
acquiring a configuration access command of the file system process attribute information directory;
generating a target path according to the PID and the configuration access command;
and accessing the state data in the file system process attribute information directory according to the target path.
According to a preferred embodiment of the present invention, the retrieving unit is specifically configured to:
matching the specified keywords with all keywords in the state data to obtain matched keywords;
and acquiring the parameter value corresponding to the matched keyword from the state data as the current thread number.
According to the preferred embodiment of the present invention, the obtaining unit is further configured to obtain a configuration thread number of the RocketMQ;
the device further comprises:
the calculating unit is used for calculating a first difference value between the configuration thread number and the current thread number;
the calculating unit is further configured to calculate a ratio of the first difference to the number of configuration threads;
and the sending unit is used for sending an alarm when the ratio is greater than or equal to the first configuration value.
According to a preferred embodiment of the invention, the device further comprises:
the testing unit is used for carrying out pressure testing on the electronic equipment to obtain the simulation thread number of the RocketMQ;
the calculating unit is further configured to calculate a second difference between the current thread number and the analog thread number;
the sending unit is further configured to send an alarm when the absolute value of the second difference is greater than a preset threshold.
An electronic device, the electronic device comprising:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the RocktMQ thread number monitoring method.
A computer-readable storage medium having stored therein at least one instruction, the at least one instruction being executable by a processor in an electronic device to implement the rockmq thread number monitoring method.
According to the technical scheme, the invention can detect the running state of the RocktMQ after receiving the RocktMQ thread number monitoring instruction, and when the running state is in an available state, the invention adopts the PS command and combines the appointed key words to obtain the PID of the RocktMQ process from all running processes so as to avoid redundant operation and increase the workload, further accesses the state data in the file system process attribute information directory of the RocktMQ according to the PID so as to reduce the detection range and improve the efficiency, and then combines the appointed key words to call the current thread number of the RocktMQ from the state data, store and display the current thread number, and further display the current thread number to related workers so that the related workers can find abnormality and respond in time, further improve the operation and maintenance efficiency, and avoid running blocking phenomenon, thereby resulting in slow system running and improving the user experience.
Drawings
Fig. 1 is a flow chart of a preferred embodiment of the rockmq thread number monitoring method of the present invention.
Fig. 2 is a functional block diagram of a preferred embodiment of the rockmq thread number monitor apparatus of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present invention, which implements a rockmq thread number monitoring method.
Description of the main elements
Figure BDA0001907338940000051
Figure BDA0001907338940000061
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a flow chart of a preferred embodiment of the rockmq thread number monitoring method according to the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The rockmq thread number monitoring method is applied to one or more electronic devices, where the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game console, an interactive network Television (IPTV), an intelligent wearable device, and the like.
The electronic device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network servers.
The Network where the electronic device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
And S10, detecting the running state of the RocktMQ when receiving the RocktMQ thread number monitoring instruction.
When a RocktMQ thread number monitoring instruction is received, the electronic equipment detects the running state of the RocktMQ.
In at least one embodiment of the present invention, a standard Spring Boot product in the market generally does not monitor the rockmq thread number, but the rockmq thread number is a core index concerned in the application operation and maintenance field, and the rockmq thread number has an upper limit value, if the upper limit value is exceeded, an application request will be blocked, and a user may feel that the operation experience is slow and the user experience is not good.
Therefore, according to the technical scheme, the electronic equipment can effectively avoid the system blocking condition, and related personnel can check the RocktMQ thread number in time and respond to the actual condition of the thread number in time.
In at least one embodiment of the invention, the message middleware of the RocketMQ one queue model, namely: an independent system software or service program, located on the operating system of the client or server, manages computer resources and network communications, and can connect two independent applications or independent systems to implement messaging system functions.
Specifically, the electronic device receives the rockmq thread number monitoring instruction, which includes, but is not limited to, one or a combination of the following:
(1) And receiving the RocktMQ thread number monitoring instruction triggered by the user.
Specifically, the user may trigger the rockmq thread number monitoring instruction by clicking a trigger button, where the trigger button may be a virtual button or an entity button.
The user may also input a corresponding voice instruction as the rockmq thread number monitoring instruction, which is not limited in the present invention.
Or, the user may also input fingerprint information to trigger the rockmq thread number monitoring instruction and the like.
(2) And receiving a signal of triggering the RocktMQ thread number monitoring instruction by the electronic equipment at preset time intervals.
Specifically, the preset time interval may be configured by the electronic device, or may be configured by the user in a self-defined manner, which is not limited in the present invention.
For example: the preset time interval may be every 1 minute, etc.
(3) And receiving a signal configured by the electronic equipment and triggering the RockettMQ thread number monitoring instruction at preset time.
Specifically, the preset time may be configured by the electronic device, or may be configured by the user in a user-defined manner, which is not limited in the present invention.
For example: the preset time may be 12 months, 1 day, 10 am, etc.
(4) And receiving the RockettMQ thread number monitoring instruction triggered by the electronic equipment in a configuration state.
Specifically, the configuration state includes, but is not limited to, a state in which the electronic device is stuck or blocked in operation, and the like, so that the electronic device automatically determines the cause of the operation abnormality.
Further, the running state of the RocktMQ comprises an available state and an unavailable state.
Specifically, the available state refers to that the electronic device is in a running state; the unavailable state refers to that the electronic equipment is in a dead halt state or a shutdown state and the like.
It is to be understood that the electronic device needs to respond to the RocketMQ thread number monitoring instruction only when the operation state is the available state.
Specifically, the electronic device may detect the running state of the rocktmmq by using a script rocktmq.
For example: and inputting a related script of the rocktmq.sh into the electronic equipment, and according to the writing mode of the script, when the output is 'rocktmq is not running', indicating that the running state is unavailable, otherwise, indicating that the running state is available.
S11, when the running state is available, adopting a PS command and combining with a specified keyword to acquire the PID (Process Identification) of the RocktMQ Process from all running processes.
And when the running state is the available state, the electronic equipment acquires the PID of the RocktMQ process from all running processes by adopting a PS command and combining with the specified keyword.
In at least one embodiment of the invention, a PS (Process Status) command in Linux is used to display all processes currently running in the system, so that the electronic device queries all processes.
Specifically, the specified keywords include NamesrvStartup and BrokerStartup, which are used for the RocketMQ middleware and are class names in the runtime script of the RocketMQ middleware, so that the PID of the RocketMQ process can be acquired by the specified keywords NamesrvStartup and BrokerStartup and calling the PS command.
Further, the electronic device acquires PIDs of the rockmq process from all running processes by adopting a PS command and combining a specified keyword, including:
the electronic equipment invokes all process information of the RocketMQ from all running processes by adopting a PS command, and acquires the PID of the RocketMQ process from all process information by combining the specified keywords NamesrvStartup and BrokerStartup.
For example: the electronic device employs a command: PID = ' ps-fC java | grep "$ INSTANCES" | egr "NamessrvStartup | BrokerStartup" | awk ' { print $2} ', and a running result can be obtained: [ root @ SZC-L0075300 rocker tmq ] # ps-fC java | grep "rmq _ lcoud-config-prd-ins 5201" | egr "NamesrvStartup | BrokerStartup" | awk '{ print $2}'16056, so the electronic device can determine that the PID of the RocktMQ process is 16056.
And S12, accessing the state data in the file system process attribute information directory of the RocktMQ according to the PID.
And the electronic equipment accesses the state data in the file system process attribute information directory of the RocktMQ according to the PID.
In at least one embodiment of the present invention, the file system process attribute information directory is a system file of the RocketMQ, and all state data is stored in the file system process attribute information directory;
wherein the status data comprises one or more of the following in combination:
process name, running state, PID, thread count.
Further, the accessing, by the electronic device, the state data in the file system process attribute information directory of the RocketMQ according to the PID includes:
and the electronic equipment acquires a configuration access command of the file system process attribute information directory, generates a target path by combining the configuration access command according to the PID, and accesses the state data in the file system process attribute information directory according to the target path.
Specifically, the configuration access command is/proc/$ process ID/status, the electronic device adds the PID to the configuration access command, generates a target path/proc/PID/status, and accesses the state data in the file system process attribute information directory according to the target path.
For example: the electronic device may generate a target path/proc/16056/status according to PID 16056 to access state data of a process with PID 16056.
And S13, calling the current thread number of the RockettMQ from the state data by combining the appointed key words.
And the electronic equipment combines the appointed keywords to call the current thread number of the RocktMQ from the state data.
In at least one embodiment of the present invention, each of the state data corresponds to a key, for example: the key word of the process Name is Name, and the key word of the running State is State.
Further, the specified keyword corresponds to the current thread number, and the specified keyword comprises Threads.
Further, the electronic device, in conjunction with the specified keyword, retrieving the rockmq current thread number from the state data includes:
and the electronic equipment matches the specified keywords with all keywords in the state data to obtain matched keywords, and obtains parameter values corresponding to the matched keywords from the state data as the current thread number.
For example: the electronic device may form an instruction rmq _ Threads () according to the specified keyword Threads, and further obtain the current thread number matching the specified keyword Threads from the status data.
And S14, storing and displaying the current thread number.
And the electronic equipment saves and displays the current thread number.
In at least one embodiment of the present invention, after the electronic device calls the current thread count, the current thread count is stored in a configuration database, so as to facilitate the call.
Specifically, the configuration database may be a local database of the electronic device, or an external database in communication with the electronic device, or the like.
Further, after the electronic device stores the current thread count in the configuration database, the electronic device may retrieve the current thread count from the configuration database and display the thread count to the user, so that the user can directly view the thread count.
Specifically, the displaying, by the electronic device, the current thread number includes:
and the electronic equipment displays the current thread number through a Grafana display platform.
Specifically, the Grafana display platform is a visualization panel (Dashboard), supports various diagrams and layout displays, and supports Graphite, zabbix, influxDB, prometheus and OpenTSDB as data sources. The Grafana display platform has the following characteristics: the method has flexible and rich graphical options, can mix various styles, supports day and night modes and supports a plurality of data sources.
At this time, the configuration database may be a non-relational database of the Grafana display platform, so as to avoid occupying an operating memory of the electronic device.
Of course, in other embodiments, the electronic device may also display the current thread number through Highcharts, which is not limited by the invention.
The Highcharts is a diagram library written in pure JavaScript language, can be added with interactive diagrams on a web site or a web application program simply and conveniently, and supports various diagrams of a monitoring platform.
Preferably, the method further comprises:
the electronic equipment obtains the configuration thread number of the RocktMQ, calculates a first difference value between the configuration thread number and the current thread number, calculates a ratio of the first difference value to the configuration thread number, and sends out an alarm when the ratio is larger than or equal to a first configuration value.
Specifically, the configuration thread number is the maximum number of threads that the RocketMQ can run.
The first configuration value is a preset threshold value, and the first configuration value may be configured according to the performance of the electronic device, or may be configured by the user according to actual requirements, which is not limited in the present invention. For example, the first configuration value may be 80%, etc.
Thus, when the ratio is greater than or equal to the first configuration value, it indicates that the current thread count is too high, and if no action is taken, the operation of the electronic device is affected, and therefore, the electronic device issues an alarm.
Preferably, the method further comprises:
the electronic equipment carries out pressure test on the electronic equipment to obtain the simulation thread number of the RocktMQ, calculates a second difference value between the current thread number and the simulation thread number, and gives an alarm when the absolute value of the second difference value is larger than a preset threshold value.
Specifically, the pressure test is to simulate an actual use scenario of the electronic device to realize a simulation test of an actual operation index of the electronic device.
Further, the preset threshold value is used as a reference for comparison, and may assist in determining whether the thread number is abnormal, for example: the preset threshold may be 5%, etc.
In this embodiment, the electronic device simulates the operation of the RocketMQ, obtains the simulated thread number, further calculates a second difference between the current thread number and the simulated thread number, and when an absolute value of the second difference is greater than the preset threshold, indicates that the electronic device may operate abnormally due to a large difference between the simulated value and the actual value, and then sends an alarm to prompt related personnel to handle the abnormal condition of the RocketMQ thread number in time.
In summary, in the present invention, when a rockmq thread number monitoring instruction is received, the running state of the rockmq is detected; when the running state is available, a PS command is adopted, and the specified keywords are combined, so that the PID of the RocktMQ process is obtained from all running processes; accessing state data in a file system process attribute information directory of the RocktMQ according to the PID; calling the current thread number of the RocktMQ from the state data by combining with a specified keyword; and saving and displaying the current thread number. Therefore, the invention can enable related workers to find abnormality and respond in time, further improve the operation and maintenance efficiency, and simultaneously avoid the system blockage phenomenon, thereby resulting in slow system operation and improving the user experience.
Fig. 2 is a functional block diagram of a preferred embodiment of the rockmq thread number monitoring apparatus according to the present invention. The rockmq thread number monitoring apparatus 11 includes a detecting unit 110, an obtaining unit 111, an accessing unit 112, a calling unit 113, a presenting unit 114, a calculating unit 115, an issuing unit 116, and a testing unit 117. The module/unit referred to in the present invention means a series of computer program segments capable of being executed by the processor 13 and performing a fixed function, and stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
When receiving a rockmq thread number monitoring instruction, the detection unit 110 detects the running state of the rockmq.
In at least one embodiment of the present invention, a standard Spring Boot product in the market generally does not monitor the rockmq thread number, but the rockmq thread number is a core index concerned in the application operation and maintenance field, and the rockmq thread number has an upper limit value, if the upper limit value is exceeded, an application request will be blocked, and a user may feel that the operation experience is slow and the user experience is not good.
Therefore, according to the technical scheme, the electronic equipment can effectively avoid the system blocking condition, and related personnel can check the RocktMQ thread number in time and respond to the actual condition of the thread number in time.
In at least one embodiment of the invention, the message middleware of the rockmq-one queue model, namely: an independent system software or service program, located on the operating system of the client or server, manages computer resources and network communications, can connect two independent applications or independent systems, and implements messaging system functions.
Specifically, the electronic device receives the rockmq thread number monitoring instruction, which includes, but is not limited to, one or a combination of the following:
(1) And receiving the RocktMQ thread number monitoring instruction triggered by the user.
Specifically, the user may trigger the rockmq thread number monitoring instruction by clicking a trigger button, where the trigger button may be a virtual button or an entity button.
The user may also input a corresponding voice instruction as the rockmq thread number monitoring instruction, which is not limited in the present invention.
Or, the user may also input fingerprint information to trigger the RocketMQ thread number monitoring instruction, and the like.
(2) And receiving a signal of triggering the RockettMQ thread number monitoring instruction by the electronic equipment at preset time intervals.
Specifically, the preset time interval may be configured by the electronic device, or may be configured by the user in a self-defined manner, which is not limited in the present invention.
For example: the preset time interval may be every 1 minute, etc.
(3) And receiving a signal which is configured by the electronic equipment and triggers the RocktMQ thread number monitoring instruction at preset time.
Specifically, the preset time may be configured by the electronic device, or may be configured by the user in a user-defined manner, which is not limited in the present invention.
For example: the preset time may be 12 months, 1 day, 10 am, etc.
(4) And receiving the RocktMQ thread number monitoring instruction triggered by the electronic equipment in a configuration state.
Specifically, the configuration state includes, but is not limited to, a state in which the electronic device is stuck or blocked in operation, and the like, so that the electronic device automatically determines the cause of the operation abnormality.
Further, the running state of the RocktMQ comprises an available state and an unavailable state.
Specifically, the available state refers to that the electronic device is in a running state; the unavailable state refers to that the electronic equipment is in a dead halt state or a shutdown state and the like.
It is to be understood that the electronic device needs to respond to the RocketMQ thread number monitoring instruction only when the operation state is the available state.
Specifically, the detecting unit 110 may detect the running state of the rocktmmq by using a script rocktmq.
For example: the detection unit 110 inputs a related script of rocktmq.sh, and according to the writing mode of the script, when the output is "rocktmq is not running", it indicates that the running state is unavailable, otherwise, it indicates that the running state is available.
When the running state is the available state, the obtaining unit 111 obtains the PIDs of the rockmq process from all running processes by using a PS command in combination with a specified keyword.
In at least one embodiment of the invention, a PS (Process Status) command in Linux is used to display all processes currently running in the system, so that the electronic device queries all processes.
Specifically, the specified keywords include NamesrvStartup and BrokerStartup, which are used for the RocketMQ middleware and are class names in the runtime script of the RocketMQ middleware, so that the PID of the RocketMQ process can be acquired by the specified keywords NamesrvStartup and BrokerStartup and calling the PS command.
Further, the acquiring unit 111 acquires PIDs of the rockmq process from all running processes by using a PS command in combination with a specified keyword, including:
the obtaining unit 111 uses a PS command to call all process information of the rockmq from all running processes, and the obtaining unit 111 obtains the PID of the rockmq process from all the process information in combination with the specified keywords NamesrvStartup and BrokerStartup.
For example: the acquiring unit 111 employs a command: PID = ' ps-fC java | grep "$ INSTANCES" | egr "NamessrvStartup | BrokerStartup" | awk ' { print $2} ', and a running result can be obtained: [ root @ SZC-L0075300 Rockettmq ] # ps-fC java | grep "rmq _ LCloud-config-prd-ins5201" | egrep "NamesrvStartup | BrokerStartup" | awk '{ print $2}'16056, so the acquisition unit 111 can determine the PID of the RockettMQ process to be 16056.
The accessing unit 112 accesses the state data in the file system process attribute information directory of the rockmq according to the PID.
In at least one embodiment of the present invention, the file system process attribute information directory is a system file of the rocktmq, and all state data is stored in the file system process attribute information directory;
wherein the status data comprises one or more of the following in combination:
process name, running state, PID, thread count.
Further, the accessing unit 112 accesses the state data in the file system process attribute information directory of the RocketMQ according to the PID, including:
the access unit 112 obtains a configuration access command of the file system process attribute information directory, and generates a target path according to the PID in combination with the configuration access command, and the access unit 112 accesses the state data in the file system process attribute information directory according to the target path.
Specifically, the configuration access command is/proc/$ process ID/status, the accessing unit 112 adds the PID to the configuration access command, generates a target path/proc/PID/status, and accesses the state data in the file system process attribute information directory according to the target path.
For example: the access unit 112 may generate a target path/proc/16056/status according to the PID 16056 to access the status data of the process with PID 16056.
The retrieving unit 113 retrieves the rockmq current thread number from the state data in conjunction with the specified key.
In at least one embodiment of the present invention, each of the state data corresponds to a key, for example: the key word of the process Name is Name, and the key word of the running State is State.
Further, the specified keyword corresponds to the current thread number, and the specified keyword comprises Threads.
Further, the retrieving unit 113, in conjunction with the specified key, retrieves the current thread number of the rockmq from the state data, including:
the calling unit 113 matches the specified keyword with all keywords in the status data to obtain a matched keyword, and obtains a parameter value corresponding to the matched keyword from the status data as the current thread number.
For example: the fetch unit 113 may form an instruction rmq _ Threads () according to the specified keyword Threads, and further obtain the current thread number matching the specified keyword Threads from the state data.
Presentation unit 114 saves and presents the current thread count.
In at least one embodiment of the present invention, after the retrieving unit 113 retrieves the current thread count, the current thread count is stored in a configuration database, so as to facilitate retrieval.
Specifically, the configuration database may be a local database of the electronic device, or an external database in communication with the electronic device, or the like.
Further, after the display unit 114 saves the current thread number to the configuration database, the retrieving unit 113 may retrieve the current thread number from the configuration database, and the display unit 114 displays the current thread number to the user, so that the user can directly view the current thread number.
Specifically, the displaying unit 114 displays the current thread number, including:
the presentation unit 114 presents the current thread count through the Grafana presentation platform.
Specifically, the Grafana display platform is a visualization panel (Dashboard), supports various diagrams and layout displays, and supports Graphite, zabbix, influxDB, prometheus and OpenTSDB as data sources. The Grafana display platform has the following characteristics: the method has flexible and rich graphical options, can mix various styles, supports day and night modes and supports a plurality of data sources.
At this time, the configuration database may be a non-relational database of the Grafana display platform, so as to avoid occupying an operating memory of the electronic device.
Of course, in other embodiments, the presentation unit 114 may also present the current thread number through Highcharts, which is not limited by the present invention.
The Highcharts is a diagram library written in pure JavaScript language, can be added with interactive diagrams on a web site or a web application program simply and conveniently, and supports various diagrams of a monitoring platform.
Preferably, the method further comprises:
the obtaining unit 111 obtains the configured thread number of the rocktmq, the calculating unit 115 calculates a first difference between the configured thread number and the current thread number, and calculates a ratio of the first difference to the configured thread number, and when the ratio is greater than or equal to a first configuration value, the sending unit 116 sends an alarm.
Specifically, the configuration thread number is the maximum number of threads that the RocketMQ can run.
The first configuration value is a preset threshold value, and the first configuration value may be configured according to the performance of the electronic device, or may be configured by the user according to actual requirements, which is not limited in the present invention. For example, the first configuration value may be 80%, etc.
Thus, when the ratio is greater than or equal to the first configuration value, it indicates that the current thread count is too high, and if no action is taken, the operation of the electronic device will be affected, and therefore, the issuing unit 116 issues an alarm.
Preferably, the method further comprises:
the testing unit 117 performs a pressure test on the electronic device to obtain a simulated thread number of the RocketMQ, the calculating unit 115 calculates a second difference between the current thread number and the simulated thread number, and the sending unit 116 sends an alarm when an absolute value of the second difference is greater than a preset threshold.
Specifically, the pressure test is to simulate an actual use scenario of the electronic device to realize a simulation test of an actual operation index of the electronic device.
Further, the preset threshold value is used as a reference for comparison, and may assist in determining whether the thread number is abnormal, for example: the preset threshold may be 5%, etc.
In this embodiment, the testing unit 117 simulates the operation of the rocktmq, obtains the simulated thread number, further calculates a second difference between the current thread number and the simulated thread number, and when an absolute value of the second difference is greater than the preset threshold, indicates that the electronic device may operate abnormally due to a large difference between the simulated value and the actual value, and further sends an alarm to prompt related personnel to handle the abnormal condition of the rocktmq thread number in time.
In summary, in the present invention, when a rockmq thread number monitoring instruction is received, the running state of the rockmq is detected; when the running state is available, a PS command is adopted, and the specified keywords are combined, so that the PID of the RocktMQ process is obtained from all running processes; accessing state data in a file system process attribute information directory of the RocktMQ according to the PID; calling the current thread number of the RocktMQ from the state data by combining with a specified keyword; and saving and displaying the current thread number. Therefore, the invention can enable related workers to find abnormality and respond in time, further improve the operation and maintenance efficiency, and simultaneously avoid the system blockage phenomenon, thereby resulting in slow system operation and improving the user experience.
Fig. 3 is a schematic structural diagram of an electronic device according to a preferred embodiment of the method for monitoring the number of threads of a RocketMQ according to the present invention.
The electronic device 1 is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware thereof includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device 1 may also be, but not limited to, any electronic product that can perform human-computer interaction with a user through a keyboard, a mouse, a remote controller, a touch panel, or a voice control device, for example, a personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive web Television (IPTV), an intelligent wearable device, and the like.
The electronic device 1 may also be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices.
The Network where the electronic device 1 is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program, such as a rockmq thread number monitor, stored in the memory 12 and operable on the processor 13.
It will be appreciated by those skilled in the art that the schematic diagram is merely an example of the electronic device 1, and does not constitute a limitation of the electronic device 1, and may include more or less components than those shown, or combine some components, or different components, for example, the electronic device 1 may further include an input-output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
The processor 13 executes an operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the foregoing respective rockmq thread number monitoring method embodiments, such as steps S10, S11, S12, S13, and S14 shown in fig. 1.
Alternatively, the processor 13, when executing the computer program, implements the functions of the modules/units in the above device embodiments, for example: when a RocketMQ thread number monitoring instruction is received, detecting the running state of the RocketMQ; when the running state is available, a PS command is adopted, and the specified keywords are combined, so that the PID of the RocktMQ process is obtained from all running processes; accessing state data in a file system process attribute information directory of the RocketMQ according to the PID; calling the current thread number of the RocktetMQ from the state data by combining the appointed key word; and saving and displaying the current thread number.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into a detection unit 110, an acquisition unit 111, an access unit 112, a recall unit 113, a presentation unit 114, a calculation unit 115, an issue unit 116 and a test unit 117.
The memory 12 can be used for storing the computer programs and/or modules, and the processor 13 implements various functions of the electronic device 1 by running or executing the computer programs and/or modules stored in the memory 12 and calling data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 12 may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the Memory 12 may be a circuit having a Memory function without any physical form In the integrated circuit, such as a RAM (Random-Access Memory), a FIFO (First In First Out), and the like. Alternatively, the memory 12 may be a memory in a physical form, such as a memory stick, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
With reference to fig. 1, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a rockmq thread number monitoring method, and the processor 13 may execute the plurality of instructions to implement: when a RocktMQ thread number monitoring instruction is received, detecting the running state of the RocktMQ; when the running state is the available state, a PS command is adopted, and a specified keyword is combined, so that the PID of the RocktetMQ process is obtained from all running processes; accessing state data in a file system process attribute information directory of the RocktMQ according to the PID; calling the current thread number of the RocktMQ from the state data by combining with a specified keyword; and saving and displaying the current thread number.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
calling all process information of the RocktMQ from all running processes by adopting a PS command;
and acquiring the PID of the RocktMQ process from all process information by combining the specified keywords NamesrvStartup and BrokerStartup.
According to the preferred embodiment of the present invention, the file system process attribute information directory is a system file of the rockmq, and all state data is stored in the file system process attribute information directory;
wherein the status data comprises one or more of the following in combination:
process name, running state, PID, thread count.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
acquiring a configuration access command of the file system process attribute information directory;
generating a target path according to the PID and the configuration access command;
and accessing the state data in the process attribute information directory of the file system according to the target path.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
matching the specified keywords with all keywords in the state data to obtain matched keywords;
and acquiring a parameter value corresponding to the matched keyword from the state data as the current thread number.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
acquiring the configuration thread number of the RocktMQ;
calculating a first difference value between the configuration thread number and the current thread number;
calculating the ratio of the first difference value to the number of the configuration threads;
and when the ratio is greater than or equal to the first configuration value, an alarm is given.
According to a preferred embodiment of the present invention, the processor 13 further executes a plurality of instructions including:
carrying out pressure test on the electronic equipment to obtain the simulation thread number of the RockettMQ;
calculating a second difference value between the current thread number and the simulation thread number;
and when the absolute value of the second difference is larger than a preset threshold value, giving an alarm.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the instruction, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice. The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not to denote any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (9)

1. A RockettMQ thread number monitoring method is characterized by comprising the following steps:
when a RocktMQ thread number monitoring instruction is received, detecting the running state of the RocktMQ;
when the running state is the available state, calling all process information of the RocketMQ from all running processes by adopting a PS command, and acquiring the PID of the RocketMQ process from all the process information by combining a first specified keyword;
acquiring a configuration access command of a file system process attribute information directory, generating a target path according to the PID and the configuration access command, and accessing state data in the file system process attribute information directory according to the target path, wherein the state data comprises one or more of the following combinations: process name, running state, PID, thread number;
the current thread number of the RocktetMQ is called from the state data by combining a second specified keyword;
and saving and displaying the current thread number.
2. The rockmq thread number monitoring method according to claim 1, wherein the first specified keys are NamesrvStartup and BrokerStartup.
3. The rocktmq thread number monitoring method of claim 1, wherein the file system process attribute information directory is a system file of the rocktmq, and all state data is stored in the file system process attribute information directory.
4. The rocktmq thread number monitoring method according to claim 1, wherein the retrieving, in conjunction with a second specified key, a rocktmq current thread number from the state data comprises:
matching the second specified keyword with all keywords in the state data to obtain matched keywords;
and acquiring the parameter value corresponding to the matched keyword from the state data as the current thread number.
5. The rockmq thread number monitoring method of claim 1, wherein the method further comprises:
acquiring the configuration thread number of the RocktMQ;
calculating a first difference value between the configuration thread number and the current thread number;
calculating the ratio of the first difference value to the configuration thread number;
and when the ratio is greater than or equal to the first configuration value, an alarm is given.
6. The rockmq thread number monitoring method of claim 1, wherein the method further comprises:
carrying out pressure test on the electronic equipment to obtain the simulation thread number of the RocktetMQ;
calculating a second difference value between the current thread number and the simulation thread number;
and when the absolute value of the second difference is larger than a preset threshold value, giving an alarm.
7. A RocketMQ thread number monitoring device, the device comprising:
the detecting unit is used for detecting the running state of the RocketMQ when receiving the RocketMQ thread number monitoring instruction;
an obtaining unit, configured to, when the running state is an available state, use a PS command to retrieve all process information of the RocketMQ from all running processes, and obtain, in combination with a first specified keyword, a PID of the RocketMQ process from all process information;
an access unit, configured to obtain a configuration access command of a file system process attribute information directory, generate a target path according to the PID in combination with the configuration access command, and access state data in the file system process attribute information directory according to the target path, where the state data includes one or a combination of more of the following: process name, running state, PID, thread number;
the calling unit is used for calling the current thread number of the RocktMQ from the state data in combination with a second specified keyword;
and the display unit is used for storing and displaying the current thread number.
8. An electronic device, characterized in that the electronic device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the rockmq thread number monitoring method as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein at least one instruction that is executable by a processor in an electronic device to implement the rockmq thread number monitoring method according to any one of claims 1 to 6.
CN201811537813.9A 2018-12-15 2018-12-15 RocktMQ thread number monitoring method and device, electronic equipment and storage medium Active CN109840179B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811537813.9A CN109840179B (en) 2018-12-15 2018-12-15 RocktMQ thread number monitoring method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811537813.9A CN109840179B (en) 2018-12-15 2018-12-15 RocktMQ thread number monitoring method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109840179A CN109840179A (en) 2019-06-04
CN109840179B true CN109840179B (en) 2023-04-11

Family

ID=66883208

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811537813.9A Active CN109840179B (en) 2018-12-15 2018-12-15 RocktMQ thread number monitoring method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109840179B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625463B (en) * 2020-05-28 2024-02-13 北京达佳互联信息技术有限公司 Program state detection method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521099A (en) * 2011-11-24 2012-06-27 深圳市同洲视讯传媒有限公司 Process monitoring method and process monitoring system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853205A (en) * 2010-06-23 2010-10-06 山东中创软件商用中间件股份有限公司 Method and apparatus for monitoring the running of program
KR101252185B1 (en) * 2010-08-10 2013-04-05 주식회사 잉카인터넷 method for blocking hack using thread check
CN103428272B (en) * 2013-07-16 2016-06-15 无限极(中国)有限公司 The monitoring and dispatching system of a kind of middleware thread and method
US9400701B2 (en) * 2014-07-07 2016-07-26 International Business Machines Corporation Technology for stall detection
CN105574407B (en) * 2015-12-28 2018-09-25 无锡天脉聚源传媒科技有限公司 A kind of shared treating method and apparatus
CN107360019A (en) * 2017-06-06 2017-11-17 武汉票据交易中心有限公司 A kind of thread monitor method and system of server
CN108874624B (en) * 2018-05-31 2023-03-28 康键信息技术(深圳)有限公司 Server, method for monitoring Java process and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521099A (en) * 2011-11-24 2012-06-27 深圳市同洲视讯传媒有限公司 Process monitoring method and process monitoring system

Also Published As

Publication number Publication date
CN109840179A (en) 2019-06-04

Similar Documents

Publication Publication Date Title
US11733982B1 (en) Dynamically changing input data streams processed by data stream language programs
US10303533B1 (en) Real-time log analysis service for integrating external event data with log data for use in root cause analysis
US20180077044A1 (en) Analyzing servers based on data streams generated by instrumented software executing on the servers
CN109800124B (en) CPU utilization monitoring method and device, electronic equipment and storage medium
CN112306700A (en) Abnormal RPC request diagnosis method and device
CN110825731A (en) Data storage method and device, electronic equipment and storage medium
CN113238815B (en) Interface access control method, device, equipment and storage medium
CN114721912B (en) Data analysis method, device, equipment and medium
CN109840179B (en) RocktMQ thread number monitoring method and device, electronic equipment and storage medium
CN109815082B (en) KAFKA theme monitoring method and device, electronic equipment and storage medium
CN109828885B (en) RocketMQ memory monitoring method and device, electronic equipment and storage medium
CN116382665A (en) Visual operation method and device of elastic search, storage medium and computer equipment
CN114371969B (en) Page performance testing method and device, electronic equipment and storage medium
CN109766236A (en) KAFKA message queue number monitoring method, device, electronic equipment and storage medium
CN109766238B (en) Session number-based operation and maintenance platform performance monitoring method and device and related equipment
US20230010906A1 (en) System event analysis and data management
US10909242B2 (en) System and method for detecting security risks in a computer system
CN112906387A (en) Risk content identification method, apparatus, device, medium, and computer program product
CN111782208A (en) Index early warning method and device, computer equipment and storage medium
CN111435350A (en) Real-time monitoring method, system, equipment and storage medium for mass data
CN114077510B (en) Method and device for positioning and displaying fault root cause
CN116610724B (en) Log data tracking method and device, electronic equipment and storage medium
EP4152174A1 (en) Data processing method and apparatus, and computing device and medium
CN115712449A (en) Application configuration method, device, system, equipment and storage medium
CN113835788A (en) Method for quickly acquiring input event and method for quickly responding to input event

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant