Skip to content

Instantly share code, notes, and snippets.

@nocodehummel
Last active February 10, 2025 23:39
Show Gist options
  • Select an option

  • Save nocodehummel/789316aae1bbfc4353219ea3228aac56 to your computer and use it in GitHub Desktop.

Select an option

Save nocodehummel/789316aae1bbfc4353219ea3228aac56 to your computer and use it in GitHub Desktop.
Systemctl status check
# check systemctl status
failed_jobs=$(systemctl --failed | grep -Ei "failed" | wc -l)
if [ "$failed_jobs" -gt 0 ]; then
echo -e "${RED}Failed systemctl jobs detected:${NC}"
tput setaf 1
systemctl --failed
tput sgr0
else
echo "No failed systemctl jobs."
systemctl list-timers | head -n 20
fi
# check disk space
filesystem="/"
threshold=10
usedspace=$(df -h "$filesystem" | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$usedspace" -ge $((100 - threshold)) ]; then
echo -e "${RED}Warning: $usedspace% space is used on $filesystem!${NC}"
df -h
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment