Skip to content

Human-Gechi/System-Information-Audit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

System-Information-Audit

Overview

This project contains a Bash script that performs automated system audits and logs detailed hardware and performance metrics to log files in /var/log.

What it does

  • CPU Information: Captures processor family, model, core count, and thread information
  • Memory Usage: Logs current memory utilization in human-readable format
  • Network Configuration: Extracts and masks IP addresses for security
  • System Uptime: Logs system uptime and per-user process count
  • Process Monitoring: Counts active processes for the current user
  • Automatic Logging:Ensures log folder and file exist

Log location

All runtime logs are written to: /var/log/system_logs/system_logs.log

The script will create /var/log/system_logs and the log file if missing (requires sudo for initial creation and or to change ownership).

Make script executable:

chmod +x system_monitor.sh

Run manually:

bash system_monitor.sh

Memory threshold & popup

  • Threshold is set in the script (Threshold variable, default 80).
  • When memory usage >= threshold the script logs a warning and attempts a Windows popup: /mnt/c/Windows/System32/cmd.exe /c msg * "[Critical] Memory Usage: ${Percentage_used}%"
  • Requirements/notes:
    • Works under WSL with Windows msg available;
    • On full Linux desktop use notify-send or another local notifier instead(Make sure dependencies are installed)
    • Adjust Threshold inside system_monitor.sh to change behavior.

Log rotation (logrotate)

Place a logrotate config in /etc/logrotate.d/ to rotate and compress logs. Example config:

// filepath: /etc/logrotate.d/system_usage
/var/log/system_logs/system_logs.log {
    weekly #create new log files every week
    rotate 4 #after 4 weeks, rotate and compress
    create 0640 your_username your_username
    compress # compress to .gz
    delaycompress #wait till a rotation is done before zipping
    missingok
    notifempty #if file is empty, do not do anything; no rotatin
}

the logrotate configuration is in the repo as (system_usage), you can configure it with

sudo cp system_usage /etc/logrotate.d/system_usage
sudo chown root:user /etc/logrotate.d/system_usage
sudo chmod 0644 /etc/logrotate.d/system_usage

Create directory and set secure ownership/permissions:

sudo mkdir -p /var/log/system_logs
sudo touch /var/log/system_logs/system_logs.log
sudo chown root:$user /var/log/system_logs /var/log/system_logs/system_logs.log
sudo chmod 0755 /var/log/system_logs
sudo chmod 0640 /var/log/system_logs/system_logs.log

Test and force rotation:

sudo logrotate -f /etc/logrotate.d/system_monitor       # force rotation to see if it'd work under normal circumstances

## Scheduling
Run periodically with cron or a systemd timer. Example cron (every 5 hours from 9am):
```cron
0 9,14,19,0,5 * * * /path_to_your_folder

Configuration & troubleshooting

  • Edit system_monitor.sh to change interface name (IP extraction), user for process counting, or Threshold.
  • If logs are not written, check file permissions and run the script manually to inspect errors.
  • On WSL, Windows popup behavior depends on Windows configuration and session permissions.

License & notes

  • Minimal toolset; intended for simple local monitoring and education.
  • Keep log access restricted due to sensitive system data.

About

Hardware, Process and Network Investigation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages