Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('php_flag display_errors','on');
- ini_set('php_value error_reporting', E_ALL);
- define('TMP_PATH', './tmp/'); //1. Папка для хранения изображений. Default: "./tmp/"
- define('IMG_PATH', './img/'); //1. Папка для хранения изображений. Default: "./img/"
- define('ZABBIX_URL', 'https://zabbix.univers.local'); //2. URL интерфейса Zabbix. Default: "http://host.local/zabbix/"
- define('ZABBIX_USER', 'тут_логин'); //3. Пользователь в Zabbix. Default: "admin"
- define('ZABBIX_PW', 'тут_паролька'); //4. Пароль в Zabbix. Default: "zabbix"
- $resources = array();
- $resources[] = array('url' => ZABBIX_URL . '/map.php?noedit=1&sysmapid=1'); // Карта сети
- //$resources[] = array('url' => ZABBIX_URL . 'chart2.php?graphid=414&sid=bab26b5059a13b11&width=1138&period=86400&stime=20120703112617&refresh=627'); // График температуры
- // Инсталлирован ли у нас CURL?
- function_exists('curl_init') || die('CURL is not installed!');
- // Логинимся скриптом в Zabbix
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, ZABBIX_URL . '/index.php');
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
- curl_setopt($ch, CURLOPT_POST, true); // использовать метод POST
- curl_setopt($ch, CURLOPT_POSTFIELDS, array(
- 'request' => '',
- 'password' => ZABBIX_PW,
- 'name' => ZABBIX_USER,
- 'enter' => 'Sign in',
- 'autologin' => 1,
- ));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // не проверять SSL сертификат
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // не проверять Host SSL сертификата
- curl_setopt($ch, CURLOPT_COOKIEJAR, TMP_PATH . '/cookie.txt'); // Сохраняем куки в файл
- curl_setopt($ch, CURLOPT_COOKIEFILE, TMP_PATH . '/cookie.txt');
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); // это необходимо, чтобы cURL не высылал заголовок на ожидание
- $t = curl_exec($ch);
- curl_close($ch);
- $img='';
- foreach($resources as $k => $res) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $res['url']);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_COOKIEJAR, TMP_PATH . '/cookie.txt');
- curl_setopt($ch, CURLOPT_COOKIEFILE, TMP_PATH . '/cookie.txt');
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false ); // required for https urls
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
- $file = curl_exec($ch);
- if($file) file_put_contents(IMG_PATH . 'img' . $k . '.png', $file);
- curl_close($ch);
- $img .= "\t " . '<img src="' . IMG_PATH . 'img' . $k . '.png' . '" alt="img' . $k . '" />' . "\n";
- }
- usleep(500000); // sleep for 0.5 sec
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Мониторинг критических параметров zabbix</title>
- </head>
- <body>
- <div>
- <?=$img?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement