Fully written in Bash.
stslog is a simple system status logger written in Bash. It periodically collects and logs system metrics such as kernel version, OS version, number of logged-in users, CPU usage, memory and swap usage, and more. You can view the current status on demand, configure logging intervals, and review historical logs.
- On-Demand Status: Run
stslogwithout arguments or with-sto display the latest system status. - Automatic Logging: Set up a cron job to log status at regular intervals.
- Custom Schedule: Use
-ewith minute (m), hour (h), day (d), or month (M) intervals (e.g.,m5for every 5 minutes). - Cron Management: View the current cron schedule with
-c. - Log Review: Display all logs (
-l) or logs within a date range (-d "start/end").
- Root privileges: Installation and scheduling require root.
- Bash: The scripts are written for Bash.
- cron: To schedule periodic logging.
- lsb_release (from
lsb-releasepackage): For OS version information.
-
Clone the repository:
git clone https://github.com/mammadnet/stslog.git cd stslog -
Install:
sudo ./install.sh
This will:
- Create
/opt/stslog - Copy all scripts into
/opt/stslog - Set up a default cron job logging every 5 minutes
- Create a symlink
/bin/stslogfor easy access
- Create
-
Verify:
which stslog # /bin/stslog
stslog
# or
stslog -sSet up or update the cron job interval:
sudo stslog -e <interval>- Minute interval:
mN— everyNminutes (1–59) - Hour interval:
hN— everyNhours (1–24) - Day interval:
dN— everyNdays (1–30) - Month interval:
MN— everyNmonths (1–12)
Example: Log every 15 minutes:
sudo stslog -e m15stslog -c-
Show all logs:
stslog -l
-
Show logs within a date range:
stslog -d "YYYY-MM-DD HH:MM/YYYY-MM-DD HH:MM"Example:
stslog -d "2025-07-01 00:00/2025-07-02 12:00"
Logs are stored in /var/log/status.log:
[2025-07-02 14:23:01 +0300] Kernel:5.4.0-81-generic OS:Ubuntu-20.04 LTS Users:[alice:2,bob:1] CPU:12.5,0.03 0.05 0.01 Memory:2048/4096 MB Swap:512/1024 MB
Each line contains:
- Timestamp
- Kernel version
- OS description
- Active users with session counts
- CPU usage (%), and load averages (1, 5, 15 min)
- Memory usage (used/total MB)
- Swap usage (used/total MB)
To remove stslog:
sudo crontab -l | grep -v /opt/stslog/logger.sh | crontab -
sudo rm /bin/stslog
sudo rm -rf /opt/stslog
sudo rm /var/log/status.logContributions and improvements are welcome. Feel free to open issues or submit pull requests.