pcp
[Top] [All Lists]

Re: [pcp] PMIE Help

To: chandana@xxxxxxxxxxxxx
Subject: Re: [pcp] PMIE Help
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Fri, 09 Nov 2012 07:46:35 +1100
Cc: pcp@xxxxxxxxxxx
In-reply-to: <50939986.4050203@xxxxxxxxxxxxx>
References: <50939986.4050203@xxxxxxxxxxxxx>
On Fri, 2012-11-02 at 20:59 +1100, Chandana De Silva wrote:
> All,
> 
> I am rying to write a rule to check MySQL Slave lag.
> 
> I have a simple rule which works, as shown below. What I want to have
> is a slightly more complex rule which also prints the rate of change,
> which the number of seconds the slave has caught up or lost in the 
> last minute. I think I can get that with the calculation for
> lag_rateofchange.
>  I need to have a rule which is something like;
> 
> $replication_lag >= $lag_critical && $lag_rateofchange >0
>     -> shell "$send_nagios -S MySQL_Replication -s 1 Slave %v seconds
> behind master, catching up at <X> seconds per minute\n";
> 
> How can I get the value of $ lag_rateofchange in the ouput text ? ( I
> have tried a second %v as suggested by the pmie man page, but that
> repeated the first value.)

Chandana,

Sorry for the tardy response ... foreshadows that there is not a good
answer to your question ... 8^(>

One of the weaknesses of the pmie "language" is the inability to extract
values from arbitrary parts of the expression predicate and paste them
into action parameters.  %v (and in fact %h and %i also) is a special
case "hack" ... from the man page the qualifier "left-most top-level
expression in the condition" pretty much means there is only ONE
expression that can be picked out.

In your example (after macro expansion) the rule is

mysql.slave_status.seconds_behind_master >= 3600 &&
(( mysql.slave_status.seconds_behind_master @0 - 
mysql.slave_status.seconds_behind_master @1 )) > 0

Since there are no instances or hosts in the expression, %v will be
bound to the value of mysql.slave_status.seconds_behind_master when the
predicate is true and rule is executed.

To get the <X> you're after would need something even more
complicated ... <X> is really the difference between
mysql.slave_status.seconds_behind_master now and
mysql.slave_status.seconds_behind_master at the previous sample all
divided by $delta for this rule ... you can get this from _another_
rule, like this

(mysql.slave_status.seconds_behind_master @0 - 
mysql.slave_status.seconds_behind_master @1) / $delta > 0 &&
mysql.slave_status.seconds_behind_master >= 3600

I'm curious where the reference to a second %v is in the pmie(1) man
page ... that would be wrong and should be corrected.

Sorry, not the answer you were hoping for.


<Prev in Thread] Current Thread [Next in Thread>