some AI generated scripts for inspiration
This commit is contained in:
commit
cee69984d5
44
fs.sh
Normal file
44
fs.sh
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
THRESHOLD=90
|
||||
|
||||
echo "Checking disk usage (>= $THRESHOLD%)"
|
||||
df -P | while IFS= read -r line; do
|
||||
case "$line" in
|
||||
Filesystem*|"") continue ;;
|
||||
esac
|
||||
|
||||
fs=$(printf '%s\n' "$line" | awk '{print $1}')
|
||||
usep=$(printf '%s\n' "$line" | awk '{print $5}' | tr -d '%')
|
||||
mountp=$(printf '%s\n' "$line" | awk '{print $6}')
|
||||
|
||||
# skip empty or loop devices
|
||||
case "$fs" in
|
||||
""|/dev/loop*) continue ;;
|
||||
esac
|
||||
|
||||
if [ "$usep" -ge "$THRESHOLD" ] 2>/dev/null; then
|
||||
printf 'WARNING: %s is %s%% full (mounted on %s)\n' "$fs" "$usep" "$mountp"
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Checking inode usage (>= $THRESHOLD%)"
|
||||
df -P -i | while IFS= read -r line; do
|
||||
case "$line" in
|
||||
Filesystem*|"") continue ;;
|
||||
esac
|
||||
|
||||
fs=$(printf '%s\n' "$line" | awk '{print $1}')
|
||||
usep=$(printf '%s\n' "$line" | awk '{print $5}' | tr -d '%')
|
||||
mountp=$(printf '%s\n' "$line" | awk '{print $6}')
|
||||
|
||||
# skip empty or loop devices
|
||||
case "$fs" in
|
||||
""|/dev/loop*) continue ;;
|
||||
esac
|
||||
|
||||
if [ "$usep" -ge "$THRESHOLD" ] 2>/dev/null; then
|
||||
printf 'WARNING: %s has %s%% inode usage (mounted on %s)\n' "$fs" "$usep" "$mountp"
|
||||
fi
|
||||
done
|
||||
27
smart.sh
Normal file
27
smart.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
if ! command -v smartctl >/dev/null 2>&1; then
|
||||
echo "Error: smartctl is not installed." >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Scan for disks
|
||||
smartctl --scan | while IFS= read -r line; do
|
||||
device=$(printf '%s\n' "$line" | awk '{print $1}')
|
||||
[ -n "$device" ] || continue
|
||||
|
||||
echo "Device: $device"
|
||||
|
||||
echo "SMART Health Status:"
|
||||
smartctl -H "$device"
|
||||
echo
|
||||
|
||||
echo "Error Counts:"
|
||||
# Extract the error log from smartctl -l error
|
||||
# Works for SATA/SAS/NVMe; if unsupported, smartctl prints a message.
|
||||
smartctl -l error "$device" 2>/dev/null | \
|
||||
grep -E "Error Count|read:|write:|uncorrect" || \
|
||||
echo " No error log or errors not reported."
|
||||
|
||||
echo
|
||||
done
|
||||
Loading…
x
Reference in New Issue
Block a user