List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:December 15 2006 7:53pm
Subject:Re: insert into some table show status like 'foo'
View as plain text  
At 11:12 AM -0800 12/15/06, Chris Comparini wrote:
>Hello,
>
>Say I wanted to log some various server status variables to
>a table.  What I'd like to do, ideally, is something like
>this:
>
>insert into SomeLogTable (Threads) show status like 'Threads_running';
>
>MySQL does not allow this, of course.  But, is there some other way
>to see the "Threads_running" (or other status variables) such that
>this would be possible?
>
>Incidentally, one of the things I'd like to log thus is the slave
>status "Seconds_Behind_Master".  It's a little disappointing that
>you cannot do this:
>
>show slave status like 'Seconds_Behind_Master';
>
>.. but rather have to get the entire slave status back in order
>to see this one thing.  Anyway...
>
>If anyone has any ideas on this, I'd love to hear them.
>


If you're referring to MySQL status vars and you are using MySQL >= 
5.0, you can indeed do this. For example:

mysql-5.0.15-log@localhost> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
1 row in set (0.00 sec)

mysql-5.0.15-log@localhost> select @@wait_timeout;
+----------------+
| @@wait_timeout |
+----------------+
|          28800 |
+----------------+
1 row in set (0.00 sec)

Strangely, at least for me not all system vars can be accessed this 
way; I haven't been able to see many innodb_... variables. But I 
haven't played with this much, I might be doing something wrong.

For more info, see:

	http://dev.mysql.com/doc/refman/5.0/en/using-system-variables.html


    - steve

-- 
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg                                http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center                            sbedberg@stripped |
| Bioinformatics programming/database/sysadmin             (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
Thread
insert into some table show status like 'foo'Chris Comparini15 Dec
  • RE: insert into some table show status like 'foo'Mikhail Berman15 Dec
    • Re: insert into some table show status like 'foo'Chris Comparini15 Dec
  • Re: insert into some table show status like 'foo'Steve Edberg15 Dec
    • Re: insert into some table show status like 'foo'Chris Comparini16 Dec