最小的监视工具

minitor的Python项目详细描述


小型车

最小的监控系统

它是做什么的?

minitor接受一个yaml配置文件,其中包含一组要运行的命令和一组要在这些命令失败时执行的警报。它的设计尽可能简单,并依赖于其他命令行工具来执行检查和发出警报。

但为什么呢?

我正在运行一些小型服务,发现sensu、consul、nagios等对我的用例来说都太复杂了。

那我该怎么用呢?

运行

使用以下命令安装和执行:

pip install minitor
minitor

如果是本地开发,您可以使用:

make run

它将读取config.yml的内容并开始循环。您还可以直接运行它,并通过--config参数提供一个新的配置文件。

码头工人

您可以直接从Docker中提取此存储库:

docker pull iamthefij/minitor

Docker映像使用从sample-config.yml复制的默认config.yml。这对你没有任何帮助,所以当你运行docker映像时,你应该提供你自己的config.yml文件:

docker run -v $PWD/config.yml:/app/config.yml iamthefij/minitor

配置

在这个repo中,您可以以sample-config.yml文件为例进行探索,但一般结构如下。应该注意的是,环境变量插值是在加载yaml文件时发生的。

全局配置是:

keyvalue
^{}Maximum frequency to run checks for each monitor
^{}List of all monitors. Detailed description below
^{}List of all alerts. Detailed description below

监视器

所有监视器都应列在monitors下。

每个监视器允许以下配置:

keyvalue
^{}Name of the monitor running. This will show up in messages and logs.
^{}Specifies the command that should be executed, either in exec or shell form. This command's exit value will determine whether the check is successful
^{}A list of Alerts to be triggered when the monitor is in a "down" state
^{}A list of Alerts to be triggered when the monitor moves to an "up" state
^{}The interval at which this monitor should be checked. This must be greater than the global ^{} value
^{}Allows specifying the number of failed checks before an alert should be triggered
^{}Allows specifying how often an alert should be retriggered. There are a few magic numbers here. Defaults to ^{} for an exponential backoff. Setting to ^{} disables re-alerting. Positive values will allow retriggering after the specified number of checks

警报

警报作为在{{CD11}}下键入的对象存在。他们的钥匙应该是警报的名字。这在alert_downalert_up中的监视器设置中使用。

每个警报允许以下配置:

keyvalue
^{}Specifies the command that should be executed, either in exec or shell form. This is the command that will be run when the alert is executed. This can be templated with environment variables or the variables shown in the table below

此外,在执行警报时,它们将通过python的format函数传递,该函数带有监控器某些属性的参数。可以使用python格式语法引用以下特定于监视器的变量:

tokenvalue
^{}Number of times this monitor has alerted
^{}The exception message that was raised
^{}The total number of sequential failed checks for this monitor
^{}The last returned value from the check command to either stderr or stdout
^{}The ISO datetime of the last successful check
^{}The name of the monitor that failed and triggered the alert

指标

从v0.3.0开始,minitor支持导出Prometheus的度量。普罗米修斯是一个开源工具,用于从不同来源读取和查询度量。结合另一个工具Grafana,它允许构建图表和仪表板。您也可以选择只使用minitor来记录检查结果,而不是使用grafana进行警报。

也可以使用metrics端点来监视minitor本身!这允许在不同的服务器上设置多个minitor实例,并让它们相互监视,以便您可以检测到minitor中断。

要使用度量运行minitor,请使用--metrics(或-m)标志。默认情况下,度量值将在端口8080上提供,但可以使用--metrics-port(或-p)覆盖它

minitor --metrics
# or
minitor --metrics --metrics-port 3000

贡献

无论您是想提交修补程序还是告诉我我弄坏了什么,都可以通过github镜像进行贡献,我可以将prs合并回源存储库。

一级回购:https://git.iamthefij.com/iamthefij/minitor.git

Github镜像:https://github.com/IamTheFij/minitor.git

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

推荐PyPI第三方库


热门话题
java拆分一个数组并将它们保存在两个单独的数组中   在java中将属性放入hashmap时如何从对象中排除属性   来自IntStream的字节的java Java8流哈希集   java Tomcat8。5和Openjdk11 NoClassDefFoundError:无法初始化类组织。阿帕奇。cxf。附件附件   Java程序无法使用字节数组正确复制文件   java Ivy OutOfMemoryIvy:发布期间出错   java在Restlet中,如何从服务器资源获取路由器实例?   java安全/加密log4j文件   在接口中声明常量和在java类中声明常量有什么区别   java在Linux中实现热键组合(alt+~)   枚举包装器中的java类型安全   java IBM portlet项目将css和jquery放在何处   java使用SharedReferences在ArrayAdapter中存储和检索字符串   java如何为ant设置环境变量   java是否可以持久存储样式化文本?   java返回while和if-else循环