Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added READ.me
Empty file.
1 change: 1 addition & 0 deletions logs/process_monitor.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tue Apr 14 12:13:36 WAT 2026: Checked
32 changes: 32 additions & 0 deletions logs/system_report_2026-04-14.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
System Report - Tue Apr 14 11:54:40 WAT 2026
Disk Usage:
Filesystem Size Used Avail Use% Mounted on
none 3.8G 0 3.8G 0% /usr/lib/modules/6.6.87.2-microsoft-standard-WSL2
none 3.8G 4.0K 3.8G 1% /mnt/wsl
drivers 476G 446G 31G 94% /usr/lib/wsl/drivers
/dev/sdd 1007G 1.7G 954G 1% /
none 3.8G 92K 3.8G 1% /mnt/wslg
none 3.8G 0 3.8G 0% /usr/lib/wsl/lib
rootfs 3.8G 2.7M 3.8G 1% /init
none 3.8G 500K 3.8G 1% /run
none 3.8G 0 3.8G 0% /run/lock
none 3.8G 0 3.8G 0% /run/shm
none 3.8G 76K 3.8G 1% /mnt/wslg/versions.txt
none 3.8G 76K 3.8G 1% /mnt/wslg/doc
C:\ 476G 446G 31G 94% /mnt/c
tmpfs 761M 8.0K 761M 1% /run/user/1000
Memory Usage:
total used free shared buff/cache available
Mem: 7608 321 7151 3 134 7137
Swap: 2048 0 2048
CPU Load:
11:54:41 up 3:38, 1 user, load average: 0.00, 0.00, 0.00
Total Processes:
27
Top 5 Memory Processes:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 258 0.0 0.2 107172 21504 ? Ssl 08:15 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 202 0.0 0.2 30184 18688 ? Ss 08:15 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 69 0.0 0.1 47736 15232 ? S<s 08:15 0:05 /lib/systemd/systemd-journald
systemd+ 101 0.0 0.1 26204 13824 ? Ss 08:15 0:01 /lib/systemd/systemd-resolved
root 1 0.0 0.1 165952 10752 ? Ss 08:15 0:10 /sbin/init
1 change: 1 addition & 0 deletions logs/user_info.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tue Apr 14 11:54:16 WAT 2026: Hello momo from nigeria. you are 16 years old (minor).
31 changes: 31 additions & 0 deletions run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -euo pipefail

LOG_FILE="./logs/app.log"

function system_check() {
bash scripts/system_check.sh
}

function backup() {
read -p "Enter directory to backup: " dir
bash scripts/backup.sh "$dir"
}

while true; do
echo "1. System Check"
echo "2. Backup"
echo "3. Exit"

read -p "Choose option: " choice

case $choice in
1) system_check ;;
2) backup ;;
3) exit 0 ;;
*) echo "Invalid option" ;;
esac

echo "$(date): Selected $choice" >> "$LOG_FILE"
done
28 changes: 28 additions & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

LOG_FILE="../logs/backup.log"
BACKUP_DIR="../backups"

input_dir=$1

# Validate directory
if [[ ! -d "$input_dir" ]]; then
echo "Directory does not exist!"
exit 1
fi

timestamp=$(date +%Y%m%d_%H%M%S)
backup_file="$BACKUP_DIR/backup_$timestamp.tar.gz"

# Create backup
tar -czf "$backup_file" "$input_dir"

echo "Backup created: $backup_file"

# Keep only last 5 backups
ls -t $BACKUP_DIR | tail -n +6 | while read file; do
rm "$BACKUP_DIR/$file"
done

# Log
echo "$(date): Backup created for $input_dir" >> "$LOG_FILE"
43 changes: 43 additions & 0 deletions scripts/file_manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

LOG_FILE="../logs/file_manager.log"

action=$1
file1=$2
file2=$3

case $action in
create)
if [[ -f "$file1" ]]; then
echo "File already exists!"
else
touch "$file1"
echo "File created: $file1"
fi
;;
delete)
if [[ -f "$file1" ]]; then
rm "$file1"
echo "File deleted: $file1"
else
echo "File not found!"
fi
;;
list)
ls
;;
rename)
if [[ -f "$file1" ]]; then
mv "$file1" "$file2"
echo "Renamed to $file2"
else
echo "File not found!"
fi
;;
*)
echo "Invalid command"
;;
esac

# Log action
echo "$(date): $action $file1 $file2" >> "$LOG_FILE"
17 changes: 17 additions & 0 deletions scripts/process_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

LOG_FILE="../logs/process_monitor.log"

services=("nginx" "ssh" "docker")

process=$1

if pgrep "$process" > /dev/null
then
echo "$process is Running"
else
echo "$process is Stopped. Restarting..."
echo "Restarted $process (simulated)"
fi

echo "$(date): Checked $process" >> "$LOG_FILE"
26 changes: 26 additions & 0 deletions scripts/system_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

LOG_FILE="../logs/system_report_$(date +%F).log"

echo "System Report - $(date)" | tee "$LOG_FILE"

echo "Disk Usage:" | tee -a "$LOG_FILE"
df -h | tee -a "$LOG_FILE"

usage=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')

if (( usage > 80 )); then
echo "WARNING: Disk usage above 80%" | tee -a "$LOG_FILE"
fi

echo "Memory Usage:" | tee -a "$LOG_FILE"
free -m | tee -a "$LOG_FILE"

echo "CPU Load:" | tee -a "$LOG_FILE"
uptime | tee -a "$LOG_FILE"

echo "Total Processes:" | tee -a "$LOG_FILE"
ps aux | wc -l | tee -a "$LOG_FILE"

echo "Top 5 Memory Processes:" | tee -a "$LOG_FILE"
ps aux --sort=-%mem | head -n 6 | tee -a "$LOG_FILE"
24 changes: 24 additions & 0 deletions scripts/user_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
mkdir -p ../logs
LOG_FILE="../logs/user_info.log"
read -p "Enter your name: " name
read -p "Enter your age: " age
read -p "Enter your country: " country
if [[ -z "$name" || -z "$age" || -z "$country" ]]; then
echo "Error: ALL FIELDS ARE REQUIRED!"
exit 1
fi
if ! [[ "$age" =~ ^[0-9]+$ ]]; then
echo "Error: AGE MUST BE A NUMBER!"
exit 1
fi
if (( age < 18 )); then
category="minor"
elif (( age <= 65 )); then
category= "Adult"
else
category= "senior"
fi
message="Hello $name from $country. you are $age years old ($category)."
echo "$message"
echo "$(date): $message" >> "$LOG_FILE"