PDF报告Zabbix中的生成无效

时间:2016-02-12 14:32:46

标签: php pdf report zabbix

我正在尝试将以下repo中的pdf报告生成模块添加到zabbix:

https://github.com/SandipSingh14/Zabbix_

我创建了tmp和报告文件夹。 看起来PDF没有在服务器上创建,不知道为什么!请参阅以下请求的快照:

Error Snapshot

PHP配置文件:

<?php
//CONFIGURABLE
# zabbix server info(user must have API access)
$z_server       = 'http://10.10.100.122/zabbix';
$z_user     = 'admin';
$z_pass         = 'zabbix';
# Temporary directory for storing pdf data and graphs - must exist
$z_tmp_path = '/usr/share/zabbix/zabbix-dynamic-pdf-report/tmp';
# Directory for storing PDF reports
$pdf_report_dir = '/usr/share/zabbix/zabbix-dynamic-pdf-report/report';
# Root URL to reports
$pdf_report_url = $z_server ."/zabbix-dynamic-pdf-report/report";
# paper settings
$paper_format   = 'A4'; // formats supported: 4A0, 2A0, A0 -> A10, B0 ->      B10, C0 -> C10, RA0 -> RA4, SRA0 -> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO
$paper_orientation = 'portrait'; // formats supported: portrait / landscape
# time zone - see http://php.net/manual/en/timezones.php
$timezone   = 'Asia/Calcutta';
# Logo used in PDF - may be empty
# TODO: Specify image size!
$pdf_logo   = './images/zabbix.png';
$company_name   = 'Zabbix';

//DO NOT CHANGE BELOW THIS LINE
$z_tmp_cookies  = "/tmp/";
$z_url_index    = $z_server ."index.php";
$z_url_graph    = $z_server ."chart2.php";
$z_url_api  = $z_server ."api_jsonrpc.php";
$z_login_data   = "name=" .$z_user ."&password=" .$z_pass   ."&autologin=1&enter=Sign+in";
?>

这是我在使用index.php

中的调试时得到的结果

HostID:10153 报告类型:主机 时间段:3600 临时图像路径:/ tmp / zabbix_report_OPt9cZ

HOSTNAME(id:10153)
CPU load(id:1289)
Memory usage(id:1290)
Disk space usage C:(id:1297)
Disk space usage E:(id:1399)
Disk space usage F:(id:1400)
Disk space usage G:(id:1401)
Report ready - available as: http://10.10.100.122/zabbix/zabbix-dynamic-pdf-  report/report/HOSTNAME.pdf
操作系统:Ubuntu Zabbix版本:2.4.7

以下是PHP错误日志:

[Mon Feb 15 21:19:47.162244 2016] [:error] [pid 29796] [client 10.10.100.108:55341] PHP Warning:  Creating default object from empty value in /usr/share/zabbix/zabbix-dynamic-pdf-report/inc/ZabbixAPI.class.php on line 122, referer: http://10.10.100.122/zabbix/zabbix-dynamic-pdf-report/index.php
[Mon Feb 15 21:19:47.696413 2016] [:error] [pid 29796] [client 10.10.100.108:55341] PHP Warning:  fopen(/usr/share/zabbix/zabbix-dynamic-pdf-report/report/BLR-D-J9PSXX1.pdf): failed to open stream: Permission denied in /usr/share/zabbix/zabbix-dynamic-pdf-report/createpdf.php on line 319, referer: http://10.10.100.122/zabbix/zabbix-dynamic-pdf-report/index.php
[Mon Feb 15 21:19:47.696446 2016] [:error] [pid 29796] [client 10.10.100.108:55341] PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /usr/share/zabbix/zabbix-dynamic-pdf-report/createpdf.php on line 320, referer: http://10.10.100.122/zabbix/zabbix-dynamic-pdf-report/index.php
[Mon Feb 15 21:19:47.696455 2016] [:error] [pid 29796] [client 10.10.100.108:55341] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /usr/share/zabbix/zabbix-dynamic-pdf-report/createpdf.php on line 321, referer: http://10.10.100.122/zabbix/zabbix-dynamic-pdf-report/index.php

请帮助我提出建议!

1 个答案:

答案 0 :(得分:0)

zabbixdynamicpdfreport

zabbixdynamicpdfreport模块允许我们生成pdf报告。实施后,我们可以选择在“小时”,“日”,“周”,“月”,“年”的时间范围内为“主持人”,“主持人群组”生成报告。 我们可以从“旧报告”部分检索旧报告。

实施

  • 注意:此过程仅针对Ubuntu或类似的操作系统提及。

依赖关系

  • php5curl
  • php5json

sudo apt-­get install php5­curl php5­json

克隆包含模块

的git仓库

cd /opt/ git clone https://github.com/SandipSingh14/Zabbix_

根据zabbixserver配置zabbixdynamicpdfreport(更改后Zabbix_ /zabbixdynamicpdfreport/config.inc.php应如下所示)

cat Zabbix_​/zabbix­dynamic­pdf­report/config.inc.php

<?php 
//CONFIGURABLE 
# zabbix server info(user must have API access) 
$z_server = 'http://zabbix.example.com/'; 
$z_user = 'admin'; 
$z_pass = 'zabbix'; 
# Temporary directory for storing pdf data and graphs ­ must exist 
$z_tmp_path    = './tmp'; 
# Directory for storing PDF reports 
$pdf_report_dir    = './report'; 
# Root URL to reports 
$pdf_report_url    = "./report"; 
# paper settings 
$paper_format    = 'A4'; // formats supported: 4A0, 2A0, A0 ­> A10, B0 ­> B10, C0 ­> C10, RA0 ­> RA4, SRA0 ­> SRA4, LETTER, LEGAL, EXECUTIVE, FOLIO 
$paper_orientation = 'portrait'; // formats supported: portrait / lanscape 
# time zone ­ see http://php.net/manual/en/timezones.php 
$timezone    = 'Asia/Calcutta'; # Logo used in PDF ­ may be empty 
# TODO: Specify image size! 
$pdf_logo    = './images/zabbix.png'; 
$company_name   = 'Zabbix'; 
//DO NOT CHANGE BELOW THIS LINE 
$z_tmp_cookies     = "/tmp/"; 
$z_url_index     = $z_server ."index.php"; 
$z_url_graph    = $z_server ."chart2.php"; 
$z_url_api    = $z_server ."api_jsonrpc.php"; 
$z_login_data    = "name=" .$z_user ."&password=" .$z_pass ."&autologin=1&enter=Sign+in"; 
?> 
  • 注意:根据您的zabbix服务器更改下面提到的变量
    • z_server = http:// $ ZABBIX_SERVER_DOMAIN /
    • z_user = $ ZABBIX_USERNAME#此用户必须具有管理员权限
    • z_pass = $ ZABBIX_PASSWORD
    • timezone = Asia / Calcutta#如果你在印度。

在zabbixdynamicpdfreport

中更改目录并创建目录

cd Zabbix_/zabbix­dynamic­pdf­report mkdir tmp report

将zabbix auth更改为登录方法,登录zabbix服务器时需要它。

sed ­i 's,user.authenticate,user.login,g' inc/ZabbixAPI.class.php sed ­i 's,user.authenticate,user.login,g' inc/ZabbixAPI.class.php.org

将zabbixdynamicpdfreport复制到/ usr / share / zabbix /

cp ­r /opt/Zabbix_/zabbix­dynamic­pdf­report /usr/share/zabbix/

重新启动apache

service apache2 restart

打开生成PDF报告页面

http://zabbix.example.com/zabbix­dynamic­pdf­report/index.php

页面应如下所示:

enter image description here

现在您可以选择报告类型'HOST OR HOSTGROUP'并单击下拉列表以选择主机名或主机组名称

enter image description here