Prometheus 4: 监控CPU

1. 查看监控CPU所需的key

[root@localhost node_exporter]# curl http://localhost:9100/metrics | grep -i node_cpu | head
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0# HELP node_cpu_guest_seconds_total Seconds the CPUs spent in guests (VMs) for each mode.
# TYPE node_cpu_guest_seconds_total counter
node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0
node_cpu_guest_seconds_total{cpu="0",mode="user"} 0
node_cpu_guest_seconds_total{cpu="1",mode="nice"} 0
node_cpu_guest_seconds_total{cpu="1",mode="user"} 0
node_cpu_guest_seconds_total{cpu="2",mode="nice"} 0
node_cpu_guest_seconds_total{cpu="2",mode="user"} 0
node_cpu_guest_seconds_total{cpu="3",mode="nice"} 0
node_cpu_guest_seconds_total{cpu="3",mode="user"} 0
100 80912    0 80912    0     0  3748k      0 --:--:-- --:--:-- --:--:-- 3950k
[root@localhost node_exporter]# 

 其中:CPU使用时间为CPU开始使用时间的累加。可以分成:

user time:从系统启动开始,累计到当前时刻,处于用户状态的运行时间,不包括nice为负进程的时间。

sys time:内核时间。从系统启动开始,累计到当前时刻,处于内核运行的时间。

nice time:nice time值使用时间。从系统启动开始,累计到当前时刻,nice 值为负的进程所占用的CPU时间。

idle time:空闲时间。从系统启动开始,累计到当前时刻。除IO等待时间以外的其它等待时间iowait。

irq time:中断时间。从系统启动开始,累计到当前时刻,硬中断时间。

softirq time:软中断时间。从系统启动开始,累计到当前时刻,软中断时间。

CPU总体运行时间,如下图所示

CPU的使用率为:CPU除了idle time之外的其它所有状态的时间之和/总CPU时间。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值