2011-08-18
Fb303 is included in the thrift source code package contrib
* What does it provide? *
A standard interface to monitoring, dynamic options and configuration,
Uptime reports, activity, etc.
That is to say, fb303 provides several interface methods, but it does not have the default implementation (very poor). fb303 does not need to be declared in its own thrift servcie interface, the automatically generated processor inherits the FacebookService of fb303. processor, but you need to write handler to process the interface method.
Fb303 library structure (requires compilation and installation, steps are similar to thrift ):
The constants and thrift data types are the same.
Ttypes defines fb_status
Empty Implementation of FacebookBase Iface
FacebookService A clinet accesses the thrift service to obtain the result. B. IFace Standard Basic Service C Processor serialization code
Call process: 1. Create a client 2. Call the handler 3 server of the server to serialize the number of service messages obtained by handler for survival time. The cpu status is serialized through the fb303 interface and returned to the client...
Modify the sample client fb303_simple_mgmt.py in fb303_scripts
Class Fb303Client (FacebookService. Client, CMyClient ):
Pass
Fb303_client = Fb303Client (protocol, protocol)
Protocol changed as needed
Modify domain ServerNameExchange. py
From fb303 import *
Class Processor (Iface, TProcessor) --> class Processor (Iface, FacebookService. Processor ):
Process finally calls handler for processing
Handler adds related methods:
Def getStatusDetails (self ):
Return "I am very fine! "
Def getStatus (self ):
Return 1
Cpu usage analysis/proc/stat content to obtain results
To sum up, use monit for monitoring. You don't need to add additional code yourself...