On Tue, Jul 17, 2001 at 04:11:44PM -0500, doug wrote:
> > MySQL 3.23.29: up 31 days, processed 237,155,060 queries (87/sec. avg)
>
> Ok Jeremy I have to ask: How do you get your MySQL stats in your
> signature like that?:->
It's a bit of a hack, but you're not the first to ask... So here goes.
It's a combo of 2 things: some small muttrc file changes and a script
called `mysig' which generates the signature.
Mind you, my original goal was to simply get something in my signature
on every post to the MySQL lists so that the filter wouldn't bug me
and I wouldn't have to think about it. But once that was done, I just
took things a step or to farther... Maybe too far. :-)
Anyway, I have the following lines in my ~/.mutt/muttrc file:
---snip---
folder-hook .*mysql.* set signature="~/bin/mysig|"
folder-hook .*nusphere.* set signature="~/bin/mysig|"
---snip---
Those essentially tell mutt to use a custom signature (produced by
running ~/bin/mysig) any time I compose a message while I'm any any
folder that contains "mysql" or "nusphere" in its name. (The nusphere
bit was a leftover from the Gemini beta program.)
So what does ~/bin/mysig look like? It's a perl script which is bit
longer that it may need to be and relies on a subclass (Finance::DBI)
of a perl module (Db::MySql) that not available to the public (yet).
But you should get the basic ideas.
---snip---
#!/usr/local/bin/perl
#
# mysig - grab some mysql stats for my signature on some mailing
# lists.. Why? Because I could.
#
# Jeremy Zawodny <[EMAIL PROTECTED]>. This is GPL'd.
use strict;
use Finance::DBI;
my $db = Finance::DBI->Connect('test');
my $debug = 0;
die "$!" unless $db;
my $version = get_variable("version");
my $num_queries = get_status("Questions");
my $uptime = get_status("Uptime");
my $days_up = int($uptime / (60 * 60 * 24));
my $queries_per_sec = int($num_queries / $uptime);
$version =~ s/-log//g;
$version =~ s/-gamma//g;
$version =~ s/-alpha//g;
$version =~ s/-beta//g;
print "$num_queries $uptime $ days_up $queries_per_sec\n" if $debug;
open SIG, "</home/jzawodn/.sig" or die "$!";
print while <SIG>;
close SIG;
print "\nMySQL $version: up $days_up days, processed ", commify($num_queries), "
queries ($queries_per_sec/sec. avg)\n";
exit;
############################################################################
sub get_status($)
{
my $name = shift;
my $sql = qq[SHOW STATUS LIKE "$name"];
return ($db->Array($sql))[1];
}
sub get_variable($)
{
my $name = shift;
my $sql = qq[SHOW VARIABLES LIKE "$name"];
return ($db->Array($sql))[1];
}
sub commify($)
{
local $_ = shift;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
---snip---
For the record, I'll be talking about that elusive perl module at the
upcoming Open Source Database Summit. I'm working to clean it up so
that I can put it on CPAN this summer.
Jeremy
--
Jeremy D. Zawodny, <[EMAIL PROTECTED]>
Technical Yahoo - Yahoo Finance
Desk: (408) 349-7878 Fax: (408) 349-5454 Cell: (408) 685-5936 <-- NEW
MySQL 3.23.29: up 31 days, processed 237,496,954 queries (87/sec. avg)
---------------------------------------------------------------------
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