读博士期间用到了十几台服务器,为了实时监控它们的情况,自己写了一个程序。下面这些Linux命令大多是那时总结的。
- Number of Physical CPUs
cat /proc/cpuinfo | grep -i 'physical id' |sort -u | wc -l
- Number of Cores on each physical CPU
cat /proc/cpuinfo | grep -i 'cpu cores' | sort -u | gawk '{print $4}'
- Number of Total CPU Threads
cat /proc/cpuinfo |grep -i 'processor' | sort -u |wc -l
- HTSupported
cat /proc/cpuinfo |grep -i ‘ht’ | sort | wc -l
HTEnabled
CPU model
cat /proc/cpuinfo |grep 'model name' |uniq
- Linux Distribution
cat /etc/issue |gawk 'NR <2'
- Linux Kernel Version
uname -r
- Number of Cores in Use by a Specific Task
$ ps -eo pcpu,args |grep 'python -u'|gawk '{if ($1 !~ /^0/) {print $1}}'
101
101
101
add |wc -l at the end
- Memory in KB
cat /proc/meminfo |grep 'MemTotal' |gawk '{print $2}'
- HDD/SSD size
sudo fdisk -l 2>/dev/null |grep -i 'Disk'|grep 'da' | gawk '{print $3,$4}'
- HDD/SSD space available
df -H