Browse Source

Add memory monitor script (#757)

sphinx-v2.1.5
Luke Childs 4 years ago
committed by GitHub
parent
commit
95e443742e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      scripts/debug
  2. 31
      scripts/memory-monitor
  3. 4
      scripts/start

4
scripts/debug

@ -94,6 +94,10 @@ free --human --mega
echo
"${UMBREL_ROOT}/scripts/memory-usage"
echo
echo "Memory monitor logs"
echo "-------------------"
tail -n 10 "${UMBREL_ROOT}/logs/memory-monitor.log"
echo
echo "Filesystem information"

31
scripts/memory-monitor

@ -0,0 +1,31 @@
#!/usr/bin/env bash
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
PERCENT_MEMORY_THRESHOLD=90
check_if_not_already_running() {
if ps ax | grep $0 | grep -v $$ | grep bash | grep -v grep
then
echo "Memory monitor is already running"
exit 1
fi
}
log () {
echo "$(date "+%Y-%m-%d %H:%M:%S") ${@}"
}
check_if_not_already_running
log "Memory monitor running!"
while true; do
percent_memory_used=$(free | awk 'NR==2{print int($3*100/$2) }')
if (( $percent_memory_used > $PERCENT_MEMORY_THRESHOLD )); then
log "Warning memory usage at ${percent_memory_used}%"
if [[ "$(jq -r '.installedApps | length > 0' ${UMBREL_ROOT}/db/user.json)" == "true" ]]; then
touch "${UMBREL_ROOT}/statuses/memory-warning"
fi
fi
sleep 60
done

4
scripts/start

@ -73,6 +73,10 @@ echo "Starting karen..."
echo
./karen &>> "${UMBREL_LOGS}/karen.log" &
echo "Starting memory monitor..."
echo
./scripts/memory-monitor &>> "${UMBREL_LOGS}/memory-monitor.log" &
echo "Starting backup monitor..."
echo
./scripts/backup/monitor &>> "${UMBREL_LOGS}/backup-monitor.log" &

Loading…
Cancel
Save