Skip to content

Commit

Permalink
Added system metrics for shm (#312)
Browse files Browse the repository at this point in the history
* Added system metrics for shm

* Added system metrics for shm
  • Loading branch information
d-stefanovic authored Mar 28, 2022
1 parent af15059 commit 6eb0650
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions system-metrics-collector
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
SYSTEM_DISK_LOCATION="/"
DOCKER_DISK_LOCATION="/$([ -d /var/lib/docker ] && echo 'var/lib/docker')"
OUTPUT="/tmp/system-metrics"
SHM_LOCATION_1="/dev/shm"
SHM_LOCATION_2="/run/shm"

while true; do
MEMORY=$(free | grep Mem | awk '{ printf("%6.2f%%\n", ($3/$2 * 100.0)) }')
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" >> $OUTPUT

SHM_1=$(df "$SHM_LOCATION_1" | sed 1d | awk '{ printf("%6.2f%%\n", ($3/$2 * 100.0)) }')
SHM_2=$(df "$SHM_LOCATION_2" | sed 1d | awk '{ printf("%6.2f%%\n", ($3/$2 * 100.0)) }')
echo "$(date) | mem:$MEMORY, system_disk:$SYSTEM_DISK, docker_disk:$DOCKER_DISK, $SHM_LOCATION_1:$SHM_1, $SHM_LOCATION_2:$SHM_2" >> $OUTPUT
sleep 1
done

0 comments on commit 6eb0650

Please sign in to comment.