The strange world of checkmk packages/plugins

Hi,

CheckMK Free version 2.0

I’m trying to install and setup DFSR backlog plugin :

https://exchange.checkmk.com/p/dfs-backlog-1

The package is installed and enabled

There is no documentation to explain how to use this package…

There is 2 files :
dfs_backlog.ps1
dfs_backlog.py

What are the role of this files and where to put them ?

I have to bake a new MSI agent ?

How can i activate a rule ?

The world of checkmk plugin & rules is a little bit strange to use, do you have some advice to use this DFSR backlog check ?

thanks
regards

I put the dfs_backlog.ps1 in C:\ProgramData\checkmk\agent\plugins

When i restart the agent , i have this error in logs :
Sync Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is Failed

the agent is now unreachable

After remove dfs_backlog.ps1 from host plugin directory , the agent is OK but nothing is monitoried for DFSR

Plugin management is a nightmare in checkmk …

Hi John
did you follow this article? Checkmk extension packages (MKPs) - Integrating extensions from the community into Checkmk
Some plugins have a really long runtime and can easily make the agent unresponsive.
You can configure the agent to execute the plugins asinc and cache to prevent this here:
C:\ProgramData\checkmk\agent\check_mk.user.yml
Have also a look here:
Monitoring Windows - The agent for Windows in detail
PS: 2.0 is out of support, consider updating to at leat 2.1.

BR
Thomas

Hi Thomas,

Thank you for your answer

In fact I’ve already looked at this documentation.

What I don’t understand :

  • When you install the MKP dfs-backlog-2.0 plugin, you don’t see anything in the discovery rules or in the agent rules.

  • The plugin project GitHub - ellr/checkmk_dfs_backlog: Checkmk plugin for dfs_backlog check does not indicate where to put the 2 files.

  • In Windows, the existing plugins are all stored in C:\Program Files (x86)\checkmk\service\plugins in which I added the ps1 in this folder.

  • If you put a plugin in this path: C:\ProgramData\checkmk\agent\plugins the plugin service crashes so I deduce that the folder which should contain the plugin is in the path C:\Program Files (x86)\checkmk\ and not C:\ProgramData\checkmk.

  • Where should the .py file be stored? after su - mysite , i found the py file in ./local/lib/python3/cmk/base/plugins/agent_based/dfs_backlog.py

  • How do I find the DFSR options in ChecMK? Discovery rules? Agent rules? The plugin options are nowhere to be found.

I don’t understand the logic and process of this plugin

thx
Regards,

Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'  is  sync with age:0 timeout:60 retry:0
2024-02-02 11:31:04.864 [srv 79532] [Trace] Left [1] files to execute in 'plugins'
2024-02-02 11:31:04.865 [srv 79532] [Trace] To start [1] sync plugins
2024-02-02 11:31:04.865 [srv 79532] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2024-02-02 11:31:04.866 [srv 79532] [Trace] Left [0] files to execute
2024-02-02 11:31:04.867 [srv 79532] [Trace] Exec app 'powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1"', mode [0]
2024-02-02 11:31:04.868 [srv 79532] [Trace] Left [0] files to execute in 'local'

The plugin seems to be running but i don’t know how to see DFSR options on CheckMK GUI side

Name:                          dfs_backlog
Version:                       2.0
Packaged on Checkmk Version:   2.0.0p23
Required Checkmk Version:      2.0.0
Valid until Checkmk version:   No version limitation
Title:                         DFSR backlog check
Author:                        Roger Ellenberger
Download-URL:                  https://github.com/ellr/checkmk_dfs_backlog
Files:                         
  Agent based plugins (Checks, Inventory)
    dfs_backlog.py
  Agents
    plugins/dfs_backlog.ps1
  Checks' man pages
  Legacy check plugins
  Documentation files
  Legacy inventory plugins
  Notification scripts
  PNP4Nagios templates (deprecated)
  Legacy GUI extensions
Description:
  DFS backlog check for Windows AD environment originally created by Kai Biebel

Shipped extension packages
==========================
OMD[monitoring]:~$ mkp list
Name        Version Title              Author            Req. Version Until Version Files State                        
----------- ------- ------------------ ----------------- ------------ ------------- ----- -----------------------------
dfs_backlog 2.0     DFSR backlog check Roger Ellenberger 2.0.0        None          2     Enabled (active on this site)
yum         2.4.3   YUM Update Check   Henri Wahl        2.0.0        None          7     Enabled (active on this site)

Test Agent is OK for dfs_backlog

C:\Program Files x86\checkmk\service> .\check_mk_agent.exe test
<<<dfs_backlog:sep(59)>>>
EDI (srv1);0
EDI (LOCALHOST);0
SHARE (srv1);0
SHARE(LOCALHOST);0
<<<>>>
<<<systemtime>>>
1706877645

The plugin variable is : # MK_PLUGINSDIR=“C:\ProgramData\checkmk\agent\plugins”

So i put ps1 in this directory and the CheckMK test and discovery crashes :

[agent]: Empty output from host

C:\Program Files (x86)\checkmk\service>.\check_mk_agent.exe showconfig ps
# Environment Variables:
# MK_LOCALDIR="C:\ProgramData\checkmk\agent\local"
# MK_STATEDIR="C:\ProgramData\checkmk\agent\state"
# MK_PLUGINSDIR="C:\ProgramData\checkmk\agent\plugins"
# MK_TEMPDIR="C:\ProgramData\checkmk\agent\tmp"
# MK_LOGDIR="C:\ProgramData\checkmk\agent\log"
# MK_CONFDIR="C:\ProgramData\checkmk\agent\config"
# MK_SPOOLDIR="C:\ProgramData\checkmk\agent\spool"
# MK_INSTALLDIR="C:\ProgramData\checkmk\agent\install"
# MK_MSI_PATH="C:\ProgramData\checkmk\agent\update"
# MK_MODULESDIR="C:\ProgramData\checkmk\agent\modules"
# Loaded Config Files:
# system: 'C:\Program Files (x86)\checkmk\service\check_mk.yml'
# bakery: 'C:\ProgramData\checkmk\agent\bakery'
# user  : 'C:\ProgramData\checkmk\agent\check_mk.user.yml'

# ps
enabled: yes
use_wmi: yes
full_path: no

I activate some options in C:\ProgramData\checkmk\agent\check_mk.user.yml , the agent service does not crashes anymore but no DFSR on CheckMK GUI side

The only important source of information for agent plugin issues is the agent log inside c:/programdata/checkmk/agent/log/
Here you see if your plugin finishes without an error code.
I think your problem is that the local system user (as this runs the cmk agent) cannot get any information about the DFS backlog.
Your test run was executed with your user and this user had access to the information.

Hello,

Thank you for your feedback, i have some logs :

2024-02-05 09:27:34.032 [srv 20844] [Trace] Sync Plugin Entry 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' forced to be async, due to cache_age [300]
2024-02-05 09:27:34.033 [srv 20844] Send at port 'mail:\\.\mailslot\Global\WinAgent_0' 'success' by 'winperf' [4392]
2024-02-05 09:27:34.034 [srv 20844] perf: Section 'fileinfo' took [3] milliseconds
2024-02-05 09:27:34.035 [srv 20844] [Trace] Sync Plugin Entry 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' forced to be async, due to cache_age [300]
2024-02-05 09:27:34.035 [srv 20844] Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'  is  async with age:300 timeout:120 retry:2
2024-02-05 09:27:34.036 [srv 20844] [Trace] Left [1] files to execute in 'plugins'
2024-02-05 09:27:34.037 [srv 20844] [Trace] To start [1] sync plugins
2024-02-05 09:27:34.038 [srv 20844] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2024-02-05 09:27:34.038 [srv 20844] [Trace] Left [0] files to execute
2024-02-05 09:27:34.039 [srv 20844] [Warn ] Data 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is too old, age is '453' seconds
2024-02-05 09:27:34.039 [srv 20844] [Trace] Left [0] files to execute in 'local'
2024-02-05 09:27:34.040 [srv 20844] Received [368] bytes from 'wmi_cpuload'
2024-02-05 09:27:34.041 [srv 20844] restarting async plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'
2024-02-05 09:28:33.930 [srv 20844] [Trace] Sync Plugin Entry 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' forced to be async, due to cache_age [300]
2024-02-05 09:28:33.931 [srv 20844] Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'  is  async with age:300 timeout:120 retry:2
2024-02-05 09:28:33.932 [srv 20844] [Trace] Left [1] files to execute in 'plugins'
2024-02-05 09:28:33.933 [srv 20844] [Trace] To start [1] sync plugins
2024-02-05 09:28:33.934 [srv 20844] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2024-02-05 09:28:33.934 [srv 20844] [Warn ] Data 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is too old, age is '513' seconds
2024-02-05 09:28:33.935 [srv 20844] restarting async plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'
2024-02-05 09:28:33.936 [srv 20844] [Trace] Left [0] files to execute
2024-02-05 09:28:33.936 [srv 20844] Thread for plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is still running, restart is not required
2024-02-05 09:28:33.937 [srv 20844] [Trace] Left [0] files to execute in 'local'
2024-02-05 09:29:00.681 [srv 20844] [Warn ] perf:  In [146688] milliseconds process 'powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1"' pid:[6772] FAILED - generated [93] bytes of data in [3] blocks
2024-02-05 09:29:00.683 [srv 20844] [Warn ] Async Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is failed
2024-02-05 09:29:00.683 [srv 20844] [Warn ] Async Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' has too many failures 3
2024-02-05 09:29:00.684 [srv 20844] Process 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' resets data after 146 seconds
2024-02-05 09:29:00.684 [srv 20844] [Trace] Thread OFF: 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'

In the checkmk_user.yml

  execution:

        - pattern: $CUSTOM_PLUGINS_PATH$\dfs_backlog.ps1
          async: no
          run: yes
          timeout: 120
          cache_age: 300
          retry_count: 2

In the log we see that your script does not finish correctly.
As i said before the problem is the user that executes the script (local system).
You have two options. Configure the agent to run as a user that has rights to fetch the wanted information or configure the plugin to run with another user account (run as function for plugins and local checks).

1 Like

Thank you Andreas for your help, i will try to change the user executor

I switched the async mode to YES :

2024-02-05 10:30:47.890 [srv 5492] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2024-02-05 10:30:47.891 [srv 5492] [Trace] Left [37] files to execute
2024-02-05 10:30:47.893 [srv 5492] Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'  is  async with age:300 timeout:120 retry:2
2024-02-05 10:30:47.894 [srv 5492] [Trace] Left [1] files to execute in 'plugins'
2024-02-05 10:30:47.894 [srv 5492] [Warn ] Data 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is too old, age is '23926048' seconds
2024-02-05 10:30:47.895 [srv 5492] restarting async plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'
2024-02-05 10:30:47.895 [srv 5492] restarted thread for plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'
2024-02-05 10:30:47.896 [srv 5492] Async Thread for C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1 is to be started
2024-02-05 10:30:47.897 [srv 5492] Allowed Extensions: [checkmk.py,py,exe,bat,vbs,cmd,ps1]
2024-02-05 10:30:47.897 [srv 5492] [Trace] Exec app 'powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1"', mode [0]
2024-02-05 10:30:47.898 [srv 5492] [Trace] Left [37] files to execute
2024-02-05 10:30:47.900 [srv 5492] Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'  is  async with age:300 timeout:120 
retry:2

2024-02-05 10:33:14.914 [srv 5492] [Warn ] perf:  In [147013] milliseconds process 'powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1"' pid:[20368] FAILED - generated [93] bytes of data in [4] blocks
2024-02-05 10:33:14.915 [srv 5492] [Warn ] Async Plugin 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1' is failed
2024-02-05 10:33:14.916 [srv 5492] [Err  ] Failed to start minibox thread C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1
2024-02-05 10:33:14.917 [srv 5492] [Trace] Thread OFF: 'C:\ProgramData\checkmk\agent\plugins\dfs_backlog.ps1'

You see it fails after the time you configured → timeout 120 → failed after 147 seconds.
How long does your script run if executed on command line with your user?
The execution with the agent should not take longer time.

Thank you again Andreas,

I ask to the Windows expert team to do actions. The powershell script is now executed well on Windows side

Now i’m trying to work on CheckMK server site. The plugin python file dfs_backlog.py is compatible with python 3.7.

On RHEL Enterprise we have python 3.6, so this script doesn’t work. I’m upgrading python and make tests

It’s a real shame that authors don’t document their codes…

Python 3.8 is installed

I ran a Discovery Service but i cannot see DFSR Backlog sensor

/local/lib/python3/cmk/base/plugins/agent_based$ python3 dfs_backlog.py 
Traceback (most recent call last):
  File "/opt/omd/sites/monitoring/local/lib/python3/cmk/base/plugins/agent_based/dfs_backlog.py", line 28, in <module>
    from .agent_based_api.v1.type_defs import (
ImportError: attempted relative import with no known parent package

This error concerns the dfs_backlog.py :

from .agent_based_api.v1.type_defs import (
    CheckResult,
    DiscoveryResult,