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:

1 beacons:
2   inotify:
3     - files:
4         /etc/important_file: {}
5         /opt: {}

View Code

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中:

1 beacons:
2   inotify:
3     - files:
4         /etc/important_file:
5           mask:
6             - modify
7     - disable_during_state_run: True

View Code

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进行修改并保存。 您将在事件总线上看到与以下内容类似的事件:

1 {
2  "_stamp": "2015-09-09T15:59:37.972753",
3  "data": {
4      "change": "IN_IGNORED",
5      "id": "larry",
6      "path": "/etc/important_file"
7  },
8  "tag": "salt/beacon/larry/inotify//etc/important_file"
9 }

View Code

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:

1 revert-file:
2   local.state.apply:
3     - tgt: {{ data['data']['id'] }}
4     - arg:
5       - maintain_important_file

View Code

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']}}是正确的,因为它匹配上面显示的事件结构。

转载于:https://www.cnblogs.com/zuoyang/p/9239767.html

【SaltStack官方版】—— EventsReactor系统—BEACONS相关推荐

  1. gts250 linux驱动下载,英伟达GTS250显卡驱动下载_GTS250显卡驱动官方版下载 - 系统之家...

    英伟达gts250显卡驱动(NVIDIA Geforce GTS 250驱动)官方版是一款非常实用的电脑显卡驱动程序,是从目前NVIDIA中端市场上较火的一款产品GeForce 9800GTX+进化而 ...

  2. win7系统备份还原软件_泰哥一键备份还原下载_泰哥一键备份还原官方版下载[系统备份]...

          泰哥一键备份还原官方版是一款优秀的系统备份还原工具,泰哥一键备份还原官方版可以帮助用户在 Win32(64).WinPE.DOS 下对任意分区进行一键备份.恢复,泰哥一键备份还原官方版支持 ...

  3. 【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 ...

  4. 【SaltStack官方版】—— returners——返回器

    ETURNERS 返回器 By default the return values of the commands sent to the Salt minions are returned to t ...

  5. u盘修复linux系统,360u盘修复工具官方版u盘pe安装linux系统

    电脑配件质量不佳或损坏,是引起显示器黑屏故障的主要成因.如内存,显示卡,主板.CPU等出现问题肯定可能引起黑屏故障的出现.其故障表现为显示器灯呈橘黄色,此时可用替换法更换下显示卡,内存.CPU,主板等 ...

  6. Android11vivox21刷机包,vivo x21旧版官方固件rom系统刷机包

    这是vivo x21旧版官方固件rom系统刷机包,可以做备用,降级可用!!vivo x21已经提示更新了,如果你的手机更新之后系统没有之前好用的,可以选择降级用,直接完整版的固件rom包下载,解压出来 ...

  7. 最新系统之家系统win11 32位官方版v2021.07

    最新系统之家系统win11 32位官方版v2021.07是一款全新的电脑系统,用户可以轻松感受到微软在新版本系统方面的强大性.无论开机菜单的实用性还是桌面的简洁性都给用户带来了全新的感受.而且对于海量 ...

  8. 全国计算机等级考试模拟系统中 二级c语言的 安装密码,NCRE模拟考试系统安卓版下载-2017全国计算机等级考试二级练习系统v2.4.1 官方版下载__飞翔下载...

    2017全国计算机等级考试练习软件,模拟全真考试环境,包含2017年计算机考试的题目,重点,只要多练习题目,考试很容易就合格了.欢迎有需要的用户下载使用. 安装说明: 软件分两部分安装,首先安装系统包 ...

  9. win10系统下载中文版 64位32位 官方版​

    win10系统下载中文版 64位&32位 官方版 软件大小:4.9GB 软件语言:简体中文 软件类别:操作系统 软件授权:官方版 更新时间:2015-01-22 应用平台:/Win8/Win7 ...

最新文章

  1. 在cisco路由器上实现DHCP功能实例
  2. 单独使用 EHCache
  3. 安卓收藏功能怎么实现_收藏!微信群接龙功能怎么操作?
  4. 电商企业纷纷结缘信息化 管理系统如何给力?
  5. java流处理为什么快_“任何情况下,都不可以堕胎”是道德普遍主义的观点。
  6. activity 启动模式_Android世界:Activity的启动模式及其适用范围
  7. Java读取word文件,字体,颜色
  8. pythonsys标准_python 以标准输出(sys.stdout)为例,看python的标准输入、标准错误输出...
  9. 中国首部智能交通微纪录片正式发布 探讨交通强国高质量发展路径
  10. 不思议迷宫c语言基础,不思议迷宫神龙收藏品一览
  11. windows linux mysql_linux/windows环境mysql数据库安装与使用
  12. linux执行db2的sql脚本,LinuxShell自动执行当前目录所有DB2 SQL语句
  13. 数字员工到岗,普通员工惊慌?先别急,往下看
  14. 安卓手机充电慢_很火的安卓手机充电特效设置
  15. 高斯正算matlab,MATLAB实现高斯-克吕格投影正算
  16. Django实战: Python爬虫爬取链家上海二手房信息,存入数据库并在前端显示
  17. moss2007 是什么_MOSS 2007站点权限
  18. 7-5 走楼梯升级版(PTA程序设计)
  19. 【hadoop生态之Hive】Hive的DML数据操纵语言【笔记+代码】
  20. 用Python写简历

热门文章

  1. spring boot中小学餐饮配送系统 毕业设计-附源码645661
  2. ●「.|貓」erPhotoshop滤镜巧制超级美女插画效果
  3. 前端框架ice飞冰与java后台交互分享
  4. App在后台被杀死后重启-重进首页方法
  5. Spring源码解析-bean实例化
  6. IPHONE开发 VIEW之间的相互切换
  7. 不可不知的量化因子模型选股策略
  8. 金融科技之交易:动量效应选股策略
  9. Cocos2d-JS打造:国内首款正版海贼王手游《航海王启航》
  10. nginx的log_format日志格式和字段介绍