IP邻居表监视脚本
MindYourNeighbors的Python项目详细描述
#关心你的邻居
根据您的直接邻居启动脚本
[![生成状态](https://travis-ci.org/jaesivsm/MindYourNeighbors.svg?branch=master)](https://travis-ci.org/jaesivsm/MindYourNeighbors)[![覆盖状态](https://coveralls.io/repos/github/jaesivsm/MindYourNeighbors/badge.svg?branch=master)](https://coveralls.io/github/jaesivsm/MindYourNeighbors?branch=master)[![代码气候](https://codeclimate.com/github/jaesivsm/MindYourNeighbors/badges/gpa.svg)](https://codeclimate.com/github/jaesivsm/MindYourNeighbors)
##怎么做?
mindYourNeighbors基本上解析IP邻居,如果发现配置未排除的结果,将启动一次已配置的命令。
##为什么?
原始用例:
用作路由器和家庭服务器的Linux盒。在这个盒子上运行着一些软件,这些软件可以很好地与消费(即:传输)结合在一起。 我想在其他用户使用网络时关闭这个软件。
##功能
mindYourNeighbors的行为可以通过配置文件进行控制,配置文件可以放在~/.config/mind\u your\neighborrds.cfg或/etc/mind\u your\neighborrds.cfg中。
配置文件按节组织。default部分包含默认选项,所有其他部分(除了日志级别和缓存文件路径)将继承这些选项。所有其他部分将逐个读取;每次filter_on廑regex或filter_on廑machine中定义的条件匹配,并且不被exclude中定义的条件排除,filter_out_regex或filter_out_machine缓存将填充标记neighbor或标记no neighbor。
缓存长度不能超过阈值,因为只考虑了ip neigh命令结果中的reachable行,而且这些行的变化很大,threshold参数允许您配置状态更改的速度。
当缓存中只有neighbor或no neighbor标记时,相应的命令将执行一次。
#####已知机器
您可以用known_machine作为标题填充一个部分,在其中您将写出您知道的机器的名称和mac地址。然后您就可以通过filter_out_machine和filter_on_machine来过滤它们。
请参考配置示例文件以了解实际用例。
##选项列表
####默认节选项
- loglevel: allows you to choose the verbosity level in the syslog between DEBUG, INFO, WARN, ERROR and FATAL.
- cache_file: the path to the file where MindYourNeighbors will store its cache.
####按部分,可重写选项
- threshold: the number of consecutive matches (or un matches) it takes for MindYourNeighbors to execute the “match” or “no match” command.
- filter_on_regex: a regex to filters lines from the ip neigh command, lines will have to match to be counted
- filter_out_regex: a regex to filters lines from the ip neigh command, matching line will be excluded
- exclude: a comma separated list of string. If one of those string should be found in a ip neigh line, it should be excluded.
- filter_on_machine: a comma separated list of machine names to filter in (they must be registered in known_machine)
- filter_out_machine: a comma separated list of machine names to filter out (they must be registered in known_machine)
- command_match: A command to execute when the cache has been filed with neighbor marker.
- command_no_match: A command to execute when the cache has been filed with no neighbor marker.
- device: if none provide the ip neigh command will be parsed else ip neigh show dev <device>.
- enable: a boolean (true or false), enabling or disabling a section.
- nslookup: a boolean (true or false), making MindYourNeighbors looking up domain names for IP it’ll print in the logs. Can be useful for debuging.
- error_on_stderr: a boolean (true or false); if true and the command print something on stderr, the command will be ignored and executed again.
- cron: a cron styled time description in which the section will be activated