-
-
Save canit00/6aeabfb56f06c10843ed76eecec8d75f to your computer and use it in GitHub Desktop.
Revisions
-
mahemoff revised this gist
Sep 15, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,4 +6,5 @@ ok: [host] => { * Note this only looks at first mount point on current node * Fails if disk is near-full * Last step pushes to a push-based monitoring service, which will alert us if it doesn't get there after some time * Need to setup a variable `disk_limit`, which is the max acceptable usage ratio, e.g. set it to 0.8 if you want to keep disks within 80% of max size -
mahemoff revised this gist
Sep 15, 2018 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,9 @@ * Shows a message while asserting like: ok: [host] => { "msg": "disk usage 4.2B of total 20.0GB (21.0%) (should exceed limit 90.0%)" } * Note this only looks at first mount point on current node * Fails if disk is near-full * Last step pushes to a push-based monitoring service, which will alert us if it doesn't get there after some time -
mahemoff revised this gist
Sep 15, 2018 . 1 changed file with 23 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,23 @@ - set_fact: mount: "{{ ansible_mounts | first }}" - set_fact: disk_usage="{{ mount.size_total - mount.size_available }}" - set_fact: disk_usage_ratio="{{ disk_usage|float / mount.size_total }}" - set_fact: disk_usage_s="{{ (disk_usage|float / 1000000000) | round(1, 'common') }}GB" - set_fact: disk_total_s="{{ (mount.size_total / 1000000000) | round(1, 'common') }}GB" - set_fact: disk_usage_ratio_s="{{ 100 * (disk_usage_ratio|float) | round(1, 'common') }}%" - set_fact: disk_limit_ratio_s="{{ (100 * disk_limit|float) |round }}%" - debug: msg: "disk usage {{ disk_usage_s }} of total {{ disk_total_s }} ({{ disk_usage_ratio_s }}) (should be within limit {{ disk_limit_ratio_s }})" - name: assert: that: ( (disk_usage|float)/mount.size_total ) < disk_limit|float msg: "Disk usage {{ disk_usage_ratio_s }} exceeds {{ disk_limit_ratio_s }}" tags: disk any_errors_fatal: true - name: indicate disks okay to statuscake local_action: command /usr/bin/wget 'https://push.statuscake.com/?PK=abcdefghi&TestID=123456&time=0' run_once: true -
mahemoff revised this gist
Sep 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ - name: show disk space debug: msg="{{ ((mount.size_total - mount.size_available) / 1000000000) | round(1,'common') }}GB of {{ (mount.size_total / 1000000000)|round( 1, 'common') }}GB ({{ (100 * ( (mount.size_total - mount.size_available) / mount.size_total)) | round(1, 'common')}}%)" vars: mount: "{{ ansible_mounts | first }}" tags: disk -
mahemoff renamed this gist
Sep 15, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mahemoff renamed this gist
Sep 15, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mahemoff revised this gist
Sep 15, 2018 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ * Shows a message like: "120.7GB of 329.7GB (57.8%)" * Fails if disk is near-full * Only looks at first mount point on current node. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,5 @@ that: mount.size_available > mount.size_total|float * 0.2 msg: Disk space is near full! vars: mount: "{{ ansible_mounts | first }}" tags: disk -
mahemoff renamed this gist
Sep 15, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mahemoff created this gist
Sep 15, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ - name: show disk space debug: msg="{{ ((mount.size_total - mount.size_available) / 1000000000) | round(1,'common') }}GB of {{ (mount.size_total / 1000000000)|round( 1, 'common') }}GB ({{ (100 * ( (mount.size_total - mount.size_available) / mount.size_available)) | round(1, 'common')}}%)" vars: mount: "{{ ansible_mounts | first }}" tags: disk - name: ensure at least 20% free assert: that: mount.size_available > mount.size_total|float * 0.2 msg: Disk space is near full! vars: mount: "{{ ansible_mounts | first }}"