ganglia gweb events or "user defined markers"

在说gweb的event 前, 我先举个例子 : 

在办公室有时会听到NOC的同事大喊, 流量飙升了, 怎么回事?

然后一般会有同事回应可能是在跨机房拷贝一些文件或者数据什么的, 又或者是在做跨机房的数据备份什么的.

如果在流量图上有标记的话, 那么NOC的同事对待这种流量突变的情况也不会一惊一乍.

gweb支持配置event, 这里指的event就是用户定义的时间段标签.

例如 : 

配置文件目录和customize view的目录一样

http://blog.163.com/digoal@126/blog/static/1638770402014815105622529/

/data01/web/ganglia-web/conf/events.json

包含的内容举例 : 

[
  { "event_id":"1234",   # 事件 ID
    "start_time":1308496361,  # 开始时间
    "end_time":1308496961,  # 结束时间
    "summary":"DB Backup",    # summary
    "description":"Prod daily db backup",  # 事件描述
    "grid":"*",
    "cluster":"*",
    "host_regex":"centos1"  # 主机名规则表达式
  },
  { "event_id":"2345",  # 第二个事件的内容
    "start_time":1308497211,
    "summary":"FS cleanup",
    "grid":"*",
    "cluster":"*",
    "host_regex":"centos1"
  }
]

当events很多时, 解析JSON可能会增加CPU负载, 可以考虑使用mdb2格式, 即将event存入MYSQL数据库. 需要修改conf.php

默认的conf.php中event相关的配置如下 : 

# What is the provider use to provide events.
# Examples: "json", "mdb2"
$conf['overlay_events_provider'] = "json";
# Where is the Overlay events file stored
$conf['overlay_events_file'] = $conf['conf_dir'] . "/events.json";

# If using MDB2, connection string:
$conf['overlay_events_dsn'] = "mysql://dbuser:dbpassword@localhost/ganglia";

$conf['overlay_events_color_map_file'] = $conf['conf_dir'] . "/event_color.json";

例子, 使用events.json添加event.

获得一个时间, 用于start_time

digoal=# SELECT EXTRACT(EPOCH FROM now()),now();
    date_part     |              now
------------------+-------------------------------
 1410765863.10149 | 2014-09-15 15:24:23.101488+08
(1 row)

编辑events.json

[root@db-172-16-3-221 conf]# vi events.json
[
  { "event_id":"digoal",
    "start_time":1410765863,
    "end_time":1410765999,
    "summary":"DB Backup",
    "description":"Prod daily db backup",
    "grid":"*",
    "cluster":"*",
    "host_regex":".*"
  }
]

现在在图中就可以看到这个事件了. summary会显示在图中 : 

通过这个图我们就知道这个时候正在做数据库备份, 如果流量上升的话可以得到合理的解释.

(当然不排除恰巧同时也发生了其他事件到在图形的异常)

除了使用events.json来编辑创建event, 还可以使用web界面或者API来创建event.

使用WEB 界面来创建event.

也可以使用API来创建event : 

通过HTTP GET或POST请求来创建event.

An easy way to manipulate events is through the Ganglia Events API, which is available
from your gweb interface at  /ganglia/api/events.php. To use it, invoke the URL along
with key/value pairs that define events. Key/value pairs can be supplied as either GET
or POST arguments. The full list of key/value pairs is provided in : 

Key: Value
action: addto add a new event, editto edit, removeor deleteto remove an event.
start_time: Start time of an event. Allowed options are now(uses current system time), UNIX timestamp, or any other well formed date, as supported by PHP’s strtotime function.
end_time: Optional. Same format as start_time.
summary: Summary of an event. It will be shown in the graph legend.
host_regex: Host regular expression, such as web-|app-.

例子 : 

curl "http://mygangliahost.com/ganglia/api/events.php?\
action=add&start_time=now&\
summary=Prod DB Backup&host_regex=db02"

OR

curl -X POST --data " action=add&start_time=now\
&summary=Prod DB Backup&host_regex=db02" \
http://mygangliahost.com/ganglia/api/events.php

返回值 : 

API will return a JSON-encoded status message with either status = ok or status = error.
If you are adding an event, you will also get the  event_idof the event that was just
added in case you want to edit it later, such as to add an end_time.

[参考]
1. http://blog.163.com/digoal@126/blog/static/1638770402014810227936/

2. http://blog.163.com/digoal@126/blog/static/1638770402014815105622529/

时间: 2024-08-22 14:44:45

ganglia gweb events or "user defined markers"的相关文章

ganglia gweb AUTH configure with nginx

ganglia的认证是基于Zend框架来写的, 权限分布可见lib/GangliaAcl.php. (默认所有集群归属于ALL_CLUSTERS, 所有用户归属于GUEST, 默认GUEST角色有所有cluster的VIEW权限, 没有EDIT权限. ADMIN角色有所有cluster的VIEW和EDIT权限; 私有cluster: GUEST没有私有cluster的任何权限(其实是回收了VIEW权限)) 参考 :  http://framework.zend.com/manual/1.12/e

ganglia gweb customize views

上一篇简单的将了一些gweb的聚合和比较视图. 那些视图都是临时创建的, gweb还支持配置自定义视图标签, 方便随时使用. 其实功能和gweb的聚合和比较视图类似, 只是把这些标签化了, 方便随时来使用. 创建视图的规则 :  Defining views using JSON Views are stored as JSON files in the conf_dir directory. The default for the conf_diris /var/lib/ganglia/con

ganglia gweb Custom Composite Graphs

在讲gweb 自定义view时, 我们看到json文件里面对items主机配置时, 可以选择查看主机的graph还是metric, # pwd /data01/web/ganglia-web/conf view_jira.json { "view_name":"jira", # 视图名称 "items":[ # 视图里包含的东西, 配置为列表形式, 如下 { "hostname":"web01.domain.com&

Tomcat源码分析——server.xml文件的解析

前言 在<Tomcat源码分析--server.xml文件的加载>一文中我们介绍了server.xml的加载,本文基于Tomcat7.0的Java源码,接着对server.xml文件是如何解析的进行分析. 概要 规则 Tomcat将server.xml文件中的所有元素上的属性都抽象为Rule,以Server元素为例,在内存中对应Server实例,Server实例的属性值就来自于Server元素的属性值.通过对规则(Rule)的应用,最终改变Server实例的属性值. Rule是一个抽象类,其中

KBMMW 4.92.00 发布

We are happy to announce the release of kbmMW Professional and Enterprise Edition. Yet again kbmMW continues to set the bar for what an n-tier product must be capable of in the real world! Keywords for this release: - New memory debugging/leak detect

gweb &amp; nginx configure

gweb是ganglia的组件之一, 前面我简单的写了一些gmond, gmetad的安装和配置. http://blog.163.com/digoal@126/blog/static/1638770402014810227936/ http://blog.163.com/digoal@126/blog/static/1638770402014810346993/ 简单来讲gmond用于采集监控数据, gmetad将采集到的监控数据写入rrd数据文件. gweb则负责可视化工作. 要使用gweb

ganglia - distributed monitor system

传统的监控系统, 通常采用agent+server的方式, agent负责收集监控信息, 主动或被动发送给server, server负责向agent请求监控数据(agent被动), server和agent都通常使用TCP来进行连接.  传统监控的主要弊端, 当被监控的主机很多的情况下, server端的压力会很大, 例如要监控2万台主机的30个监控项, 就有60万个监控数据要从agent收集, 假设每分钟收集一次监控数据, 每秒需要上千次的metric get请求.  ganglia的设计思

ganglia Spoof with Modules or gmetric

spoof的作用是篡改metric包里主机IP, 主机名, metric名的信息. 例如我们要在A主机监控其他主机或应用, 同时通过A主机发送到网络上的metric接收者, 正常情况下, metric发出去会携带A主机的IP, 主机名. 那么就导致接收方会按照IP将信息写入A主机对应的RRD文件, 在gweb上显示时, 也会显示在A主机的监控项里面. 但实际上我们希望它写入其他主机对应的rrd文件. 如图1, 在不使用spoof时, 如果从a主机将b,c,d的监控数据发出去, 会写入a主机IP对

ganglia metric introduce

本文主要介绍一下ganglia metric的概念, 为以后更好的了解metric的扩展. metric即监控项, gmond自带的核心模块中, 包含了7类监控项目, 共计40几个监控项. 使用gmond -m可以查看所有的监控项. 我们先来了解一下metric的数据结构 :  ganglia-3.6.0/lib/gm_protocol.h struct Ganglia_25metric { int key; char *name; // metric name, 一台主机的metric nam