From 6d579e7f8906712833063487a7a4f521e9c2abc5 Mon Sep 17 00:00:00 2001 From: weidongkl Date: Thu, 26 Sep 2024 10:54:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96get=5Flocal=5Fdis?= =?UTF-8?q?k/check=5Fsshd=20=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: weidongkl --- sysmonitor-1.3.2/script/check_sshd.sh | 6 +++--- sysmonitor-1.3.2/script/get_local_disk.sh | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sysmonitor-1.3.2/script/check_sshd.sh b/sysmonitor-1.3.2/script/check_sshd.sh index 34899a2..0341593 100755 --- a/sysmonitor-1.3.2/script/check_sshd.sh +++ b/sysmonitor-1.3.2/script/check_sshd.sh @@ -12,8 +12,8 @@ count=$(expr $NUM - 1) function sshd_process_exist() { - status=$(systemctl status sshd -n 0 | grep "Active:" | grep running) - [ -n "${status}" ] && return 0 + systemctl is-active sshd + [ $? -eq 0 ] && return 0 return 1 } @@ -30,7 +30,7 @@ do done if [ $SSHD_STATUS -ne 0 ];then - SSHD_PID=$(ps -ef | grep -w "/usr/sbin/sshd" | grep -v grep | awk '{if ($3==1) print $2}') + SSHD_PID=$(pidof /usr/sbin/sshd) kill -9 $SSHD_PID 2>/dev/null exit 1 fi diff --git a/sysmonitor-1.3.2/script/get_local_disk.sh b/sysmonitor-1.3.2/script/get_local_disk.sh index 063e540..6f5227d 100755 --- a/sysmonitor-1.3.2/script/get_local_disk.sh +++ b/sysmonitor-1.3.2/script/get_local_disk.sh @@ -7,13 +7,18 @@ fc_disk_file="" local_disk_file="" -if uname -a | grep -q aarch64; then - fc_local_disk=`ls -l /sys/block/ | grep -E 'pci|HISI0162' 2> /dev/null` -elif uname -a | grep -q riscv64; then - fc_local_disk=`ls -l /sys/block/ | grep -E 'pci|virtio' 2> /dev/null` -else - fc_local_disk=`ls -l /sys/block/ | grep pci 2> /dev/null` -fi +case $(uname -m) in + "aarch64") + fc_local_disk=`ls -l /sys/block/ | grep -E 'pci|HISI0162' 2> /dev/null` + ;; + "riscv64") + fc_local_disk=`ls -l /sys/block/ | grep -E 'pci|virtio' 2> /dev/null` + ;; + *) + fc_local_disk=`ls -l /sys/block/ | grep pci 2> /dev/null` + ;; +esac + disk_list="" # **************************************************************************** # -- Gitee