php - Zabbix 导出图形 (.PNG) 文件

标签 php linux curl zabbix

我的目标:

我想以 .png 格式提取与主机关联的图表。我的 GOOGLE 研究表明我们没有专为完成此任务而设计的 Zabbix API。很少有博客建议用户使用 Chart2.php 和 CURL。有人可以向我解释如何去做(详细步骤)吗?

注意:抱歉从来没有在 php 和 curl 上工作过

当我尝试过

curl https://example.com/zabbix/chart2.php?graphid=1552&width=300&height=300

知道了,但是链接打不开

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="/zabbix/openid?graphid=1552&amp;modauthopenid.referrer=https%3A%2F%2Fexample.com%2Fzabbix%2Fchart2.php%3Fgraphid%3D1552">here</a>.</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at example.com Port 80</address>
</body></html>

另外,我如何将它与我的 zabbix api (JAVA) 调用结合起来?

最佳答案

这适用于普通的密码身份验证,您需要将其调整为我不使用的 openid,而且您肯定必须更改选项才能使用 curl。

1。 wget --save-cookies=z.coo -4 --keep-session-cookies -O - -S --post-data='name=(一个zabbix用户名)&password=(密码)&enter=Enter' 'http://example.com/zabbix/index.php?login=1'

2。 wget -4 --load-cookies=z.coo -O result.png 'http://example.com/zabbix/chart2.php?graphid=410&width=1778&period=102105&stime=20121129005934'

第一个发布身份验证并保存 cookie。第二个加载相同的 cookie 文件并检索 png。

您肯定想在不使用 shell 的情况下实现它,而是使用您喜欢的语言和 zabbix 的 JSON-RPC API,其中已经有很多客户端库。

尽管据我所知,您仍然需要像这样登录才能获取图表的图像。至少目前是这样。

编辑:https://support.zabbix.com/browse/ZBXNEXT-562是投票(或开始工作)的人

关于php - Zabbix 导出图形 (.PNG) 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13653853/

相关文章:

php - 使用php从日期中减去天、月或年

perl - 相当于此 perl 代码的curl 命令行

tomcat - 我的 docker 容器 kong 以 "An invalid response was received from the upstream server"响应

javascript - 将 curl 转换为 Javascript ajax 代码

PHP 何时使用 filter_var 而不是内置 php 函数

php - 简单的 PHP 表单 : Attachment to email (code golf)

php - 使用 php 和 mysql 从多个数组表单输入插入数据

linux - 需要 shell 脚本,当检测到我的 5 个重写规则文件中的任何更改/修改时,将执行/etc/init.d/httpd

linux bash : reacting to -c and -[0-9] in a case

linux - 如何正确配置 ssh proxycommand 以运行 docker exec?