ceilometer命令行常用的二级子命令有以下一些:
meter-list List the user’s meters .获取监控维度列表
query-samples Query samples.筛选采样样本
resource-list List the resources.获取监控资源列表
resource-show Show the resource.获取监控资源详情
sample-create Create a sample创建采样样本
sample-list List the samples (return OldSample objects if -m/–meter is set).获取采样样本列表
sample-show Show an sample.显示采样样本详情
statistics List the statistics for a meter.获取监控维度统计数据
ceilometer meter-list
首先创建要使用 hw_qemu_guest_agent
的镜像
hzhuangzhexiao@10-180-2-112:~$ glance image-show 06ec58df-fc10-4e25-88ac-6c6f1533de58
+--------------------------------+------------------------------------------+
| Property | Value |
+--------------------------------+------------------------------------------+
| Property 'hw_qemu_guest_agent' | yes |
| Property 'hypervisor_type' | qemu |
| Property 'os_type' | linux |
| Property 'support_inject_ip' | yes |
| checksum | 2bc9185deadfb28dcb881c4e0b7f9595 |
| container_format | ovf |
| created_at | 2016-02-03T09:31:18 |
| deleted | False |
| disk_format | qcow2 |
| id | 06ec58df-fc10-4e25-88ac-6c6f1533de58 |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | debian_7_x86_64_nce_release2_22362.qcow2 |
| owner | 5116a55a1a91499986c20803a901f0a4 |
| protected | False |
| size | 519897088 |
| status | active |
| updated_at | 2016-02-03T09:31:44 |
+--------------------------------+------------------------------------------+
然后查到云主机的uuid
通过这个查询,这个云主机有哪些 meter。
ceilometer meter-list -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b"
一般返回示例为
hzhuangzhexiao@10-180-2-112:~$ ceilometer meter-list -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b"
+--------------------------------------------------------------------------------+-------+------+---------------------------------------------------------------------------------------------------------------------+----------------------------------+----------------------------------+
| Name | Type | Unit | Resource ID | User ID | Project ID |
+--------------------------------------------------------------------------------+-------+------+---------------------------------------------------------------------------------------------------------------------+----------------------------------+----------------------------------+
| netease.cpu.rate | gauge | % | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda.read.delay | gauge | ms | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda.read.delay | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda.read.rate | gauge | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda.read.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda.read.req | gauge | Hz | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda.read.req | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda.write.delay | gauge | ms | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda.write.delay | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda.write.rate | gauge | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda.write.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda.write.req | gauge | Hz | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda.write.req | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda1.read.delay | gauge | ms | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda1.read.delay | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda1.read.rate | gauge | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda1.read.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda1.read.req | gauge | Hz | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda1.read.req | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda1.write.delay | gauge | ms | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda1.write.delay | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda1.write.rate | gauge | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda1.write.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vda1.write.req | gauge | Hz | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vda1.write.req | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vdb.read.delay | gauge | ms | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vdb.read.delay | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vdb.read.rate | gauge | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vdb.read.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vdb.read.req | gauge | Hz | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vdb.read.req | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vdb.write.delay | gauge | ms | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vdb.write.delay | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vdb.write.rate | gauge | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vdb.write.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.disk.vdb.write.req | gauge | Hz | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.disk.vdb.write.req | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.fs.vda1.$!.total | gauge | byte | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.fs.vda1.$!.total | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.fs.vda1.$!.used | gauge | byte | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.fs.vda1.$!.used | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.loadavg.avg5_rate | gauge | - | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.loadavg.avg5_rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.memory.total | gauge | kB | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.memory.total | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.memory.used | gauge | kB | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.memory.used | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.memory.used.rate | gauge | % | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.memory.used.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.recv | delta | Byte | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.recv | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.recv.rate | delta | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.recv.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.trans | delta | Byte | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.trans | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
| netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.trans.rate | delta | Bps | aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.nic.eth0.826f526e-6d7f-4073-9bb7-a4bf302835c5.10-180-194-55.trans.rate | 1e5607d739cc4c4fab1ba1ee9bbf1c17 | 067d4c55e93e42eca837d1c7a1a74ce8 |
+--------------------------------------------------------------------------------+-------+------+---------------------------------------------------------------------------------------------------------------------+----------------------------------+----------------------------------+
hzhuangzhexiao@10-180-2-112:~$
sample list
然后就是sample list的使用
-m 指定是哪个meter
-q 查询
resource 指定刚才 meter-list里面查询出来的resource。
hzhuangzhexiao@10-180-2-112:~$ ceilometer sample-list -m netease.cpu.rate -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate" -l 10
+-------------------------------------------------------+------------------+-------+----------------+------+---------------------+
| Resource ID | Name | Type | Volume | Unit | Timestamp |
+-------------------------------------------------------+------------------+-------+----------------+------+---------------------+
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.700466977985 | % | 2016-03-16T08:34:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.4329004329 | % | 2016-03-16T08:33:42 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.800266755585 | % | 2016-03-16T08:33:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.532268795742 | % | 2016-03-16T08:32:42 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.801068090788 | % | 2016-03-16T08:32:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.435365036839 | % | 2016-03-16T08:31:42 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.714528751276 | % | 2016-03-16T08:31:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.456323337679 | % | 2016-03-16T08:30:43 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.90331214453 | % | 2016-03-16T08:30:12 |
| aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate | netease.cpu.rate | gauge | 0.366056572379 | % | 2016-03-16T08:29:42 |
+-------------------------------------------------------+------------------+-------+----------------+------+---------------------+
ceilometer statistics
ceilometer statistics -m netease.cpu.rate -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-15T01:34:37"
hzhuangzhexiao@10-180-2-112:~$ ceilometer statistics -m netease.cpu.rate -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-15T01:34:37"
+--------+---------------------+---------------------+-------+----------------+---------------+-------------+-------+----------+---------------------+---------------------+
| Period | Period Start | Period End | Max | Min | Avg | Sum | Count | Duration | Duration Start | Duration End |
+--------+---------------------+---------------------+-------+----------------+---------------+-------------+-------+----------+---------------------+---------------------+
| 0 | 2016-03-16T06:35:59 | 2016-03-16T08:34:12 | 100.0 | 0.066467264872 | 10.0118438734 | 2372.806998 | 237 | 7093.0 | 2016-03-16T06:35:59 | 2016-03-16T08:34:12 |
+--------+---------------------+---------------------+-------+----------------+---------------+-------------+-------+----------+---------------------+---------------------+
加上 -p
参数,设置时间的粒度
hzhuangzhexiao@10-180-2-112:~$ ceilometer statistics -m netease.cpu.rate -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-16T08:24:37" -p 60
hzhuangzhexiao@10-180-2-112:~$ ceilometer statistics -m netease.cpu.rate -q resource="aed3992e-7f9a-4fab-88e5-727c0a700a4b.netease.cpu.rate;timestamp<2016-03-16T08:34:37;timestamp>2016-03-16T08:24:37" -p 60
+--------+---------------------+---------------------+----------------+----------------+----------------+---------------+-------+----------+---------------------+---------------------+
| Period | Period Start | Period End | Max | Min | Avg | Sum | Count | Duration | Duration Start | Duration End |
+--------+---------------------+---------------------+----------------+----------------+----------------+---------------+-------+----------+---------------------+---------------------+
| 60 | 2016-03-16T08:24:37 | 2016-03-16T08:25:37 | 2.66933600267 | 0.800266755585 | 1.73480137913 | 3.46960275825 | 2 | 30.0 | 2016-03-16T08:24:42 | 2016-03-16T08:25:12 |
| 60 | 2016-03-16T08:25:37 | 2016-03-16T08:26:37 | 0.730654267685 | 0.5 | 0.615327133843 | 1.23065426769 | 2 | 30.0 | 2016-03-16T08:25:42 | 2016-03-16T08:26:12 |
| 60 | 2016-03-16T08:26:37 | 2016-03-16T08:27:37 | 0.866089273817 | 0.535833891494 | 0.700961582656 | 1.40192316531 | 2 | 30.0 | 2016-03-16T08:26:42 | 2016-03-16T08:27:12 |
| 60 | 2016-03-16T08:27:37 | 2016-03-16T08:28:37 | 0.867244829887 | 0.333333333333 | 0.60028908161 | 1.20057816322 | 2 | 30.0 | 2016-03-16T08:27:42 | 2016-03-16T08:28:12 |
| 60 | 2016-03-16T08:28:37 | 2016-03-16T08:29:37 | 0.733333333333 | 0.633544514838 | 0.683438924086 | 1.36687784817 | 2 | 30.0 | 2016-03-16T08:28:42 | 2016-03-16T08:29:12 |
| 60 | 2016-03-16T08:29:37 | 2016-03-16T08:30:37 | 0.90331214453 | 0.366056572379 | 0.634684358455 | 1.26936871691 | 2 | 30.0 | 2016-03-16T08:29:42 | 2016-03-16T08:30:12 |
| 60 | 2016-03-16T08:30:37 | 2016-03-16T08:31:37 | 0.714528751276 | 0.456323337679 | 0.585426044478 | 1.17085208896 | 2 | 29.0 | 2016-03-16T08:30:43 | 2016-03-16T08:31:12 |
| 60 | 2016-03-16T08:31:37 | 2016-03-16T08:32:37 | 0.801068090788 | 0.435365036839 | 0.618216563813 | 1.23643312763 | 2 | 30.0 | 2016-03-16T08:31:42 | 2016-03-16T08:32:12 |
| 60 | 2016-03-16T08:32:37 | 2016-03-16T08:33:37 | 0.800266755585 | 0.532268795742 | 0.666267775664 | 1.33253555133 | 2 | 30.0 | 2016-03-16T08:32:42 | 2016-03-16T08:33:12 |
| 60 | 2016-03-16T08:33:37 | 2016-03-16T08:34:37 | 0.700466977985 | 0.4329004329 | 0.566683705443 | 1.13336741089 | 2 | 30.0 | 2016-03-16T08:33:42 | 2016-03-16T08:34:12 |
+--------+---------------------+---------------------+----------------+----------------+----------------+---------------+-------+----------+---------------------+---------------------+
hzhuangzhexiao@10-180-2-112:~$
命令行参数指定tips (by 罗丹):
-
在
-q
中指定多个过滤条件的方法:用分号连接,各个过滤条件之间是与的关系。
若要用并关系或者按counter_volume取值查询,目前估计只能用query-sample
这个CLIceilometer …… -q "resource=xxx ; timestamp<yyy"
-
目前只有在访问meter表的代码里用到get_meter方法中才支持通配, 即
$ ceilometer meter-list -q resource=通配表达式
其余的-q参数中虽然指定resource的值,但是最后没有落到get_meter方法来处理,还是无法通配。
-
带
-q <QUERY>
的后接参数不同命令支持的-q
范围不一样,大抵因为访问的表不同。 -
-q
后接参数中的resource=xxx
,其中的xxx是uuid+维度名的形式
-
-m
后接的meter_name
,只是维度名,不含uuid -
statistics指定多个groupby参数作为分组依据的方法:
ceilometer statistics …… -g "project_id" -g "user_id"
-
statistics对于cardinality公式的参数给法示例:
ceilometer statistics -m cpu -a 'cardinality<-project_id'
-
query-samples 对于counter_volume
(具体的采样值)
的指定时,数值不能加双引号不能加双引号不能加双引号
。 -
search_offset这个过滤参数的含义: 该参数指定了以分钟为单位的偏移值,必须和timestamp参数一起搭配使用,举例如
ceilometer sample-list -q “timestamp<xxx;search\_offset=9"
那么就会把这个timestamp指定的时间之后的9分钟内的样本一起返回。
参考文档
ceilometer query-sample 的参数使用方法
ceilometer api v2文档
ceilometer 常用命令行(by luodan)
网友评论