From a59b400913332d60251fcedaf2f2fcd7e50fcb38 Mon Sep 17 00:00:00 2001 From: lean Date: Wed, 25 Mar 2020 01:44:35 +0800 Subject: [PATCH] autocore:getcpu method change --- package/lean/autocore/Makefile | 2 +- package/lean/autocore/files/sbin/getcpu | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package/lean/autocore/Makefile b/package/lean/autocore/Makefile index 5a3ea1132..207bfced8 100644 --- a/package/lean/autocore/Makefile +++ b/package/lean/autocore/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=autocore PKG_VERSION:=1 -PKG_RELEASE:=29 +PKG_RELEASE:=30 include $(INCLUDE_DIR)/package.mk diff --git a/package/lean/autocore/files/sbin/getcpu b/package/lean/autocore/files/sbin/getcpu index 454147702..61e8d6ee4 100755 --- a/package/lean/autocore/files/sbin/getcpu +++ b/package/lean/autocore/files/sbin/getcpu @@ -1,7 +1,8 @@ #!/bin/sh -AT=$(cat /proc/stat | grep "^cpu " | awk '{print $2+$3+$4+$5+$6+$7+$8 " " $2+$3+$4+$7+$8}') -sleep 3 -BT=$(cat /proc/stat | grep "^cpu " | awk '{print $2+$3+$4+$5+$6+$7+$8 " " $2+$3+$4+$7+$8}') - -printf "%.01f%%" $(echo $AT $BT | awk '{print (($4-$2)/($3-$1))*100}') >/tmp/cpuusage \ No newline at end of file +if [ $(busybox ps -w | grep getcpu | grep -v grep | wc -l) -le 2 ]; then + AT=$(cat /proc/stat | grep "^cpu " | awk '{print $2+$3+$4+$5+$6+$7+$8 " " $2+$3+$4+$7+$8}') + sleep 1 + BT=$(cat /proc/stat | grep "^cpu " | awk '{print $2+$3+$4+$5+$6+$7+$8 " " $2+$3+$4+$7+$8}') + printf "%.01f%%" $(echo $AT $BT | awk '{print (($4-$2)/($3-$1))*100}') >/tmp/cpuusage +fi \ No newline at end of file