AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-133815

Dan Garthwaite's questions

Martin Hope
Dan Garthwaite
Asked: 2014-08-08 12:53:16 +0800 CST

如何获取用户 ssh 所在的端口号?

  • 1

我正在将服务器从现有的多用户环境中的端口 22 转换出来。我已将 sshd 配置为侦听两个端口:22 和新端口。

现在我想检测用户何时连接或连接到端口 22。这显然比我预期的要难。

我尝试在 sshd_config 中启动日志记录,但即使 DEBUG 也没有记录端口号。

我目前正在扫描 netstat 的输出以查找与端口 22 的 TCP 连接,但这列出了来自随机机器人扫描程序的大量误报。【港口搬迁的原因】

ssh
  • 2 个回答
  • 350 Views
Martin Hope
Dan Garthwaite
Asked: 2014-04-17 08:05:31 +0800 CST

如何从“dpkg -l | grep ^rc”报告的过去 pkgs 中自动清理配置文件

  • 0

有许多 pkg 没有被“apt-get purge”删除,我想自动清理它们。

你不能apt-get purge apache2.2-common因为 pkg 已经被删除了。

您仍然可以列出 pkg 中的文件dpkg -L apache2.2-common。

这意味着我可以删除 pkg 中的文件列表,但是 dpkg 怎么知道呢?如何删除遗留的配置文件并将其从以下报告中删除?

示例输出:

$ dpkg -l | grep ^rc
rc  apache2.2-common                  2.2.14-5ubuntu8.10                Apache HTTP Server common files
rc  libapache2-mod-php5filter         5.3.10-1ubuntu2ppa6~lucid         server-side, HTML-embedded scripting languag
rc  libapr1                           1.3.8-1ubuntu0.3                  The Apache Portable Runtime Library
rc  libaprutil1                       1.3.9+dfsg-3ubuntu0.10.04.1       The Apache Portable Runtime Utility Library
rc  libgd2-xpm                        2.0.36~rc1~dfsg-3.1ubuntu1        GD Graphics Library version 2
rc  libt1-5                           5.1.2-3ubuntu0.10.04.2            Type 1 font rasterizer library - runtime
rc  php5-gd                           5.3.10-1ubuntu2ppa6~lucid         GD module for php5
rc  ssl-cert                          1.0.23ubuntu2                     simple debconf wrapper for OpenSSL
ubuntu
  • 1 个回答
  • 1729 Views
Martin Hope
Dan Garthwaite
Asked: 2014-01-13 08:54:53 +0800 CST

如何免除周末在 Nagios 的新鲜度检查

  • 1

谢谢你,serverfault,给了我how-does-an-administrator-generalize-alerting-when-an-event-doesnt-happen的答案。

现在,我只想在周一到周五检查这些被动服务的新鲜度。

有一些微妙之处:

  • 应该允许状态在周末有所改善。
  • 状态不应在周末降级。
  • 通知仍应在周末发出。

我能想到的最好的方法是 YACS - Yet Another Cron Script (to shave)。但即便如此,服务定义不是每周都需要切换吗?这种服务定义动态是否经常使用 Nagios 完成?

monitoring
  • 1 个回答
  • 804 Views
Martin Hope
Dan Garthwaite
Asked: 2013-11-15 14:18:56 +0800 CST

当事件没有发生时,管理员如何概括警报?

  • 6

通常,我的用户要求我同样负责知道事件是否尚未发生。

我总是不得不使用 cron'ed shell 脚本和大量的日期边缘案例测试来构建自定义和脆弱的解决方案。

集中式日志记录应该允许一种更好、更易于维护的方式来掌握过去 N 小时内没有发生的事情。诸如logstash 通知和nagios 警报之类的东西。

更新

toppledwagon 的回答非常有帮助。o O(灯泡。)我现在有十几个批处理作业正在检查新鲜度。我想让他彻底的回答公正,并跟进我是如何实施他的想法的。

我将 jenkins 配置为发出系统日志,logstash 捕获它们并通过 nsca 将状态更新发送到 nagios。我还使用 check_mk 来保持一切干燥并在 nagios 中组织。

Logstash 过滤器

:::ruby
filter {
  if [type] == "syslog" {
    grok {
      match => [ "message", '%{SYSLOGBASE} job="%{DATA:job}"(?: repo="%{DATA:repo}")?$',
                 "message", "%{SYSLOGLINE}" ]
      break_on_match => true
    }
    date { match => [ "timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ] }
  }
}

神奇之处在于 grok 的 match 参数中的那对模式以及 break_on_match => true。Logstash 将依次尝试每个模式,直到其中一个匹配。

Logstash 输出

我们使用 logstash nagios_nsca 输出插件让 icinga 知道我们在 syslog 中看到了 jenkins 作业。

:::ruby
output {
  if [type] == "syslog"
    and [program] == "jenkins"
    and [job] == "Install on Cluster"
    and "_grokparsefailure" not in [tags] {
      nagios_nsca {
        host => "icinga.example.com"
        port => 5667
        send_nsca_config => "/etc/send_nsca.cfg"
        message_format => "%{job} %{repo}"
        nagios_host => "jenkins"
        nagios_service => "deployed %{repo}"
        nagios_status => "2"
      }
   } # if type=syslog, program=jenkins, job="Install on Cluster"
} # output

冰糖 (nagios)

最后,我们通过 nsca 到达了 icinga (nagios)。现在,我们将需要为我们想要注意的每项工作定义的被动服务检查没有按时发生。这可能是很多工作,所以让我们使用check_mk将 Python 工作列表转换为 nagios 对象定义。

check_mk那样很酷。

/etc/check_mk/conf.d/freshness.mk

# check_mk requires local variables be prefixed with '_'

_dailies = [ 'newyork' ]
_day_stale = 86400 * 1.5

_weeklies = [ 'atlanta', 'denver', ]
_week_stale = 86400 * 8

_monthlies = [ 'stlouis' ]
_month_stale = 86400 * 32

_service_opts = [
    ("active_checks_enabled", "0"),
    ("passive_checks_enabled", "1"),
    ("check_freshness", "1"),
    ("notification_period", "workhours"),
    ("contacts", "root"),
    ("check_period", "workhours"),
]

# Define a new command 'check-periodically' that sets the service to UKNOWN.
# This is called after _week_stale seconds have passed since the service last checked in.

extra_nagios_conf += """
  define command {
    command_name check-periodicaly
    command_line $USER1$/check_dummy 3 $ARG1$
  }

  """
# Loop through all passive checks and assign the new check-period command to them.

for _repo in _dailies + _weeklies + _monthlies:
    _service_name = 'deployed %s' % _repo
    legacy_checks += [(('check-periodicaly', _service_name, False), ['lead'])]


# Look before you leap - python needs the list defined before appending to it.
# We can't assume it already exists because it may be defined earlier.

if "freshness_threshold" not in extra_service_conf:
    extra_service_conf["freshness_threshold"] = []

# Some check_mk wizardry to set when the check has passed its expiration date.
# Results in (659200, ALL_HOSTS, [ 'atlanta', 'denver' ]) for weeklies, etc.

extra_service_conf["freshness_threshold"] += [
    (_day_stale,   ALL_HOSTS, ["deployed %s"   % _x for _x in _dailies]  ),
    (_week_stale,  ALL_HOSTS, ["deployed %s"  % _x for _x in _weeklies] ),
    (_month_stale, ALL_HOSTS, ["deployed %s" % _x for _x in _monthlies] ),
]

# Now we assign all the other nagios directives listed in _service_opts

for _k,_v in _service_opts:
    if _k not in extra_service_conf:
        extra_service_conf[_k] =  []

    extra_service_conf[_k] += [(_v, ALL_HOSTS, ["deployed "]) ]
monitoring
  • 2 个回答
  • 3380 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve