moving projects

This commit is contained in:
ville rantanen
2013-09-03 10:04:14 +03:00
parent 3e36193fe4
commit 30cb1e6128
13 changed files with 570 additions and 0 deletions

44
anduril/vm_report_status Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
cores=$( grep -c processor /proc/cpuinfo )
# verbose mode
tgtf=/mnt/csc-cloud/vm_state/${HOSTNAME}.long
# debug
if [ -z "$1" ]
then touch "$tgtf"
fi
if [ -f "$tgtf" ]
then echo "======== $HOSTNAME =======" > "$tgtf"
TZ="Europe/Helsinki" uptime >> "$tgtf"
echo "Cores: $cores" >> "$tgtf"
free -tg | head -n 2 >> "$tgtf"
ps a --format user| grep -v -e root -e USER | sort -u | tr '\n' ' ' >> "$tgtf"
echo "" >> "$tgtf"
fi
# concise mode
tgtf=/mnt/csc-cloud/vm_state/${HOSTNAME}.short
# debug
if [ -z "$1" ]
then touch "$tgtf"
fi
if [ -f "$tgtf" ]
then echo -n "|$HOSTNAME L:" > "$tgtf"
load=$( cat /proc/loadavg | cut -d" " -f3 | tr -d [:cntrl:] )
echo -n "$load/$cores M:" >> "$tgtf"
# used + cached = total - free
free=$(( $( grep ^MemFree /proc/meminfo | tr -d -c [:digit:] ) / 1048576 ))
cache=$(( $( grep ^Cached /proc/meminfo | tr -d -c [:digit:] ) / 1048576 ))
total=$(( $( grep ^MemTotal /proc/meminfo | tr -d -c [:digit:] ) / 1048576 ))
used=$(( $total -$free -$cache ))
echo -n "$used+$cache/$total U:" >> "$tgtf"
ps a --format user| grep -v -e root -e USER | sort -u | wc -l | tr -c -d [:digit:] >> "$tgtf"
TZ="Europe/Helsinki" date "+ @%H:%M" >> "$tgtf"
# save history
echo -e "$HOSTNAME\t$load\t$used\t"$( date +%s ) >> /mnt/csc-cloud/vm_state/history/${HOSTNAME}
fi