python 应用thrift---- thrift的监控fb303 - import coding_dog ---- by 坚毅的刀刀 - 博客大巴...

python 应用thrift---- thrift的监控fb303 - import coding_dog ---- by 坚毅的刀刀 - 博客大巴

python 应用thrift---- thrift的监控fb303 - [coding]

2011-08-18

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://shenguanpu.blogbus.com/logs/156741276.html

fb303  在thrift的源码包 contrib之中

* What does it provide? *
A standard interface to monitoring, dynamic options and configuration,
uptime reports, activity, etc.

也就是说fb303提供了几种接口方法,而并没有默认实现(很坑爹)有了fb303不需要在自己的thrift servcie 接口里去声明,只需要自动生成的processor继承fb303的FacebookService.Processor  但需要自己写handler 去处理接口方法

fb303库结构(需要编译并安装,步骤类似thrift):

  1. constants 和thrift数据类型相同
  2. ttypes 定义 fb_status
  3. FacebookBase  Iface的空实现
  4. FacebookService  A clinet 访问thrift服务,获取结果  B IFace标准基础服务 C Processor  序列化代码

 


调用过程:1 做一个client  2 去调用服务器的handler  3 服务器把handler得到的服务信息 访问数 生存时间 cpu状况 通过fb303接口序列化并返回给客户端。。。

  • 修改fb303_scripts中的示例客户端fb303_simple_mgmt.py
    class Fb303Client(FacebookService.Client, CMyClient):
      pass
    fb303_client = Fb303Client(protocol, protocol)
    protocol 按需要更改
  • 修改 domain ServerNameExchange.py
      from fb303 import *
     
    class Processor(Iface, TProcessor) --> class Processor(Iface, FacebookService.Processor):
    Process最终调用handler做处理
  • handler增加相关方法:
    def getStatusDetails(self):
          return " i am very fine!"

    def getStatus(self):
          return 1

cpu使用情况可分析 /proc/stat  内容 获得结果

综上,还是用monit做监控吧,不用自己添加额外代码。。。

posted on 2012-09-21 17:37  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2012/09/21/2697259.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值