Skip to content

Commit

Permalink
don't check cpu where %cpu is not available for ps (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogyo210 authored Apr 19, 2024
1 parent d13091f commit 7fc7501
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions system-metrics-collector
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#
# $ cat /tmp/system-metrics-collector
#
# Mon May 18 14:50:58 UTC 2020 | mem: 5.03%, disk: 47.75%
# Mon May 18 14:51:28 UTC 2020 | mem: 5.03%, disk: 47.75%
# Mon May 18 14:50:58 UTC 2020 | cpu: 6% , mem: 5.03% , system_disk 1% , docker_disk: 1% , shared_memory 1%
# Mon May 18 14:51:28 UTC 2020 | cpu: 4% , mem: 5.03% , system_disk 1.9% , docker_disk: 11% , shared_memory 41%
#
# Jobs that run for an hour collect around 120 log lines. This should be safe
# and not introduce any performance of disk usage problems.
Expand All @@ -31,7 +31,7 @@ while true; do
SHARED_MEMORY=$(free -m | grep Mem | awk '{ print $5 }')
SYSTEM_DISK=$(df "$SYSTEM_DISK_LOCATION" | sed 1d | awk '{ printf("%6.2f%%\n", ($3/$2 * 100.0)) }')
DOCKER_DISK=$(df "$DOCKER_DISK_LOCATION" | sed 1d | awk '{ printf("%6.2f%%\n", ($3/$2 * 100.0)) }')
CPU_USAGE=$(ps -A -o %cpu | awk '{s+=$1} END {print s "%"}')
CPU_USAGE=$(ps L | grep -q '%cpu' && ps -A -o %cpu | awk '{s+=$1} END {print s "%"}')
echo "$(date) | cpu:$CPU_USAGE, mem:$MEMORY, system_disk:$SYSTEM_DISK, docker_disk:$DOCKER_DISK, shared_memory: $SHARED_MEMORY M" >> $OUTPUT
sleep 1
done

0 comments on commit 7fc7501

Please sign in to comment.