¿ù°£ Àα⠰Խù°

°Ô½Ã¹° 138°Ç
   
[MON] samba.monitor - È®ÀοϷá
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2010-03-26 (±Ý) 11:18 Á¶È¸ : 5915
±ÛÁÖ¼Ò :
                          

samba.monitor

#!/usr/bin/perl
#
# Test SMB Connections using smbclient, you'll need Samba
#  Just tries to get a list of shares from the box
#
# For use with "mon".
#
# smb.monitor -p password -u username host1 [ hostN... ]
#
#    Copyright (C) 2005, David Busby
#
#    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
#

exit 0 if (!@ARGV);

use Getopt::Std;
getopts ("p:u:");

# Samba Default
#my $resolve_order = "lmhosts hosts wins bcast"
my $resolve_order = 'wins bcast';
my $debug_level = 1;
my %bad;

# Check the hosts
foreach my $host (@ARGV)
{
  my $res = do
  {
    my $x;
    my $cmd = "/usr/bin/smbclient -d $debug_level -L $host -R '$resolve_order' -U '$opt_u\%$opt_p' 2>&1";
    my $buf = `$cmd`;
    $x->{status} = $?;
    $x->{buffer} = $buf;
    $x;
  };

  if ($res->{status}!=0)
  {
    $bad{$host} = $res;
  }
}

# Write messages about the failures
foreach my $h (keys %bad)
{
  print "SMB FAILURE: $h $bad{$h}->{status} - $bad{$h}->{buffer}\n";
}
exit scalar(keys(%bad));


mon.cf

watch samba1
     service samba
      interval 5s
      monitor samba.monitor -u »ï¹Ù°èÁ¤ -p Æнº¿öµå
      period wd {Sun-Sat}
      alert echo.alert "service down"
      upalert echo.alert "service alive"

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.