File: fstab-check.sh

package info (click to toggle)
prometheus-node-exporter-collectors 0.0~git20241119.a2b43e1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: python: 1,681; sh: 596; awk: 74; makefile: 23
file content (14 lines) | stat: -rwxr-xr-x 475 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env bash

echo "# HELP node_fstab_mount_status List and status of filesystem mountpoints (0 = not mounted, 1 = mounted)"
echo "# TYPE node_fstab_mount_status gauge"
mapfile -t mountpoints < <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ {print $2}' /etc/fstab)
for mount in "${mountpoints[@]}"
do
  if ! findmnt "$mount" &> /dev/null
  then
    echo "node_fstab_mount_status{mountpoint=\"$mount\"} 0"
  else
    echo "node_fstab_mount_status{mountpoint=\"$mount\"} 1"
  fi
done