CN110119335A - Server NTP process monitoring method, electronic device and storage medium - Google Patents
Server NTP process monitoring method, electronic device and storage medium Download PDFInfo
- Publication number
- CN110119335A CN110119335A CN201910238704.5A CN201910238704A CN110119335A CN 110119335 A CN110119335 A CN 110119335A CN 201910238704 A CN201910238704 A CN 201910238704A CN 110119335 A CN110119335 A CN 110119335A
- Authority
- CN
- China
- Prior art keywords
- time
- server
- ntp
- local server
- local
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/3006—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3466—Performance evaluation by tracing or monitoring
- G06F11/3476—Data logging
Abstract
The present invention relates to software developments, server NTP process monitoring method, electronic device and storage medium are provided, monitoring script is executed in a manner of timed task on every local server ansible platform, on local server clock and NTP service be monitored;By executing monitoring script, check whether the system time of local server is synchronous with ntp server, if the time between local server and ntp server has time offset value, and time offset value is more than or less than time migration threshold value, determine time irreversibility, exports time irreversibility relevant information into engine file;Inquire local server docker.log file whether the nonsynchronous information of having time, alerted if so, then triggering phone and mail.Whether the present invention can monitor NTP service abnormal, to handle in time, using will not because of server inaccurate clock and cause using abnormal.
Description
Technical field
The present invention relates to field of software development, specifically, being related to a kind of server NTP process monitoring method, electronics dress
It sets and storage medium.
Background technique
With the fast development of computer network, network application is very universal, such as electric power, finance, communication, traffic
Every field needs to be kept for the time synchronization of computer and time accurate on a large scale, and linux is serviced in industry local area network at present
Will start NTP (Network Time Protocol) service verification clock on device, if but ntp service is abnormal, it is accurate not can guarantee clock,
It since the time of this server and other servers are there are the time difference, will lead to using exception, if NTP service is normal, and match
It is equipped with the monitoring clock software for misleading and causing the clock of server incorrect, not relatively good.
Summary of the invention
In order to solve the above technical problems, the present invention provides a kind of server NTP process monitoring method, is applied to electronics and fills
It sets, monitoring script is executed on every local server in a manner of timed task ansible platform, to local server
On clock and NTP service be monitored;By executing the monitoring script, the system time and NTP of local server are checked
Whether server synchronizes, if the time between local server and NTP server has time offset value, and time offset value
More than or less than time migration threshold value, then time irreversibility is determined, export time irreversibility relevant information into engine file,
Described in time irreversibility relevant information include between local server IP address, local server and ntp server when
Between offset value information;Inquire local server engine log whether the nonsynchronous information of having time, if so, then trigger phone with
Mail alarm.
Preferably, using/usr/sbin/ntpq-p starting NTP service, using grep'[0-9] ' the current mesh of command lookup
Record file in by number beginning row, using awk'{ print $ 9 } ' output local server and long-range ntp server time
Deviant, using awk-F { print $ 1 } ' remove the number after decimal point, to extract local server and long-range NTP
The time offset value of server, and time offset value is stored in/tmp/ntp_gf.tmp file in.
Preferably, using while read line
do
Time offset value in ntp_gf.tmp file is assigned to variable line by done < file circulation line by line, and by institute
Time offset value is stated compared with time migration threshold value, if the deviant between local server and ntp server is greater than 1 second,
Then export the IP address of local server.
Preferably, the time difference synchronizes in the following way if it exists:
Time=date+ " %H:%M "
Miao=` " %S " `
Miaos=` $ Miao+ $ line/1000
date-s$Time:$Miaos
Wherein, Time is the time of local server, and date is the date, and H is hour, and M is minute, and S is local server
Second;Wherein, $ line is the time offset value obtained.
Preferably, mail and warning by telephone are triggered by mvc application monitor supervision platform perform script.
Preferably, the data in engine log being read, to accelerate progress, by grep-v, " # filters out the row of annotation, leads to
It crosses grep-v back and filters out the character comprising back, the word comprising appsystem is filtered out by grep appsystem
Symbol, if reading the information that there is difference in the time that the text in engine log includes local server time and ntp server,
Then trigger mail alarm.
The present invention also provides a kind of electronic device, which includes: memory and processor, is deposited in the memory
Server NTP process monitoring program is contained, is realized when the server NTP process monitoring program is executed by the processor as follows
Step: monitoring script is executed on every local server in a manner of timed task ansible platform, to local service
Clock and NTP service on device are monitored;By executing the monitoring script, check the system time of local server with
Whether ntp server synchronizes, if the time between local server and ntp server has time offset value, and time migration
Value is more than or less than time migration threshold value, then determines time irreversibility, exports time irreversibility relevant information into engine file,
Wherein the relevant information of the time irreversibility includes between local server IP address, local server and ntp server
Time migration value information;Inquire local server docker.log file whether the nonsynchronous information of having time, if so, then touching
Power generation words are alerted with mail.
Preferably, using/usr/sbin/ntpq-p starting NTP service, using grep'[0-9] ' the current mesh of command lookup
Record file in by number beginning row, using awk'{ print $ 9 } ' output local server and long-range ntp server time
Deviant, using awk-F { print $ 1 } ' remove the number after decimal point, to extract local server and long-range NTP
The time offset value of server, and time offset value is stored in/tmp/ntp_gf.tmp file in.
Preferably, using while read line
do
Time offset value in ntp_gf.tmp file is assigned to variable line by done < file circulation line by line, and by institute
Time offset value is stated compared with time migration threshold value, if the deviant between local server and ntp server is greater than 1 second,
Then export the IP address of local server.
The present invention also provides a kind of computer readable storage medium, the computer-readable recording medium storage has computer
Program, the computer program includes program instruction, when described program instruction is executed by processor, realizes service as described above
Device NTP process monitoring method.
Server NTP process monitoring method, electronic device and storage medium through the invention can monitor NTP service
It is whether abnormal, then trigger alarm if any abnormal, to handle in time, using will not because of server inaccurate clock and cause
Using exception.
Detailed description of the invention
By the way that embodiment is described in conjunction with following accompanying drawings, features described above of the invention and technological merit will become
More understands and be readily appreciated that.
Fig. 1 is the flow diagram of the server NTP process monitoring method of the embodiment of the present invention;
Fig. 2 is the hardware structure schematic diagram of the electronic device of the embodiment of the present invention;
Fig. 3 is the module structure drafting of the server NTP process monitoring program of the embodiment of the present invention.
Specific embodiment
Server NTP process monitoring method, electronic device and storage of the present invention described below with reference to the accompanying drawings
The embodiment of medium.Those skilled in the art will recognize, without departing from the spirit and scope of the present invention the case where
Under, described embodiment can be modified with a variety of different modes or combinations thereof.Therefore, attached drawing and description are in essence
On be it is illustrative, be not intended to limit the scope of the claims.In addition, in the present specification, attached drawing is not in scale
It draws, and identical appended drawing reference indicates identical part.
Fig. 1 is the flow diagram of server NTP process monitoring method provided in an embodiment of the present invention.This method include with
Lower step:
Step S10, by ansible platform (the O&M automation tools applied to configuration management) in every local service
Monitoring script is executed on device, can be executed with the mode of timed task, is checked for example, executing at intervals of two minutes once, to local clothes
Clock on business device carries out verification monitoring and NTP service is monitored.
Step S30, by executing the monitoring script, check local server system time and ntp server whether
It is synchronous, if the time between local server and ntp server has time offset value, and when time offset value is more than or less than
Between offset threshold, then determine time irreversibility, time irreversibility relevant information exported into engine file, wherein the time is not
Synchronous relevant information includes the time offset value letter between the address local server IP, local server and ntp server
Breath.
Step S50, inquire local server docker.log (engine log) whether the nonsynchronous information of having time, if
Have, then triggers phone and mail alerts, so that maintenance personnel is able to carry out timely processing.Also, it the automatic straightening time, repairs in time
Change the clock on server.It avoids abnormal using causing to apply because of clock.
Lower mask body combination number order illustrates its process, is serviced using/usr/sbin/ntpq-p starting NTP ,/
Usr/sbin/ntpq is the finger daemon file of NTP service, and NTP service could be provided by needing to start.It extracts in configuration file
Number, wherein-p indicates the directory listing of display server peer device, and shows the summary of their states.Wherein
Just show the time offset value of local server Yu long-range ntp server.Using grep'[0-9] ' command lookup current directory
By the row of number beginning in file.The time offset value of local server and long-range ntp server is then used in the 9th row
Awk'{ print $ 9 } ' the 9th row of output, also, ignore decimal, using awk-F { print $ 1 } ' only export the 1st field.
For example, the numerical value of the 9th row is 10.23, then 10 are only exported.It is serviced to extract local server and long-range NTP
The time offset value of device, and time offset value is stored in/tmp/ntp_gf.tmp file in.
Then while read line is used, do circulation is carried out the time offset value of the preservation in extraction document one by one, carried out
Time offset value is compared with time migration threshold value.While read line is that disposably the file information is read in and is assigned to
Redirection mechanism is used in variable line, while, all information in file, which are all read into lay equal stress on, has been directed to entire while
Line variable in sentence.If deviant is more than or less than 1000ms, parameter assignment will be judged for 1.Here is partial code:
while read line
do
if[$line-gt$ALERTVAL]||[$line-lt-$ALERTVAL]
then
FLAG=1
fi
done</tmp/ntp_gf.tmp
Wherein, ALERTVAL is time migration threshold value, can be arranged according to time offset value demand, such as
ALERTVAL is 1000ms (1000ms=1s), and FLAG is to judge parameter.
Read is redirected by input, and all contents of the first row of ntp_gf.tmp file are assigned to variable line,
Then the second row of circular treatment file, the third line ... .. until file last line.When read is run through most from file
Afterwards after a line, circulation terminates at this time.
Extract the value of FLAG, if parameter FLAG is greater than 0, i.e. expression local server and ntp server there are the time difference,
Deviant between local server and ntp server is greater than 1 second, then exports the IP address of local server, if it exists the time
Difference synchronizes in the following way:
Time=date+ " %H:%M "
Miao=` " %S " `
Miaos=` $ Miao+ $ line/1000
date-s$Time:$Miaos
Wherein, Time is the time of local server, and date is the date, and H is hour, and M is minute, and S is local server
Second;Wherein, $ line is the time offset value that front obtains.Since $ line unit is millisecond, Miaos is that compensation is later
Second, it is converted on second post-compensation to local zone time, then it can be synchronous with ntp server by the time.
Preferably, it is executed by mvc (Model View Controller, Model View Controller) using monitor supervision platform
Script triggers mail and warning by telephone.
Preferably, multiple servers can be formed into server group, safeguard service device group, so that it may maintenance wherein each
The time of server.
Preferably, the data in docker.log (engine log) file are read by for i in cat order, to add
" # filters out the row of annotation to fast progress, by grep-v, filters out the character comprising back by grep-v back, passes through
Grep appsystem filters out the character comprising appsystem.If reading the text in docker.log includes NTP
Is larger (i.e. there are difference in the time of local server time and ntp server), then export that " following host clock is not right, asks
Game server and Beijing time compare, if having time difference is greater than 1s, please be adjusted ".
As shown in fig.2, being the hardware structure schematic diagram of the embodiment of electronic device of the present invention.It is described in the present embodiment
Electronic device 2 be it is a kind of can according to the instruction for being previously set or store, automatic progress numerical value calculating and/or information processing
Equipment.For example, it may be smart phone, tablet computer, laptop, desktop computer, rack-mount server, blade type take
It is engaged in device, tower server or Cabinet-type server (including server set composed by independent server or multiple servers
Group) etc..As shown in figure 3, the electronic device 2 includes at least, but it is not limited to, depositing for connection can be in communication with each other by system bus
Reservoir 21, processor 22, network interface 23.Wherein: the memory 21 includes at least a type of computer-readable storage
Medium, the readable storage medium storing program for executing include flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory etc.),
Random access storage device (RAM), static random-access memory (SRAM), read-only memory (ROM), electrically erasable are only
Read memory (EEPROM), programmable read only memory (PROM), magnetic storage, disk, CD etc..In some embodiments
In, the memory 21 can be the internal storage unit of the electronic device 2, such as the hard disk or memory of the electronic device 2.
In further embodiments, the memory 21 is also possible to the External memory equipment of the electronic device 2, such as electronics dress
Set the plug-in type hard disk being equipped on 2, intelligent memory card (Smart Media Card, SMC), secure digital (Secure
Digital, SD) card, flash card (Flash Card) etc..Certainly, the memory 21 can also both include the electronic device 2
Internal storage unit also include its External memory equipment.In the present embodiment, the memory 21 is installed on commonly used in storage
Operating system and types of applications software of the electronic device 2, such as the server NTP process monitoring program code etc..This
Outside, the memory 21 can be also used for temporarily storing the Various types of data that has exported or will export.
The processor 22 can be in some embodiments central processing unit (Central Processing Unit,
CPU), controller, microcontroller, microprocessor or other data processing chips.The processor 22 is commonly used in the control electricity
The overall operation of sub-device 2, such as execute control relevant to the electronic device 2 progress data interaction or communication and processing
Deng.In the present embodiment, the processor 22 is for running the program code stored in the memory 21 or processing data, example
Server NTP process monitoring program as described in running.
The network interface 23 may include radio network interface or wired network interface, which is commonly used in
Communication connection is established between the electronic device 2 and other electronic devices.For example, the network interface 23 is for passing through network
By the electronic device 2 with push platform be connected, the electronic device 2 and push platform between establish data transmission channel and
Communication connection etc..The network can be intranet (Intranet), internet (Internet), global system for mobile telecommunications system
Unite (Global System of Mobile communication, GSM), wideband code division multiple access (Wideband
CodeDivision Multiple Access, WCDMA), 4G network, 5G network, bluetooth (Bluetooth), the nothings such as Wi-Fi
Line or cable network.
Optionally, which can also include display, and display is referred to as display screen or display unit.
It can be light-emitting diode display, liquid crystal display, touch-control liquid crystal display and Organic Light Emitting Diode in some embodiments
(Organic Light-Emitting Diode, OLED) display etc..Display is used to be shown in handle in electronic device 2
Information and for showing visual user interface.
It should be pointed out that Fig. 2 illustrates only the electronic device 2 with component 21-23, it should be understood that not
It is required that implement all components shown, the implementation that can be substituted is more or less component.
It may include operating system, server NTP process monitoring program 50 in memory 21 comprising readable storage medium storing program for executing
Deng.Processor 22 realizes following steps when executing server NTP process monitoring program 50 in memory 21:
Step S10, by ansible platform (the O&M automation tools applied to configuration management) in every local service
Monitoring script is executed on device, can be executed with the mode of timed task, is checked for example, executing at intervals of two minutes once, to local clothes
Clock on business device carries out verification monitoring and NTP service is monitored.
Step S30, by executing the monitoring script, check local server system time and ntp server whether
It is synchronous, if the time between local server and ntp server has time offset value, and when time offset value is more than or less than
Between offset threshold, then determine time irreversibility, time irreversibility relevant information exported into engine file, wherein the time is not
Synchronous relevant information includes the time offset value letter between the address local server IP, local server and ntp server
Breath.
Step S50, inquire local server docker.log file whether the nonsynchronous information of having time, if so, then
It triggers phone and mail alerts, so that maintenance personnel is able to carry out timely processing.Also, automatic straightening time, time update clothes
The clock being engaged on device.It avoids abnormal using causing to apply because of clock.
In the present embodiment, the server NTP process monitoring program 50 being stored in memory 21 can be divided
For one or more program module, one or more of program modules are stored in memory 21, and can be by one
Or performed by multiple processors (the present embodiment is processor 22), to complete the present invention.For example, Fig. 3 shows the server
The program module schematic diagram of NTP process monitoring program, in the embodiment, the server NTP process monitoring program 50 can be by
It is divided into monitoring script execution unit 501, time synchronization judging unit 502, alarm triggered unit 503.Wherein, alleged by the present invention
Program module be refer to complete specific function series of computation machine program instruction section, than program more suitable for description described in
Implementation procedure of the server NTP process monitoring program in the electronic device 2.Described program mould will specifically be introduced by being described below
The concrete function of block.
The monitoring script execution unit 501 executes monitoring script on every local server by ansible platform,
It can be executed with the mode of timed task, be checked once for example, executing at intervals of two minutes, the clock on local server is carried out
Verification monitoring and NTP service are monitored.
Time synchronization judging unit 502 checks whether system time and ntp server are same by executing the monitoring script
Step, if time irreversibility, exports " system time is asynchronous with ntp server " and time irreversibility relevant information arrives
In docker.log (engine file).Wherein the relevant information of the time irreversibility includes local server IP address, local
Time migration value information between server and ntp server.Judging the method whether synchronous with ntp server is, if local
Time between server and ntp server has time offset value, and time offset value is more than or less than time migration threshold value,
Then think time irreversibility.
Alarm triggered unit 503 be used for inquire local server docker.log file whether the nonsynchronous letter of having time
Breath, if so, triggering phone and mail alarm, then so that maintenance personnel is able to carry out timely processing.Also, the automatic straightening time,
Clock on time update server.It avoids abnormal using causing to apply because of clock.
It in one alternate embodiment, further include time offset value extraction unit 504, time offset value extraction unit 504
Using/usr/sbin/ntpq-p starting NTP service ,/usr/sbin/ntpq is the finger daemon file of NTP service, needs to open
It is dynamic that NTP service could be provided.Extract the number in configuration file, wherein-p indicates the catalogue column of display server peer device
Table, and show the summary of their states.In the time migration for wherein just showing local server Yu long-range ntp server
Value.Using grep'[0-9] ' in command lookup current directory file by the row of number beginning.Local server and long-range NTP take
The time offset value of business device is then to use awk'{ print $ 9 in the 9th row } ' the 9th row of output, also, ignore decimal, it uses
Awk-F { print $ 1 } ' only export the 1st field.
For example, the numerical value of the 9th row is 10.23, then 10 are only exported.It is serviced to extract local server and long-range NTP
The time offset value of device, and time offset value is stored in/tmp/ntp_gf.tmp file in.
Then while read line is used, do circulation is carried out the time offset value of the preservation in extraction document one by one, carried out
Time offset value is compared with time migration threshold value.While read line is that disposably the file information is read in and is assigned to
Redirection mechanism is used in variable line, while, all information in file, which are all read into lay equal stress on, has been directed to entire while
Line variable in sentence.If deviant is more than or less than 1000ms, parameter assignment will be judged for 1.Here is partial code:
while read line
do
if[$line-gt$ALERTVAL]||[$line-lt-$ALERTVAL]
then
FLAG=1
fi
done</tmp/ntp_gf.tmp
Wherein, ALERTVAL is time migration threshold value, can be arranged according to time offset value demand, such as
ALERTVAL is 1000ms (1000ms=1s), and FLAG is to judge parameter.
Read is redirected by input, and all contents of the first row of ntp_gf.tmp file are assigned to variable line,
Then the second row of circular treatment file, the third line ... .. until file last line.When read is run through most from file
Afterwards after a line, circulation terminates at this time.
Time synchronization judging unit 502 extract FLAG value, if parameter FLAG be greater than 0, i.e., expression local server with
There are the time differences for ntp server, and the deviant between local server and ntp server is greater than 1 second, then export local server
IP address, the time difference synchronizes in the following way if it exists:
Time=date+ " %H:%M "
Miao=` " %S " `
Miaos=` $ Miao+ $ line/1000
date-s$Time:$Miaos
Wherein, Time is the time of local server, and date is the date, and H is hour, and M is minute, and S is local server
Second;Wherein, $ line is the time offset value that front obtains.Since $ line unit is millisecond, Miaos is that compensation is later
Second, it is converted on second post-compensation to local zone time, then it can be synchronous with ntp server by the time.
In one alternate embodiment, alarm triggered unit 503 passes through mvc (Model View Controller, model
View controller) using monitor supervision platform perform script triggering mail and warning by telephone.
Furtherly, alarm triggered unit 503 reads docker.log (engine log) by for i in cat order
Data in file, to accelerate progress, by grep-v, " # filters out the row of annotation, is filtered out by grep-v back and includes
The character of back filters out the character comprising appsystem by grep appsystem.If reading docker.log
In text include NTP is larger (i.e. there are difference in the time of local server time and ntp server), then export " with
Lower host clock is not right, asks game server and Beijing time to compare, if having time difference is greater than 1s, please be adjusted ".
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, the computer readable storage medium
It can be hard disk, multimedia card, SD card, flash card, SMC, read-only memory (ROM), Erasable Programmable Read Only Memory EPROM
(EPROM), any one in portable compact disc read-only memory (CD-ROM), USB storage etc. or several timess
Meaning combination.It include server NTP process monitoring program etc., the server NTP process in the computer readable storage medium
Following operation is realized when monitoring programme 50 is executed by processor 22:
Step S10, by ansible platform (the O&M automation tools applied to configuration management) in every local service
Monitoring script is executed on device, can be executed with the mode of timed task, is checked for example, executing at intervals of two minutes once, to local clothes
Clock on business device carries out verification monitoring and NTP service is monitored.
Step S30, by executing the monitoring script, check local server system time and ntp server whether
It is synchronous, if the time between local server and ntp server has time offset value, and when time offset value is more than or less than
Between offset threshold, then determine time irreversibility, time irreversibility relevant information exported into engine file, wherein the time is not
Synchronous relevant information includes the time offset value letter between the address local server IP, local server and ntp server
Breath.
Step S50, inquire local server docker.log file whether the nonsynchronous information of having time, if so, then
It triggers phone and mail alerts, so that maintenance personnel is able to carry out timely processing.Also, automatic straightening time, time update clothes
The clock being engaged on device.It avoids abnormal using causing to apply because of clock.
The specific embodiment of the computer readable storage medium of the present invention and above-mentioned server NTP process monitoring method with
And the specific embodiment of electronic device 2 is roughly the same, details are not described herein.
The above description is only a preferred embodiment of the present invention, is not intended to restrict the invention, for those skilled in the art
For member, the invention may be variously modified and varied.All within the spirits and principles of the present invention, it is made it is any modification,
Equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.
Claims (10)
1. a kind of server NTP process monitoring method is applied to electronic device, which is characterized in that
Monitoring script is executed in a manner of timed task on every local server ansible platform, to local service
Clock and NTP service on device are monitored;
By executing the monitoring script, check whether the system time of local server is synchronous with ntp server, if local clothes
The time being engaged between device and ntp server has time offset value, and time offset value is more than or less than time migration threshold value, then
Determine time irreversibility, export time irreversibility relevant information into engine file, wherein the related letter of the time irreversibility
Breath includes the time migration value information between local server IP address, local server and ntp server;
Inquire local server engine log whether the nonsynchronous information of having time, alerted if so, then triggering phone and mail.
2. server NTP process monitoring method according to claim 1, which is characterized in that
Serviced using/usr/sbin/ntpq-p starting NTP, using grep'[0-9] ' in command lookup current directory file by counting
Word beginning row, using awk'{ print $ 9 } ' output local server and long-range ntp server time offset value, use
Awk-F { print $ 1 } ' remove the number after decimal point, to extract the time of local server Yu long-range ntp server
Deviant, and time offset value is stored in/tmp/ntp_gf.tmp file in.
3. server NTP process monitoring method according to claim 2, which is characterized in that
Using while read line
do
Time offset value in ntp_gf.tmp file is assigned to variable line by done < file circulation line by line, and will be described when
Between deviant compared with time migration threshold value, it is defeated if deviant between local server and ntp server is greater than 1 second
The IP address of local server out.
4. server NTP process monitoring method according to claim 2, which is characterized in that
The time difference synchronizes in the following way if it exists:
Time=date+ " %H:%M "
Miao=` " %S " `
Miaos=` $ Miao+ $ line/1000
date-s$Time:$Miaos
Wherein, Time is the time of local server, and date is the date, and H is hour, and M is minute, and S is the second of local server;
Wherein, $ line is the time offset value obtained.
5. server NTP process monitoring method according to claim 2, which is characterized in that
Mail and warning by telephone are triggered by mvc application monitor supervision platform perform script.
6. server NTP process monitoring method according to claim 2, which is characterized in that
The data in engine log file are read, to accelerate progress, " # filters out the row of annotation, passes through grep-v by grep-v
Back filters out the character comprising back, filters out the character comprising appsystem by grep appsystem, if read
Text into engine log includes having the information of difference the time of local server time and ntp server, then triggers mail
Alarm.
7. a kind of electronic device, which is characterized in that the electronic device includes: memory and processor, is stored in the memory
There is server NTP process monitoring program, following step is realized when the server NTP process monitoring program is executed by the processor
It is rapid:
Monitoring script is executed in a manner of timed task on every local server ansible platform, to local service
Clock and NTP service on device are monitored;
By executing the monitoring script, check whether the system time of local server is synchronous with ntp server, if local clothes
The time being engaged between device and ntp server has time offset value, and time offset value is more than or less than time migration threshold value, then
Determine time irreversibility, export time irreversibility relevant information into engine file, wherein the related letter of the time irreversibility
Breath includes the time migration value information between local server IP address, local server and ntp server;
Inquire local server engine log whether the nonsynchronous information of having time, alerted if so, then triggering phone and mail.
8. electronic device according to claim 7, which is characterized in that
Serviced using/usr/sbin/ntpq-p starting NTP, using grep'[0-9] ' in command lookup current directory file by counting
Word beginning row, using awk'{ print $ 9 } ' output local server and long-range ntp server time offset value, use
Awk-F { print $ 1 } ' remove the number after decimal point, to extract the time of local server Yu long-range ntp server
Deviant, and time offset value is stored in/tmp/ntp_gf.tmp file in.
9. electronic device according to claim 8, which is characterized in that
Using while read line
do
Time offset value in ntp_gf.tmp file is assigned to variable line by done < file circulation line by line, and will be described when
Between deviant compared with time migration threshold value, it is defeated if deviant between local server and ntp server is greater than 1 second
The IP address of local server out.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has computer journey
Sequence, the computer program includes program instruction, when described program instruction is executed by processor, realizes that claim 1-6 such as appoints
Server NTP process monitoring method described in one.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910238704.5A CN110119335A (en) | 2019-03-27 | 2019-03-27 | Server NTP process monitoring method, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910238704.5A CN110119335A (en) | 2019-03-27 | 2019-03-27 | Server NTP process monitoring method, electronic device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110119335A true CN110119335A (en) | 2019-08-13 |
Family
ID=67520666
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910238704.5A Pending CN110119335A (en) | 2019-03-27 | 2019-03-27 | Server NTP process monitoring method, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110119335A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112651705A (en) * | 2020-12-15 | 2021-04-13 | 下一代互联网重大应用技术(北京)工程研究中心有限公司 | Mail processing method, device, equipment and medium |
CN113992295A (en) * | 2021-10-29 | 2022-01-28 | 世邦通信股份有限公司 | Method and system for realizing timing of multiple NTP (network time protocol) servers, computer equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1645935A2 (en) * | 2004-10-07 | 2006-04-12 | Westerngeco Seismic Holdings Limited | Synchronization of real time clocks of nodes in a network environment |
JP2010141612A (en) * | 2008-12-11 | 2010-06-24 | Oki Telecommunication Systems Co Ltd | Synchronization system, synchronization method, synchronization program, and communications apparatus |
CN204362065U (en) * | 2013-09-09 | 2015-05-27 | 哈尼施费格尔技术公司 | The system of the time between synchronous multiple system |
CN108833047A (en) * | 2018-08-13 | 2018-11-16 | 东软集团股份有限公司 | Method for synchronizing time, device, readable storage medium storing program for executing and electronic equipment |
CN109032908A (en) * | 2018-07-20 | 2018-12-18 | 郑州云海信息技术有限公司 | Batch realizes the test method and system of BMC time and OS time consistency |
CN109445517A (en) * | 2018-11-08 | 2019-03-08 | 郑州云海信息技术有限公司 | A kind of method, apparatus, terminal and the storage medium of synchronous BMC and OS time |
-
2019
- 2019-03-27 CN CN201910238704.5A patent/CN110119335A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1645935A2 (en) * | 2004-10-07 | 2006-04-12 | Westerngeco Seismic Holdings Limited | Synchronization of real time clocks of nodes in a network environment |
JP2010141612A (en) * | 2008-12-11 | 2010-06-24 | Oki Telecommunication Systems Co Ltd | Synchronization system, synchronization method, synchronization program, and communications apparatus |
CN204362065U (en) * | 2013-09-09 | 2015-05-27 | 哈尼施费格尔技术公司 | The system of the time between synchronous multiple system |
CN109032908A (en) * | 2018-07-20 | 2018-12-18 | 郑州云海信息技术有限公司 | Batch realizes the test method and system of BMC time and OS time consistency |
CN108833047A (en) * | 2018-08-13 | 2018-11-16 | 东软集团股份有限公司 | Method for synchronizing time, device, readable storage medium storing program for executing and electronic equipment |
CN109445517A (en) * | 2018-11-08 | 2019-03-08 | 郑州云海信息技术有限公司 | A kind of method, apparatus, terminal and the storage medium of synchronous BMC and OS time |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112651705A (en) * | 2020-12-15 | 2021-04-13 | 下一代互联网重大应用技术(北京)工程研究中心有限公司 | Mail processing method, device, equipment and medium |
CN112651705B (en) * | 2020-12-15 | 2023-09-19 | 赛尔网络有限公司 | Mail processing method, device, equipment and medium |
CN113992295A (en) * | 2021-10-29 | 2022-01-28 | 世邦通信股份有限公司 | Method and system for realizing timing of multiple NTP (network time protocol) servers, computer equipment and storage medium |
CN113992295B (en) * | 2021-10-29 | 2024-04-02 | 世邦通信股份有限公司 | Multi-NTP server timing realization method and system, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109460343A (en) | System exception monitoring method, device, equipment and storage medium based on log | |
US9519537B2 (en) | Apparatus, system and method for application log data processing | |
CN111563016A (en) | Log collection and analysis method and device, computer system and readable storage medium | |
CN110119335A (en) | Server NTP process monitoring method, electronic device and storage medium | |
CN112099800A (en) | Code data processing method and device and server | |
CN112631924A (en) | Automatic testing method and device, computer equipment and storage medium | |
CN111475494A (en) | Mass data processing method, system, terminal and storage medium | |
US10754748B2 (en) | System and method for constructing extensible event log with javascript object notation (JSON) encoded payload data | |
CN113282854A (en) | Data request response method and device, electronic equipment and storage medium | |
CN113076231A (en) | Server application scene setting method, system, terminal and storage medium | |
CN109558300B (en) | Whole cabinet alarm processing method and device, terminal and storage medium | |
CN115086047B (en) | Interface authentication method and device, electronic equipment and storage medium | |
CN115145870A (en) | Method and device for positioning reason of failed task, electronic equipment and storage medium | |
CN113722225A (en) | Page testing method and device, computer equipment and storage medium | |
CN111143193B (en) | Big data service testing method, system, terminal and storage medium based on RobotFramework | |
CN109683813B (en) | NVME SSD automatic formatting method, device, terminal and storage medium | |
CN110348984B (en) | Automatic credit card data input method and related equipment under different transaction channels | |
CN114157662A (en) | Cloud platform parameter adaptation method and device, terminal equipment and storage medium | |
CN113656378A (en) | Server management method, device and medium | |
CN111124467A (en) | Method and system for displaying authority role, computer equipment and readable storage medium | |
CN113703852B (en) | Out-of-band management method and device of server, electronic equipment and readable storage medium | |
CN112988250B (en) | Multi-mainboard USB service configuration method, system, terminal and storage medium | |
CN112328661B (en) | Method, system and electronic equipment for monitoring ticket processing performance | |
CN114238232B (en) | Intelligent ammeter file reading and writing system, method, equipment and medium | |
CN111078718B (en) | Frequency control method, device, equipment and computer storage medium |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190813 |