Skip to content

app_report_app

遇见王斌 edited this page Aug 1, 2017 · 2 revisions

日常使用报表(根据application名字进行特定搜索)

加个crontab,可以定期导出报表哦

注意:日常使用报表需要zabbix server 3.0.x 以上支持(程序中会调用 3.0.x 新增的 trend_get 接口支持)

1 报表功能

日常使用报表可以输出一段时间内特定的item(根据application名字进行特定搜索)在最高值、平均值、最小值,并将其输出到excel表格中

1.1 使用说明

#zabbix_api --report_app "CPU" "2017-01-01 00:00:00" "2017-03-01 00:00:00"  --table 

1.2 参数说明

  • 选择特定主机组或者主机
    • --hostgroupid,--hostid 选择特定主机组或者主机
  • 导出 excel 报表相关
    • --xls /tmp/ceshi.xls 导出excel文档,名字为ceshi.xls
    • --title title_name 导出excel文档的头标题
  • 输出内容相关
    • --sort num 对设置的列进行升序输出,通过--desc可以将升序修改为降序
    • --table 以表格内容在终端输出显示

2 报表实例

2.1 选择特定主机

查询特定host 的 application 列表

通过--hostgroupid,--hostid选择特定主机

[root@Linux ~]#zabbix_api --report_app "CPU" "2016-12-01 00:00:00" "2017-01-01 00:00:00" --table --hostid 10084
1.2.9
主机:ceshi
主机组:无
+CPU-----+-------+--------------------+---------+---------+---------+
| hostid | name  | itemName           | min     | max     | avg     |
+--------+-------+--------------------+---------+---------+---------+
| 10084  | ceshi | CPU idle time      | 35.9216 | 96.3813 | 93.0219 |
| 10084  | ceshi | CPU interrupt time | 0.0     | 0.0383  | 0.005   |
| 10084  | ceshi | CPU iowait time    | 2.2971  | 28.0711 | 4.9127  |
| 10084  | ceshi | CPU nice time      | 0.0     | 0.944   | 0.0008  |
| 10084  | ceshi | CPU softirq time   | 0.0334  | 0.7599  | 0.117   |
| 10084  | ceshi | CPU steal time     | 0.0     | 0.0     | 0.0     |
| 10084  | ceshi | CPU system time    | 0.5688  | 5.2582  | 0.8132  |
| 10084  | ceshi | CPU user time      | 0.2007  | 45.491  | 1.1232  |
+--------+-------+--------------------+---------+---------+---------+

其他方法和参数和日常使用报表(根据item名字模糊搜索)类似