Hi Chandana,
----- Original Message -----
> All,
>
> I am trying to monitor a MySQL slave using PCP. I have installed the
> MySQL PMDA, and can see some values using pminfo -f mysql
Ah, good stuff, that's half the battle with the database PMDAs.
> The mysql.status.com_show_slave_statusseems to be a counter of some
> sort;
> mysql.status.com_show_slave_status
> Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff
> Semantics: counter Units: count
That'd be a row from "show status". It might be the number of
times "show slave status" has been called? Not sure - if you
find out, lemme know, we could add in some metric help text.
> What I am interested in seeing is this information below some form,
> as I
> need to specifically monitor the 'seconds behind master' value from
> pmie. Can someone help, please ?
>
> mysql> show slave status \G
I don't have a setup to test this, but I can take you through what
is needed. Its fairly straightfwd, I've attached a little patch to
show the approach, described below (top to bottom in the patch).
Firstly, we'll need to extend mysql_connection_setup() to setup a
cursor for reading the results from "show slave status" as this is
a new SQL command to the PMDA.
Then we'll need a mysql_slave_status_refresh() routine to harvest
the results from the new query.
Then we extend mysql_refresh() to associate the next free cluster
of metrics (3) with our new value harvester. This is called once
per pmFetch(3); in this case, it'll be the pmie sampling interval
that defines the rate.
Then we add a clause in the mysql_fetch_callback() to marshal the
data from the last SQL query (which we stuck in %slave_status),
into a form that can then be packed into the PDU sent back to the
client (pmie). This can be called multiple times per pmFetch, if
we are querying multiple metric values at once (hence, we don't
want to do the SQL query here).
Finally, we define the new metric - note it is in cluster 3. The
name is important too, it must match the name stored earlier into
the %slave_status hash as mysql_fetch_callback uses that as the
hash key.
So ... that should be pretty close to working, may have missed a
thing or two - lemme know how it goes. Once that metric exists,
the pmie rule should pretty much write itself; something like...
bad_slave = (mysql.slave_status.seconds_behind_master > 5)
-> system 10minutes "mail -s 'The slaves are revolting, %v sec lag'
</dev/null chandana@xxxxxxxxxxxxx"
cheers.
--
Nathan
chandana.patch
Description: Text Data
|