【SaltStack官方版】—— Events&Reactor系统—BEACONS
Events&Reactor系统—BEACONS
Beacons let you use the Salt event system to monitor non-Salt processes. The beacon system allows the minion to hook into a variety of system processes and continually monitor these processes. When monitored activity occurs in a system process, an event is sent on the Salt event bus that can be used to trigger a reactor.
beacons使您可以使用Salt事件系统来监视非Salt进程。 beacon系统允许minion进入各种系统进程并持续监控这些进程。 当监视的活动发生在系统进程中时,Salt事件总线上会发送一个事件,用于触发反应堆。
Salt beacons can currently monitor and send Salt events for many system activities, including:
Salt beacons目前可以监视和发送Salt事件以用于许多系统活动,包括:
- file system changes
- system load
- service status
- shell activity, such as user login
- network and disk usage
See beacon modules for a current list. 请参阅当前列表的beacon模块。
Note
Salt beacons are an event generation mechanism. Beacons leverage the Salt reactor system to make changes when beacon events occur.
Salt beacons是一种事件生成机制。beacons事件发生时,beacons利用Salt反应堆系统进行更改。
configuring beacons
Salt beacons do not require any changes to the system components that are being monitored, everything is configured using Salt.
Salt beacons不需要对正在监测的系统组件进行任何更改,所有内容均使用Salt进行配置。
Beacons are typically enabled by a beacons:
top level block in /etc/salt/minion
or any file in /etc/salt/minion.d/
such as /etc/salt/minion.d/beacons.conf
or add it to pillars for that minion:
beacons通常通过放置beacons:在/etc/salt/minion或/etc/salt/minion.d/中的任何文件(如/etc/salt/minion.d/beacons.conf)来启用或将那个minion添加到pillars:
beacons:
inotify:
- files:
/etc/important_file: {}
/opt: {}
The beacon system, like many others in Salt, can also be configured via the minion pillar, grains, or local config file.
像Salt中的许多其他系统一样,Beacon系统也可以通过pillar, grains或本地配置文件进行配置。
Note
The inotify beacon only works on OSes that have inotify kernel support. Currently this excludes FreeBSD, macOS, and Windows.
inotify beacon只适用于具有inotify内核支持的操作系统。 目前这不包括FreeBSD,macOS和Windows。
create watched file
Create the file named /etc/important_file
and add some simple content:
创建名为/etc/important_file的文件并添加一些简单的内容:
important_config: True
add beacon configs to minion
On the Salt minion, add the following configuration to /etc/salt/minion.d/beacons.conf
:
在Salt minion上,将以下配置添加到/etc/salt/minion.d/beacons.conf中:
beacons:
inotify:
- files:
/etc/important_file:
mask:
- modify
- disable_during_state_run: True
Save the configuration file and restart the minion service. The beacon is now set up to notify salt upon modifications made to the file.
保存配置文件并重新启动minion的服务。beacon现在设置为在对文件进行修改时通知salt。
Note
The disable_during_state_run: True parameter prevents the inotify beacon from generating reactor events due to salt itself modifying the file.
disable_during_state_run:True参数可以防止inotify beacon生成反应器事件,因为salt本身会修改文件。
view events on the master
On your Salt master, start the event runner using the following command:
在你的Salt master上,使用以下命令启动事件执行器:
salt-run state.event pretty=true
This runner displays events as they are received by the master on the Salt event bus. To test the beacon you set up in the previous section, make and save a modification to /etc/important_file
. You'll see an event similar to the following on the event bus:
这个执行在Salt事件总线上由maser接收时显示事件。 要测试您在前一节中设置的beacon,请对/etc/important_file进行修改并保存。 您将在事件总线上看到与以下内容类似的事件:
{
"_stamp": "2015-09-09T15:59:37.972753",
"data": {
"change": "IN_IGNORED",
"id": "larry",
"path": "/etc/important_file"
},
"tag": "salt/beacon/larry/inotify//etc/important_file"
}
This indicates that the event is being captured and sent correctly. Now you can create a reactor to take action when this event occurs.
这表示事件正在被捕获并正确发送。 现在,您可以创建一个反应堆,在发生此事件时采取行动。
create a reactor
This reactor reverts the file named /etc/important_file
to the contents provided by salt each time it is modified.
该反应器在每次修改时将名为/etc/important_file的文件恢复为salt提供的内容。
reactor sls
On your Salt master, create a file named /srv/reactor/revert.sls
.
在Salt master端,创建一个名为/srv/reactor/revert.sls
.
Note
If the /srv/reactor directory doesn't exist, create it.
mkdir -p /srv/reactor
Add the following to /srv/reactor/revert.sls
:
revert-file:
local.state.apply:
- tgt: {{ data['data']['id'] }}
- arg:
- maintain_important_file
Note
In addition to setting disable_during_state_run: True for an inotify beacon whose reaction is to modify the watched file, it is important to ensure the state applied is also idempotent.
除了设置disable_during_state_run:True对于反应修改观察文件的inotify beacon而言,重要的是要确保所应用的状态也是幂等的。
Note
The expression {{ data['data']['id'] }} is correct as it matches the event structure shown above.
表达式{{data ['data'] ['id']}}是正确的,因为它匹配上面显示的事件结构。
【SaltStack官方版】—— Events&Reactor系统—BEACONS的更多相关文章
- 【SaltStack官方版】—— Events&Reactor系统—EVENT SYSTEM
Events&Reactor系统 EVENT SYSTEM The Salt Event System is used to fire off events enabling third pa ...
- 【SaltStack官方版】—— EVENTS & REACTOR指南
EVENTS & REACTOR Event System Event Bus Event types Salt Master Events Authentication events Sta ...
- 【SaltStack官方版】—— returners——返回器
ETURNERS 返回器 By default the return values of the commands sent to the Salt minions are returned to t ...
- 【SaltStack官方版】—— STORING JOB RESULTS IN AN EXTERNAL SYSTEM
STORING JOB RESULTS IN AN EXTERNAL SYSTEM After a job executes, job results are returned to the Salt ...
- 【SaltStack官方版】—— MANAGING THE JOB CACHE
MANAGING THE JOB CACHE The Salt Master maintains a job cache of all job executions which can be quer ...
- 【SaltStack官方版】—— job management
JOB MANAGEMENT New in version 0.9.7. Since Salt executes jobs running on many systems, Salt needs to ...
- 【SaltStack官方版】—— states教程, part 3 - 定义,包括,延伸
STATES TUTORIAL, PART 3 - TEMPLATING, INCLUDES, EXTENDS 本教程建立在第1部分和第2部分涵盖的主题上.建议您从此开始.这章教程我们将讨论更多 s ...
- 【SaltStack官方版】—— states教程, part 2 - 更复杂的states和必要的事物
states tutorial, part 2 - more complex states, requisites 本教程建立在第1部分涵盖的主题上.建议您从此处开始. 在Salt States教程的 ...
- 【SaltStack官方版】—— states教程, part 4 - states 说明
STATES TUTORIAL, PART 4 本教程建立在第1部分.第2部分.第3部分涵盖的主题上.建议您从此开始.这章教程我们将讨论更多 sls 文件的扩展模板和配置技巧. This part o ...
随机推荐
- Jmeter之Synchronizing Timer(同步集合点)
在性能测试时,需要压测并发,此时就需要用到Synchronizing Timer组件. 一.界面显示 二.配置说明 1.名称:标识 2.注释:备注 3.Grouping (1.Number of si ...
- OutLook会议室预定提醒
项目组采用敏捷开发管理,每两周一个迭代.写个工具做会议室预定. 代码下载:https://download.csdn.net/download/linmilove/10547579 Appointme ...
- Matlab与C++混合编程 1--在C++中调用自己写的matlab函数
在Visual Studio中使用C++中调用MATLAB程序 在matlab中可以通过mbuild工具将.m文件编译成dll文件供外部的C++程序调用,这样就可以实现matlab和C++混合编程的目 ...
- 5.使用github脚本LAZY----几个最好的发行版----自定义终端----基本命令
使用现成的脚本 LAZY * 如果您不想手动设置,可以用这个脚本帮您设置 访问:github.com/arismelachroinos/lscript sudo apt-get git git clo ...
- 【Qt开发】状态栏设置
1.在Qt 里面,状态栏显示的信息有三种类型:临时信息.一般信息和永久信息. 其中,临时信息指临时显示的信息,比如QAction 的提示等,也可以设置自己的 临时信息,比如程序启动之后显示Read ...
- 【Linux开发】【Qt开发】arm-linux-gnueabihf-gdb versus gdb-multiarch
主要是说,在Ubuntu14.04 64bit的操作系统上,配置Qt的gdb和gcc的时候,在Qt build&run选项中,debugger中选中arm-linux-gnuabihf-gdb ...
- 【Qt开发】解决Qt5.7.0中文显示乱码的问题
[Qt开发]解决Qt5.7.0中文显示乱码的问题 亲测可用: 乱码主要是编码格式的问题,这里可以通过Edit菜单中选择当前文档的编码方式,选择按照UTF-8格式保存,然后输入对应的中文,保存,然后运行 ...
- 文档压缩 | gzip、bzip2、xz
6.文档的压缩与打包 Linux下常见后缀名所对应的的压缩工具 .gz 表示由gzip压缩工具压缩的文件 .bz2 表示由bzip2压缩工具压缩的文件 .tar 表示由tar打包程序打包的文件(tar ...
- 递归 dfs 记忆化搜索 动态规划
今天做洛谷P1434 [SHOI2002]滑雪 的时候仔细想了想记忆化搜索 现在总结一下 为了描述问题的某一状态,必须用到该状态的上一状态,而描述上一状态,又必须用到上一状态的上一状态……这种用自已来 ...
- [BZOJ 3509] [CodeChef] COUNTARI (FFT+分块)
[BZOJ 3509] [CodeChef] COUNTARI (FFT+分块) 题面 给出一个长度为n的数组,问有多少三元组\((i,j,k)\)满足\(i<j<k,a_j-a_i=a_ ...