Watchdog für mysql in Perl?

2002-01-04 Thread Sascha Kettner

Hi!

Short question: i want to have a perl watchdog telling me when executed
if my sql-server is running and if anything is allright with it. So if i
get any errormessage i can restart the server by remote. Has someone
done this allready? Any hint?

Thanks again and best regards

Sascha Kettner


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Watchdog für mysql in Perl?

2002-01-04 Thread Erik Price

Well, you could use a shell script to run mysqladmin status.

I.e. this bash script:

#! /bin/bash

# mystatus.sh is really just a simple alias for a
# longer command.

# Usage: 'mystatus.sh PASSWORD'

# replace values of $my_hostname and $my_username if needed
my_hostname='localhost'
my_username='root'
my_password=${1}
export my_hostname my_username my_password

# execute the command
/usr/local/mysql/bin/mysqladmin -h $my_hostname -u $my_username \
 --password=$my_password status

# end of file

I tested this out with variables corresponding to my own system, I'm 
running RH Linux with MySQL 3.23.46.  You don't even have to replace the 
values in the variables section of the script with your own, if your 
MySQL server is on the localhost.  The setup as is takes the password 
from STDIN, so it's not stored anywhere (though I don't know how to 
write a script that hides the password as you type it [yet]).  I'm 
sure that you could do a better script than this in Perl, which I don't 
yet know.

I'm still learning how to write bash scripts (this is my second one that 
does anything useful) so if this code is amateurish, sorry.

Erik





On Friday, January 4, 2002, at 06:52  AM, Sascha Kettner wrote:

 Hi!

 Short question: i want to have a perl watchdog telling me when executed
 if my sql-server is running and if anything is allright with it. So if i
 get any errormessage i can restart the server by remote. Has someone
 done this allready? Any hint?

 Thanks again and best regards

 Sascha Kettner


 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Watchdog für mysql in Perl?

2002-01-04 Thread Gary . Every

I use a simple script that does the following:

--- snip ---
mysql -e SELECT * from table_name limit 1 db  2/tmp/filename
x=`cat /tmp/filename`
if [ $x =  ]
then
do_nothing=1
else
## There's an issue!
echo ERROR!
fi
--- end snip ---

Using the re-direct of stderr is the key. the 2/tmp/filename sends all
error output to the /tmp/filename file. If there are no errors, the file
will be empty.

I run it as a cron job every ten minutes, and if there is an error, it pages
me.
Keeps me in the know!

-Original Message-
From: Sascha Kettner [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 04, 2002 5:53 AM
To: [EMAIL PROTECTED]
Subject: Watchdog für mysql in Perl?


Hi!

Short question: i want to have a perl watchdog telling me when executed
if my sql-server is running and if anything is allright with it. So if i
get any errormessage i can restart the server by remote. Has someone
done this allready? Any hint?

Thanks again and best regards

Sascha Kettner


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail mysql-unsubscribe-##L=##[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php