Skip to content

Commit

Permalink
add cpu usage collector
Browse files Browse the repository at this point in the history
  • Loading branch information
bogyo210 committed Apr 12, 2024
1 parent 11fbd37 commit 7f41f67
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system-metrics-collector
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +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)) }')
echo "$(date) | mem:$MEMORY, system_disk:$SYSTEM_DISK, docker_disk:$DOCKER_DISK, shared_memory: $SHARED_MEMORY M" >> $OUTPUT
CPU_USAGE=$(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 7f41f67

Please sign in to comment.