sysadmin-helper is a CLI tool written in Bash for Linux system maintenance. It provides functions for:
- Monitoring: Checking CPU, memory, and disk usage.
- Logs: Rotating and analyzing log files.
- Backup: Creating and restoring backups of important directories.
- Maintenance: Performing system updates and cleaning up temporary files.
-
Clone the repository:
git clone https://github.com/alexmllo/sysadmin-helper.git cd sysadmin-helper
-
Make the main script executable:
chmod +x bin/sysadmin-helper.sh
-
Configure your environment:
Edit
conf/sysadmin-helper.conf
to set your desired thresholds, log file locations, backup directories, and package manager. -
Run the help command:
./bin/sysadmin-helper.sh help
Use one of the subcommands to execute a specific task:
Display CPU, memory, and disk usage metrics:
./bin/sysadmin-helper.sh monitor
-
Rotate Logs: Rotate and compress the log file:
./bin/sysadmin-helper.sh logs rotate
-
Analyze Logs: Analyze the log file for errors:
./bin/sysadmin-helper.sh logs analyze
-
Create a Backup: Create a backup of the directories specified in the configuration:
./bin/sysadmin-helper.sh backup create
-
Restore a Backup: Restore from a specified backup file to a destination (default is root):
./bin/sysadmin-helper.sh backup restore /path/to/backup.tar.gz /destination/path
Run routine maintenance tasks such as updating system packages and cleaning temporary files:
./bin/sysadmin-helper.sh maintain
Alternatively, run specific tasks:
./bin/sysadmin-helper.sh maintain update
./bin/sysadmin-helper.sh maintain cleanup
The configuration file (conf/sysadmin-helper.conf
) includes settings such as:
-
Thresholds for Monitoring:
THRESHOLD_CPU=80 THRESHOLD_MEM=80 THRESHOLD_DISK=90
-
Log File Location:
LOG_FILE="/var/log/sysadmin-helper.log"
-
Backup Settings:
BACKUP_DIR="/tmp/sysadmin-backups" BACKUP_SOURCES="/etc,/var/log"
-
Maintenance Settings: Specify your package manager (e.g., apt, yum):
PACKAGE_MANAGER="apt"