石墨测量的简单报警系统。

graphite_beacon_cron的Python项目详细描述


石墨灯塔[logo](https://raw.github.com/klen/graphite beacon/develop/beacon.png)


[graphite](http://graphite.wikidot.com/)度量的简单警报系统。

功能:

-最简单的安装(一个python包依赖)
-无软件依赖项(数据库,amqp等)
-轻量级和完全异步
-smtp、hipchat、slack、pagerduty、http处理程序(请请求其他处理程序)
-易于配置并支持历史值

[![构建状态](http://img.shields.io/travis/klen/graphite-beacon.svg?style=flat square)(http://travis ci.org/klen/graphite beacon)
[![报道](http://img.shields.io/covertalls/klen/graphite-beacon.svg?style=flat square)(https://covertalls.io/r/klen/graphite beacon)
[![版本](http://img.shields.io/pypi/v/graphite-beacon.svg?style=flat square)(https://pypi.python.org/pypi/graphite_beacon)
[![许可证](http://img.shields.io/pypi/l/graphite-beacon.svg?style=flat square)(https://pypi.python.org/pypi/graphite_beacon)
[![下载](http://img.shields.io/pypi/dm/graphite-beacon.svg?style=flat square)](https://pypi.python.org/pypi/graphite嫒beacon)


示例:
``js
{
"graphite嫒url":"http://g.server.org",
"smtp":{
"from":"beacon@server.org",
"to":["me@gmail.com"]
"alerts":[
"name":"mem
"format":"bytes",
"query":"aliasbynode(sumserieswithwildcards(collectd.*.memory.{memory free,memory cached},3),1)",
"rules":["critical:<;200MB","warning:<;400MB","warning:<;historical/2"]},
{"name":"cpu",
"format":"percent",
"query":"aliasbynode(sumserieswithwildcards(collectd.*.cpu-*.cpu user,2),1)",
"rules":["critical:>;=80%,"warning:>;=70%"]}
]}
```

——

-python(2.6,2.7,3,3.4)
-TORNADO
-FuncParserLib



在/etc/apt/sources.list系统配置文件中添加以下内容:

echo"deb src http://dl.bintray.com/klen/deb/";sudo tee-a/etc/apt/sources.list

apt-get:

apt-get update
apt-get install graphite beacon

/path/to/config.json:/srv/alerting/etc/config.json deliverous/graphite beacon



usage
----


>只需运行"graphite beacon":

$graphite beacon
[i 141025 11:16:23 core:141]读取配置
[i 141025 11:16:23 core:55]内存(10分钟):init
[I 141025 11:16:23 core:166]已加载选项:



\"4.1H"…





>;short'2k''2k''2k''2k''2k''2k''3mil''3bil''4bill''4bill''5tri''5tri'br/>
>;bytes'2kb''2kb''2kb''3mbb''4mbb''4gb''4gb''4gb''4gb''4gb''4gb''4gb''4gb''4gb'

>;bits'2kb''2kb''2kb''3mbb''3mbb''4gb''4gb''4gb''4gb'br/>
>;注意:JSON中不允许有注释,但是Graphite Beacon会将它们删除

``js

{
//Graphite服务器url
"Graphite URL":"http://localhost",

///公共Graphite服务器url
///在通知处理程序时使用,默认为Graphiterl
"public_graphite_url":空,

//http auth username
"auth_username":空,

///http auth password
"auth_password":空,

///指向pidfile
"pidfile"的路径:空,

/默认值格式(无,字节,秒,short)
/可以为每个警报重新定义。
"format":"short"、

///可以为每个警报重新定义默认查询间隔
/
"interval":"10min"、

///石墨查询的默认时间窗口
/默认为查询间隔,可以为每个警报重新定义。
"时间窗口":"10分钟"、

//通知重复间隔
//如果警报失败,则其通知将重复间隔
"重复间隔":"2小时",

//石墨查询的默认结束时间
//默认为当前时间,可以为每个警报重新定义。
"直到":"0second",

//默认日志级别
"logging":"info",

//默认方法(平均值、最后一个值、总和、最小值、最大值)。
//可以重新定义对于每个警报。
"method":"average",

//未收到数据时发送的默认警报(normal=无警报)
//可以为每个警报重新定义
"无数据":"critical",

//加载失败时发送的默认警报(超时、服务器错误等)
/(normal=无警报)
//可以为每个警报重新定义
"加载错误":"关键"

///默认前缀(用于通知)
"前缀":"[信标]",

///默认处理程序(日志、smtp、hipchat、http、slack、pagerduty)
"关键处理程序":["日志"、"smtp"],
"警告处理程序":["日志","smtp"],
"normal_handlers":["log","smtp"],

///发送初始值(当reactor启动时发送当前值)
"send_initial":true,

/一起用于忽略缺少的值
"default_nan value":-1,
"ignore_nan":false,

/默认警报(请参阅下面的配置)
"警报":[],

///要包含的其他配置文件的路径:
"包含":[]
}
`````

您可以使用配置文件设置选项。请参阅
[json](examples/example config.json)和
[yaml](examples/example config.yaml)的示例。


graphite metrics
-url alert-加载http并检查状态

>;注意:json中不允许有注释,但graphite beacon会将其删除

``js

"alerts":[
{
///(必需)alert name
"name":"memory",

/(必需)alert query
"query":"*.memory.memory free",

/(可选)警报类型(graphite,url)
"source":"graphite",

/(可选)默认值格式(none,bytes,s,ms,short)
"format":"bytes",

/(可选)警报方法(平均值,最后一个值,总和,最小值,最大值)
"method":"average",

/(可选)警报间隔[例如15秒、30分钟、2小时、1天、3个月、1年]
"间隔":"1分钟",

/(可选)在未收到数据时发送什么类型的警报(正常=无警报)
"无数据":"警告",

/(可选)警报间隔结束时间(请参见"警报间隔"示例)
"直到":"5秒",

//(必需)警报规则
///规则格式:"{level}:{operator}{value}"
/级别1[严重,警告,正常]
/[运算符之一,[>;,<;,>;=,<;=,=,!=]
//value(绝对值:3000000或缩写形式,如3MB/12分钟)
///多个条件可以用and或or分隔
"规则":["关键:<;200MB","警告:<;300MB"]
}
]
````


历史*1.5"

或内存小于常用值的一半:

"警告:<;历史/2"



保留每个查询的历史值。历史值
表示历史中所有值的平均值。使用历史值的规则只有在收集了足够的值(请参见"history_size")后才能生效。


默认情况下,历史值保留1天。您可以使用"历史记录大小"选项来更改此设置。


请参见下面的示例,了解当今天的新用户数小于最近10天平均数的80%时,如何发送警告:

``js
{
"名称":"注册",
///每天运行一次
"间隔":"1天",
"query":"Your Graphite query here",
/获取过去10天的平均值
"history_size":"10day",
"rules":[
//警告如果今天的新用户少于10天平均值的80%
"warning:<;history*0.8",
/如果今天的新用户在10天内低于平均值的50%,则为关键用户
"关键用户:<;历史用户*0.5"
]
}
],
```




>"至":[],//要发送到
"host":"localhost",//smtp host
"port":25,//smtp port
"username":null,//smtp user(可选)
"password":null,//smtp password(可选)
"use_tls":false,//use tls的电子邮件地址列表?
"html":真的,//发送html电子邮件?

//graphite电子邮件链接(默认情况下等于主graphite URL)
"graphite URL":null
}
}
````

'https://api.custom.hipchat.my',


"room":"myroom",
"key":"mykey"


````





` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` web钩子(http)




` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `"params":{},//(可选)附加查询(数据)参数
"method":"get//(可选)http method
}
}
````

___;slack handler

在slack上向用户或频道发送消息。

``js
{
"slack":{
"webhook":"https://hooks.slack.com/services/…",
"channel":"general"、//"channel"或@user(可选)
"username":"graphite beacon",







{值}--当前度量值
/${limit_value}——度量限制值
"command":"../myscript${level}${name}${value}…",

//将触发此处理程序的警报白名单(可选)
//如果不存在,所有警报都将触发此处理程序。
"警报白名单":["…"]
}
}
`````


/>"pagerduty":{
"subdomain":"yoursubdomain",
"apitoken":"apitoken",
"service-key":"servicekey",
}
}
``````

gram-bot-token",
"bot-ident":"用于激活组中bot的令牌"
}
}
````

`````
配置文件(json/yaml)
(default config.json)
--Graphite URL Graphite URL(default http://localhost)
--帮助显示此帮助信息
--pid file set pid file

--日志文件最大大小滚动前日志文件的最大大小
(默认值100000000)
--日志文件最大备份要保留的日志文件数(默认值10)
--日志文件前缀=日志文件的路径前缀。请注意,如果
正在运行多个Tornado进程,则每个
进程的
日志文件前缀必须不同(例如,包括端口号)
--日志到序列号将日志输出发送到stderr(如果可能,则为彩色)。默认情况下,如果未设置
--log_file_prefix且未配置其他
日志记录,则使用stderr。
--logging=debug info warning error none
设置python日志级别。如果"无",TORNADO
将不会触及日志记录配置。
(默认信息)
````


Bug Tracker
----


追踪器在https://github.com/klen/graphite beacon/issues


contributors
----

*Andrej Kuro_enko(https://github.com/kurochenko)
*Cody Soyland(https://github.com/cody soyland)
*Garrett Heel(https://github.com/garrett heel)
*George Ionita(https://github.com/georgeionita)
*james yuzawa(https://github.com/yuzawa san)
*kirill klenov(https://github.com/klen)
*konstantin bakulin(https://github.com/kbakulin)
*lammert hellinga(https://github.com/kogelvis)
*miguel moll(https://github.com/miguelmoll)
*nick pillitteri(https://github.com/56季度)
*niku toivola(https://github.com/nikut)
*olli pekka puolitaival(https://github.com/oppuolitaival)
*phillip hagedorn(https://github.com/phacedorn)
*raine virta(https://github.com/raine)
*scott nonnenberg(https://github.com/scottnonnenberg)
*Sean Johnson(https://github.com/pirogoeth)
*Terry Peng(https://github.com/tpeng)
*Thomas Clavier(https://github.com/tclavier)
*Yuriy Ilyin(https://github.com/yuriy ilyin)
*Dugeem(https://github.com/dugeem)
*Joakim(https://github.com/vibyjocke)


license
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java限制C++代码访问JNI中的某些类   Android上的java DateFormat:不可解析的日期   通过json进行java迭代,并为其他请求调用多个API   Netbeans中的java JavaFX项目引发异常“输入流不能为null”   多线程Java newFixedThreadPool解释   |在java字符串中无法识别。split()方法   Java中的原始包装器类是否被视为引用类型?   Java swing。如何在intellij idea GUI设计工具中重写组件方法   数组乘矩阵   java将30GB的XML文件分割成小块XML   java通过一棵树递归找到一个节点,并返回指向该节点的路径   java如何将可观察的<Observable<List<T>>转换为可观察的<List<T>>   使用java在web服务器上更改php文件中的字符串?   java希望开发像tomcat这样的servlet容器   java希望提高编程的数学技能