Skip to content

Commit

Permalink
redirect ps error (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogyo210 committed Apr 25, 2024
1 parent c730ad3 commit 9c23b3c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion system-metrics-collector
Original file line number Diff line number Diff line change
Expand Up @@ -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 L | grep -q '%cpu' && ps -A -o %cpu | awk '{s+=$1} END {print s "%"}')
CPU_USAGE=$(ps L | grep -q '%cpu' && ps -A -o %cpu 2>/dev/null | 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 9c23b3c

Please sign in to comment.