34 lines
1000 B
Bash
34 lines
1000 B
Bash
|
|
#!/bin/bash
|
||
|
|
# usage: sequencelogic-process-info.sh {what}
|
||
|
|
command2=""
|
||
|
|
pre2=""
|
||
|
|
post=""
|
||
|
|
if [ $# = 1 ];
|
||
|
|
then
|
||
|
|
what=$1
|
||
|
|
command2="echo `cat /proc/cpuinfo | awk '/^processor/ {++n} END {print n}'`"
|
||
|
|
else
|
||
|
|
ipAddress=$1
|
||
|
|
command2="ssh -i /home/sequencelogic/.ssh/low_power sequencelogic@${ipAddress} cat /proc/cpuinfo | awk '/^processor/ {++n} END {print n}'"
|
||
|
|
pre2="ssh -i /home/sequencelogic/.ssh/low_power sequencelogic@${ipAddress} "
|
||
|
|
what=$2
|
||
|
|
fi
|
||
|
|
|
||
|
|
cores=1
|
||
|
|
if [ `uname` = Linux ]; then
|
||
|
|
cores=$(${command2})
|
||
|
|
else
|
||
|
|
cores=$(sysctl -n hw.ncpu)
|
||
|
|
fi
|
||
|
|
|
||
|
|
${pre2} ps auxww | grep "${what}" | grep -v grep | grep -v robot.sh | grep -v 'sequencelogic-process-info' | sed 's/java.*com[.]sequencelogic/com.sequencelogic/' | awk -v cores=${cores} '
|
||
|
|
BEGIN { comma=""; printf "[" }
|
||
|
|
{
|
||
|
|
name=$11
|
||
|
|
# nb. using +1 to keep server logic from computing overall host cpu load
|
||
|
|
printf "%s{\"cpu_pct\":%d, \"mem_pct\":%d, \"host\":\"/%s\"}", comma, (100*($3/cores+1))/100, (100*($4+1))/100, name
|
||
|
|
comma=",\n"
|
||
|
|
}
|
||
|
|
END { printf "]\n" }
|
||
|
|
'
|
||
|
|
exit 0
|