etc

n준크 2009. 9. 9. 15:17

-valgrind

 
 
 

etc

n준크 2008. 8. 1. 14:21
LONG 글의 나머지 부분을 쓰시면 됩니다. ARTICLE

################################################################
감시 모듈(MON) 인스톨 설정  (dbserver1의 Master측만)
################################################################
○인스톨

# wget http://www.jp.kernel.org/pub/software/admin/mon/mon-0.99.2.tar.gz
# gunzip < mon-0.99.2.tar.gz | tar xvf -
# mv mon-0.99.2 /usr/local/mon

 

○필요한 CPAN들

# perl -MCPAN -e 'install Mon::SNMP'
# perl -MCPAN -e 'install Time::Period'
# perl -MCPAN -e 'install Time::HiRes'
# perl -MCPAN -e 'install Convert::BER'
# perl -MCPAN -e 'install DBI'
# perl -MCPAN -e 'install Proc::ProcessTable'
# perl -MCPAN -e 'force install DBD::mysql'

 

○/etc/init.d 에 이런 식으로 추가

# vi /etc/init.d/mon
#! /bin/sh
DAEMON="/usr/bin/perl"

 

set -e

# Check for echo -n vs echo \c
if echo '\c' | grep -s c >/dev/null 2>&1 ; then
ECHO_N="echo -n" ECHO_C=""
else
ECHO_N="echo"
ECHO_C='\c'
fi

# only start if we can find the postmaster.
test -x $DAEMON || exit 0

# Parse command line parameters.
case $1 in
start)
$ECHO_N "Starting MON: "$ECHO_C
su - root -c "$DAEMON /usr/local/mon/mon -b /usr/local/mon -B /usr/local/mon/etc &"
echo "ok"
;;
stop)
echo -n "Stopping MON:"
kill -9 `ps -ef | grep mon | grep perl | grep -v grep | awk '{print $2}'` 2> /dev/null
echo "ok"
;;
*)
# Print help
echo "Usage: $0 {start|stop}" 1>&2
exit 1
;;
esac
exit 0

 

○설정

# cd /usr/local/mon/etc
# vi mon.cf
이하와 같이 파일을 추가
maxprocs = 20
histlength = 100
randstart = 60s

 

hostgroup dbserver1

watch dbserver1
service mysql
interval 10s
    
monitor msql-mysql.monitor --mode=mysql --username=repl --password=password --database=exampledb localhost
allow_empty_group
period wd {Sun-Sat}
alertevery 45m
alert mail.alert <떨어졌을 때에 송신하는 관리자의 메일 주소 등>
upalert mail.alert -u <일어섰을 때에 송신하는 관리자의 메일 주소 등>
alert stop-heartbeat.alert

# vi /usr/local/mon/mon.d/msql-mysql.monitor 를 수정
- @tables = $dbh->func( '_ListTables' );
+ @tables = map { $_ =~ s/.*\.//; $_ } $dbh->tables();

# cd /usr/local/mon/alert.d
. . .에 stop-heartbeat.alert의 파일명으로 추가
#!/usr/bin/perl
#
use Getopt::Std;
use Text::Wrap;

getopts ("S:s:g:h:t:l:u");

$summary=<STDIN>;
chomp $summary;

$summary = $opt_S if (defined $opt_S);

$mailaddrs = join (',', @ARGV);

$ALERT = $opt_u ? "UPALERT" : "ALERT";

$t = localtime($opt_t);
($wday,$mon,$day,$tm) = split (/\s+/, $t);

open (HA, "| /etc/init.d/heartbeat stop") ||
die "could not open pipe to mail: $!\n";
print HA <<EOF;
To: $mailaddrs
Subject: $ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm)
X-Mailer: $0

EOF

print HA wrap ("", "", "Summary output : $summary"), "\n";

print HA <<EOF;

Group : $opt_g
Service : $opt_s
Time noticed : $t
Secs until next alert : $opt_l
EOF

print HA wrap ("", "\t\t\t", "Members : $opt_h"), "\n";

print HA <<EOF;

Detailed text (if any) follows:
-------------------------------
EOF

#
# The remaining lines normally contain more detailed information,
# but this is monitor-dependent.
#
while (<STDIN>) {
print HA;
}
close (HA);


# chmod 775 stop-heartbeat.alert

 

○기동(dbserver1의 Master측에서 기동)

# /etc/init.d/mon start &

 

○확인
mon