123456789101112131415161718192021222324252627282930313233343536 |
- #!/bin/bash
- clear
- database="/root/usuarios.db"
- echo $$ > /tmp/pids
- if [ ! -f "$database" ]
- then
- echo "Archivo /root/usuarios.db no encontrado"
- exit 1
- fi
- while true
- do
- while read usline
- do
- user="$(echo $usline | cut -d' ' -f1)"
- s2ssh="$(echo $usline | cut -d' ' -f2)"
- if [ -z "$user" ] ; then
- echo "" > /dev/null
- else
- ps x | grep [[:space:]]$user[[:space:]] | grep -v grep | grep -v pts > /tmp/tmp2
- s1ssh="$(cat /tmp/tmp2 | wc -l)"
- tput setaf 3 ; tput bold ; printf ' %-35s%s\n' $user $s1ssh/$s2ssh; tput sgr0
- if [ "$s1ssh" -gt "$s2ssh" ]; then
- while read line
- do
- tmp="$(echo $line | cut -d' ' -f1)"
- kill $tmp
- done < /tmp/tmp2
- rm /tmp/tmp2
- fi
- fi
-
- done < "$database"
- sleep 2
- clear
- done
|