How to collect stats of apps from CloudFoundry and do analysis?
来源:互联网 发布:用jquery遍历数组 编辑:程序博客网 时间:2024/05/17 01:12
Suppose we have apps running on CloudFoundry, how can we get the stats of app and doing some analysis here?
vmc stats appname is really useful. But what we need is a component which returns a json result according to a sepecific URL.
According to the code of CF, we can find there's something useful here:
https://github.com/cloudfoundry/vcap-common/blob/master/lib/vcap/component.rb#L44
#Common component setup for discovery and monitoring
During the start process of router, an endpoint of var component will be startup for /varz or /healthz
The method register(opts) will be called in router.rb:
# Register ourselves with the system status_config = config['status'] || {} VCAP::Component.register(:type => 'Router', :host => VCAP.local_ip(config['local_route']), :index => config['index'], :config => config, :port => status_config['port'], :user => status_config['user'], :password => status_config['password'], :logger => Router.log)
The method to start a server is below, so if we can request this server with /varz, the stats will be returned.
def start_http_server(host, port, auth, logger) http_server = Thin::Server.new(host, port, :signals => false) do Thin::Logging.silent = true use Rack::Auth::Basic do |username, password| [username, password] == auth end map '/healthz' do run Healthz.new(logger) end map '/varz' do run Varz.new(logger) end end http_server.start!end
We can see Thin is is used here to start a http server.
So, we need to figure out the port and host on which the server is running. Actually, this things is customizable. We can find this in dea.yml
# Used for /healthz and /vars endpoints. If not provided random# values will be generated on component start. Uncomment to use# static values.#status:# port: 34501# user: thin# password: thin
That means we can specify its port and auth before we start a DEA, just add status part in your config file, and then:
Sending http request to that server will return you a JSON response which contains a key named "running apps", its value what you need!
What's more, in
.../cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/gems/vcap_common-1.0.10/lib/vcap/component.rb
we can see how these parameters before to be used to register itself into your local vcap environment:
def register(opts) uuid = VCAP.secure_uuid type = opts[:type] index = opts[:index] uuid = "#{index}-#{uuid}" if index host = opts[:host] || VCAP.local_ip port = opts[:port] || VCAP.grab_ephemeral_port nats = opts[:nats] || NATS auth = [opts[:user] || VCAP.secure_uuid, opts[:password] || VCAP.secure_uuid] logger = opts[:logger] || Logger.new(nil) # Discover message limited @discover = { :type => type, :index => index, :uuid => uuid, :host => "#{host}:#{port}", :credentials => auth, :start => Time.now } # Varz is customizable @varz = @discover.dup @varz[:num_cores] = VCAP.num_cores @varz[:config] = sanitize_config(opts[:config]) if opts[:config] @healthz = "ok\n".freeze ... ...
But the rest of this part requires some knowledge of EventMachine. So we'll talk about it later.
- How to collect stats of apps from CloudFoundry and do analysis?
- How-to: make spark streaming collect data from Kafka topics and store data into hdfs
- How to collect TrustZone debug logs and check the meaning of error code in the logs
- How to Add and Remove Apps
- How to package and distribute your apps
- How to collect explorer
- How to do run-time (or explicit) linking of C++ plug-in components and objects
- Do you know how many combinations to select n numbers from 1 to m with sum of which is mysum?
- How to Interpret the OS stats section of an AWR report (文档 ID 762526.1)
- How do I convert from BLOB to TEXT in Mysql?
- 人脸识别 -Do We Really Need to Collect Millions of Faces for Effective Face Recognition?
- Do We Really Need to Collect Millions of Faces for effective face recognition
- How to Collect and Display System Statistics (CPU and IO) for CBO use (Doc ID 149560.1)
- How do I pass a list of files to grep
- An example of how to do a simulation by LAMMPS
- How to Do Everything with PHP and MySQL
- How to do the job effectively and excellently
- How to do Reseach
- 黑马程序员--基础复习2012.8.14 多线程
- 季卫东:中国互联网企业平均寿命只有三到五年
- http常用状态码
- 关于数组的一些问题
- wxPython: 简单的绘图例子
- How to collect stats of apps from CloudFoundry and do analysis?
- DREAMWERVER CS5序列号反复验证 解决方法
- vim删除 整片文档
- 平静中的激情,程序员的生活
- wxPython:状态栏介绍
- C语言中return,exit,和break
- HDU 3466 Proud Merchants DP 分享排序方式的证明。。
- wxPython:菜单介绍
- 2012年8月编程语言排行榜:Objective-C高歌猛进,C#继续“杯具”