运维自动化之基于python语言的文字界面的运维管理软件

简介:

之前开发了php+mysql+shell运维监控系统,监控起来很方便,但在运维管理方便还是不能实现,所以最近打算使用python语言编写一套的运维管理系统,可以使用单台或多台机器同时管理与部署等功能,实现类似functriaquae等管理软件功能。

本软件是参考了triaquae软件的思路(对方软件地址为http://triaquae2.sinaapp.com/),参考对方软件的组方面的部分代码,经过与原作者Alex Li的协商,允许我使用对方部分代码与思路,所以我把此软件进行开源,分享给大家。

 

 下面开始安装与应用测试

一、软件的安装
软件可以到https://github.com/dl528888/auto_op/里面进行下载
1、先解压软件
 
  1. root@squid:/tmp# tar zxvf auto_op.tar.gz   
  2. auto/  
  3. auto/auto_op.py  
  4. auto/setup.py  
  5. auto/install.txt  
安装前软件的结构
 
 
  1. root@squid:/tmp# tree auto  
  2. auto  
  3. |-- auto_op-software-install-and-function-document.docx         #中文的安装文档  
  4. |-- auto_op.py                                              #程序包  
  5. |-- install.txt                                             #软件介绍与安装说明  
  6. `-- setup.py                                                #部署环境与安装          
  7.  
  8. 0 directories, 4 files  
2、进入目录查看安装文档install.txt
 
  1. root@squid:/tmp# cd auto/  
  2. root@squid:/tmp/auto# ll  
  3. total 44  
  4. drwxr-xr-x 2 root root  4096 Mar 20 23:44 ./  
  5. drwxrwxrwt 8 root root  4096 Mar 21 09:56 ../  
  6. -rw-r--r-- 1 root root 24774 Mar 20 23:33 auto_op.py  
  7. -rw-r--r-- 1 root root   494 Mar 20 23:44 install.txt  
  8. -rw-r--r-- 1 root root  3346 Mar 20 22:53 setup.py  
  9. root@squid:/tmp/auto# cat install.txt   
  10. Version 1.0  
  11.  
  12. Introduction  
  13. This software is manage many servers.I refer to TriAquae.TriAquae's author is Alex Li.You can let all your Linux servers(or single server)  doing the same job in the same time,such as send a file,run a script,modify file,excute command and etc.  
  14.  
  15. Install  
  16.  
  17. 1. tar zxvf auto_op.tar.gz  
  18. 2. cd auto  
  19. 3. python setup.py build --prefix=/installdir/  
  20. 4. python setup.py install  
  21. 5. /installdir/auto_op.py  
  22.  
  23. Support  
  24.  
  25. If you have some problem , you can send mailto 244979152@qq.com.  
3、根据安装文档安装,先指定安装目录
 
  1. root@squid:/tmp/auto# python setup.py build --prefix=/usr/local/auto_op  
  2. Start to check pre-installation environment...................................  
  3.  
  4. direcotry not exsit,creating successful........  
  5. If no error printed out , you can run 'python setup.py install' to install the program  
4、然后再进行安装
 
  1. root@squid:/tmp/auto# python setup.py install  
  2. Extract files to working directory...  
  3.  
  4.  
  5. Complete ok  
  6. Now you can run /usr/local/auto_op/auto_op.py start manage your network.  
5、进入安装目录运行软件
 
  1. root@squid:/tmp/auto# cd /usr/local/auto_op/  
  2. root@squid:/usr/local/auto_op# ll  
  3. total 36  
  4. drwxr-xr-x  2 root root  4096 Mar 21 10:02 ./  
  5. drwxr-xr-x 12 root root  4096 Mar 21 10:02 ../  
  6. -rw-r--r--  1 root root 24783 Mar 21 10:02 auto_op.py  
  7. root@squid:/usr/local/auto_op# chmod 755 auto_op.py   
  8. root@squid:/usr/local/auto_op# ll  
  9. total 36  
  10. drwxr-xr-x  2 root root  4096 Mar 21 10:02 ./  
  11. drwxr-xr-x 12 root root  4096 Mar 21 10:02 ../  
  12. -rwxr-xr-x  1 root root 24783 Mar 21 10:02 auto_op.py*  
  13. root@squid:/usr/local/auto_op# ./auto_op.py   
  14. ------------------------------------Memu list-----------------------------------------------------------  
  15.                 1. Add new group  
  16.                 2. Rename group name  
  17.                 3. Delete group  
  18.                 4. List group member  
  19.                 5. List host in the group  
  20.                 6. Add new server to group  
  21.                 7. Delete server from group  
  22.                 8. Command excution on group servers  
  23.                 9. Command excution on one server  
  24.                 10. Upload or download on group servers  
  25.                 11. Upload or download on one server  
  26.                 12. Quit  
  27. --------------------------------Input number of you want to exec command---------------------------------  
  28.                                                                                Author is DengLei  
可以看到有很多选项,下面是介绍
 
  1. 1. Add new group                        #添加新组  
  2. 2. Rename group name                    #对组重命名  
  3. 3. Delete group                     #删除组  
  4. 4. List group member                    #列出已有的组名称与成员数量  
  5. 5. List host in the group                   #列出组内的主机ip  
  6. 6. Add new server to group              #增加新主机到组里  
  7. 7. Delete server from group             #删除组里的主机  
  8. 8. Command excution on group servers        #在组内的所有主机统一执行命令  
  9. 9. Command excution on one server       #对组内的某个主机执行命令  
  10. 10. Upload or download on group servers #对组内的所有主机进行上传与下载文件  
  11. 11. Upload or download on one server        #对组内的某个主机进行上传与下载文件  
  12. 12. Quit                                #退出  
安装后的软件结构
 
  1. root@squid:/tmp# tree /usr/local/auto_op/  
  2. /usr/local/auto_op/  
  3. |-- auto_op.py                          #程序包  
  4. |-- logs                                #日志目录  
  5. |   `-- operation.log                   #操作日志  
  6. `-- server_list                         #组目录  
  7.     `-- test                            #组  
  8.  
  9. 2 directories, 3 files  
二、测试
1、选择1进行创建新组
 
  1. please input you choice:1                           #选择1创建新组  
  2. please input new group name:test                        #组名为test  
  3. Created group test successful.  
  4. Do you want to add new server to Group test [ Y / N ]:y #选择添加新主机到test组里  
  5. Input new server IP or Hostname:192.168.101.235     #新主机的ip  
  6. Input newser's port:22                              #新主机的端口  
  7. Input newser's username:root                        #新主机的用户名  
  8. Input newser's password:123456                      #新主机的秘密  
  9. New server 192.168.101.235 added successfully.  

2、在新创建个one组,然后进行重命名组操作
 
  1. please input you choice:1                            #选项1是创建新组  
  2. please input new group name:one                      #新组名为one  
  3. Created group one successful.  
  4. Do you want to add new server to Group one [ Y / N ]:n  #不添加主机到组里     
  5. ------------------------------------Memu list-----------------------------------------------------------  
  6.                 1. Add new group  
  7.                 2. Rename group name  
  8.                 3. Delete group  
  9.                 4. List group member  
  10.                 5. List host in the group  
  11.                 6. Add new server to group  
  12.                 7. Delete server from group  
  13.                 8. Command excution on group servers  
  14.                 9. Command excution on one server  
  15.                 10. Upload or download on group servers  
  16.                 11. Upload or download on one server  
  17.                 12. Quit  
  18. --------------------------------Input number of you want to exec command---------------------------------  
  19.                                                                                Author is DengLei  
  20. please input you choice:2                            #选项2是对组重命名  
  21. ---------------  
  22. Which group name do you want to change?:one          #重命名组为one  
  23. New name:first                                   #重命名为first  
  24.  group name of one changed to first  
3、选择4查看本机所有组的状态
 
  1. please input you choice:4  
  2. now there is group is  
  3. test[1]  
  4. first[0]  
可以看到test组有1个成员,first没有成员
4、删除first组
 
  1. please input you choice:3                                #选项3是删除组  
  2. please inupt you want to del group name:first                #输入要删除的组名  
  3. first     
  4. Are you sure you want to delete groupfirst [ Y / N ]: y         #确认是否删除  
  5. Deleted group first  
  6.    
  7. ------------------------------------Memu list-----------------------------------------------------------  
  8.                 1. Add new group  
  9.                 2. Rename group name  
  10.                 3. Delete group  
  11.                 4. List group member  
  12.                 5. List host in the group  
  13.                 6. Add new server to group  
  14.                 7. Delete server from group  
  15.                 8. Command excution on group servers  
  16.                 9. Command excution on one server  
  17.                 10. Upload or download on group servers  
  18.                 11. Upload or download on one server  
  19.                 12. Quit  
  20. --------------------------------Input number of you want to exec command---------------------------------  
  21.                                                                                Author is DengLei  
  22. please input you choice:4                                #在查看一下当前的所有组  
  23. now there is group is  
  24. test[1]  
5、选择5查看test组里所有的主机
 
  1. please input you choice:5                                #选项5查看组内的主机  
  2.  
  3. Input Group name which the server is in:test                #输入查看的组名  
  4. ------------------------Server List----------------------------  
  5. 192.168.101.235                                      #test组内的主机  
6、选项6增加新主机到组里
 
  1. please input you choice:6                               #选项6添加新主机到组  
  2.  
  3. Input Group name which the server is in:test            #选项添加新主机的组  
  4. ------------------------Server List----------------------------  
  5. 192.168.101.235                                      #组内的所有主机  
  6.  
  7. groupfile is /usr/local/auto_op/server_list/test  
  8. Input new server IP or Hostname:192.168.101.236         #新主机的ip  
  9. Input newser's port:22                                  #新主机的端口  
  10. Input newser's username:root                            #新主机的用户  
  11. Input newser's password:123456                       #新主机的密码  
  12. New server 192.168.101.236 added successfully.  
  13. Keep on adding new server?:[ Y / N ]y                   #是否继续添加新主机  
  14. Input new server IP or Hostname:1.1.1.1  
  15. Input newser's port:22  
  16. Input newser's username:root  
  17. Input newser's password:123456  
  18. New server 1.1.1.1 added successfully.  
  19. Keep on adding new server?:[ Y / N ]n  
7、选择7删除主机从组里
 
  1. please input you choice:7  
  2.  
  3. Input Group name which the server is in:test  
  4. ------------------------Server List----------------------------  
  5. 192.168.101.235  
  6. 192.168.101.236  
  7. 1.1.1.1  
  8.  
  9.  
  10. Notice: All matched IP adresses will be deleted,becare  
  11. Input the server IP which you want to delete:1.1.1.1  
  12. 1.1.1.1  
  13. matched rows: 1  
  14. Do you want to delete all the matched rows?(y/n)y  
  15. IP 1.1.1.1 has been deleted from group test   
  16.  
  17. Notice: All matched IP adresses will be deleted,becare  
  18. Input the server IP which you want to delete:you command is CTRL+C go back  
  19. ------------------------------------Memu list-----------------------------------------------------------  
  20.                 1. Add new group  
  21.                 2. Rename group name  
  22.                 3. Delete group  
  23.                 4. List group member  
  24.                 5. List host in the group  
  25.                 6. Add new server to group  
  26.                 7. Delete server from group  
  27.                 8. Command excution on group servers  
  28.                 9. Command excution on one server  
  29.                 10. Upload or download on group servers  
  30.                 11. Upload or download on one server  
  31.                 12. Quit  
  32. --------------------------------Input number of you want to exec command---------------------------------  
  33.                                                                                Author is DengLei  
  34. please input you choice:5  
  35.  
  36. Input Group name which the server is in:test  
  37. ------------------------Server List----------------------------  
  38. 192.168.101.235  
  39. 192.168.101.236  

8、选项8对组内所有主机同时执行命令

 
  1. please input you choice:8                    #选择8对组内所有主机执行命令  
  2. now there is group is                        #列出当前所有的组  
  3. test[2]  
  4. please input you choice group:test               #输入项执行命令的组  
  5. You choice test group  
  6. please input you want to select command,Ctrl + C to quit:hostname       #输入执行的命令  
  7. -------------------------------  
  8. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:21:51  
  9. exec result is  
  10. linux-cbb3                                                   #执行的结果  
  11.  192.168.101.235 exec command ['hostname'] OK!  
  12. end time is 2013-03-21 10:21:51  
  13. -------------------------------  
  14. -------------------------------  
  15. start to connect ip 192.168.101.236 port 22 username root  at time 2013-03-21 10:21:51  
  16. exec result is  
  17. squid  
  18.  192.168.101.236 exec command ['hostname'] OK!  
  19. end time is 2013-03-21 10:21:52  
  20. -------------------------------  
  21. please input you want to select command,Ctrl + C to quit:  
9、选项9对组内的某个主机执行命令
 
  1. please input you choice:9                            #选择9  
  2. now there is group is                                 
  3. test[2]  
  4.  
  5. Input Group name which the server is in:test                                 #选择test组  
  6. ------------------------Server List----------------------------  
  7. 192.168.101.235  
  8. 192.168.101.236  
  9.  
  10. Please input you want to execute the command of the host name:192.168.101.235   #选择主机  
  11. please input you want to select command,Ctrl + C to quit:uptime              #输入命令  
  12. -------------------------------  
  13. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:23:50  
  14. exec result is  
  15.  10:25pm  up 152 days 18:02,  1 user,  load average: 0.07, 0.02, 0.00  
  16.  192.168.101.235 exec command ['uptime'] OK!  
  17. end time is 2013-03-21 10:23:51  
  18. -------------------------------  
  19. please input you want to select command,Ctrl + C to quit:  
10、选项10是对组内进行文件的上传与下载
 
  1. please input you choice:10  
  2. ------------------------------------Memu list-----------------------------------------------------------  
  3.                 1. Upload file to remote group servers  
  4.                 2. Download file to remote group server  
  5.                 3. Quit  
  6. --------------------------------Input number of you want to exec command---------------------------------  
  7.                                                                                Author is DengLei  
可以看到选项10里有3个选项
1、把本地的文件上传到组内所有主机里
2、从组内的所有主机下载文件到本机
3、退出
我们先进行1项,把本地的文件上传到组内所有主机里
 
  1. please input you choice:1  
  2. now there is group is  
  3. test[2]  
  4. please input you choice group:test  
  5. You choice test group  
  6. please input you want to upload localpath file name,Ctrl + C to quit:/tmp/log   #上传本机的文件  
  7. please input you want to upload remotepath file name,Ctrl + C to quit:/tmp/test-upload-file-to-group.log        #上传到组内主机的文件名  
  8. Are you sure upload file from /tmp/log to /tmp/test-upload-file-to-group.log in the test group y  
  9. ------------------------------- #确认是否传输  
  10. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:28:46  
  11. 192.168.101.235 exec put /tmp/log to /tmp/test-upload-file-to-group.log OK!  
  12. end time is 2013-03-21 10:28:47  
  13. -------------------------------  
  14. -------------------------------  
  15. start to connect ip 192.168.101.236 port 22 username root  at time 2013-03-21 10:28:47  
  16. 192.168.101.236 exec put /tmp/log to /tmp/test-upload-file-to-group.log OK!  
  17. end time is 2013-03-21 10:28:47  
  18. -------------------------------  
查询的话就是
 
  1. please input you choice:8  
  2. now there is group is  
  3. test[2]  
  4. please input you choice group:test  
  5. You choice test group  
  6. please input you want to select command,Ctrl + C to quit:ls -l /tmp/test-upload-file-to-group.log  
  7. -------------------------------  
  8. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:30:42  
  9. exec result is  
  10. -rw-r--r-- 1 root root 21 Mar 21 22:30 /tmp/test-upload-file-to-group.log  
  11.  192.168.101.235 exec command ['ls -l /tmp/test-upload-file-to-group.log'] OK!  
  12. end time is 2013-03-21 10:30:42  
  13. -------------------------------  
  14. -------------------------------  
  15. start to connect ip 192.168.101.236 port 22 username root  at time 2013-03-21 10:30:42  
  16. exec result is  
  17. -rw-r--r-- 1 root root 21 Mar 21 10:28 /tmp/test-upload-file-to-group.log  
  18.  192.168.101.236 exec command ['ls -l /tmp/test-upload-file-to-group.log'] OK!  
  19. end time is 2013-03-21 10:30:43  
  20. -------------------------------  
下面进行选项2,从组内的所有主机下载文件到本机
 
  1. please input you choice:10  
  2. ------------------------------------Memu list-----------------------------------------------------------  
  3.                 1. Upload file to remote group servers  
  4.                 2. Download file to remote group server  
  5.                 3. Quit  
  6. --------------------------------Input number of you want to exec command---------------------------------  
  7.                                                                                Author is DengLei  
  8. please input you choice:2  
  9. now there is group is  
  10. test[2]  
  11. please input you choice group:test  
  12. You choice test group  
  13. please input you want to download localpath file name,Ctrl + C to quit:/tmp/test-download-to-group.log  
  14. please input you want to download remotepath file name,Ctrl + C to quit:/tmp/test-upload-file-to-group.log  
  15. Are you sure download file from /tmp/test-download-to-group.log to /tmp/test-upload-file-to-group.log in the test group y  
  16. -------------------------------  
  17. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:32:13  
  18. 192.168.101.235 exec get /tmp/test-upload-file-to-group.log from /tmp/test-download-to-group.log_192.168.101.235 OK!  
  19. end time is 2013-03-21 10:32:13  
  20. -------------------------------  
  21. -------------------------------  
  22. start to connect ip 192.168.101.236 port 22 username root  at time 2013-03-21 10:32:13  
  23. 192.168.101.236 exec get /tmp/test-upload-file-to-group.log from /tmp/test-download-to-group.log_192.168.101.236 OK!  
  24. end time is 2013-03-21 10:32:14  
我这回是把之前上传的/tmp/test-upload-file-to-group.log文件给现在到本地,命名为/tmp/test-download-to-group.log,由于是不同主机把文件传给本机,所以我在文件名后面加上了他们的ip好区分。
下面是查看的结果
 
  1. please input you choice:8  
  2. now there is group is  
  3. test[2]  
  4. please input you choice group:test  
  5. You choice test group  
  6. please input you want to select command,Ctrl + C to quit:ls -l /tmp/test-download-to-group.log*  
  7. -------------------------------  
  8. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:34:22  
  9. exec result is  
  10. 192.168.101.235 exec command ['ls -l /tmp/test-download-to-group.log*'] OK!  
  11. end time is 2013-03-21 10:34:22  
  12. -------------------------------  
  13. -------------------------------  
  14. start to connect ip 192.168.101.236 port 22 username root  at time 2013-03-21 10:34:22  
  15. exec result is  
  16. -rw-r--r-- 1 root root 21 Mar 21 10:32 /tmp/test-download-to-group.log_192.168.101.235  
  17.  -rw-r--r-- 1 root root 21 Mar 21 10:32 /tmp/test-download-to-group.log_192.168.101.236  
  18.  192.168.101.236 exec command ['ls -l /tmp/test-download-to-group.log*'] OK!  
  19. end time is 2013-03-21 10:34:23  
  20. -------------------------------  
可以看到主机192.168.101.236已经获得了/tmp/test-download-to-group.log_192.168.101.235与/tmp/test-download-to-group.log_192.168.101.236的2个文件
11、选项11是进行组内某主机的上传与下载,也就是单台主机的
 
  1. please input you choice:11  
  2. ------------------------------------Memu list-----------------------------------------------------------  
  3.                 1. Upload file to remote one server  
  4.                 2. Download file to remote one server  
  5.                 3. Quit  
  6. --------------------------------Input number of you want to exec command---------------------------------  
  7.                                                                                Author is DengLei  
里面也有3个选项
1、从本机上传文件给远程主机
2、从远程主机下载文件给本机
3、退出
现在进行选项1,从本机上传文件给远程主机
 
  1. please input you choice:1  
  2. now there is group is  
  3. test[2]  
  4.  
  5. Input Group name which the server is in:test  
  6. ------------------------Server List----------------------------  
  7. 192.168.101.235  
  8. 192.168.101.236  
  9.  
  10. Please input you want to execute the command of the host name:192.168.101.235  
  11. please input you want to upload localpath file name,Ctrl + C to quit:/tmp/test-download-to-group.log_192.168.101.236  
  12. please input you want to upload remotepath file name,Ctrl + C to quit:/tmp/test-upload-to-host.log  
  13. Are you sure upload file from /tmp/test-download-to-group.log_192.168.101.236 to /tmp/test-upload-to-host.log in the 192.168.101.235 host y  
  14. -------------------------------  
  15. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:38:44  
  16. 192.168.101.235 exec put /tmp/test-download-to-group.log_192.168.101.236 to /tmp/test-upload-to-host.log OK!  
  17. end time is 2013-03-21 10:38:44  
  18. -------------------------------  
然后查询
 
  1. please input you choice:9  
  2. now there is group is  
  3. test[2]  
  4.  
  5. Input Group name which the server is in:test  
  6. ------------------------Server List----------------------------  
  7. 192.168.101.235  
  8. 192.168.101.236  
  9.  
  10. Please input you want to execute the command of the host name:192.168.101.235  
  11. please input you want to select command,Ctrl + C to quit:ls -l /tmp/test-upload-to-host.log  
  12. -------------------------------  
  13. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:39:59  
  14. exec result is  
  15. -rw-r--r-- 1 root root 21 Mar 21 22:40 /tmp/test-upload-to-host.log  
  16.  192.168.101.235 exec command ['ls -l /tmp/test-upload-to-host.log'] OK!  
  17. end time is 2013-03-21 10:40:00  
  18. -------------------------------  
可以看到文件已经上传到192.168.101.235主机了
现在进行选项2,从远程主机下载文件给本机
 
  1. please input you choice:11  
  2. ------------------------------------Memu list-----------------------------------------------------------  
  3.                 1. Upload file to remote one server  
  4.                 2. Download file to remote one server  
  5.                 3. Quit  
  6. --------------------------------Input number of you want to exec command---------------------------------  
  7.                                                                                Author is DengLei  
  8. please input you choice:2  
  9. now there is group is  
  10. test[2]  
  11.  
  12. Input Group name which the server is in:test  
  13. ------------------------Server List----------------------------  
  14. 192.168.101.235  
  15. 192.168.101.236  
  16.  
  17. Please input you want to execute the command of the host name:192.168.101.235  
  18. please input you want to download localpath file name,Ctrl + C to quit:/tmp/test-download-to-host.log  
  19. please input you want to download remotepath file name,Ctrl + C to quit:/tmp/test-upload-to-host.log  
  20. Are you sure download file from /tmp/test-download-to-host.log to /tmp/test-upload-to-host.log in the 192.168.101.235 host y  
  21. -------------------------------  
  22. start to connect ip 192.168.101.235 port 22 username root  at time 2013-03-21 10:41:04  
  23. 192.168.101.235 exec get /tmp/test-upload-to-host.log from /tmp/test-download-to-host.log_192.168.101.235 OK!  
  24. end time is 2013-03-21 10:41:04  
  25. -------------------------------  
进行查看
 
  1. please input you choice:9  
  2. now there is group is  
  3. test[2]  
  4.  
  5. Input Group name which the server is in:test  
  6. ------------------------Server List----------------------------  
  7. 192.168.101.235  
  8. 192.168.101.236  
  9.  
  10. Please input you want to execute the command of the host name:192.168.101.236  
  11. please input you want to select command,Ctrl + C to quit:ls -l /tmp/test-download-to-host.log_192.168.101.235  
  12. -------------------------------  
  13. start to connect ip 192.168.101.236 port 22 username root  at time 2013-03-21 10:41:45  
  14. exec result is  
  15. -rw-r--r-- 1 root root 21 Mar 21 10:41 /tmp/test-download-to-host.log_192.168.101.235  
  16.  192.168.101.236 exec command ['ls -l /tmp/test-download-to-host.log_192.168.101.235'] OK!  
  17. end time is 2013-03-21 10:41:46  
  18. -------------------------------  
也传输成功
12、操作日志查看
所有的操作都有存放到日志里,方便查看
 
  1. root@squid:/tmp# cd /usr/local/auto_op/  
  2. root@squid:/usr/local/auto_op# ll  
  3. total 44  
  4. drwxr-xr-x  4 root root  4096 Mar 21 10:03 ./  
  5. drwxr-xr-x 12 root root  4096 Mar 21 10:02 ../  
  6. -rwxr-xr-x  1 root root 24783 Mar 21 10:02 auto_op.py*  
  7. drwxr-xr-x  2 root root  4096 Mar 21 10:09 logs/  
  8. drwxr-xr-x  2 root root  4096 Mar 21 10:19 server_list/  
  9. root@squid:/usr/local/auto_op# cd logs/  
  10. root@squid:/usr/local/auto_op/logs# ll  
  11. total 16  
  12. drwxr-xr-x 2 root root 4096 Mar 21 10:09 ./  
  13. drwxr-xr-x 4 root root 4096 Mar 21 10:03 ../  
  14. -rw-r--r-- 1 root root 5415 Mar 21 10:41 operation.log  
  15. root@squid:/usr/local/auto_op/logs# tail -f operation.log   
  16. 2013-03-21 10:36:40   show group test server list['192.168.101.235', '192.168.101.236']  
  17. 2013-03-21 10:38:44   192.168.101.235 exec put /tmp/test-download-to-group.log_192.168.101.236 to /tmp/test-upload-to-host.log OK!  
  18. 2013-03-21 10:39:08   show group test server list['192.168.101.235', '192.168.101.236']  
  19. 2013-03-21 10:39:25   192.168.101.235 exec command ['ls -l /tmp/test-download-to-group.log_192.168.101.236'] OK!  
  20. 2013-03-21 10:39:50   show group test server list['192.168.101.235', '192.168.101.236']  
  21. 2013-03-21 10:40:00   192.168.101.235 exec command ['ls -l /tmp/test-upload-to-host.log'] OK!  
  22. 2013-03-21 10:40:38   show group test server list['192.168.101.235', '192.168.101.236']  
  23. 2013-03-21 10:41:04   192.168.101.235 exec get /tmp/test-upload-to-host.log from /tmp/test-download-to-host.log_192.168.101.235 OK!  
  24. 2013-03-21 10:41:24   show group test server list['192.168.101.235', '192.168.101.236']  
  25. 2013-03-21 10:41:46   192.168.101.236 exec command ['ls -l /tmp/test-download-to-host.log_192.168.101.235'] OK!  
可以看到之前的操作

现在本软件的所有功能就都实现了,希望各位能多提供建议与问题,也希望各位同仁能一起分享一下自己对运维自动化的经验,多对软件进行开源,谢谢。






 本文转自 reinxu 51CTO博客,原文链接:http://blog.51cto.com/dl528888/1159510,如需转载请自行联系原作者


相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
12天前
|
数据采集 存储 API
网络爬虫与数据采集:使用Python自动化获取网页数据
【4月更文挑战第12天】本文介绍了Python网络爬虫的基础知识,包括网络爬虫概念(请求网页、解析、存储数据和处理异常)和Python常用的爬虫库requests(发送HTTP请求)与BeautifulSoup(解析HTML)。通过基本流程示例展示了如何导入库、发送请求、解析网页、提取数据、存储数据及处理异常。还提到了Python爬虫的实际应用,如获取新闻数据和商品信息。
|
23天前
|
运维 监控
现代运维中的自动化技术应用与挑战
现代运维工作中,自动化技术的应用已成为提高效率、降低成本的重要手段。本文探讨了自动化技术在运维领域的应用现状和挑战,包括自动化工具的选择、实施过程中的注意事项以及未来发展趋势。通过深入分析,帮助读者更好地理解和应用自动化技术,提升运维工作效率。
12 2
|
28天前
|
Web App开发 Python
在ModelScope中,你可以使用Python的浏览器自动化库
在ModelScope中,你可以使用Python的浏览器自动化库
15 2
|
1月前
|
人工智能 运维 监控
现代运维中的自动化趋势与挑战
随着信息技术的快速发展,现代运维领域也面临着越来越多的挑战与机遇。本文将探讨当前运维中自动化的趋势以及相关的挑战,分析自动化在提高效率、降低成本等方面的重要性,并讨论未来运维领域的发展方向。
28 2
|
1天前
|
人工智能 Python
【Python实用技能】建议收藏:自动化实现网页内容转PDF并保存的方法探索(含代码,亲测可用)
【Python实用技能】建议收藏:自动化实现网页内容转PDF并保存的方法探索(含代码,亲测可用)
14 0
|
6天前
|
前端开发 Java Go
开发语言详解(python、java、Go(Golong)。。。。)
开发语言详解(python、java、Go(Golong)。。。。)
|
11天前
|
Web App开发 测试技术 网络安全
|
11天前
|
监控 jenkins 测试技术
深入探索软件自动化测试的高效策略
【4月更文挑战第13天】 随着软件开发周期的不断缩短和发布频率的增加,传统的手动测试方法已难以满足快速迭代的需求。本文将详细探讨如何通过有效的自动化测试策略提高测试效率和质量。我们将分析自动化测试中的关键要素,包括测试用例的设计、框架选择、持续集成的应用以及性能监控,并结合实际案例来展示如何构建和维护一个健壮的自动化测试系统。文中还将讨论自动化测试过程中常见的误区和挑战,为读者提供实用的解决方案和最佳实践。
|
14天前
|
机器学习/深度学习 JavaScript 前端开发
机器学习模型部署:使用Python和Vue搭建用户友好的预测界面
【4月更文挑战第10天】本文介绍了如何使用Python和Vue.js构建机器学习模型预测界面。Python作为机器学习的首选语言,结合Vue.js的前端框架,能有效部署模型并提供直观的预测服务。步骤包括:1) 使用Python训练模型并保存;2) 创建Python后端应用提供API接口;3) 利用Vue CLI构建前端项目;4) 设计Vue组件实现用户界面;5) 前后端交互通过HTTP请求;6) 优化用户体验;7) 全面测试并部署。这种技术组合为机器学习模型的实用化提供了高效解决方案,未来有望更加智能和个性化。
|
15天前
|
JSON 测试技术 持续交付
自动化测试与脚本编写:Python实践指南
【4月更文挑战第9天】本文探讨了Python在自动化测试中的应用,强调其作为热门选择的原因。Python拥有丰富的测试框架(如unittest、pytest、nose)以支持自动化测试,简化测试用例的编写与维护。示例展示了使用unittest进行单元测试的基本步骤。此外,Python还适用于集成测试、系统测试等,提供模拟外部系统行为的工具。在脚本编写实践中,Python的灵活语法和强大库(如os、shutil、sqlite3、json)助力执行复杂测试任务。同时,Python支持并发、分布式执行及与Jenkins、Travis CI等持续集成工具的集成,提升测试效率和质量。