MySQL facter

Yesterday I started to play with mcollective I added some agents like service and facter. I really liked the facter agent.... and then I decided to add facts for MySQL. Of course I needed to learn some ruby first :-) A fact is created for the version and all other MySQL facts come from the SHOW STATUS statement. All the new facts start by mysql_ I plan to add new facts related to the replication like Seconds_Behind_Master The current version is available on github here

Some usage examples:

with facter:
[root@delvaux facter]# facter mysql_version 2>/dev/null
5.5.10
[root@delvaux facter]# facter mysql_max_used_connections 2>/dev/null
3
with mcollective:
[root@delvaux facter]# mc-facts mysql_version
Report for fact: mysql_version

        5.0.51a-24+lenny5-log                   found 1 times
        5.5.10                                  found 1 times

Finished processing 2 / 2 hosts in 64.36 ms



[root@delvaux facter]# mc-facts mysql_open_files
Report for fact: mysql_open_files

        16                                      found 1 times
        18                                      found 1 times

Finished processing 2 / 2 hosts in 2418.13 ms

[root@delvaux facter]# mc-facts mysql_open_files -v
Determining the amount of hosts matching filter for 2 seconds .... 2
Report for fact: mysql_open_files

        16                                      found 1 times

            delvaux.maladree.be

        18                                      found 1 times

            debian1.maladree.be


---- rpc stats ----
           Nodes: 2 / 2
     Pass / Fail: 0 / 0
      Start Time: Sat Apr 02 00:11:46 +0200 2011
  Discovery Time: 2001.84ms
      Agent Time: 1344.24ms
      Total Time: 3346.08ms

[root@delvaux facter]# mc-facts mysql_threads_connected 
Report for fact: mysql_threads_connected

        2                                       found 2 times

Finished processing 2 / 2 hosts in 3270.86 ms

[root@delvaux facter]# mc-facts mysql_threads_connected -v
Determining the amount of hosts matching filter for 2 seconds .... 2
Report for fact: mysql_threads_connected

        2                                       found 2 times

            debian1.maladree.be
            delvaux.maladree.be


---- rpc stats ----
           Nodes: 2 / 2
     Pass / Fail: 0 / 0
      Start Time: Sat Apr 02 00:12:47 +0200 2011
  Discovery Time: 2001.73ms
      Agent Time: 50.43ms
      Total Time: 2052.15ms

Yesterday I started to play with mcollective

I added some agents like service and facter.

I really liked the facter agent…. and then I decided to add facts for MySQL.
Of course I needed to learn some ruby first 🙂

A fact is created for the version and all other MySQL facts come from the SHOW STATUS statement.

All the new facts start by mysql_

I plan to add new facts related to the replication like Seconds_Behind_Master

The current version is available on github here

Some usage examples:

with facter:

[root@delvaux facter]# facter mysql_version 2>/dev/null
5.5.10
[root@delvaux facter]# facter mysql_max_used_connections 2>/dev/null
3

with mcollective:

[root@delvaux facter]# mc-facts mysql_version
Report for fact: mysql_version

        5.0.51a-24+lenny5-log                   found 1 times
        5.5.10                                  found 1 times

Finished processing 2 / 2 hosts in 64.36 ms



[root@delvaux facter]# mc-facts mysql_open_files
Report for fact: mysql_open_files

        16                                      found 1 times
        18                                      found 1 times

Finished processing 2 / 2 hosts in 2418.13 ms

[root@delvaux facter]# mc-facts mysql_open_files -v
Determining the amount of hosts matching filter for 2 seconds .... 2
Report for fact: mysql_open_files

        16                                      found 1 times

            delvaux.maladree.be

        18                                      found 1 times

            debian1.maladree.be


---- rpc stats ----
           Nodes: 2 / 2
     Pass / Fail: 0 / 0
      Start Time: Sat Apr 02 00:11:46 +0200 2011
  Discovery Time: 2001.84ms
      Agent Time: 1344.24ms
      Total Time: 3346.08ms

[root@delvaux facter]# mc-facts mysql_threads_connected 
Report for fact: mysql_threads_connected

        2                                       found 2 times

Finished processing 2 / 2 hosts in 3270.86 ms

[root@delvaux facter]# mc-facts mysql_threads_connected -v
Determining the amount of hosts matching filter for 2 seconds .... 2
Report for fact: mysql_threads_connected

        2                                       found 2 times

            debian1.maladree.be
            delvaux.maladree.be


---- rpc stats ----
           Nodes: 2 / 2
     Pass / Fail: 0 / 0
      Start Time: Sat Apr 02 00:12:47 +0200 2011
  Discovery Time: 2001.73ms
      Agent Time: 50.43ms
      Total Time: 2052.15ms

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

2 Comments

  1. I’ve added also facts from the SHOW SLAVE STATUS statement.

    Those facts are prefixed with mysql_replica_

    Example:

    [root@delvaux facter]# mc-facts mysql_replica_slave_sql_running -v
    Determining the amount of hosts matching filter for 2 seconds .... 3
    Report for fact: mysql_replica_slave_sql_running
    
             Yes                                    found 2 times
    
                debian1
                debian2
    
    
    ---- rpc stats ----
               Nodes: 3 / 3
         Pass / Fail: 0 / 0
          Start Time: Sat Apr 02 23:22:31 +0200 2011
      Discovery Time: 2005.77ms
          Agent Time: 51.02ms
          Total Time: 2056.79ms
    
  2. I just added a new fact to see the server version (from @@version_comment) :

    [root@nodea facter]# facter mysql_version_server
    Percona Server (GPL), Release beta20.0, Revision 46
    
    [root@delvaux facter]# facter mysql_version_server
    MySQL Community Server (GPL) by Remi
    

Leave a Reply

Your email address will not be published. Required fields are marked *

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.