+ Responder ao Tópico



  1. #1

    Padrão Shell Script + Mail

    Estou tendo uns pequenos problemas com isso. besteira mas eu nao tou com cabeca no momento para solucionar todos agora.

    basicamente ta dando um problema no email

    #!/bin/bash

    # Snort Check up Script

    checkps=´ps -p `cat /var/run/snort_eth0.pid` | grep snort | cut -d "?" -f1´
    checkfile=´cat /var/run/snort_eth0.pid´

    if [ -f /var/run/snort_eth0.pid ]
    # Good pid file is there.
    then
    if [ "$checkps" = "$checkfile" ]
    then
    echo "Great, snort is running"
    # Good snort is running
    else
    # Shit, snort is dead, restarting it again.
    echo "Snort is dead"
    /etc/rc.d/init.d/snortd restart
    mail -s "Snort was dead! Restarting it..." [email protected]
    fi;


    else
    # Pid is out of here. Shit. Trying restart snortd.
    echo "Snort´s pid file wasnt found."
    /etc/rc.d/init.d/snortd restart
    mail -s "SNORT has been restarted" [email protected]
    fi;

    ele nao ta mandando o email. eu ainda tou fazendo mudancas

    qualquer ajuda eh bem vinda <IMG SRC="images/forum/icons/icon_smile.gif"> entao vamos la <IMG SRC="images/forum/icons/icon_smile.gif"> o script nao ta funcionando la muito legal nao.

  2. #2

    Padrão Shell Script + Mail

    "snort_check.sh" 28L, 767C written
    [[email protected] snort]# ./snort_check.sh
    Snort is dead
    [[email protected] snort]# ps -p `cat /var/run/snort_eth0.pid` | grep snort | cut -d "?
    " -f1
    13389
    [[email protected] snort]# cat /var/run/snort_eth0.pid
    13389
    [[email protected] snort]#

    bom ... entao o erro ta em if [ "$checkps" = "$checkfile" ]

    entretanto eu sempre usei essa sintaxe e nunca deu erro. alguem tem alguma sugestao?
    # comentei todas as linhas de mail e init.d



  3. #3

    Padrão Shell Script + Mail

    Mudei algumas coisas, para quem interessar esta tudo funcionando EXCETO
    a parte do email <IMG SRC="images/forum/icons/icon_frown.gif">

    [[email protected] snort]# cat check_snort.sh
    #!/bin/bash

    # Snort Check up Script

    #check=`ps -p \`cat /var/run/snort_eth0.pid\` | grep snort | awk &acute;{print $4;}&acute;`

    if [ -f /var/run/snort_eth0.pid ]
    # Good pid file is there.
    then
    check=`ps -p \`cat /var/run/snort_eth0.pid\` | grep snort | awk &acute;{print $4
    ;}&acute;`
    if [ "$check" = &acute;snort&acute; ]
    then
    echo "Great, snort is running"
    # Good snort is running
    else
    # Shit, snort is dead, restarting it again.
    echo "Snort is dead"
    # /etc/rc.d/init.d/snortd restart
    # mail -s "Snort was dead! Restarting it..." <a href="mailto:[email protected]" target="_new">[email protected]</a>
    fi;


    else
    # Pid is out of here. Shit. Trying restart snortd.
    echo "Snort&acute;s pid file wasnt found."
    # /etc/rc.d/init.d/snortd restart
    # mail -s "SNORT has been restarted" <a href="mailto:[email protected]" target="_new">[email protected]</a>
    fi;

    <p> Better Safe Than Sorry </p>


    [ Esta mensagem foi editada por: mistymst em 02-02-2003 15:46 ]