#!/usr/local/bin/perl -w # # clamdwatch v0.01, Copyright (C) Mike Cathey # # Use this at your own risk! # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # use IO::Socket::UNIX; my $LocalSocket = "/var/run/clamd.ctl"; my $sock = new IO::Socket::UNIX(Type => SOCK_STREAM, Timeout => 10, Peer => $LocalSocket ); if (!$sock) { print "Clamd Not Running\n"; exit; } if ( $sock->connected ) { my $err = ""; $sock->send("PING"); $sock->recv($err, 20); if ($err eq "PONG\n") { print "Clamd Running\n"; } else { # clamd busy? # would the client just wait until a clamd thread was available? print "Unknown State\n"; } } else { # you should never get here... print "Unknown State (Clamd Useless)\n"; }