jeudi 8 novembre 2018

Connaitre la quantité de RAM que prend un processus

#!/bin/bash

if [ "$1" = "" ] ; then
  echo -n "Nom du process : "
  read process
else
  process=$1
fi

ps aux | grep $process | grep -v grep | awk 'BEGIN { sum=0 } {sum=sum+$6; } END {printf("Taille RAM utilisée: %s Mo\n",sum / 1024)}'

Ping check

!/bin/bash

PINGLAT=$(ping -c1 8.8.8.8 | grep -i time | head -n 1 | awk '{print $7}' | awk 'BEGIN {FS="[=]|[ ]"} {print $2}')
PINGTHRESHOLD=400
PINGLATINT=$(echo "$PINGLAT/1" | bc)

echo $PINGLATINT

if [ $PINGLATINT -gt $PINGTHRESHOLD ]
 then play -q ~jdoe/Musique/bip.mp3
 else exit 0
fi