cdchenli 发表于 2018-8-3 11:59:22

Python性能监控Graphite

首先删除原来diamond生成的servers目录  
# rm -rf /var/lib/carbon/whisper/servers/
  
然后手动运行diamond的httpcode脚本
  
# diamond -f -l -r ./httpcode.py-c /etc/diamond/diamond.conf
  
ERROR: Pidfile exists. Server already running?#需要手动停止diamond服务
  
# /etc/init.d/diamond stop
  
Stopping diamond:                                          [确定]
  
# diamond -f -l -r ./httpcode.py-c /etc/diamond/diamond.conf
  
Changed UID: 0 () GID: 0 ().
  
Loaded Handler: diamond.handler.graphite.GraphiteHandler
  
GraphiteHandler: Established connection to graphite server localhost:2003.
  
Loaded Handler: diamond.handler.archive.ArchiveHandler
  
Loading Collectors from: .
  
Loaded Module: httpcode
  
Loaded Collector: httpcode.HttpCodeCollector
  
Initialized Collector: HttpCodeCollector
  
Skipped loading disabled Collector: HttpCodeCollector
  
Started task scheduler.
  
Stopping task scheduler.
  
Stopped task scheduler.
  
Exiting.
  
如果没有报错,则查看浏览器会发现多了一个servers目录;但是当时目录就是没有生成,我还真纳闷了。原来在配置文件中没有启动此配置
  
# vim httpcode.py
  
......
  
config = super(HttpCodeCollector, self).get_default_config()
  
      config.update({
  
            'path':   'weblog',
  
            'enabled':'True'#开启此选项
  
      })
  

  

  
如果用diamond来搜集,则无需此选项,因为diamond有针对类的配置文件,在配置文件中开启会比在脚本中开启看起来更统一
页: [1]
查看完整版本: Python性能监控Graphite