I would like to monitor Zabbix Server via external monitoring, i.e. with simple `curl` command. Is there a page, like `zabbix.example.com/status` with, i.e., 'DB connection', 'Server is running', etc.?
Ad Widget
Collapse
Is there a status page for Zabbix Server itself?
Collapse
X
-
Yeah, the eternal problem: how to monitor the monitoring system.
One way is to use Zabbix API to query some known data from Zabbix (from a specific host etc). If that call works, it means that- Zabbix frontend is working (API uses the same web server as GUI)
- database is working (the host data is retrieved from the database)
- Zabbix monitoring process is working (if you use the history API to get the latest value and compare its timestamp to current time you can see if the data is being collected correctly)
-
Another way to monitor the system would be to create an item and a trigger that triggers regularly (for example by using cron and zabbix sender), and an action that sends the result (= heartbeat) to an external monitoring system. If the heartbeat is missing for some time, your external system can raise an alarm because Zabbix monitoring is then not working.
MarkkuComment
-
Yes, simple it shall be:
See also an example: https://blog.zabbix.com/zabbix-api-s...-and-jq/12434/Originally posted by MarkkuOne way is to use Zabbix API to query some known data from Zabbix
Note that since Zabbix 5.4 you don't have to login (and logout) to the API with username+password, you can create the token manually and then use it statically in your curl command.
MarkkuComment
-
Here is a simple script I created. I placed it to zabbix ui directory with other zabbix php files:
PHP Code:<?php
require_once dirname(__FILE__).'/conf/zabbix.conf.php';
$timeout = 5;
function check_connection($address, $port) {
$connection = @fsockopen($address, $port, $errno, $errstr, 5);
if (is_resource($connection))
{
fclose($connection);
return 'OK';
}
else
{
return 'ERROR';
}
}
$server_status = check_connection($ZBX_SERVER, $ZBX_SERVER_PORT);
if ($DB['PORT'] == "0")
{
switch ($DB['TYPE']) {
case 'MYSQL':
$port = "3306";
break;
case 'POSTGRESQL':
$port = "5432";
break;
}
}
else
{
$port = $DB['PORT'];
}
$db_status = check_connection($DB['SERVER'], $port);
header('Content-Type: application/json; charset=utf-8');
$data = ['server' => $server_status, 'db' => $db_status];
echo json_encode( $data );
?>Comment
Comment