Customizing Performance Monitoring with Powershell MRPE Checks

I currently have a custom MRPE powershell check that behaves similarly to the Nagios check_tcp plugin. I have it set up to output performance metric data for the response time. It is configured, working, and outputting data that is being graphed. However, it is graphing using generic graphs and I would like it to graph in the same way that the check_tcp plugin graphs. I found that the check_tcp metric is configured in this file:

~/lib/python3/cmk/gui/plugins/metrics/translation.py

check_metrics["check_tcp"] = {
    "time": {"name": "response_time"},
}

The “response_time” configuration is reference in the following files:

~/lib/python3/cmk/gui/plugins/metrics/network.py
~/lib/python3/cmk/gui/plugins/metrics/perfometers.py

Upon investigation, I found a number of articles that indicated creating a custom file here with a custom check_metric that would utilize the current built in definitions for graphing:

~/local/share/check_mk/web/plugins/metrics

vi ~/local/share/check_mk/web/plugins/metrics/powershell.py

check_metrics["powershell.exe"] = {
    "time": {"name": "response_time"},
}

This did not work so I tried to add the following to get it to work based on what the above translation.py file had in it:

#!/usr/bin/env python3

from typing import Dict

from cmk.gui.plugins.metrics.utils import check_metrics, CheckMetricEntry, KB, m, MB

#  Custom metrics for powershell.exe checks

check_metrics["powershell.exe"] = {
    "time": {"name": "response_time"},
}

It still isn’t working. I was wondering what would be required to get this working for these checks? This also would include the “Service Perf-O-Meter”.

See attached images of current setup.

Thank you.

Check_tcp Graphing:

Powershell.exe Graphing:

You may try this:

metric_info["mem_total"] = {
    "title": _("Total Memory"),
    "unit": "bytes",
    "color": "33/a",
}

While “mem_total” is your metric label.

regards

Michael

1 Like

So something like this…?

#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-

from cmk.gui.i18n import _
from cmk.gui.plugins.metrics import , metric_info, check_metrics, perfometer_info

#  Custom metrics for powershell.exe checks

check_metrics["powershell.exe"] = {
    "ps_tcp_time": {"name": "ps_tcp_response_time"},
}

metric_info["ps_tcp_response_time"] = {
    "title": _("Powershell TCP Response Time"),
    "unit": "s",
    "color": "23/a",
}

perfometer_info.append(
    {
        "type": "logarithmic",
        "metric": "ps_tcp_response_time",
        "half_value": 10,
        "exponent": 4,
    }
)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.