Polysh命令实现多日志查询的方法示例
作者:爱情小傻蛋 发布时间:2023-03-02 08:00:22
标签:Polysh,交互式命令,多日志查询
一、Polysh简介
Polysh 是一个交互式命令,可以在一台服务器上批量的对一批服务器进行处理,运行交互式命令。Polysh可以同时登录多个远程主机,而不需要通过relay一台一台的登录,并执行相同的指令,方便了问题的排查和定位,大大减少了我们的工作量。
Polysh is a tool to aggregate several remote shells into one. It is used to launch an interactive remote shell on many machines at once. It is written in Python and requires Python ≥ 2.4.
注: 官方解释:Polysh 是一个由几个远程脚本集合而成的工具,它被用于在许多服务器上运行一个交互式的远程脚本,由 Python 编写,最低要求为 Python 2.4 。
二、polysh安装
通过relay登录staging机器,执行如下命令安装polysh。安装目录为用户目录: /opt/hl/。
1.已安装python的安装
wget wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gz
tar -zxvf polysh-0.4.tar.gz
vim prod-polysh.sh
脚本内容如下:
#10.252.176.33,10.252.176.35是你要链接的机器ip
python /opt/hl/polysh-0.4/polysh.py {10.252.176.33,10.252.176.35}
开放给其他用户可执行的权限
chmod 777 prod-polysh.sh
2.未安装python的安装
wget wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gz
tar -zxvf polysh-0.4.tar.gz
cd polysh-0.4
su
python setup.py install
vim prod-polysh.sh
脚本内容如下:
#10.252.176.33,10.252.176.35是你要链接的机器ip
python /opt/hl/polysh-0.4/polysh.py {10.252.176.33,10.252.176.35}
开放给其他用户可执行的权限
chmod 777 prod-polysh.sh
三、Xshell配置Xagent(mac可跳过这一步)
打开文件-属性,选择SSH选项,选择”使用密码处理的Xagent(SSH代理)”。然后将Xshell重启。
四、polysh使用
4.1.使用方法一
polysh 10.252.176.33 10.252.176.35
4.2.使用方法二
./prod-polysh.sh
则会出现如下提示信息
[---hl-----]$ ./prod-polysh.sh
ready (8)
ready (8) 表示 8台机器已经连接完毕,可以执行查询命令。exit或Crtl+z都可以退出。
4.3.执行命令
ready (8)>cd /opt/hl
ready (8)>pwd
显示如下:
10.252.176.33: /opt/hl
10.252.176.35 : /opt/hl
五、源码
可以通过git获取polysh的源码
git clone git://repo.or.cz/polysh.git
六、其他
以冒号开头的指令不会发送到远程主机,polysh会执行以冒号开头的指令,例如:
ready (2)> :help
:add Add one or many remote shells.
:chdir Change the current directory of polysh (not the remote shells).
:disable Disable sending commands to remote shells.
:enable Enable sending commands to remote shells.
:export_vars Export some environment variables on enabled remote shells.
:help List control commands or show their documentations.
:hide_password Do not echo the next typed line.
:list List remote shells and their states.
:purge Delete disabled remote shells.
:quit Quit polysh.
:reconnect Try to reconnect to disconnected remote shells.
:rename Rename all enabled remote shells with the argument.
:replicate Copy a path from one remote shell to all others
:reset_prompt Change the prompt to be recognized by polysh.
:send_ctrl Send a control character to remote shells.
:set_debug Enable or disable debugging output for remote shells.
:set_log Duplicate every console I/O into the given local file.
:show_read_buffer Print the data read by remote shells.
:upload Upload the specified local path to enabled remote shells.
来源:http://www.jianshu.com/p/2ed0ad5ccb3f
0
投稿
猜你喜欢
- 服务器维护有一段时间了,这其中最大的收获莫过于对服务器的备份与恢复,今天总结相关内容与大家分享,希望对服务器维护的朋友有点帮助。1.系统备份
- Apache服务器的设置文件位于/usr/local/apache/conf/目录下,传统上使用三个配置文件httpd.conf,acces
- 相信在自己的网站上使用AdSense的朋友都曾遇到过展示英文广告的情况,即使网页内容全部为中文,即使访问用户全部来自中国或中文区域。虽然出现
- C.对表的内容的一些说明 mysql> use po
- 资金不是第一难题记者:如何看待目前整个web2.0行业的问题?如资金短缺、盈利模式难题、风投相对缩减等。试用网徐乐:不要急躁,不要做虚假流量
- 你的网站是不是常常被黑,或者一不注意就成了黑客的“肉鸡”?对于Web网站服务器来说,如果不进行安全设置,很容易被黑客“盯上”,随时都有被入侵
- 如果Google发现某个Adsense用户在点击自己的Adsense广告,那么会将这个Adsense帐号关闭。一些Adsense用户却不明白
- 衡量一个网站是否运营的成功,我想都离不开这几个要素,专业,互动,用户体验,亮点(围绕以盈利模式确立的亮点).一个简单的公式,专业+互动+用户
- 说明:满分50分,时间8分钟。请把答案写在纸上。一、单项选择题(2分×15=30分)1.搜索引擎搜索结果页面,简称什么?
- 最近在学习 python,使用 flask 实现了个个人博客程序,完了想部署到服务器上。因为是新手,一路磕磕绊绊最终把它基本搞定。网上资料对
- 有人问关键词在整个网站的布局问题。以前也写过帖子介绍过多个关键词的优化问题,今天再补充几点。简单说,多个关键词在网站中需要合理布局,最难的安
- 如果我们餐厅里的座位在一个角落,很难被服务员注意到,我们可能得大声的喊“服务员!”&ldqu
- 1.更新您的source ,我们之前提过 更新source不代表升级 ,仍需要经过编译的动作。 编译source 1./usr/src#ma
- 首先要安装VirtualBox的增强版功能(VBoxGuestAdditions)在 设备--->安装增强版功能----->运行
- Photoshop官方提供免费相册,非常酷的一个相册,全站基于Flash技术架构的,其操作非常方便。容量大小为2G,支持图片直接外链,仅可上
- server|window
- 有时,在处理Linux终端中的文件时,您可能希望清除文件的内容,而无需使用任何Linux命令行编辑器打开它。怎么能实现这一目标?在本文中,我
- 我开通了一个独立IP LINUX空间,空间支持伪静态功能。由于网站根目录下安装的是DEDECMS,bbs目录下安装的是论坛,home目录下安
- 先前我曾经报道过Google即将推出通过Google Analytics统计Google Adsense的功能,今天,我登录AdSense后
- 昨天晚上登录了一下 AdSense,很久没上去看看了,结果也没有让我绑定 Analytics 之类的提示和链接,因为至今人在使用老的 AdS