From 07772a483e3db9e885993b84721d41f95b7188a9 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Jan 2026 10:09:21 +0100 Subject: [PATCH] Initial setup: Zabbix srv-monitor02 Dokumentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .gitignore für sensible Dateien - copilot-instructions.md mit API-Zugriff und MSSQL-Fehlerbehebung Co-Authored-By: Claude Opus 4.5 --- .gitignore | 8 +++ copilot-instructions.md | 152 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 .gitignore create mode 100644 copilot-instructions.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb675f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Sensitive files +api.txt +*.key +*.pem + +# Temp files +*.tmp +*.bak diff --git a/copilot-instructions.md b/copilot-instructions.md new file mode 100644 index 0000000..5124eb7 --- /dev/null +++ b/copilot-instructions.md @@ -0,0 +1,152 @@ +# VINOS Zabbix Server (srv-monitor02) - Copilot Instructions + +## MANDATORY RULES + +- **API-Schlüssel:** Liegt in `api.txt` (NICHT committen!) +- **Zabbix Version:** 7.0.3 (API-Syntax beachten - 7.x hat geänderte Parameter) +- Authentifizierung per Bearer Token im Authorization Header + +## System Overview + +| Eigenschaft | Wert | +|-------------|------| +| **Server** | srv-monitor02 | +| **URL** | https://srv-monitor02/ | +| **API Endpoint** | https://srv-monitor02/api_jsonrpc.php | +| **Zabbix Version** | 7.0.3 | +| **Kunde** | VINOS | + +## API-Zugriff + +### Authentifizierung (Zabbix 7.x) + +```bash +curl -sk -X POST "https://srv-monitor02/api_jsonrpc.php" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer " \ + -d '{ + "jsonrpc": "2.0", + "method": "problem.get", + "params": { ... }, + "id": 1 + }' +``` + +### Wichtige API-Änderungen in 7.x + +- `selectHosts` bei `problem.get` nicht mehr unterstützt - stattdessen `trigger.get` mit `selectHosts` verwenden +- `apiinfo.version` OHNE Authorization Header aufrufen + +### Nützliche Abfragen + +**Aktuelle Probleme:** +```json +{ + "method": "problem.get", + "params": { + "output": "extend", + "recent": true, + "sortfield": ["eventid"], + "sortorder": "DESC", + "limit": 30 + } +} +``` + +**Trigger-Details mit Host:** +```json +{ + "method": "trigger.get", + "params": { + "output": "extend", + "triggerids": [""], + "expandDescription": true, + "selectHosts": ["hostid", "host", "name"], + "selectItems": ["itemid", "name", "key_", "lastvalue"] + } +} +``` + +**Items eines Hosts abfragen:** +```json +{ + "method": "item.get", + "params": { + "output": ["itemid", "name", "key_", "lastvalue", "lastclock"], + "hostids": [""], + "search": { "key_": "suchbegriff" } + } +} +``` + +## Bekannte Hosts + +| Host | HostID | Beschreibung | +|------|--------|--------------| +| SRV-DB12 REMA Datenbank | 10786 | MSSQL Server mit Wartungsplänen | + +## Bekannte Probleme & Lösungen + +### MSSQL Job-Fehler: Fehlercode 0x534 (Fehler 15404) + +**Symptom:** +``` +Auftragsfehler: Es kann nicht bestimmt werden, ob der Besitzer ('VINOS\username') +von Auftrag 'Jobname' Serverzugriff aufweist. +(Ursache: Die Informationen über Windows NT-Gruppe oder -Benutzer "VINOS\username" +konnten nicht abgerufen werden, Fehlercode 0x534. [SQLSTATE 42000] (Fehler 15404)) +``` + +**Ursache:** +Der SQL Server kann den Job-Besitzer (Windows-Account) nicht mehr im Active Directory auflösen. + +**Lösungen:** + +1. **Job-Besitzer auf `sa` ändern (empfohlen):** + ```sql + USE msdb; + GO + EXEC dbo.sp_update_job + @job_name = N'Backup_tgl.Subplan_1', + @owner_login_name = N'sa'; + GO + ``` + +2. **Alle Jobs eines Benutzers auf `sa` ändern:** + ```sql + USE msdb; + GO + DECLARE @job_id uniqueidentifier + DECLARE job_cursor CURSOR FOR + SELECT job_id FROM sysjobs WHERE owner_sid = SUSER_SID('VINOS\gt') + + OPEN job_cursor + FETCH NEXT FROM job_cursor INTO @job_id + WHILE @@FETCH_STATUS = 0 + BEGIN + EXEC dbo.sp_update_job @job_id = @job_id, @owner_login_name = N'sa' + FETCH NEXT FROM job_cursor INTO @job_id + END + CLOSE job_cursor + DEALLOCATE job_cursor + GO + ``` + +3. **Via SSMS:** + - Job Properties → General → Owner → Auf `sa` ändern + +**Verifizierung nach Fix:** +- In Zabbix: Problem sollte nach nächstem erfolgreichen Job-Lauf automatisch schließen +- Oder manuell Job starten und Status prüfen + +## Development Workflow + +1. API-Abfragen testen mit `curl` und `jq` +2. Bei komplexeren Abfragen: Immer zuerst die relevanten IDs ermitteln +3. Dokumentation aktualisieren bei neuen Erkenntnissen + +## Pitfalls + +- **API-Version prüfen:** Zabbix 7.x hat viele Breaking Changes gegenüber 6.x +- **SSL-Zertifikat:** `-sk` Flag bei curl verwenden (self-signed cert) +- **Timestamps:** Zabbix liefert Unix-Timestamps, ggf. konvertieren