K
K
Konstantin2014-04-04 09:55:45
PHP
Konstantin, 2014-04-04 09:55:45

How to display Zabbix charts / screens on a separate page?

There is Zabbix 2.2 . It is
necessary to regularly pull out individual graphs / network maps from it and place it on an html page with your own formatting.
In fact, as I understand it, it can be a script (preferably in php) that runs in cron, which will save the necessary pictures generated by Zabbix to a folder.
What working solutions exist?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin, 2014-04-04
@KGBelyaev

I asked myself, I will answer - of course you can!
I took a more complex example - habrahabr.ru/post/104460
Then it was trimmed / modified to the desired functionality.
The following solution turned out: a guest user was created in Zabbix, with permissions to view the necessary graphs / network maps.
Then, after going through these very charts, direct links to the generated pictures were obtained (just in the body of the html page issued by Zabbix).
That. a collection of links of the form was received: http://server_address/zabbix/chart2.php... , where graphid is the chart number, width is the width of the generated image.
All these links were driven into a script, which, in turn, was driven into cron to regularly update these pictures.
Now you can draw a page and insert links to the resulting pictures into it.
The actual script:

<?php

// Папка для хранения изображений
define('TMP_PATH', '/var/web/zabbix_images/');

$resources = array();

//Графики
$resources[] = array('url' => 'http://адрес_сервера/zabbix/chart2.php?graphid=534&width=1000');
$resources[] = array('url' => 'http://адрес_сервера/zabbix/chart2.php?graphid=524&width=800');
//Карта сети
$resources[] = array('url' => 'http://адрес_сервера/zabbix/map.php?sysmapid=1');

//Получаем изображения
foreach($resources as $k => $res)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $res['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$file = curl_exec($ch);
if($file) file_put_contents(TMP_PATH . 'img' . $k . '.png', $file);
curl_close($ch);
}
?>

P
Puma Thailand, 2014-04-04
@opium

there are no screenshots for this in zabbix.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question