Python app thrift -- thrift monitoring fb303-

Source: Internet
Author: User

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...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.