shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

script lsof...


From: Marcelo Salavee Lemos
Subject: script lsof...
Date: Wed, 22 Aug 2007 09:33:03 -0300
User-agent: Thunderbird 2.0.0.6 (X11/20070728)

Olá,

Tenho um script para me avisar no caso de alguma alteração de porta no servidor. Agora estou querendo além dos Status antes/após alteração, gostaria de listar
a diferença entre eles.
Alguma dica?

------------------------------------------------------------------------------
#!/bin/sh

MAILTO="root"
HOSTNAME=`hostname`
getports() {
lsof -i -n -P | awk '/LISTEN/{print $1"/"$3"/"$8}' | sort -u | grep -v smtpd
}

VELHO="$(getports)"


NOVO="$(getports)"


echo -e "Portas Autorizadas:\n$VELHO"
while sleep 20 ; do
       NOVO="$(getports)"
       if test "$VELHO" != "$NOVO" ; then

echo "Alteracao de Portas DETECTADO. Plano-B entrando em ACAO!"
mail -s "Atencao: Portas Alteradas em $HOSTNAME WARNING!" $MAILTO << EOF


########################################################
############# Status antes da alteracao: ###############
$VELHO
########################################################
############## Status apos a alteracao: ################
$NOVO
########################################################
########################################################
EOF
fi
VELHO="$NOVO"
done
-------------------------------------------------------------------------------------------


Valeu!
Abraços,
Marcelo

---------------------------------------------------------------------
Esta mensagem pode conter informacao confidencial.
Se voce nao for o destinatario ou a pessoa autorizada a receber
esta mensagem, nao podera usar, copiar ou divulgar as informacoes nela
contidas ou tomar qualquer acao baseada nessas informacoes. Se
voce recebeu esta mensagem por engano, favor avisar imediatamente o
remetente, respondendo o e-mail e, em seguida, apague-o.
Agradecemos sua cooperacao.

This message may contain confidential information.
If you are not the addressee or authorized person to receive it for the
addressee, you must not use, copy, disclose or take any action based on
this message or any information herein. If you have received this message
in error, please advise the sender immediately by replying this e-mail message and delete it.
Thanks in advance for your cooperation.
----------------------------------------------------------------------
                 Faculdade de Medicina USP
----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]