Skip to content

Commit f1a028d

Browse files
committed
mk-oracle: update README with custom metrics section
CMK-34048 Change-Id: I14be508f1b9d2a97a6772b6533bbc874c30ea839
1 parent d5799bc commit f1a028d

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

packages/mk-oracle/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Discovery](#discovery)
1414
- [Options](#options)
1515
- [Sections](#sections)
16+
- [Custom SQL Metrics](#custom-sql-metrics)
1617
- [Complete Configuration Example](#complete-configuration-example)
1718
- [Oracle Wallet Authentication](#oracle-wallet-authentication)
1819
- [Default Configuration](#default-configuration)
@@ -443,6 +444,71 @@ sections:
443444
is_async: yes
444445
```
445446

447+
### Custom SQL Metrics
448+
449+
Use `custom_metrics` to define ad-hoc SQL queries whose output is emitted under the legacy `oracle_sql` agent section. Each entry is keyed by the **item name** that becomes the service item on the Checkmk site (the `<item>` in `[[[SID|item]]]`).
450+
451+
```yaml
452+
oracle:
453+
main:
454+
connection:
455+
hostname: localhost
456+
authentication:
457+
username: system
458+
password: oracle
459+
type: standard
460+
custom_metrics:
461+
- product_price: # item name -> service "<SID> SQL product_price"
462+
sql: "SELECT 'details:Price OK' FROM dual"
463+
instances:
464+
- service_name: FREE
465+
custom_metrics:
466+
- last_sessions: # runs only against this instance
467+
sql: "SELECT 'details:per-instance' FROM dual"
468+
```
469+
470+
Resulting agent output:
471+
472+
```
473+
<<<oracle_sql:sep(58)>>>
474+
[[[FREE|product_price]]]
475+
details:Price OK
476+
<<<oracle_sql:sep(58)>>>
477+
[[[FREE|last_sessions]]]
478+
details:per-instance
479+
```
480+
481+
#### Placement and merge rules
482+
483+
- `custom_metrics` may appear at the **global** level (under `oracle.main`) or under any **per-instance** entry (`oracle.main.instances[*]`).
484+
- A given instance executes the union of global and its own per-instance metrics.
485+
- If a global and a per-instance entry share the same item name, the per-instance one wins.
486+
487+
#### SQL contract
488+
489+
Each SQL must produce rows with a single string column whose value starts with one of the recognised prefixes:
490+
491+
| Prefix | Purpose |
492+
| ----------- | ------------------------------------------------------ |
493+
| `details:` | First line of the service summary |
494+
| `perfdata:` | `NAME=VALUE;WARN;CRIT;MAX` performance metric |
495+
| `long:` | Additional lines in the long service output |
496+
| `exit:` | Service state: `0=OK`, `1=WARN`, `2=CRIT`, `3=UNKNOWN` |
497+
498+
The plugin emits the section header (`<<<oracle_sql:sep(58)>>>`) and the subsection header (`[[[<SID>|<item>]]]`) itself; the SQL only provides the body rows.
499+
500+
Each row returned by the SQL is emitted **as-is**: the plugin does not reinterpret, reorder, or join columns. In practice this means custom-metric SQL should `SELECT` a single string column whose value is already a complete line (e.g. `'details:OK'`), and emit one such row per output line.
501+
502+
#### Differences from the legacy `mk_oracle` bash plugin
503+
504+
Custom SQL metrics in this plugin replace the legacy `SQLS_*` configuration variables and `SQLS_SECTIONS` shell-function-based sections. Key differences:
505+
506+
- **No SQL\*Plus directives.** Statements run through the Oracle OCI driver, not `sqlplus`, so `PROMPT`, `SET …`, `SPOOL`, `WHENEVER SQLERROR`, and similar `SQL*Plus`-only commands are not available. Use plain SQL.
507+
- **Inline SQL only.** Define the query inline via `sql: "..."`. The legacy `SQLS_DIR` / `SQLS_SQL` file-based form is not supported in this iteration.
508+
- **Item name is the YAML key.** Equivalent to the legacy `SQLS_ITEM_NAME` (replaces `SQLS_SECTIONS` shell functions).
509+
- **Cache marker location.** For cached (async) sections, the legacy `cached(<since>,<age>)` marker is emitted on the **subsection** header `[[[<SID>|<item>|cached(...)]]]`, not on the section header. The section header is always plain `<<<oracle_sql:sep(58)>>>`.
510+
- **Separator is fixed at `:` (ASCII 58).** The output is always emitted under `oracle_sql:sep(58)` so the existing server-side `oracle_sql` check plugin processes it unchanged.
511+
446512
### Complete Configuration Example
447513

448514
Below is a full configuration example demonstrating all available fields:

0 commit comments

Comments
 (0)