在讲gweb 自定义view时, 我们看到json文件里面对items主机配置时, 可以选择查看主机的graph还是metric,
# pwd
/data01/web/ganglia-web/conf
view_jira.json
{
"view_name":"jira", # 视图名称
"items":[ # 视图里包含的东西, 配置为列表形式, 如下
{ "hostname":"web01.domain.com","graph":"cpu_report"}, # 图表1, 单台主机的单个graph. 在graph.d目录中定义具体内容
{ "hostname":"web03.domain.com","metric":"cpu_aidle"}, # 图表3, 单台主机的单个metric
...
metric很好理解, 使用gmond -m就能查看所有module支持的metric.
graph则是一些metric的组合, 在graph.d目录中配置.
例如 :
[root@db-172-16-3-221 graph.d]# pwd
/data01/web/ganglia-web/graph.d
[root@db-172-16-3-221 graph.d]# ll
total 80
-rw-r--r-- 1 nobody 1000 578 Jan 6 2014 apache_report.json
-rw-r--r-- 1 nobody 1000 186 Jan 6 2014 apache_response_report.json
-rw-r--r-- 1 nobody 1000 426 Jan 6 2014 cpu_report.json
-rw-r--r-- 1 nobody 1000 9065 Jan 6 2014 cpu_report.php
-rw-r--r-- 1 nobody 1000 476 Jan 6 2014 load_all_report.json
-rw-r--r-- 1 nobody 1000 590 Jan 6 2014 load_report.json
-rw-r--r-- 1 nobody 1000 680 Jan 6 2014 mem_report.json
-rw-r--r-- 1 nobody 1000 8324 Aug 4 03:04 mem_report.php
-rw-r--r-- 1 nobody 1000 4973 Jan 6 2014 metric.php
-rw-r--r-- 1 nobody 1000 355 Jan 6 2014 network_report.json
-rw-r--r-- 1 nobody 1000 1616 Jan 6 2014 nfs_v3_client_report.json
-rw-r--r-- 1 nobody 1000 358 Jan 6 2014 packet_report.json
-rw-r--r-- 1 nobody 1000 6392 Jan 6 2014 sample_report.php
-rw-r--r-- 1 nobody 1000 3543 Jan 6 2014 varnish_report.php
[root@db-172-16-3-221 graph.d]# cat cpu_report.json
{
"report_name" : "cpu_report",
"report_type" : "template",
"title" : "CPU Report",
"graphite" : "target=alias(HOST_CLUSTER.cpu_user.sum,'User')&target=alias(HOST_CLUSTER.cpu_nice.sum%2C'Nice')&target=alias(HOST_CLUSTER.cpu_system.sum,'System')&target=alias(HOST_CLUSTER.cpu_wio.sum,'Wait')&target=alias(HOST_CLUSTER.cpu_idle.sum%2C'Idle')&areaMode=stacked&max=100&colorList=3333bb,ffea00,dd0000,ff8a60,e2e2f2"
}
[root@db-172-16-3-221 graph.d]# cat load_all_report.json
{
"report_name" : "load_all_report",
"report_type" : "standard",
"title" : "Load All Report",
"vertical_label" : "load",
"series" : [
{ "metric": "load_one", "color": "3333bb", "label": "Load 1", "line_width": "2", "type": "line" },
{ "metric": "load_five", "color": "ffea00", "label": "Load 5", "line_width": "2", "type": "line" },
{ "metric": "load_fifteen", "color": "dd0000", "label": "Load 15", "line_width": "2", "type": "line" }
]
}
graph的命名规则 :
?_report.json
内容解释 :
Graph configuration
Key: Value
report_name: Name of the report that web UI uses.
title: Title of the report to show on a graph.
vertical_label: Y-axis description (optional).
series: An array of metrics to use to compose a graph.
Series options
Key: Value
metric: Name of a metric, such as load_one and cpu_system. If the metric doesn’t exist it will be skipped.
color: A 6 hex-decimal color code, such as 000000 for black.
label: Metric label, such as Load 1.
type: Item type. It can be either line or stack.
line_width: If type is set to line, this value will be used as a line width. If this value is not specified, it defaults to 2. If type is stack, it's ignored even if set.
通过配置?_report.json, 我们可以简化view的json配置.
[参考]
1. http://blog.163.com/digoal@126/blog/static/1638770402014815105622529/
时间: 2024-10-21 16:45:25