推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
fsckzy
V2EX  ›  Python

想用 python 获取几十台服务器日志中指定关键词内容

  •  
  •   fsckzy · Dec 8, 2016 · 4544 views
    This topic created in 3616 days ago, the information mentioned may be changed or developed.

    求给点思路

    几十台服务器,同样的路径,我需要看看 log 文件里面有没有出现 127.0.0.1 这个 ip

    20 replies  •  2016-12-09 13:09:19 +08:00
    clino
    clino
    Dec 8, 2016
    1
    ansible
    erevus
    erevus
    Dec 8, 2016
    2
    elk
    wyntergreg
    wyntergreg
    Dec 8, 2016
    3
    不建议用 python 搜索关键词,可以用 python 把文件拿过来用文本工具进行搜索
    izoabr
    izoabr
    Dec 8, 2016
    4
    还不如脚本 ssh 挨个上去 grep '127.0.0.1'然后回传或者写入新文件呢
    knightdf
    knightdf
    Dec 8, 2016❤️1
    5
    for ssh grep 不久完了
    vus520
    vus520
    Dec 8, 2016
    6
    salt(salt-ssh)、 ansible 不好么, grep 出来,然后放到共享目录里
    czheo
    czheo
    Dec 8, 2016
    7
    加上 xargs -P 可以并发哦。
    est
    est
    Dec 8, 2016
    8
    ansible
    ywgx
    ywgx
    Dec 8, 2016 via iPhone
    9
    楼主,我给你总结一下你的需求?

    “如何管理大量服务器集群?”
    ywgx
    ywgx
    Dec 8, 2016 via iPhone
    10
    kinghs
    kinghs
    Dec 8, 2016
    11
    paramiko 可破
    SlipStupig
    SlipStupig
    Dec 8, 2016
    12
    @erevus 这么点小需求,用 elk 学习成本太高了
    cat /your/dir/*.log | sort | uniq | xargs -n 10 | grep -e ".*127.0.0.1.*",如果是远程的话可以用 rsync 同步一下就行了
    iyaozhen
    iyaozhen
    Dec 8, 2016 via Android
    13
    简单的需要。找一台跳板机,添加信任。然后登录到各个机器上去执行 grep
    skydiver
    skydiver
    Dec 8, 2016
    14
    polysh
    RealLiuSha
    RealLiuSha
    Dec 8, 2016
    15
    ansible playbook or command module
    ty89
    ty89
    Dec 8, 2016
    16
    pssh
    v2014
    v2014
    Dec 8, 2016
    17
    fabric
    Livid
    Livid
    MOD
    PRO
    Dec 8, 2016❤️1
    18
    1. 如果是一次性需求,用 Ansible
    2. 如果是持续需求,把日志推到 papertrailapp.com 然后为 127.0.0.1 这个关键词设定一个 alert
    cxmtime
    cxmtime
    Dec 9, 2016
    19
    和楼主有类似德需求,用 ruby 写了一个工具,自己用的顺手。
    hanbaobao2005
    hanbaobao2005
    Dec 9, 2016
    20
    嗯 同 15 楼, 建议 Ansible + log 分析
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5293 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 64ms · UTC 01:27 · PVG 09:27 · LAX 17:27 · JFK 20:27
    ♥ Do have faith in what you're doing.