게시물 139건
   
[MON] samba.monitor - 확인완료
글쓴이 : 최고관리자 날짜 : 2010-03-26 (금) 11:18 조회 : 6394
글주소 :
                          

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.