Skip to content

Commit 6084ba1

Browse files
AnvarUJenkins
authored andcommitted
mk-oracle: keep SQLS_SIDS next to SQLS_TNSALIAS in the migration
CMK-37381 Change-Id: Ib759af6f67623d998647ce4f58f688dc22a9e187
1 parent adcded4 commit 6084ba1

4 files changed

Lines changed: 353 additions & 44 deletions

File tree

packages/mk-oracle/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ Each function listed in `SQLS_SECTIONS` becomes one `custom_metrics:` entry:
10131013
| `SQLS_SIDS` (literal list) | Places the entry under the matching `instances:` entries |
10141014
| `SQLS_SIDS` (shell expression) | The instances it expands to, or nothing (see below) |
10151015
| `SQLS_TNSALIAS` | Places the entry under the instance with that `alias:` |
1016+
| `SQLS_SIDS` + `SQLS_TNSALIAS` | One entry carrying both, the alias identifies it (see below) |
10161017
| `SQLS_SECTION_NAME` (≠ `oracle_sql`) | `header_name:` |
10171018
| `SQLS_SECTION_SEP` (ASCII code) | `header_sep:` (kept only together with a custom `header_name:`) |
10181019

@@ -1026,6 +1027,7 @@ Placement rules:
10261027
- A section whose `SQLS_SIDS` names a `REMOTE_INSTANCE_*` variable is attached to the
10271028
instance that variable defines. References that resolve to nothing are dropped with
10281029
a warning, and a section left without any instance is skipped.
1030+
- A section setting both `SQLS_SIDS` and `SQLS_TNSALIAS` keeps both values (see below).
10291031
- A section without `SQLS_SQL` is skipped with a warning.
10301032

10311033
##### Dynamic `SQLS_SIDS` values
@@ -1062,6 +1064,42 @@ and failing wherever the queried objects do not exist. Add the section back manu
10621064
under the `instances:` entries it is meant to run on (or, if it really applies to all
10631065
of them, as a global `custom_metrics:` entry).
10641066

1067+
##### `SQLS_SIDS` together with `SQLS_TNSALIAS`
1068+
1069+
Both may be set for the same section, and they restrict different things in the legacy
1070+
plugin: `SQLS_SIDS` selects the monitored SID the section runs on, `SQLS_TNSALIAS` the
1071+
connect identifier it uses to get there. The migration keeps both on one instance
1072+
entry:
1073+
1074+
```yaml
1075+
instances:
1076+
- sid: NORMALDB
1077+
alias: NORMALDB_ALIAS
1078+
custom_metrics:
1079+
- Invalid objects in DB:
1080+
path: /etc/check_mk/ProdSQLs/invalid_objects.sql
1081+
```
1082+
1083+
Note that `mk-oracle` identifies an instance by its `alias:` as soon as one is set, so
1084+
the `sid:` above documents the origin of the entry but no longer restricts the section.
1085+
The migration says so for every affected section:
1086+
1087+
```
1088+
# WARNING: Invalid objects in DB: SQLS_SIDS 'NORMALDB' is migrated next to SQLS_TNSALIAS 'NORMALDB_ALIAS', but the instance is resolved by its alias, so the SID no longer restricts the section
1089+
```
1090+
1091+
The SID cannot be kept at all when it does not identify one instance of the migrated
1092+
configuration — the section lists several SIDs, several sections use the same alias with
1093+
different SIDs, or the alias already belongs to a `DBUSER_*` entry with a SID of its own.
1094+
The alias then forms the entry alone and the dropped restriction is reported:
1095+
1096+
```
1097+
# WARNING: Ambiguous: SQLS_SIDS 'ONE, TWO' cannot be kept next to SQLS_TNSALIAS 'SHARED_ALIAS', the instance is resolved by its alias alone; verify that the alias connects to the intended database
1098+
```
1099+
1100+
In both cases, check that the alias resolves to the database the section was meant to
1101+
query — the connection now depends on your `tnsnames.ora` alone.
1102+
10651103
### What Is Not Migrated
10661104

10671105
The following variables are recognized but only preserved as comments in the output;

packages/mk-oracle/references/output-multiple.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ mycustomsection4 () {
6666
SQLS_SQL="custom_sql_2.sql"
6767
}
6868
mycustomsection5 () {
69-
SQLS_SIDS="NOT_USED"
69+
# the alias identifies the instance, the SID is migrated next to it
70+
SQLS_SIDS="ALIASED_SID"
7071
SQLS_TNSALIAS="TNS"
7172
SQLS_SQL="custom_sql_2.sql"
7273
}

0 commit comments

Comments
 (0)