您好,登錄后才能下訂單哦!
<?php
// Kafka集群健康檢查腳本
$brokers = [
'broker1' => 'localhost:9092',
'broker2' => 'localhost:9093',
'broker3' => 'localhost:9094'
];
foreach ($brokers as $brokerId => $brokerAddress) {
$ch = curl_init($brokerAddress . '/healthcheck');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
echo "Broker $brokerId is down\n";
} else {
echo "Broker $brokerId is up\n";
}
}
?>
這個PHP腳本會循環檢查指定的Kafka broker是否健康,通過向每個broker的/healthcheck
端點發送HTTP請求來檢查。如果某個broker無法響應請求,腳本會輸出"Broker [brokerId] is down";如果broker正常響應請求,腳本會輸出"Broker [brokerId] is up"。可以根據實際情況修改$brokers數組中的broker信息。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。