Subject: Fw: expect parameter

From: "Jeremy Kister" <[email-masked]>
Date: Fri, 15 Oct 2004 22:28:07 -0400

On Fri, 15 Oct 2004 10:22:45 -0400, Jason 'XenoPhage' Frisvold wrote:

> expression?  I'm trying to monitor the replication status on my MySQL
> server and I want to ensure that Slave_IO_Running and Slave_SQL_Running
> are both Yes.  I believe I can do this by checking for the string "|
> Yes        | Yes" in the return of "show slave status;" ...  I just need

I dont know of a version of Mysql that shows "|Yes    | Yes"; this may be
some interpretation of some softare trying to show you columns.

the best way I've found for argus to directly monitor MySQL slave status is:
Service DB {
  dsn:	DBI:mysql:host=hostname
  user:         username
   pass:        password
   sql: show slave status
   expect:	Yes Yes
   label:	slave_status
   uname:	Status
}

this could, possibly, yield false positives, though.  To be realy _really_
sure, run some perl:

#!/usr/local/bin/perl

use strict;
use DBI;

my $hostname = shift || die "specify hostname\n";
my $dbun = 'user';
my $dbpw = 'pass';

my $dsn = "DBI:mysql:host=${hostname}";
my $dbh = DBI->connect($dsn, $dbun, $dbpw, {RaiseError =>1});
my $sql = 'SHOW SLAVE STATUS';
my $sth = $dbh->prepare($sql);
$sth->execute;
my $row = $sth->fetchrow_hashref;
my $io = $row->{Slave_IO_Running};
my $sql = $row->{Slave_SQL_Running};
$sth->finish;
$dbh->disconnect();

if(($io eq 'Yes') && ($sql eq 'Yes')){
        print "OK\n"
}else{
        print "ERROR\n";
}
__END__

and then in your argus config, just put:
 Service Prog {
   command: /usr/local/script/sqltest.pl host.example.com
   expect: ^OK
   label: SQL_SLAVE
 }

--

Jeremy Kister
http://jeremy.kister.net/

---

From: "Jason 'XenoPhage' Frisvold" <[email-masked]>
Date: Sat, 16 Oct 2004 13:35:50 -0400

>some interpretation of some softare trying to show you columns.
*nod*  Columns...   Your method is much better though..  I should have 
used something similar to begin with ...  :)

>http://jeremy.kister.net/
Thanks for the help!

-- 
---------------------------
Jason 'XenoPhage' Frisvold
Engine / Technology Programmer
[email-masked]
RedHat Certified - RHCE # 803004140609871
MySQL Pro Certified - ID# 207171862
MySQL Core Certified - ID# 205982910
---------------------------
"Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming."