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%%)\n", $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\n", $(NF-2)}'
register: out
- debug: var=out.stdout_lines
[root@BS003 probject]#