-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdisk.yml
More file actions
27 lines (22 loc) · 786 Bytes
/
disk.yml
File metadata and controls
27 lines (22 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
- hosts: localhost
gather_facts: false
serial: 1
vars:
disk_usage_limit: 90
tasks:
- name: Getting All Disk Status
shell: '/bin/df -h | tail -n +2 | grep -vE "^Filesystem|tmpfs|devtmpfs" | sed s/%//g | awk "{ if(\$5 > {{ disk_usage_limit }}) print \$0 ;}"'
register: disk_status
- name: Sending Notifications to Channel
debug:
msg: "{{ disk_status.stdout }}"
when:
- disk_status.stdout != ''
# alternate method to find status
#df -lh -a "/home" | grep -vE "^Filesystem|tmpfs|devtmpfs" | awk '{ print $5 }' | cut -d'%' -f1"
# Todo
# 1. Remove above shell command with ansible facts {{ ansible_mounts }}
# 2. test on multiple systems
# 3. use below command to find largest files
# find -type f -exec du -Sh {} + | sort -rh | head -n 5