Added disc-space-checker

This commit is contained in:
2023-04-16 09:59:54 +02:00
parent 3508baebac
commit 01231cab6b
11 changed files with 75 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
[Unit]
Description=checking disc space
OnFailure=systemd-email@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{disc_space_check_folder}}disc-space-check.sh

View File

@@ -0,0 +1,13 @@
#!/bin/sh
errors=0
echo "checking disc space use..."
df
for disc_use_percent in $(df --output=pcent | sed 1d)
do
disc_use_percent_number=$(echo "$disc_use_percent" | sed "s/%//")
if [ "$disc_use_percent_number" -gt "{{size_percent_disc_space_warning}}" ]; then
echo "WARNING: $disc_use_percent_number exceeds the limit of {{size_percent_disc_space_warning}}%."
errors+=1;
fi
done
exit $errors;

View File

@@ -0,0 +1,8 @@
[Unit]
Description=starts disc-space-check.service
[Timer]
OnCalendar={{on_calendar_disc_space_check}}
[Install]
WantedBy=timers.target