Files
wsinfra-IT/Zabbix/Acknowledge-OT-Event.php
2026-03-30 11:51:52 +02:00

51 lines
1.3 KiB
PHP

<?php
// Web-Service Common
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
$rc=999;$stdout="?";$actor=$_SERVER['COMPUTERNAME'];$done=0;
$input = file_get_contents('php://input');
$json = json_decode($input, true);
$SourceUser = $json['source'] ?? $_SERVER['CURRENTUSER'] ?? null;
// Main
$eventId = (int)$json['eventId'];
$ackMessage = "Acknowledged by Infra Web-Service";
echo $eventId;
// 1) Acknowledge the event
$ackPayload = json_encode([
'jsonrpc' => '2.0',
'method' => 'event.acknowledge',
'params' => [
'eventids' => [$eventId],
'action' => 6,
'message' => $ackMessage
],
'id' => 1
]);
$ch = curl_init($zabbixOTUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-type: application/json',
'charset=utf-8',
'Authorization: Bearer ' . $zabbixOTToken
],
CURLOPT_POSTFIELDS => $ackPayload,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
]);
$ackResp = curl_exec($ch);
$ackCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$rc=0;$done=1;$stdout="Event $eventId Acknowledged";
// Log to dedicated Table
log2DB();
?>