File system monitoring

20 views
Skip to first unread message

Ebrahim Kutty

unread,
Jun 7, 2023, 4:07:17 AM6/7/23
to Ansible Project
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

Dick Visser

unread,
Jun 7, 2023, 5:18:10 AM6/7/23
to ansible...@googlegroups.com
On Wed, 7 Jun 2023 at 10:07, Ebrahim Kutty <ebrahi...@gmail.com> wrote:
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.

"Didn't work" is very little information.
But, even with the right amount of information I think it would be best to not (ab)use ansible for this task and instead use a dedicated monitoring system





   ---
   - 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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d50c6b7f-fc9a-429d-a40e-e3cac43184efn%40googlegroups.com.
--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages