Skip to content

Commit 358767c

Browse files
committed
updated plugin guide
1 parent 063822e commit 358767c

11 files changed

Lines changed: 1641 additions & 275 deletions

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### New
1111
- refactored plugin guide with added snmp plugin info
12+
- added renaming information to plugin guide
13+
- added special_agent informtion to plugin guide
1214

1315
### Changed
1416

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
> **⚠️ Disclaimer**: This is an independent, community-developed tool and is **not officially affiliated with or endorsed by CheckMK GmbH**. This project was developed by reverse-engineering existing MKP package formats and studying CheckMK documentation. Any issues, bugs, or incompatibilities are our responsibility and should be reported to this project's issue tracker, not to CheckMK support.
77
8-
> **📚 Plugin Development Guide**: Since many users of mkp-builder are developing CheckMK plugins, we maintain comprehensive documentation for CheckMK 2.3.x plugin development in [`cmk-pluigin-guide.md`](cmk-plugin-guide.md). This guide covers agent plugins, check plugins, rulesets, graphing, and bakery integration with practical examples and best practices.
8+
> **📚 Plugin Development Guide**: Since many users of mkp-builder are developing CheckMK plugins, we maintain comprehensive modular documentation for CheckMK 2.3.x plugin development in [`cmk-plugin-guide/`](cmk-plugin-guide/). The guide covers agent plugins, SNMP plugins, special agents, check plugins, rulesets, graphing, bakery integration, and metric migration with practical examples and best practices. Start with the [guide index](cmk-plugin-guide/00-index.md) or read the [guide overview](cmk-plugin-guide/README.md).
99
1010
> **🚨 Breaking Changes in v2.0.0**: If you're upgrading from v1.x, please note that v2.0.0 introduces breaking changes. The configuration file format has changed from `.mkp-builderrc` to `.mkp-builder.ini` with INI format syntax. GitHub Action input names have also been updated. See the [changelog](CHANGES.md) for full migration details.
1111

cmk-plugin-guide/00-index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
| **Create my first plugin** | [01-quickstart.md](01-quickstart.md) | - |
1313
| **Monitor a network device via SNMP** | [02-snmp-plugins.md](02-snmp-plugins.md) | [04-check-plugins.md](04-check-plugins.md) |
1414
| **Collect data from a Linux/Windows host** | [03-agent-plugins.md](03-agent-plugins.md) | [04-check-plugins.md](04-check-plugins.md) |
15+
| **Monitor via REST API or custom protocol** | [12-special-agents.md](12-special-agents.md) | [04-check-plugins.md](04-check-plugins.md) |
1516
| **Process and check collected data** | [04-check-plugins.md](04-check-plugins.md) | [05-metrics-graphing.md](05-metrics-graphing.md) |
1617
| **Add graphs and visualizations** | [05-metrics-graphing.md](05-metrics-graphing.md) | - |
18+
| **Rename metrics while preserving history** | [13-metric-migration.md](13-metric-migration.md) | [05-metrics-graphing.md](05-metrics-graphing.md) |
1719
| **Configure thresholds in the GUI** | [06-rulesets.md](06-rulesets.md) | - |
1820
| **Deploy plugins automatically** | [07-bakery.md](07-bakery.md) | [06-rulesets.md](06-rulesets.md) |
1921
| **Debug a non-working plugin** | [08-testing-debugging.md](08-testing-debugging.md) | - |
@@ -29,9 +31,12 @@ START: What type of monitoring?
2931
│ └── Then → 04-check-plugins.md → 05-metrics-graphing.md
3032
├── Agent-based (Linux/Windows) → 03-agent-plugins.md
3133
│ └── Then → 04-check-plugins.md → 05-metrics-graphing.md
34+
├── API/Cloud/Special Protocol → 12-special-agents.md
35+
│ └── Then → 04-check-plugins.md → 05-metrics-graphing.md
3236
└── Already have data → 04-check-plugins.md
3337
└── Then → 05-metrics-graphing.md
3438
39+
Need to rename metrics? → 13-metric-migration.md
3540
Need GUI configuration? → 06-rulesets.md
3641
Need automatic deployment? → 07-bakery.md
3742
Having problems? → 08-testing-debugging.md
@@ -48,10 +53,12 @@ Having problems? → 08-testing-debugging.md
4853
#### Data Collection
4954
- **[02-snmp-plugins.md](02-snmp-plugins.md)** - SNMP monitoring via network
5055
- **[03-agent-plugins.md](03-agent-plugins.md)** - Host-based data collection
56+
- **[12-special-agents.md](12-special-agents.md)** - Server-side collection (APIs, cloud services)
5157

5258
#### Data Processing
5359
- **[04-check-plugins.md](04-check-plugins.md)** - Parse data, determine states, generate metrics
5460
- **[05-metrics-graphing.md](05-metrics-graphing.md)** - Visualizations and performance data
61+
- **[13-metric-migration.md](13-metric-migration.md)** - Rename metrics while preserving historical data
5562

5663
#### Configuration & Deployment
5764
- **[06-rulesets.md](06-rulesets.md)** - GUI configuration forms

cmk-plugin-guide/01-quickstart.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ def check_my_service(section):
6969
if not section:
7070
yield Result(state=State.UNKNOWN, summary="No data")
7171
return
72-
72+
7373
status = section.get("status", "UNKNOWN")
7474
value = int(section.get("value", 0))
75-
75+
7676
if status == "OK":
7777
state = State.OK
7878
else:
7979
state = State.WARN
80-
80+
8181
yield Result(state=state, summary=f"Status: {status}")
82-
yield Metric("value", value)
82+
# Use prefixed metric name (replace 'mycompany' with your org)
83+
yield Metric("mycompany_myservice_value", value)
8384

8485
# CRITICAL: Name must start with check_plugin_
8586
check_plugin_my_service = CheckPlugin(
@@ -106,17 +107,57 @@ cmk -II target_hostname
106107
cmk -v --debug target_hostname
107108
```
108109

109-
### Entry Point Prefixes (MANDATORY!)
110+
### Naming Conventions (CRITICAL!)
111+
112+
#### Entry Point Prefixes (MANDATORY!)
110113

111114
Variables MUST start with these prefixes to be discovered:
112115
- `agent_section_` - Agent data parsers
113-
- `snmp_section_` - SNMP data parsers
116+
- `snmp_section_` - SNMP data parsers
114117
- `check_plugin_` - Check logic
115118
- `inventory_plugin_` - Inventory
119+
- `special_agent_` - Special agent configs (in server_side_calls/)
120+
- `rule_spec_` - Ruleset definitions
116121

117122
**Wrong**: `my_section = AgentSection(...)`
118123
**Right**: `agent_section_my_service = AgentSection(...)`
119124

125+
#### Metric Names (CRITICAL!)
126+
127+
**⚠️ ALWAYS prefix metric names with `mycompany_myplugin_` format!**
128+
129+
CheckMK has ~1,000 built-in metrics. Unprefixed names will conflict and break:
130+
131+
```python
132+
# ❌ WRONG - Generic names risk conflicts
133+
yield Metric("cpu_usage", 45.0)
134+
yield Metric("temperature", 65.0)
135+
yield Metric("latency", 0.05)
136+
137+
# ✅ CORRECT - Prefixed with company and plugin name
138+
yield Metric("acme_widget_cpu_usage", 45.0)
139+
yield Metric("acme_widget_temperature", 65.0)
140+
yield Metric("acme_widget_latency", 0.05)
141+
```
142+
143+
**Format**: `mycompany_myplugin_{metric_name}`
144+
- Replace `mycompany` with your company/organization
145+
- Replace `myplugin` with your plugin name
146+
- Example prefixes: `acme_weather_`, `myorg_api_`, `contoso_ups_`
147+
148+
**Why this matters:**
149+
- Prevents conflicts with CheckMK's built-in metrics
150+
- Prevents your metrics being overridden by CheckMK updates
151+
- Makes metric ownership clear
152+
- Enables safe metric renaming via translations (see [13-metric-migration.md](13-metric-migration.md))
153+
154+
#### Plugin/Section Names
155+
156+
Choose descriptive, unique names for your plugins:
157+
- Use your organization prefix: `mycompany_service_name`
158+
- Examples: `acme_weather`, `contoso_ups`, `myorg_api`
159+
- Avoid generic names: `status`, `metrics`, `monitor`
160+
120161
### Common Pitfalls
121162

122163
1. **Wrong directory** → Use exact paths shown above

0 commit comments

Comments
 (0)