Hi,
I want to configure to check the file system free space available everyday and send mail if it is more than 80% . I tried with the below YAML code, but didn't work.
---
- name: Check Filesystem Usage
hosts: 10.190.0.36
gather_facts: true
tasks:
- name: Get Filesystem Facts
shell: "df -h /|grep -v Filesystem|awk '{print $4}'|cut -d G -f1"
register: df_out
- debug:
var: df_out.stdout_lines[1] | !int
- name: Send Email Notification
command: echo "Filesystem Usage is above the threshold." | mail -s "Filesystem Alert"
ebrahi...@gmail.com when: df_out.stdout_lines[1] | int > 30 # Specify the threshold percentage here
...
Regards,
Ebrahim