首页 > 技术文章 > ceph打印出每秒的IO和pg状态

zphj1987 2020-09-09 10:47 原文

前言

在ceph 的jewel版本以及之前的版本,通过ceph -w命令是可以拿到每秒钟ceph集群的io状态的,现在的版本是ceph -s一秒秒手动去刷,ceph -w也不监控io的状态了,有的时候需要看io是否平滑,或者恢复还剩多少,能够比较直观的去看

实际上通过简单的脚本就可以实现之前差不多的效果

每秒查看状态

[root@lab201 ~]# sh ceph-s.sh 
Wed Sep  9 10:44:57 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 93.3KiB/s rd, 0B/s wr, 155op/s
Wed Sep  9 10:44:58 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 91.7KiB/s rd, 0B/s wr, 152op/s
Wed Sep  9 10:45:00 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 94.6KiB/s rd, 0B/s wr, 157op/s
Wed Sep  9 10:45:01 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 94.6KiB/s rd, 0B/s wr, 157op/s
Wed Sep  9 10:45:02 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 88.3KiB/s rd, 0B/s wr, 147op/s
Wed Sep  9 10:45:03 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 88.3KiB/s rd, 0B/s wr, 147op/s
Wed Sep  9 10:45:04 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 69.6KiB/s rd, 0B/s wr, 115op/s
Wed Sep  9 10:45:06 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 92.6KiB/s rd, 0B/s wr, 154op/s
Wed Sep  9 10:45:07 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 92.6KiB/s rd, 0B/s wr, 154op/s
Wed Sep  9 10:45:08 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 90.0KiB/s rd, 0B/s wr, 150op/s
Wed Sep  9 10:45:09 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 90.0KiB/s rd, 0B/s wr, 150op/s
Wed Sep  9 10:45:10 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 90.1KiB/s rd, 0B/s wr, 150op/s
Wed Sep  9 10:45:12 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 92.8KiB/s rd, 0B/s wr, 154op/s
Wed Sep  9 10:45:13 CST 2020	192 pgs: 192 active+clean; 1.30GiB data, 13.3GiB used, 287GiB / 300GiB avail; 92.8KiB/s rd, 0B/s wr, 154op/s

需要有时间,需要每秒的状态方便比对,如上所示

脚本

[root@lab201 ~]# cat ceph-s.sh 
#!/bin/bash
LANG=C
PATH=/sbin:/usr/sbin:/bin:/usr/bin
interval=1
length=86400
for i in $(seq 1 $(expr ${length} / ${interval}));do
date=`date`
echo -n "$date	"
ceph pg stat
sleep ${interval}
done

可以自行调整中间的间隔

变更记录

Why Who When
创建 武汉-运维-磨渣 2020-09-09

推荐阅读