limiter 748 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. clear
  3. database="/root/usuarios.db"
  4. echo $$ > /tmp/pids
  5. if [ ! -f "$database" ]
  6. then
  7. echo "Archivo /root/usuarios.db no encontrado"
  8. exit 1
  9. fi
  10. while true
  11. do
  12. while read usline
  13. do
  14. user="$(echo $usline | cut -d' ' -f1)"
  15. s2ssh="$(echo $usline | cut -d' ' -f2)"
  16. if [ -z "$user" ] ; then
  17. echo "" > /dev/null
  18. else
  19. ps x | grep [[:space:]]$user[[:space:]] | grep -v grep | grep -v pts > /tmp/tmp2
  20. s1ssh="$(cat /tmp/tmp2 | wc -l)"
  21. tput setaf 3 ; tput bold ; printf ' %-35s%s\n' $user $s1ssh/$s2ssh; tput sgr0
  22. if [ "$s1ssh" -gt "$s2ssh" ]; then
  23. while read line
  24. do
  25. tmp="$(echo $line | cut -d' ' -f1)"
  26. kill $tmp
  27. done < /tmp/tmp2
  28. rm /tmp/tmp2
  29. fi
  30. fi
  31. done < "$database"
  32. sleep 2
  33. clear
  34. done