有时候,我们想通过容器来监控主机(这也是openshift v3 正在做的),所有的监控都在容器中,从而实现快速部署 但是,默认情况下容器内是无法看到主机的所有进程的,如果想在容器中查看主机的所有进程,我们需要添加参数 –pid=host 加了这个参数启动的容器,会和主机使用同样的namespace,这样,我们就可以在容器中查……
python 希尔排序 动画演示
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
def shell_sort(arg): n = len(arg) gap = round(n/2) gap = int(gap) while gap > 0 : for i in range(gap,n): j = i while j > 0: if arg[j-gap] > arg[j]: arg[j-gap],arg[j]=arg[j],arg[j-gap] j = j-gap if gap == 1: break gap=round(gap/2) gap=int(gap) return arg |
代码参考地址:http://wuchong.me/blog/2014/02/09/algorithm-sort-summary/#comments 另外一个动画演示 希尔排序本质还是进行的插入排序,只不过把原来的数组拆……
北京最美桃花 颐和园 20170313
RHEL7 下控制服务的各种资源使用
cgroup 控制资源 CPU,内存,IO(旧版)RHEL6
如何在linux下限制各种资源
Tuned 调整系统性能
ansibleplaybook 如何使用tag
在日常的ansible-playbook中使用tags 来灵活控制我们向要执行的具体的task , 有时候能达到意想不到的效果 看例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
--- - hosts: all tasks: - name: My tagged task yum: name: httpd state: latest tags: production - name: Installs postfix yum: name: postfix state: latest |
只执行第一个task:
1 |
ansible-playbook main.yml --tags 'production' |
只执行第二个task: [crayon-642……
ansible playbook如何处理错误(rescue)
在日常使用ansible playbook的过程中,我们有时候希望做一下补救性的操作,做一些判断, 例如:
1 2 3 4 5 6 7 8 9 10 11 |
tasks: - block: - debug: msg='i execute normally' - command: /bin/false - debug: msg='i never execute, cause ERROR!' rescue: - debug: msg='I caught an error' - command: /bin/false - debug: msg='I also never execute :-(' always: - debug: msg="this always executes" |
如上的代码,第一部分出错后,会被rescue捕捉到,然后做一些补救性的工作,这个时候我们可以做一些有趣的任务例如: 1:我们要对httpd 的配置文件进行一些修改 如……