pcp
[Top] [All Lists]

Re: [pcp] zbxpcp: add derived metrics support

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] zbxpcp: add derived metrics support
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Fri, 19 Feb 2016 10:20:09 +0200
Cc: pcp developers <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <1756331291.21417357.1455663060401.JavaMail.zimbra@xxxxxxxxxx>
Organization: Red Hat
References: <56BAF517.4030300@xxxxxxxxxx> <561951755.20107378.1455148828758.JavaMail.zimbra@xxxxxxxxxx> <56C35FEA.7080703@xxxxxxxxxx> <1756331291.21417357.1455663060401.JavaMail.zimbra@xxxxxxxxxx>
Reply-to: Marko Myllynen <myllynen@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
Hi,

On 2016-02-17 00:51, Nathan Scott wrote:
> ----- Original Message -----
>> [...]
>>> Looks good - warrants a tweak to qa/1067 to regression test it?
>>
>> Metrics with instances wouldn't work if the style fix would break things
>> so I think we're ok in that sense
> 
> Oh, I meant for the derived metric config support, not the style fix up.
> 
> Such a simple change, maybe its borderline - but it might be good to have
> a regression check that if the file name (monster) is in place, and has a
> valid (or invalid) content, then good stuff (or appropriate error) happens.
> Up to you, its simple stuff - lemme know if you think its worth it; if not
> I think we can just push in that pmLoadDerivedConfig patch as-is.

What do you think about this? $sudo must be defined in order this to work.

---
 qa/1067     | 18 ++++++++++++++++--
 qa/1067.out |  4 ++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/qa/1067 b/qa/1067
index 6c24bae..3f3f6a5 100755
--- a/qa/1067
+++ b/qa/1067
@@ -18,19 +18,27 @@ which zabbix_agentd >/dev/null 2>&1 || \
 test -f /etc/zabbix/zabbix_agentd.conf || \
        _notrun "No configuration for the Zabbix agent daemon"
 grep -q zbxpcp /etc/zabbix/zabbix_agentd.conf || \
-       _notrun "No configuration of the Zabbix PCP module"
+       _notrun "No configuration of the Zabbix agent PCP module"
 
 status=1       # failure is the default!
 control=$PCP_PMDAS_DIR/sample/dynamic.indom
+derived=/etc/zabbix/zbxpcp-derived-metrics.conf
 $sudo rm -rf $tmp $tmp.* $seq.full
 
+if ! test -f $derived; then
+  $sudo touch $derived
+  clean_derived=$derived
+fi
+
 _cleanup()
 {
     _restore_config $control
-    rm -f $tmp.*
+    _restore_config $derived
+    $sudo rm -f $tmp.* $clean_derived
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 _save_config $control
+_save_config $derived
 
 _filter_values()
 {
@@ -77,6 +85,12 @@ echo '2 two' >>$tmp.indom
 $sudo cp $tmp.indom $control
 zabbix_agentd -p | fgrep pcp.sample. | _filter_values
 
+# derived metrics
+echo mem.util.allcache = mem.util.cached + mem.util.slab | $sudo tee $derived
+echo sample.derived.hundredten = sample.float.hundred + sample.double.ten | 
$sudo tee -a $derived
+zabbix_agentd -t pcp.mem.util.allcache | _filter_values
+zabbix_agentd -t pcp.sample.derived.hundredten | _filter_values
+
 # success, all done
 status=0
 exit
diff --git a/qa/1067.out b/qa/1067.out
index 4c55831..9d3e6c7 100644
--- a/qa/1067.out
+++ b/qa/1067.out
@@ -170,3 +170,7 @@ pcp.sample.dupnames.two.float.ten             VALUE
 pcp.sample.dupnames.two.double.ten            VALUE
 pcp.sample.dupnames.three.bin[bin-100]        VALUE
 pcp.sample.dupnames.three.write_me            VALUE
+mem.util.allcache = mem.util.cached + mem.util.slab
+sample.derived.hundredten = sample.float.hundred + sample.double.ten
+pcp.mem.util.allcache                         VALUE
+pcp.sample.derived.hundredten                 VALUE

Thanks,

-- 
Marko Myllynen

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