You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Troy McBride <tm...@pccc.com> on 2012/10/31 14:42:02 UTC

Spamd checker script

I am trying to write a script that takes an array of server names and 
pings their spamd to make sure that it is still alive.

$t = new Net::Telnet(Prompt=>'//', Port=> 783, 
output_log=>"out_log.txt", input_log=>"in_log.txt");

for($i=0;$i<$count;$i++) {
   $t -> open(@server_list[$i]);
   $line = $t->cmd(String=>"PING SPAMC/1.0");
   $line = $t->getline();

   if($line =~ /PONG/) {
     push(@goodservers, $server_list[$i]);
   }  else {
     push(@badservers, $server_list[$1]);
   }

}

Is this a stable solution to my problem?  Has anyone done anything like 
this and been successful?

Thanks,
TDM

Re: Spamd checker script

Posted by Ted Mittelstaedt <te...@ipinc.net>.
I run the following once an hour out of cron on my FreeBSD mailserver,
the echos are merely stuff the log and aren't necessary.  You could
easily delete them:

$ cat /root/spamdwatch.sh

#!/bin/sh
if ps -p `cat /var/run/spamd/spamd.pid` > /dev/null; then
   echo spamd is running
else
   echo spamd is not running
#  notify Support desk - SPAMD is offline
killall spamd
/usr/local/etc/rc.d/sa-spamd  start
/usr/sbin/sendmail -f devnull@ipinc.net -t << RedCatSun
To: support@ipinc.net
From: root@ipinc.net
Subject: SPAMD daemon was restarted
Errors-To:
possible spamd failures on mail.ipinc.net

RedCatSun
fi

For a dirty disgusting ugly hack it works well.

Let me just say for the record that I find it extremely disappointing to
have to do this.  All of the prior versions of spamd were stable enough
that the spamd daemon would last for months without trouble.  But the
current one dies every few days or so.

Ted

On 10/31/2012 6:42 AM, Troy McBride wrote:
> I am trying to write a script that takes an array of server names and
> pings their spamd to make sure that it is still alive.
>
> $t = new Net::Telnet(Prompt=>'//', Port=> 783,
> output_log=>"out_log.txt", input_log=>"in_log.txt");
>
> for($i=0;$i<$count;$i++) {
>    $t -> open(@server_list[$i]);
>    $line = $t->cmd(String=>"PING SPAMC/1.0");
>    $line = $t->getline();
>
>    if($line =~ /PONG/) {
>      push(@goodservers, $server_list[$i]);
>    }  else {
>      push(@badservers, $server_list[$1]);
>    }
>
> }
>
> Is this a stable solution to my problem?  Has anyone done anything like
> this and been successful?
>
> Thanks,
> TDM