Skip to content

Commit 7c48505

Browse files
oetikerclaude
andcommitted
docs: improve plugin development path structure guidance
- Use ./local/lib/python3/cmk as primary directory structure - Add critical warning about check_mk symlink to prevent production issues - Change all development paths from ~/local to ./local (OMD sites still use ~/local) - Fix checkman location to be inside plugin-specific directory - Update package distribution to reference mkp-builder from GitHub - Remove manual package creation in favor of mkp-builder tool This change prevents accidental overwriting of symlinks in production installations and provides clearer guidance for development environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 496ed25 commit 7c48505

File tree

2 files changed

+76
-35
lines changed

2 files changed

+76
-35
lines changed

CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Reorganized cmk-plugin-guide.md structure with table of contents and improved flow
1515
- Clarified SimpleLevels documentation to remove confusion about parameter formats
1616
- Added "Common Pitfalls and Solutions" section to cmk-plugin-guide.md
17-
- Added note about check_mk → python3/cmk symlink relationship to avoid path confusion
17+
- **IMPORTANT**: Updated directory structure guidance to use `./local/lib/python3/cmk` as primary path with `./local/lib/check_mk` as symlink to prevent production issues
18+
- Changed all path examples from `~/local/` to `./local/` for development checkouts (OMD sites still use `~/local/`)
19+
- Updated package distribution section to reference mkp-builder from GitHub (oposs/mkp-builder)
20+
- Fixed checkman directory location to be inside plugin-specific folder structure
21+
- Removed manual package creation instructions in favor of mkp-builder tool
1822

1923
### Fixed
2024
- Fixed critical typos in cmk-plugin-guide.md (`cmk.base.pyugins``cmk.base.plugins`)
2125
- Corrected bakery plugin directory paths for consistency
2226
- Fixed missing `parameter_form=` in ruleset example code
2327
- Fixed temperature monitor example to use correct `HostAndItemCondition`
2428
- Removed redundant and contradictory information about SimpleLevels handling
29+
- Fixed inconsistent checkman path documentation
2530

2631
## 2.0.2 - 2025-08-07
2732
### Fixed

cmk-plugin-guide.md

Lines changed: 70 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,38 @@ CheckMK agent-based check plugins consist of two main components:
3838
## Development Environment Setup
3939

4040
### Directory Structure
41+
42+
When developing CheckMK plugins, use the following directory structure:
43+
4144
```
42-
~/local/lib/python3/cmk_addons/plugins/my_plugin
45+
./local/lib/python3/cmk_addons/plugins/my_plugin/
4346
├── agent_based/ # Check plugins (using cmk.agent_based.v2)
47+
├── checkman/ # Plugin documentation (checkman format)
4448
├── graphing/ # Graphing definitions (using cmk.graphing.v1)
4549
├── rulesets/ # Rule specifications (using cmk.rulesets.v1)
4650
└── server_side_calls/ # Special agents (using cmk.server_side_calls.v1)
4751
48-
~/local/lib/check_mk/base/cee/plugins/bakery/
52+
./local/lib/python3/cmk/base/cee/plugins/bakery/
4953
└── # Agent bakery plugins (using cmk.base.plugins.bakery.bakery_api.v1)
5054
51-
~/local/share/check_mk/agents/plugins/
55+
./local/share/check_mk/agents/plugins/
5256
└── # Agent plugin source files
5357
```
5458

55-
> **📝 Important Path Note**: In CheckMK, `~/local/lib/check_mk` is a symlink to `~/local/lib/python3/cmk`. You may encounter both paths in documentation, error messages, and examples - they refer to the same location. This can cause confusion when debugging path-related issues or following different documentation sources.
59+
> **⚠️ Critical Path Setup**:
60+
> - **Always use `./local/lib/python3/cmk` as the actual directory**
61+
> - Create `./local/lib/check_mk` as a symlink pointing to `./local/lib/python3/cmk`
62+
> - This prevents accidentally overwriting the symlink in production installations
63+
> - In a CheckMK OMD site, paths start with `~/local/` (site user's home)
64+
> - In regular development checkouts, use `./local/` (relative to project root)
65+
>
66+
> ```bash
67+
> # Setup correct structure in development
68+
> mkdir -p ./local/lib/python3/cmk
69+
> ln -s python3/cmk ./local/lib/check_mk
70+
> ```
71+
72+
For a real-world example structure, see: https://github.com/oposs/cmk-oposs_smart_error
5673
5774
### Agent Plugin Location
5875
```
@@ -612,7 +629,7 @@ Every check plugin requires:
612629
### Basic Check Plugin Structure
613630
```python
614631
#!/usr/bin/env python3
615-
# File: ~/local/lib/python3/cmk_addons/plugins/agent_based/my_service.py
632+
# File: ./local/lib/python3/cmk_addons/plugins/my_plugin/agent_based/my_service.py
616633

617634
from cmk.agent_based.v2 import (
618635
AgentSection,
@@ -1042,7 +1059,7 @@ The Agent Bakery allows centralized configuration and deployment of agent plugin
10421059

10431060
### Bakery Plugin Structure
10441061
```python
1045-
# File: ~/local/lib/check_mk/base/cee/plugins/bakery/my_service.py
1062+
# File: ./local/lib/python3/cmk/base/cee/plugins/bakery/my_service.py
10461063

10471064
import json
10481065
from cmk.base.plugins.bakery.bakery_api.v1 import (
@@ -1092,7 +1109,7 @@ register.bakery_plugin(
10921109

10931110
### Bakery Ruleset Structure (CheckMK 2.3 - Modern API)
10941111
```python
1095-
# File: ~/local/lib/python3/cmk_addons/plugins/<family>/rulesets/ruleset_<name>_bakery.py
1112+
# File: ./local/lib/python3/cmk_addons/plugins/<family>/rulesets/ruleset_<name>_bakery.py
10961113

10971114
from cmk.rulesets.v1 import Label, Title, Help
10981115
from cmk.rulesets.v1.form_specs import (
@@ -1151,12 +1168,12 @@ rule_spec_my_service_bakery = AgentConfig(
11511168
### Key Points About the Bakery API
11521169

11531170
**Separation of Concerns:**
1154-
- **Bakery Plugin**: Technical logic only (`local/lib/check_mk/base/cee/plugins/bakery/`)
1155-
- **Bakery Ruleset**: GUI configuration only (`local/lib/python3/cmk_addons/plugins/<family>/rulesets/`)
1171+
- **Bakery Plugin**: Technical logic only (`./local/lib/python3/cmk/base/cee/plugins/bakery/`)
1172+
- **Bakery Ruleset**: GUI configuration only (`./local/lib/python3/cmk_addons/plugins/<family>/rulesets/`)
11561173
- Never mix both concerns in the same file
11571174

11581175
**Agent Plugin Source Location:**
1159-
- Agent plugins should be stored in `local/share/check_mk/agents/plugins/`
1176+
- Agent plugins should be stored in `./local/share/check_mk/agents/plugins/`
11601177
- The bakery automatically finds them when using `source=Path('plugin_name')`
11611178
- No need to manually read file content or specify complex paths
11621179

@@ -1172,7 +1189,7 @@ rule_spec_my_service_bakery = AgentConfig(
11721189

11731190
### Advanced Bakery Features
11741191
```python
1175-
# File: ~/local/lib/check_mk/base/cee/plugins/bakery/my_service_advanced.py
1192+
# File: ./local/lib/python3/cmk/base/cee/plugins/bakery/my_service_advanced.py
11761193

11771194
from cmk.base.plugins.bakery.bakery_api.v1 import (
11781195
register,
@@ -1274,7 +1291,7 @@ Rulesets allow users to configure plugin parameters through the CheckMK GUI usin
12741291

12751292
### Basic Ruleset Definition
12761293
```python
1277-
# File: ~/local/lib/python3/cmk_addons/plugins/rulesets/my_service.py
1294+
# File: ./local/lib/python3/cmk_addons/plugins/my_plugin/rulesets/my_service.py
12781295

12791296
from cmk.rulesets.v1 import Title, Help, Label
12801297
from cmk.rulesets.v1.form_specs import (
@@ -1380,7 +1397,7 @@ condition=HostAndItemCondition(item_title=Title("ZPool name"))
13801397
#### Real-World Example: OPOSS zpool iostat
13811398

13821399
```python
1383-
# File: ~/local/lib/python3/cmk_addons/plugins/rulesets/oposs_zpool_iostat.py
1400+
# File: ./local/lib/python3/cmk_addons/plugins/oposs_zpool_iostat/rulesets/oposs_zpool_iostat.py
13841401

13851402
rule_spec_oposs_zpool_iostat = CheckParameters(
13861403
title=Title("OPOSS zpool iostat monitoring"),
@@ -1508,7 +1525,7 @@ Create visual representations of your metrics using the `cmk.graphing.v1` API.
15081525

15091526
### Metric Definitions
15101527
```python
1511-
# File: ~/local/lib/python3/cmk_addons/plugins/graphing/my_service.py
1528+
# File: ./local/lib/python3/cmk_addons/plugins/my_plugin/graphing/my_service.py
15121529

15131530
from cmk.graphing.v1 import Title
15141531
from cmk.graphing.v1.metrics import (
@@ -1782,22 +1799,25 @@ def test_check_function():
17821799
CheckMK plugins should include proper documentation in the checkman format for user reference.
17831800

17841801
#### Creating Checkman Documentation
1785-
Create documentation files in the `checkman/` directory:
1802+
Create documentation files in the `checkman/` directory within your plugin folder:
17861803

17871804
```
1788-
~/local/lib/python3/cmk_addons/plugins/
1805+
./local/lib/python3/cmk_addons/plugins/my_plugin/
17891806
├── agent_based/
1807+
│ └── my_service.py # Check plugin code
17901808
├── checkman/ # Plugin documentation
17911809
│ └── my_service # Documentation file (no extension)
17921810
├── graphing/
1811+
│ └── my_service.py # Graphing definitions
17931812
└── rulesets/
1813+
└── my_service.py # Ruleset definitions
17941814
```
17951815

17961816
#### Checkman Format
17971817
CheckMK uses a simple text-based format for plugin documentation:
17981818

17991819
```
1800-
# File: ~/local/lib/python3/cmk_addons/plugins/checkman/my_service
1820+
# File: ./local/lib/python3/cmk_addons/plugins/my_plugin/checkman/my_service
18011821
18021822
title: My Service: Performance Monitoring
18031823
agents: linux
@@ -1917,27 +1937,43 @@ parameters:
19171937
### Manual Installation
19181938
1. Copy agent plugin to `/usr/lib/check_mk_agent/plugins/`
19191939
2. Make executable: `chmod +x plugin_name`
1920-
3. Copy check plugin to `~/local/lib/python3/cmk_addons/plugins/agent_based/`
1921-
4. Copy ruleset definitions to `~/local/lib/python3/cmk_addons/plugins/rulesets/`
1922-
5. Copy graphing definitions to `~/local/lib/python3/cmk_addons/plugins/graphing/`
1940+
3. Copy check plugin to `./local/lib/python3/cmk_addons/plugins/my_plugin/agent_based/`
1941+
4. Copy ruleset definitions to `./local/lib/python3/cmk_addons/plugins/my_plugin/rulesets/`
1942+
5. Copy graphing definitions to `./local/lib/python3/cmk_addons/plugins/my_plugin/graphing/`
19231943
6. Restart CheckMK: `cmk -R` or `omd restart`
19241944

19251945
### Using Agent Bakery
1926-
1. Create bakery plugin in `~/local/lib/check_mk/base/cee/plugins/bakery/`
1927-
2. Create rule set in `~/local/lib/python3/cmk_addons/plugins/rulesets/`
1946+
1. Create bakery plugin in `./local/lib/python3/cmk/base/cee/plugins/bakery/`
1947+
2. Create rule set in `./local/lib/python3/cmk_addons/plugins/my_plugin/rulesets/`
19281948
3. Configure via CheckMK GUI under "Agents > Agent rules"
19291949
4. Bake and deploy agents via "Agents > Agent bakery"
19301950

19311951
### Package Distribution
1952+
1953+
For professional MKP package creation and distribution, use the **mkp-builder** tool:
1954+
19321955
```bash
1933-
# Create MKP package
1934-
cd ~/local/lib/python3/cmk_addons/plugins/
1935-
tar -czf my_service_plugin.tar.gz agent_based/ bakery/ rulesets/ graphing/
1956+
# Install mkp-builder from GitHub
1957+
git clone https://github.com/oposs/mkp-builder.git
1958+
cd mkp-builder
1959+
# Follow installation instructions in the repository
1960+
1961+
# Create package configuration (mkp.yaml)
1962+
mkp-builder init
19361963

1937-
# Install on other CheckMK instances
1938-
mkp install my_service_plugin.tar.gz
1964+
# Build the MKP package
1965+
mkp-builder build
1966+
1967+
# The tool handles:
1968+
# - Proper package structure validation
1969+
# - Version management
1970+
# - Dependency tracking
1971+
# - CheckMK compatibility checks
1972+
# - Professional package metadata
19391973
```
19401974

1975+
For more details, see: https://github.com/oposs/mkp-builder
1976+
19411977
## Debugging
19421978

19431979
### Common Issues
@@ -1968,7 +2004,7 @@ cmk -d hostname
19682004
cmk -v --debug --checks=my_service hostname
19692005

19702006
# Validate plugin syntax
1971-
python3 -m py_compile ~/local/lib/python3/cmk_addons/plugins/agent_based/my_service.py
2007+
python3 -m py_compile ./local/lib/python3/cmk_addons/plugins/my_plugin/agent_based/my_service.py
19722008
```
19732009

19742010
### Logging and Debugging
@@ -2367,7 +2403,7 @@ echo "system_info Temperature Monitor v1.2.0"
23672403

23682404
### Complete Check Plugin
23692405
```python
2370-
# File: ~/local/lib/python3/cmk_addons/plugins/agent_based/temperature_monitor.py
2406+
# File: ./local/lib/python3/cmk_addons/plugins/temperature_monitor/agent_based/temperature_monitor.py
23712407

23722408
from cmk.agent_based.v2 import (
23732409
AgentSection,
@@ -2476,7 +2512,7 @@ check_plugin_temperature_monitor = CheckPlugin(
24762512

24772513
### Ruleset Configuration
24782514
```python
2479-
# File: ~/local/lib/python3/cmk_addons/plugins/rulesets/temperature_monitor.py
2515+
# File: ./local/lib/python3/cmk_addons/plugins/temperature_monitor/rulesets/temperature_monitor.py
24802516

24812517
from cmk.rulesets.v1 import Title, Help
24822518
from cmk.rulesets.v1.form_specs import (
@@ -2531,7 +2567,7 @@ rule_spec_temperature_monitor = CheckParameters(
25312567

25322568
### Graphing Configuration
25332569
```python
2534-
# File: ~/local/lib/python3/cmk_addons/plugins/graphing/temperature_monitor.py
2570+
# File: ./local/lib/python3/cmk_addons/plugins/temperature_monitor/graphing/temperature_monitor.py
25352571

25362572
from cmk.graphing.v1 import Title
25372573
from cmk.graphing.v1.metrics import (
@@ -2591,7 +2627,7 @@ perfometer_temperature = Perfometer(
25912627

25922628
#### Bakery Plugin
25932629
```python
2594-
# File: ~/local/lib/check_mk/base/cee/plugins/bakery/temperature_monitor.py
2630+
# File: ./local/lib/python3/cmk/base/cee/plugins/bakery/temperature_monitor.py
25952631

25962632
from cmk.base.plugins.bakery.bakery_api.v1 import (
25972633
register,
@@ -2627,7 +2663,7 @@ register.bakery_plugin(
26272663

26282664
#### Bakery Ruleset (CheckMK 2.3 - Modern API)
26292665
```python
2630-
# File: ~/local/lib/python3/cmk_addons/plugins/temperature_monitor/rulesets/ruleset_temperature_monitor_bakery.py
2666+
# File: ./local/lib/python3/cmk_addons/plugins/temperature_monitor/rulesets/ruleset_temperature_monitor_bakery.py
26312667

26322668
from cmk.rulesets.v1 import Label, Title, Help
26332669
from cmk.rulesets.v1.form_specs import (
@@ -2701,7 +2737,7 @@ For additional resources:
27012737

27022738
**Problem**: Bakery plugin not found
27032739
- **Cause**: Wrong directory path for bakery plugins
2704-
- **Solution**: Place in `~/local/lib/check_mk/base/cee/plugins/bakery/`
2740+
- **Solution**: Place in `./local/lib/python3/cmk/base/cee/plugins/bakery/`
27052741

27062742
### SimpleLevels and check_levels Errors
27072743

0 commit comments

Comments
 (0)