게시물 139건
   
[MON] samba.monitor
글쓴이 : 최고관리자 날짜 : 2010-03-08 (월) 11:50 조회 : 5636
글주소 :
                          

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 리눅스에서 이동 됨]

이름 패스워드
비밀글 (체크하면 글쓴이만 내용을 확인할 수 있습니다.)
왼쪽의 글자를 입력하세요.
   

 



 
사이트명 : 모지리네 | 대표 : 이경현 | 개인커뮤니티 : 랭키닷컴 운영체제(OS) | 경기도 성남시 분당구 | 전자우편 : mojily골뱅이chonnom.com Copyright ⓒ www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.