心想事成
sinxadmin
全部博文(75)
Python(1)
Java(0)
Perl(6)
Shell(5)
Oracle(32)
Mysql(8)
Solaris(0)
HP(0)
AIX(0)
Linux(16)
2011年(1)
2010年(9)
2009年(65)
cynthia
浪花小雨
hongwent
damoluom
s2t61
分类: LINUX
2009-04-24 14:24:25
#!/usr/bin/perl ##################################################################### # require 5.004; sub usage; my $TIMEOUT = 15; my $MYSQL = "mysql"; my %ERRORS = ('UNKNOWN' , '-1', 'OK' , '0', 'WARNING', '1', 'CRITICAL', '2'); my $host = shift || &usage(%ERRORS); my $user = shift || &usage(%ERRORS); my $pass = shift || ""; my $TABLE = shift || "mysql"; my $warn = shift || 20; my $crit = shift || 30; my $state = "OK"; my $count = 0; my $status = ""; # Just in case of problems, let's not hang Nagios $SIG{'ALRM'} = sub { print ("ERROR: No response from MySQL server (alarm)\n"); exit $ERRORS{"UNKNOWN"}; }; alarm($TIMEOUT); open (OUTPUT, "$MYSQL -h $host -u $user --password=\"$pass\" $TABLE -e 'show tables;' | wc -l 2>&1 |"); while (<OUTPUT>) { if (/failed/) { $state="CRITICAL"; s/.*://; last; } chomp; $count = $_ - 1; } if ($count >= $warn) { $state = "WARNING"; } if ($count >= $crit) { $state = "CRITICAL"; } $status = "Tables $state - $count Tables\n"; print $status; exit $ERRORS{$state}; sub usage { print "Required arguments not given!\n\n"; print "MySQL table count plugin for Nagios, V1.01\n"; print "Copyright (c) 2005 Brian Zammit \n\n"; print "Usage: check_mysql.pl [ [ []]]\n\n"; print " = password to use for at \n"; print " = table to use\n"; print " = number of threads to warn us about\n"; print " = number of threads to scream at us about\n"; exit $ERRORS{"UNKNOWN"}; } 阅读(1044) | 评论(0) | 转发(0) | 0 上一篇:check_mysql_stats 下一篇:mysql完全备份 给主人留下些什么吧!~~ 评论热议 请登录后评论。 登录 注册
上一篇:check_mysql_stats
下一篇:mysql完全备份
登录 注册