A Prometheus exporter for monitoring filesystem mount point availability by calling the system findmnt command and exposing metrics indicating whether configured mount points are currently active.
Mount Exporter provides critical monitoring for storage infrastructure by:
- Monitoring configured filesystem mount points
- Exposing Prometheus-compatible metrics
- Supporting automated alerting when mount points become unavailable
- Running as a single binary with minimal dependencies
- ✅ Mount Point Monitoring: Uses
findmntcommand to verify mount status - ✅ Prometheus Metrics: Exposes metrics in standard Prometheus format
- ✅ Configuration Management: YAML-based configuration with validation
- ✅ Health Checks: Built-in health endpoint for monitoring
- ✅ Structured Logging: Configurable logging levels and formats
- ✅ Graceful Shutdown: Proper signal handling and cleanup
- ✅ Container Ready: Docker support with health checks
- ✅ Production Ready: systemd service template included
-
Download the latest release
wget https://github.com/mount-exporter/mount-exporter/releases/latest/download/mount-exporter-linux-amd64 chmod +x mount-exporter-linux-amd64 sudo mv mount-exporter-linux-amd64 /usr/local/bin/mount-exporter
-
Create configuration
sudo mkdir -p /etc/mount-exporter sudo cp config.yaml /etc/mount-exporter/config.yaml sudo nano /etc/mount-exporter/config.yaml
-
Run the exporter
mount-exporter -config /etc/mount-exporter/config.yaml
# Build the image
docker build -t mount-exporter:latest .
# Run with default configuration
docker run -d \
--name mount-exporter \
-p 8080:8080 \
-v $(pwd)/examples/config.yaml:/etc/mount-exporter/config.yaml:ro \
mount-exporter:latest
# Or with custom configuration
docker run -d \
--name mount-exporter \
-p 8080:8080 \
-v /path/to/your/config.yaml:/etc/mount-exporter/config.yaml:ro \
mount-exporter:latest# Copy the service file
sudo cp examples/mount-exporter.service /etc/systemd/system/
sudo cp examples/config.yaml /etc/mount-exporter/
# Create mount-exporter user
sudo useradd -r -s /bin/false mount-exporter
sudo chown -R mount-exporter:mount-exporter /etc/mount-exporter
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable mount-exporter
sudo systemctl start mount-exporter
sudo systemctl status mount-exporterThe exporter uses YAML configuration files. Here's an example:
# server configuration
server:
host: "0.0.0.0" # Bind address
port: 8080 # Port to listen on
path: "/metrics" # Metrics endpoint path
# Mount points to monitor
mount_points:
- "/data" # Data directory
- "/var/log" # System logs
- "/mnt/backups" # Backup mount point
- "/home" # User home directories
# Collection interval
interval: 30s # How often to check mount points
# Logging configuration
logging:
level: "info" # Log level: debug, info, warn, error, fatal
format: "json" # Log format: json, textYou can override configuration using environment variables:
MOUNT_EXPORTER_HOST- Override server hostMOUNT_EXPORTER_PORT- Override server portMOUNT_EXPORTER_PATH- Override metrics pathMOUNT_EXPORTER_INTERVAL- Override collection intervalMOUNT_EXPORTER_LOG_LEVEL- Override log level
Example:
export MOUNT_EXPORTER_PORT=9090
export MOUNT_EXPORTER_LOG_LEVEL=debug
mount-exporterThe exporter exposes the following metrics on /metrics:
# HELP mount_exporter_mount_point_status Mount point availability status (1=mounted, 0=not mounted)
# TYPE mount_exporter_mount_point_status gauge
mount_exporter_mount_point_status{mount_point="/data"} 1
mount_exporter_mount_point_status{mount_point="/var/log"} 1
mount_exporter_mount_point_status{mount_point="/mnt/backups"} 0
# HELP mount_exporter_scrape_duration_seconds Time spent scraping mount point status
# TYPE mount_exporter_scrape_duration_seconds gauge
mount_exporter_scrape_duration_seconds{mount_point="/data"} 0.045
mount_exporter_scrape_duration_seconds{mount_point="/var/log"} 0.032
# HELP mount_exporter_up Whether the mount exporter is healthy (1=healthy, 0=unhealthy)
# TYPE mount_exporter_up gauge
mount_exporter_up 1
# HELP mount_exporter_scrape_success_total Total number of successful scrapes
# TYPE mount_exporter_scrape_success_total counter
mount_exporter_scrape_success_total{mount_point="/data"} 125
mount_exporter_scrape_success_total{mount_point="/var/log"} 125
/metrics- Prometheus metrics endpoint/health- Health check endpoint (JSON format)/healthz- Alternative health check endpoint/- Basic information page
The /health endpoint returns JSON response:
{"status": "healthy"}If findmnt is not available or there are other issues:
{"status": "unhealthy", "error": "findmnt command not available"}mount-exporter [OPTIONS]
Options:
-config string
Path to configuration file (default: searches for config.yaml in common locations)
-log-level string
Override log level (debug, info, warn, error, fatal)
-help
Show help message
-version
Show version informationThe exporter looks for configuration files in this order:
config.yaml(current directory)config.yml(current directory)examples/config.yamlexamples/config.yml/etc/mount-exporter/config.yaml/etc/mount-exporter/config.yml
-
Permission Denied
# Ensure the binary has execute permissions chmod +x mount-exporter -
findmnt Command Not Found
# Install util-linux package (Ubuntu/Debian) sudo apt-get update && sudo apt-get install util-linux # Install util-linux package (CentOS/RHEL) sudo yum install util-linux
-
Configuration Errors
# Validate configuration mount-exporter -config config.yaml -log-level debug -
Port Already in Use
# Check what's using the port sudo netstat -tulpn | grep :8080 # Use different port mount-exporter -config config.yaml # Set MOUNT_EXPORTER_PORT=9090 in config.yaml or environment variable
Check logs for detailed information:
# With systemd
sudo journalctl -u mount-exporter -f
# With Docker
docker logs -f mount-exporter
# Run in foreground for debugging
mount-exporter -log-level debug# Clone the repository
git clone https://github.com/mount-exporter/mount-exporter.git
cd mount-exporter
# Build the binary
make build
# Run tests
make test
# Run with coverage
make test-coveragemount-exporter/
├── main.go # Application entry point
├── config/ # Configuration package
│ ├── config.go # Configuration handling
│ └── config_test.go # Configuration tests
├── metrics/ # Metrics package
│ ├── collector.go # Prometheus collector
│ └── collector_test.go # Metrics tests
├── server/ # HTTP server package
│ ├── server.go # HTTP server
│ └── server_test.go # Server tests
├── system/ # System integration
│ ├── findmnt.go # findmnt wrapper
│ └── findmnt_test.go # System tests
├── test/ # Integration tests
│ └── integration_test.go
├── examples/ # Example configurations
│ ├── config.yaml # Example config
│ └── mount-exporter.service
├── Dockerfile # Container definition
├── Makefile # Build automation
└── README.md # This file
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- 📖 Documentation
- 🐛 Issues
- 💬 Discussions