no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | monitors:bb-mysql [2010/03/13 09:11] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== bb-mysql ====== | ||
| + | |||
| + | ^ Author | [[ cgoyard@cvf.fr | Charles Goyard ]] | | ||
| + | ^ Compatibility | Xymon 4.2 | | ||
| + | ^ Requirements | Perl, MySQL, unix | | ||
| + | ^ Download | None | | ||
| + | ^ Last Update | 2006-11-22 | | ||
| + | |||
| + | ===== Description ===== | ||
| + | |||
| + | bb-mysql - mysql check and metrics | ||
| + | |||
| + | ===== Installation ===== | ||
| + | ==== Client Configuration ==== | ||
| + | * First, create a dumb user that can do status and show variables : | ||
| + | * grant select on devnull.* to monitoring@localhost identified by ' | ||
| + | * revoke all on devnull.* from monitoring@localhost; | ||
| + | * or use the config file $BBHOME/ | ||
| + | * mysqlclient=/ | ||
| + | * auth=-uhobbitmon -phobbitmonlogintomonitor -Sothersocket | ||
| + | * Copy code below to client/ | ||
| + | * Add the following to client/ | ||
| + | [mysql] | ||
| + | #DISABLED | ||
| + | ENVFILE $HOBBITCLIENTHOME/ | ||
| + | CMD $HOBBITCLIENTHOME/ | ||
| + | LOGFILE $HOBBITCLIENTHOME/ | ||
| + | INTERVAL 5m | ||
| + | </ | ||
| + | |||
| + | ==== Server Configuration ==== | ||
| + | None | ||
| + | |||
| + | ===== Source ===== | ||
| + | ==== bb-mysql.pl ==== | ||
| + | <hidden onHidden=" | ||
| + | <code perl> | ||
| + | # | ||
| + | # | ||
| + | # bb-mysql - mysql check and metrics | ||
| + | # cgoyard: | ||
| + | |||
| + | use strict; | ||
| + | |||
| + | my $DEBUG | ||
| + | |||
| + | $ENV{BBPROG} | ||
| + | my $TESTNAME | ||
| + | |||
| + | my $BBHOME | ||
| + | my $BB = $ENV{BB}; | ||
| + | my $BBDISP | ||
| + | my $BBVAR | ||
| + | my $MACHINE | ||
| + | my $COLOR | ||
| + | my $MSG = ""; | ||
| + | my $HEAD = ""; | ||
| + | my $DATA = ""; | ||
| + | |||
| + | if ($DEBUG == 1) { | ||
| + | $BBHOME | ||
| + | $BB = "/ | ||
| + | $BBDISP | ||
| + | $BBVAR | ||
| + | $MACHINE |= " | ||
| + | } | ||
| + | |||
| + | sub clear; sub green; sub yellow; sub red; | ||
| + | sub setcolor; sub head; sub msg; sub data; | ||
| + | sub sendreport; sub resetreport; | ||
| + | |||
| + | |||
| + | ###################################################################### | ||
| + | # here we go | ||
| + | ############ | ||
| + | |||
| + | # First, create a dumb user that can do status and show variables : | ||
| + | # grant select on devnull.* to monitoring@localhost identified by ' | ||
| + | # revoke all on devnull.* from monitoring@localhost; | ||
| + | # or use the config file $BBHOME/ | ||
| + | # mysqlclient=/ | ||
| + | # auth=-uthisuser -pthatpassword -Sothersocket | ||
| + | |||
| + | |||
| + | my $auth = " | ||
| + | my $client | ||
| + | my $confnotfound = 0; | ||
| + | if(open(CONF, | ||
| + | my $line; | ||
| + | while($line = < | ||
| + | if($line =~ / | ||
| + | $client = $2; | ||
| + | } | ||
| + | elsif($line =~ / | ||
| + | $auth = $2; | ||
| + | } | ||
| + | } | ||
| + | close(CONF); | ||
| + | } | ||
| + | else { | ||
| + | $confnotfound = 1; | ||
| + | } | ||
| + | |||
| + | my (@output, $version, $metrics, $uptime, $maxcon, $ts); | ||
| + | @output = `$client $auth -Bs -e " | ||
| + | if($? == 0 and $output[0] =~ / | ||
| + | $ts = $1; | ||
| + | green; | ||
| + | } | ||
| + | else { | ||
| + | head(" | ||
| + | msg("& | ||
| + | msg(" | ||
| + | red; | ||
| + | sendreport; | ||
| + | exit 1; | ||
| + | } | ||
| + | |||
| + | # metrics | ||
| + | foreach (@output) { | ||
| + | if ( /^Server version: | ||
| + | elsif ( / | ||
| + | elsif ( / | ||
| + | elsif ( / | ||
| + | } | ||
| + | |||
| + | $metrics =~ s/ | ||
| + | msg $metrics; | ||
| + | head(" | ||
| + | msg " | ||
| + | msg " | ||
| + | msg(" | ||
| + | sendreport; | ||
| + | exit 0; | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ###################################################################### | ||
| + | # toolbox | ||
| + | ########### | ||
| + | |||
| + | #### | ||
| + | # sends the report | ||
| + | #### | ||
| + | |||
| + | sub sendreport | ||
| + | { | ||
| + | $MACHINE =~ s/\./,/g; | ||
| + | my $date = localtime; | ||
| + | my $cmd = "$BB $BBDISP \" | ||
| + | system($cmd); | ||
| + | } | ||
| + | |||
| + | sub resetreport | ||
| + | { | ||
| + | $MSG = $DATA = $HEAD = ''; | ||
| + | $COLOR = ' | ||
| + | } | ||
| + | |||
| + | # sets the global color of the test | ||
| + | # prevents downgrading severity | ||
| + | # clear == green < yellow < red | ||
| + | sub setcolor | ||
| + | { | ||
| + | my $newcolor = shift; | ||
| + | if($newcolor eq " | ||
| + | $COLOR = " | ||
| + | } | ||
| + | elsif($COLOR eq " | ||
| + | $COLOR = " | ||
| + | } | ||
| + | |||
| + | return $COLOR; | ||
| + | } | ||
| + | sub clear { setcolor ' | ||
| + | sub green { setcolor ' | ||
| + | sub yellow { setcolor ' | ||
| + | sub red { setcolor ' | ||
| + | |||
| + | |||
| + | sub data | ||
| + | { | ||
| + | my ($n, $v) = @_; | ||
| + | $DATA .= "$n: $v\n"; | ||
| + | } | ||
| + | |||
| + | sub head | ||
| + | { | ||
| + | $HEAD = " | ||
| + | } | ||
| + | |||
| + | sub msg | ||
| + | { | ||
| + | $MSG .= join(" | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== Known Bugs and Issues ===== | ||
| + | None | ||
| + | |||
| + | ===== To Do ===== | ||
| + | |||
| + | ===== Credits ===== | ||
| + | |||
| + | Reimplementation of [[http:// | ||
| + | |||
| + | ===== Changelog ===== | ||
| + | |||
| + | * **2006-07-18** | ||
| + | * Initial release | ||