Perf-o-meter to work with custom local checks

I can’t get perf-o-meter to work with custom local checks. There is no instruction on the document on how to do this.

I have written local check plugin for which i need perf-ometr. So please let me know how to get the same.

Any help appreciated

Thanks

What you need is the performance data output from your local check.
If you use there well known descriptions then you get automatically a perf-o-meter.
As an example use “threads” as the name of your performance data and you will get the same perf-o-meter as for the Linux threads check.

That means if you have a performance value where no perf-o-meter is existing the definition has to be done the same way as for any other perf-o-meter.

1 Like

Hello @andreas-doehler,

Below is my local check code

#!/bin/bash
echo “<<>>”

node_status="$(curl -s “http://localhost:9200/_cat/health?h=status” 2>&1)"
active_shards="$(curl -s "http://localhost:9200/_cat/health?h=active_shards_percent")"

case $node_status in
[gG][rR][eE][eE][nN])
status=0;
msg=“The nodes are up, the shards for each index are loaded and the replicas have been recovered on a separate nodes and active shards=$active_shards”;
;;
[yY][eE][lL][lL][oO][wW])
status=1;
msg=“Not all replicas have been recovered. If a node goes down, there can be data loss and active shards=$active_shards”;
;;
*)
status=2;
msg=“some primary data shards are missing. This means there data loss right now. This is bad but not disastrous as some nodes might still be rebooting.and active shards=$active_shards”;
;;
esac

echo “$status ELASTIC_SEARCH - $msg”

and below is the output that i am getting in checkmk that is Elastic search output in warn state

So what changes to be done to get perform-o-meter for Elastic search for that active_shards(50%)

Thanks

Your local check don’t generate performance data. Without performance data no graph or perf-o-meter.
Please read the documentation to this here Local checks

Hello @andreas-doehler,

Gone through the link(https://checkmk.com/cms_localchecks.html#perfdata) mentioned

Changed the script
#!/bin/bash
echo “<<>>”

node_status="$(curl -s “http://localhost:9200/_cat/health?h=status” 2>&1)"
active_shards="$(curl -s "http://localhost:9200/_cat/health?h=active_shards_percent")"

case $node_status in
[gG][rR][eE][eE][nN])
status=0;
msg=“Elastic search in $node_status state with active shards=$active_shards”;
;;
[yY][eE][lL][lL][oO][wW])
status=1;
msg=“Elastic search in $node_status state with active shards=$active_shards”;
;;
*)
status=2;
msg=“Elastic search in $node_status state with active shards=$active_shards”;
;;
esac

echo “$status ELASTIC_SEARCH count=$active_shards $msg”

please let me know how to get the perf-o-meter for the same this activeshards



Thanks

If you use a not already defined metric you need to define it. And then you can use this metric in a perf-o-meter.

This is a very easy example from one of my own checks.
The file must be placed inside “~/local/share/check_mk/web/plugins/metrics/”

metric_info["perc"] = {
    "color" : "#60f020",
    "unit"  : "%",
    "title" : _("Percent"),
    "help"  : _("Generic Percent usage"),
}

perfometer_info.append({
    "type"     : "linear",
    "metric"   : "perc",
    "segments" : ["perc"],
    "total"    : 100.0,
})

If you need some inspiration for your own definitions, you can look at the file
“~/lib/python/cmk/gui/plugins/metrics/check_mk.py” section “Metrics” and “Perf-O-Meters”
This is also advised to check if your metric is already defined and only the perf-o-meter is missing.

1 Like

Hello @andreas-doehler,

Is this path local/share/check_mk/web/plugins/perfometer.
/lib/python/cmk/gui/plugins/metrics/check_mk.py

in check mk server or in the host server which is added in the checkmk and in which i have added my local plugin?

All what you do, you do only on the monitoring server if you want to change something inside your web front end.

I don’t understand what you mean with the “perfometer” directory?

Actually i have added my local plugin inside “/usr/lib/check_mk_agent/plugins” inside the host which i have added in the checkmk and done the full scan of the host in the check so that local service will be visible in the checkmk.

so can we do any further changes related to perf-o-meter in this the host itself .
Since if we are doing any changes in the monitoring that is checkmk server , i guess it will get affected to all the host which is added in the check-mk and i need it should be reflected in that particular host only in the local plugin i have created.

Please let me know how to proceed further

I don’t understand - you want to change your display of information. This can only be done on the monitoring server. You monitored host only produces data that is interpreted and shown by the monitoring system.

I wrote before you can use a well known metric name like my example with the metric name “threads” then you have to do nothing and it shows you a perf-o-meter.

That’s why i also gave you the information about the file with the definitions of the perf-o-meters and metrics known by the system. You can select one and use the metric name in your check - finished.

1 Like

Helo @andreas-doehler,

So under monitoring server
/local/share/check_mk/web/plugins/metrics/mysql.galera_cluster.py

Inside this mysql.galera_cluster.py along with other metric we need to add for our local one for perf-o-meter

since i have the local plugin in the particular host check_mk_agent which gives four out put

echo “$status ELASTIC_SEARCH count=$active_shards $msg” from this host we cant do anything for perf-o-meter
since plugin script i have added in the host server only
and didnt done anything in the checkmk .to check if its working from checkmk
we just do “telnet hostname portno” , to see the plugin output working.

so i mean from that script output (echo “$status ELASTIC_SEARCH count=$active_shards $msg”), we cant do anything.

After your last post i think you don’t read the manual link i posted and also had no look at my example for a local check.

I say it again - the only important part is the name of your metric
For this name the system must know what to do. If you use a well known metric then you have to do nothing as the system already knows how to handle this. If you use a metric name like your generic “count” then you need to tell the system what to do.

This is then where my example is needed as a definition for the “what to do”

2 Likes

Hello @andreas-doehler,

Thanks a ton for your patience and all the guiding. But still the issue persist

In you example I guess in your local check in the output you are giving I guess “thread” is your metric name , for me its count:$ active-shards (which I am taking the value from curl output)

active_shards="$(curl -s "http://localhost:9200/_cat/health?h=active_shards_percent")"%22)
" echo “$status ELASTICSEARCH count=$active_shards $msg”. "

Lets take an example
let my monitoring server that is (checkmk server ) be. : abc
and host which is added in the checkmk be : xyz and many other hosts
Now I have created local plugin in “xyz” in “/usr/lib/check_mk_agent/plugins”
and in side that local script at the end I have given

" echo “$status ELASTICSEARCH count=$active_shards $msg”. "
status , service name and count which which give me graph and msg
Now I need perf-o-meter for this count value as well
For that you said we need to do changes in the monitoring server that is in our case is “abc” server . we need to add in this path “/local/share/check_mk/web/plugins/metrics/” right

As in your case your metric name is “thread” and in your example my example
when you save this with thread.py under “/local/share/check_mk/web/plugins/metrics/” with the script
how abc that is checkmk monitoring server get to know this metric saved in “abc” server under “/local/share/check_mk/web/plugins/metrics/” is to be executed for the local check created in the “xyz” host only not any other host added in the “abc” checkmk monitoring server . And how in your example “thread” is the metric name in local check but in the
path you mentioned “/local/share/check_mk/web/plugins/metrics/”
metric_info[“perc”] … “perc” is mentioned. how they are related

Please help me to resolve the same
Thanks

Hello @andreas-doehler,

Under local/share/check_mk/web/plugins/metrics#
I have elasticsearch.py

metric_info[“count”] = {
“color” : “#60f020”,
“unit” : “%”,
“title” : _(“Percent”),
“help” : _(“Generic Percent usage”),
}

perfometer_info.append({
“type” : “linear”,
“metric” : “count”,
“segments” : [“perc”],
“total” : 100.0,
})

I have added this and "count ", I have given “count” as metric name since as in local check plugin script

Local check end script is "echo “$status ELASTICSEARCH count=$active_shards $msg”. "

output as :
“1 ELASTICSEARCH count=50.0% WARN - Shards:50.0% - Elastic search in yellow”

where count shows that graph
![Screenshot 2020-12-07 at 3.34.55 PM|690x75]

(upload://gEAS07mV3779N5QrDzM6wxrkuAA.png)

so do we need to add anything like

parameters[“check-mk_local”]=…

I am not sure .

I am getting below error.
Exception: “half-value” in service perf-o-meter

Please help me for this . Please

It would be good to have only one thread for the same topic and not multiple.
@r.sander already gave you a working perf-o-meter only that it was not a 0 to 100 percent scale but logarithmic.

An example for 100 percent perf-o-meter looks like this one.

perfometer_info.append({
    "type": "linear",
    "segments": ["mem_used_percent"],
    "total": 100.0,
}) 

And i say it again, please format your code in the posts - with your actual postings no one can say if there is an indentation error or not.

1 Like

Hello @andreas-doehler,
Local check end script is "echo “$status ELASTICSEARCH active_shards=$active_shards $msg”. "

active_shards, I have found in “/lib/python/cmk/gui/plugins/metrics/check_mk.py”

now I am getting he perf-o-meter without adding anything in “/local/share/check_mk/web/plugins/metrics/”

since the active_shards is already present in “/lib/python/cmk/gui/plugins/metrics/check_mk.py”

One query , will it affect any existing perf-o-meter if we are using that metric name in our local

You cannot redeclare count as a metric with percentage as unit. Count is already used elsewhere and usually has no unit.

active_shards is also not a good metric name is the metrics also does not have percentage as unit. I have not seen this before. You need to come up with a new unique metric name.

Hello @andreas-doehler
@r.sander,

In my local check plugin in the end

"echo “$status ELASTICSEARCH shards=$active_shards $msg”.
I am giving

So shards is a the name of the performance data

So we need to mention this new metrics and Also perfometer

  1. So for that I have mentioned under “local/share/check_mk/web/plugins/metrics”
    added a file “Elasticsearch.py”
    with


    But not getting perf-o-meter related anything

  2. But where to mention this is for local like
    parameters[“check-mk_local”]=…

where to mention perfometer definition?
so that it will get to know its for local check plugin and for this host and all

  1. If in the local check plugin , I am giving metrics name as active_shards

"echo “$status ELASTICSEARCH active_shards=$active_shards $msg”.

Without doing anything perf-o-meter , I am getting.

So to write my own metrics like this how to resolve above 2 steps . Am I missing anything .
Or is it ok to use any metric name like thread or active_shards so that we don’t have to create any new ?
Please let me know

Hello @andreas-doehler,

we don’t have define metic name here?
andreas-doehler

Hello @andreas-doehler
@r.sander,

can you please help me fo this please