zoukankan      html  css  js  c++  java
  • ansible 基础巡检

    1.通过ansible 每天对线上的机器磁盘、内存、负载进行巡检

    [root@BS003 probject]# cat cpu.yaml 

    - name: Statistics CPU Memory Disk Utilization

      hosts: zabbix-agent

      tasks:

      become: no

      remote_user: "{{ user }}"

      gather_facts: no

      tasks:

        - name: "Statistics CPU Memory Disk Utilization..."

          shell: |

            free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%) ", $3,$2,$3*100/$2 }'

            df -h -t ext2 -t ext4 | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print "Disk Usage:"" " $1 " " $3"/"$2" ""("$5")"}'

            top -bn1 | grep load | awk '{printf "CPU Load: %.2f ", $(NF-2)}'

          register: out

        - debug: var=out.stdout_lines

    [root@BS003 probject]# 

  • 相关阅读:
    c#委托与事件
    c#垃圾回收与资源管理
    c#接口、抽象类
    c#集合类、ArrayList、queue
    c#位运算
    c#索引器
    c#使用属性封装
    c#继承
    c#数组参数
    Lambda表达式
  • 原文地址:https://www.cnblogs.com/sseban/p/13048195.html
Copyright © 2011-2022 走看看