mon.cf  Ãß°¡ºÎºÐ
hostgroup test-node 218.xxx.xxx.xxx
watch test-node
        service samba
        interval 5s
        monitor samba.monitor -u userid -p password
        period wd {Sun-Sat}
        alert echo.alert "test-node server samba is down!!"
        upalert echo.alert "test-node server samba is live!!"
samba.monitor
#!/usr/bin/perl
#
# Tries to connect to a samba server.
# For use with "mon"
#
# samba.monitor [-u user] [-p password] [-s share] host [host...]
#
#     -u user       Samba user to connect as
#     -p password   Password for user, if -u was used
#     -s share      Share to connect to. Defaults to value of -u
#
# Mike Morgan
# Lafayette Venetian Blinds
#
#    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 Getopt::Std;
getopts("u:p:s:");
$user = $opt_u || "";
$passwd = $opt_p || "-N";
$share = $opt_s || $opt_u;
$sc = `which smbclient`;
chomp $sc;
unless (-x $sc) {
        print "samba.monitor error: could not find smbclient\n";
        exit 1;
}
if(@ARGV == 0) {
        print "samba.monitor: no hosts found\n";
        exit 1;
}
for my $host (@ARGV) {
#       $smbclient = "$sc -U \"$user\" \"//$host/$share\" \"$passwd\" -c ls 2>&1";
        $smbclient = "$sc \"//$host/$share\" \"$passwd\" -U \"$user\" -c ls 2>&1";
        $results = `$smbclient`;
        if ($results =~ /^Error/) {
                print $results;
                exit 1;
        }
}
exit 0;
¾ÆÀ̵ð/ÆÐ½º¿öµå ÀÎÁõ½ÇÆÐ½Ã¿¡´Â... ¿À·ù¿¡ Àû¿ëµÇÁö ¾Ê´Â´Ù...
Á»´õ µÚÁ®ºÁ¾ßµÉµí...;;
 
[ÀÌ °Ô½Ã¹°Àº ÃÖ°í°ü¸®ÀÚ´Ô¿¡ ÀÇÇØ 2010-03-26 11:15:44 ¸®´ª½º¿¡¼ À̵¿ µÊ]