WebSocket pushes the method and system of warning information in a kind of network management system
Technical field
The present invention relates to the technical field of network service, is accused more particularly to WebSocket push in a kind of network management system
The method and system of alert information.
Background technology
It is only capable of realizing unidirectional communication by http in a browser, comet can simulate two-way communication to a certain extent,
But it is less efficient, and need server to have preferable support.Socket and xmlsocket in flash can be realized really
Two-way communication, by flex ajax bridge, this two functions can be used in javascript.In face of this situation,
HTML5 defines WebSocket agreements, and it realizes browser and server full-duplex communication, so as to preferably save
Server resource and bandwidth simultaneously reach real-time communication.
Duplex communication protocols of the WebSocket as the HTML5 web applications introduced, can be used in network management system in real time
Warning information is pushed to browser client.As shown in figure 1, the way of WebSocket pushed informations is used in general network management system
It is that NM server receives the warning information that an equipment reports, i.e., is pushed to by warning information by WebSocket each
Client;After client receives the WebSocket message that NM server is sent, message, refresh page are parsed.
However, in the case where some period alarm information amount is bigger, NM server can be ceaselessly to client
Message is sent, client can ceaselessly parse message, refresh page.This can bring burden to server/browser client, together
When add network throughput.
The content of the invention
In view of the above the shortcomings that prior art, it is an object of the invention to provide in a kind of network management system
WebSocket pushes the method and system of warning information, and the warning information that NM server is sent to needs is cached, passed through
The warning information number pushed is needed in monitoring unit interval piece, dynamic adjusts the timeslice of WebSocket push warning information
The size of window, the warning information in timeslice window is merged into an alarm information and sent to client, so as to protect
The real-time of alarm information push is demonstrate,proved, and can reduces network throughput.
In order to achieve the above objects and other related objects, the present invention provides WebSocket push in a kind of network management system and accused
The method of alert information, comprises the following steps:WebSocket is set to push the unit interval piece and maximum time piece of warning information
Size;Using unit interval piece as current time piece window, in the equipment received to current time piece window NM server
The warning information of report is cached, and at the end of current time piece window, the warning information of caching is merged into an information
Client is pushed to by WebSocket;The number of warning information that monitoring current time piece window is pushed, during unit of account
Between the number of warning information that is pushed of piece;If the number for the warning information that unit interval piece is pushed is less than under predetermined threshold value
Limit, then reduce the size of current time piece window;If the number for the warning information that unit interval piece is pushed is more than predetermined threshold value
The upper limit, then increase the size of current time piece window;If the number for the warning information that unit interval piece is pushed is between default threshold
It is worth between lower limit and the predetermined threshold value upper limit, then keeps the size of current time piece window constant.
In one embodiment of the invention, when reducing the size of current time piece window, current time piece window is reduced
The size of one unit interval piece.
In one embodiment of the invention, when reducing the size of current time piece window, if the current time piece after reducing
Window is less than or equal to unit interval piece, then using unit interval piece as current time piece window.
In one embodiment of the invention, when increasing the size of current time piece window, by the increase of current time piece window
The size of one unit interval piece.
In one embodiment of the invention, when increasing the size of current time piece window, if the current time piece after increase
Window is more than or equal to maximum time piece, then using maximum time piece as current time piece window.
Meanwhile the present invention also provides the system that WebSocket pushes warning information in a kind of network management system, its feature exists
In:Including setup module, caching pushing module, monitoring calculation module and adjusting module;
The setup module be used for set WebSocket push warning information unit interval piece and maximum time piece it is big
It is small;
The caching pushing module is used for using unit interval piece as current time piece window, to current time piece window net
The warning information that the equipment that pipe server receives reports is cached, and at the end of current time piece window, by caching
Warning information merges into an information and pushes to client by WebSocket;
The monitoring calculation module is used for the number for monitoring the warning information that current time piece window is pushed, unit of account
The number for the warning information that timeslice is pushed;
When the number for the warning information that the adjusting module is used to be pushed in unit interval piece is less than predetermined threshold value lower limit,
Reduce the size of current time piece window;It is more than the predetermined threshold value upper limit in the number for the warning information that unit interval piece is pushed
When, the size of increase current time piece window;The warning information that unit interval piece is pushed number under predetermined threshold value
Between limit and the predetermined threshold value upper limit, keep the size of current time piece window constant.
In one embodiment of the invention, when reducing the size of current time piece window, current time piece window is reduced
The size of one unit interval piece.
In one embodiment of the invention, when reducing the size of current time piece window, if the current time piece after reducing
Window is less than or equal to unit interval piece, then using unit interval piece as current time piece window.
In one embodiment of the invention, when increasing the size of current time piece window, by the increase of current time piece window
The size of one unit interval piece.
In one embodiment of the invention, when increasing the size of current time piece window, if the current time piece after increase
Window is more than or equal to maximum time piece, then using maximum time piece as current time piece window.
As described above, WebSocket pushes the method and system of warning information in the network management system of the present invention, have following
Beneficial effect:
(1) in the case where unit interval piece push warning information amount is bigger, the current time piece window of push is increased;
(2) in the case where unit interval piece push warning information amount is smaller, the current time piece window of smaller push;
(3) a plurality of warning information is incorporated into a piece of news and pushed by WebSocket, reduce server/visitor
The communication pressure at family end, it ensure that the real-time of alarm information push.
Brief description of the drawings
Fig. 1 is shown as the schematic diagram that WebSocket in network management system in the prior art pushes warning information;
Fig. 2 is shown as the flow chart of the method for WebSocket push warning information in the network management system of the present invention;
Fig. 3 is shown as in the present invention schematic diagram that WebSocket in network management system pushes warning information;
Fig. 4 is shown as the structural representation of the system of WebSocket push warning information in the network management system of the present invention.
Component label instructions
1 setup module
2 caching pushing modules
3 monitoring calculation modules
4 adjusting modules
Embodiment
Illustrate embodiments of the present invention below by way of specific instantiation, those skilled in the art can be by this specification
Disclosed content understands other advantages and effect of the present invention easily.The present invention can also pass through specific realities different in addition
The mode of applying is embodied or practiced, the various details in this specification can also be based on different viewpoints with application, without departing from
Various modifications or alterations are carried out under the spirit of the present invention.It should be noted that in the case where not conflicting, following examples and implementation
Feature in example can be mutually combined.
It should be noted that the diagram provided in following examples only illustrates the basic structure of the present invention in a schematic way
Think, only show the component relevant with the present invention in schema then rather than according to component count, shape and the size during actual implement
Draw, kenel, quantity and the ratio of each component can be a kind of random change during its actual implementation, and its assembly layout kenel
It is likely more complexity.
The method and system of WebSocket push warning information are believed the alarm that needs push in the network management system of the present invention
Breath is cached, and is sent collectively to client after the warning information in timeslice window is merged;Monitor the unit interval simultaneously
The number of the alarm information pushed in piece, if the number of alarm information exceedes predetermined threshold value in unit interval piece, increase the time
The size of piece window;If the number of warning information is less than predetermined threshold value in unit interval piece, the size of timeslice window is reduced.
Reference picture 2, the method for WebSocket push warning information comprises the following steps in network management system of the invention:
Step S1, WebSocket is set to push the unit interval piece of warning information and the size of maximum time piece.
Wherein, unit interval piece is the minimum interval needed for WebSocket push warning information.Maximum time piece
The maximum time interval that as WebSocket push warning information is limited.Unit interval piece is set as T0, maximum time piece is
TP.Preferably, maximum time piece is the integral multiple of unit timeslice.
Step S2, using unit interval piece as current time piece window, current time piece window NM server is received
To the warning information that reports of equipment cached, and at the end of current time piece window, the warning information of caching is merged
Client is pushed to by WebSocket for an information.
With in the prior art, NM server is directed to every warning information receiving different, this hair that carries out once push
The warning information that current time piece window receives is cached on NM server first in bright.If current time piece window is
TK。
Step S3, the number for the warning information that monitoring current time piece window is pushed, unit of account timeslice are pushed
Warning information number.
Specifically, if the number for the warning information that current time piece window is pushed is m, then unit interval piece is pushed
The number n=m*T0/TK of warning information.
If step S4, the number for the warning information that unit interval piece is pushed is less than predetermined threshold value lower limit, reduce current
The size of timeslice window;If the number for the warning information that unit interval piece is pushed is more than the predetermined threshold value upper limit, increase is worked as
The size of preceding timeslice window;If the number for the warning information that unit interval piece is pushed is between predetermined threshold value lower limit and default threshold
It is worth between the upper limit, then keeps the size of current time piece window constant.
Preferably, when reducing the size of current time piece window, current time piece window is reduced into by a unit interval piece
Size.If it is highly preferred that reduce after current time piece window be less than or equal to unit interval piece, using unit interval piece as
Current time piece window.
Preferably, when increasing the size of current time piece window, current time piece window is increased into a unit interval piece
Size.If it is highly preferred that increase after current time piece window be more than or equal to maximum time piece, using maximum time piece as
Current time piece window.
As shown in figure 3, after the method for WebSocket push warning information in the network management system using the present invention, will accuse
Alert information 1 is sent in T1 timeslice windows, warning information 2 and 3 is sent in T2 timeslice windows, by warning information 4,5,6 and 7
Send in T3 timeslice windows, by that analogy, warning information m is sent in Tm timeslice windows.Pass through such warning information
Method for pushing, can both can guarantee that the real-time of alarm information push, and and can reduces network throughput.
Reference picture 4, the system of WebSocket push warning information includes setup module 1, slow in network management system of the invention
Deposit pushing module 2, monitoring calculation module 3 and adjusting module 4.
Setup module 1 is used to set the unit interval piece of WebSocket push warning information and the size of maximum time piece.
Wherein, unit interval piece is the minimum interval needed for WebSocket push warning information.Maximum time piece
The maximum time interval that as WebSocket push warning information is limited.Unit interval piece is set as T0, maximum time piece is
TP.Preferably, maximum time piece is the integral multiple of unit timeslice.
Caching pushing module 2 is connected with setup module 1, for using unit interval piece as current time piece window, to ought
The warning information that the equipment that preceding timeslice window NM server receives reports is cached, and in current time piece window knot
Shu Shi, the warning information of caching is merged into an information client is pushed to by WebSocket.
With in the prior art, NM server is directed to every warning information receiving different, this hair that carries out once push
The warning information that current time piece window receives is cached on NM server first in bright.If current time piece window is
TK。
Monitoring calculation module 3 is connected with caching pushing module 2, the alarm letter pushed for monitoring current time piece window
The number of breath, the number for the warning information that unit of account timeslice is pushed.
Specifically, if the number for the warning information that current time piece window is pushed is m, then unit interval piece is pushed
The number n=m*T0/TK of warning information.
Adjusting module 4 is connected with setup module 1 and monitoring calculation module 3, for the alarm pushed in unit interval piece
When the number of information is less than predetermined threshold value lower limit, reduce the size of current time piece window;In the announcement that unit interval piece is pushed
When the number of alert information is more than the predetermined threshold value upper limit, increase the size of current time piece window;Pushed in unit interval piece
The number of warning information keeps the size of current time piece window not between predetermined threshold value lower limit and the predetermined threshold value upper limit
Become.
Preferably, when reducing the size of current time piece window, current time piece window is reduced into by a unit interval piece
Size.If it is highly preferred that reduce after current time piece window be less than or equal to unit interval piece, using unit interval piece as
Current time piece window.
Preferably, when increasing the size of current time piece window, current time piece window is increased into a unit interval piece
Size.If it is highly preferred that increase after current time piece window be more than or equal to maximum time piece, using maximum time piece as
Current time piece window.
In summary, WebSocket pushes the method and system of warning information in unit in network management system of the invention
Between piece push warning information amount it is bigger in the case of, increase the current time piece window of push;Push and accuse in unit interval piece
In the case that alert information content is smaller, the current time piece window of smaller push;A plurality of warning information is incorporated into a piece of news
Pushed by WebSocket, reduce the communication pressure of server/customer end, ensure that the real-time of alarm information push
Property.So the present invention effectively overcomes various shortcoming of the prior art and has high industrial utilization.
The above-described embodiments merely illustrate the principles and effects of the present invention, not for the limitation present invention.It is any ripe
Know the personage of this technology all can carry out modifications and changes under the spirit and scope without prejudice to the present invention to above-described embodiment.Cause
This, those of ordinary skill in the art is complete without departing from disclosed spirit and institute under technological thought such as
Into all equivalent modifications or change, should by the present invention claim be covered.