tdsql(pg版)的一些系统检查语句

发布时间 2024-01-06 12:50:05作者: chy_cug

一、磁盘、CPU、内存:
#!/bin/bash
for i in `cat ./ip.txt`;
do
echo "========="$i"========="
echo ""
free -m | awk 'NR==2{printf "内存 使用率:%s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
echo ""
top -bn1 | grep '%Cpu(s)' | awk -F ' ' '{print $4}' | awk -F ',' '{print $2}' | awk -F ' ' '{print $1}' | awk '{printf "CPU 空闲: %.1f\n", $1}'
echo ""
echo "磁盘使用情况"
df -h
echo "
"
done

二、查看进程的内存占用:
ps -aux | grep oss_server | grep -v 'grep' | grep -v 'sz'

三、Etcd健康检查
export ETCDCTL_API=3;etcdctl endpoint health --endpoints=20.4.74.x1:2379,20.4.74.x1:4001,20.4.74.x2:2379,20.4.74.x2:4001,20.4.74.x3:2379,20.4.74.x3:4001
20.4.74.x1:2379 is healthy: successfully committed proposal: took = 1.393326ms
20.4.74.x1:4001 is healthy: successfully committed proposal: took = 1.651819ms
20.4.74.x3:2379 is healthy: successfully committed proposal: took = 1.781993ms
20.4.74.x2:4001 is healthy: successfully committed proposal: took = 1.968837ms
20.4.74.x2:2379 is healthy: successfully committed proposal: took = 2.009535ms
20.4.74.x3:4001 is healthy: successfully committed proposal: took = 2.821403ms
--endpoints=为etcd地址和端口4001和2379
需要显示为healthy
如果不是healthy就要告警,反馈

四、Confdb检查
export PGPASSWORD=Pgxz@TbaseV2;psql -h 20.4.74.x1 -p 54321 -d postgres -U postgres -c "select application_name,client_addr,backend_start,sync_state from pg_stat_replication" ;
application_name | client_addr | backend_start | sync_state
------------------+-------------+-------------------------------+------------
stolon_dea5f7bc | 20.4.74.x2 | 2023-12-26 09:58:28.307094+08 | async
stolon_089ba3c3 | 20.4.74.x3 | 2023-12-26 10:00:50.486912+08 | async
(2 rows)
单中心为:async