Enviado em 10/10/2016 - 20:22h
Fiz um script mais to com dificuldade, ele está funciona no normalmente mais quando executo ele as linhas de número de usuário ficam desorganizadas.
Script
http://pastebin.com/raw/M7uBErRp
Imagem de como fica
https://postimg.org/image/tu5l8huix/
Quero deixa ele assim se alguém pode ajuda
https://postimg.org/image/lslmjjyl1/
Script
#!/bin/sh
lsusers="/tmp/users"
echo $$ > /tmp/pid
if [ ! -f "$lsusers" ]
then
awk -F : '$3 >= 500 { print $1 "" }' /etc/passwd | grep -v '^nobody' > /tmp/users
fi
while true
do
tput setaf 6; echo "\nUsuário Nº de Conexões\n" ; tput sgr0
while read lnusers
do
user="$(echo $lnusers | cut -d' ' -f1)"
ps x | grep $user | grep -v grep | grep -v pts > /tmp/tmp.tmp
conexoes="$(cat /tmp/tmp.tmp | wc -l)"
echo "$user $conexoes"
awk -F : '$3 >= 500 { print $1 "" }' /etc/passwd | grep -v '^nobody' > /tmp/users
done < "$lsusers"
echo " "
exit 1
done
Se tiver com dificuldade de entender o script aí o linklsusers="/tmp/users"
echo $$ > /tmp/pid
if [ ! -f "$lsusers" ]
then
awk -F : '$3 >= 500 { print $1 "" }' /etc/passwd | grep -v '^nobody' > /tmp/users
fi
while true
do
tput setaf 6; echo "\nUsuário Nº de Conexões\n" ; tput sgr0
while read lnusers
do
user="$(echo $lnusers | cut -d' ' -f1)"
ps x | grep $user | grep -v grep | grep -v pts > /tmp/tmp.tmp
conexoes="$(cat /tmp/tmp.tmp | wc -l)"
echo "$user $conexoes"
awk -F : '$3 >= 500 { print $1 "" }' /etc/passwd | grep -v '^nobody' > /tmp/users
done < "$lsusers"
echo " "
exit 1
done
http://pastebin.com/raw/M7uBErRp
Imagem de como fica
https://postimg.org/image/tu5l8huix/
Quero deixa ele assim se alguém pode ajuda
https://postimg.org/image/lslmjjyl1/