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
Binary file added backups/backup_20260408_205035.tar.gz
Binary file not shown.
Binary file added backups/backup_20260408_205615.tar.gz
Binary file not shown.
39 changes: 39 additions & 0 deletions logs/app.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
total 24K
-rw-rw-r-- 1 most_senior_man most_senior_man 613 Apr 8 20:49 backup.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 925 Apr 8 20:42 file_manager.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 385 Apr 8 20:53 process_monitor.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 600 Apr 8 20:55 run_all.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 842 Apr 8 20:37 system_check.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 783 Apr 5 17:43 user_info.sh
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 1.9M 390M 1% /run
/dev/sda2 40G 8.2G 29G 22% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 392M 136K 392M 1% /run/user/1000
/dev/sr0 6.3G 6.3G 0 100% /media/most_senior_man/Ubuntu 24.04.4 LTS amd64
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 3914 1671 123 40 2306 2243
Swap: 0 0 0
---------- CPU Load ----------
20:56:14 up 4:49, 1 user, load average: 0.52, 0.64, 0.48
----- Total running processes: 220
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
most_se+ 3018 3.0 11.4 11788172 459664 ? Sl 16:10 8:46 /snap/firefox/7967/usr/lib/firefox/firefox
most_se+ 2054 3.0 9.5 3995868 380964 ? Ssl 16:09 8:53 /usr/bin/gnome-shell
most_se+ 3261 0.6 5.7 2746260 231164 ? Sl 16:11 1:50 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:33276 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {49eeb725-dc6f-46f4-9ac3-7b49de95e02c} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 6 tab
most_se+ 3268 0.9 5.4 2822016 219064 ? Sl 16:11 2:39 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:33276 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {bd287250-3917-4d65-a238-eff1c80c9889} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 7 tab
most_se+ 3233 0.3 3.3 2626188 133316 ? Sl 16:11 0:58 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:36915 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {5f07b2a7-e046-4056-8e7c-b5c091e23ddc} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 5 tab
Backup created: ../backups/backup_20260408_205615.tar.gz
Old backups cleaned up
nginx is Stopped. Restarting...
nginx Restarted
ssh is Stopped. Restarting...
ssh Restarted
docker is Stopped. Restarting...
docker Restarted
Hello Oluwasegun from nigerian! You are an Adult.
4 changes: 4 additions & 0 deletions logs/backup.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Backup created: ../backups/backup_20260408_205035.tar.gz
Old backups cleaned up
Backup created: ../backups/backup_20260408_205615.tar.gz
Old backups cleaned up
15 changes: 15 additions & 0 deletions logs/file_manager.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
File created: sample.txt
total 12K
-rw-rw-r-- 1 most_senior_man most_senior_man 925 Apr 8 20:42 file_manager.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 0 Apr 8 20:43 sample.txt
-rw-rw-r-- 1 most_senior_man most_senior_man 842 Apr 8 20:37 system_check.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 783 Apr 5 17:43 user_info.sh
Renamed sample.txt to sample1.txt
File deleted: sample1.txt
total 24K
-rw-rw-r-- 1 most_senior_man most_senior_man 613 Apr 8 20:49 backup.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 925 Apr 8 20:42 file_manager.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 385 Apr 8 20:53 process_monitor.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 600 Apr 8 20:55 run_all.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 842 Apr 8 20:37 system_check.sh
-rw-rw-r-- 1 most_senior_man most_senior_man 783 Apr 5 17:43 user_info.sh
12 changes: 12 additions & 0 deletions logs/process_monitor.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
nginx is Stopped. Restarting...
nginx Restarted
ssh is Stopped. Restarting...
ssh Restarted
docker is Stopped. Restarting...
docker Restarted
nginx is Stopped. Restarting...
nginx Restarted
ssh is Stopped. Restarting...
ssh Restarted
docker is Stopped. Restarting...
docker Restarted
46 changes: 46 additions & 0 deletions logs/system_report_2026.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 2.1M 390M 1% /run
/dev/sda2 40G 7.9G 30G 22% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 392M 144K 392M 1% /run/user/1000
/dev/sr0 6.3G 6.3G 0 100% /media/most_senior_man/Ubuntu 24.04.4 LTS amd64
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 3914 1604 256 39 2129 2310
Swap: 0 0 0
---------- CPU Load ----------
20:38:57 up 4:32, 1 user, load average: 0.10, 0.08, 0.09
----- Total running processes: 217
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
most_se+ 3018 2.9 12.3 11787128 495484 ? Sl 16:10 7:57 /snap/firefox/7967/usr/lib/firefox/firefox
most_se+ 2054 2.8 9.4 3993624 379864 ? Ssl 16:09 7:43 /usr/bin/gnome-shell
most_se+ 3268 0.9 6.3 2822000 256012 ? Sl 16:11 2:35 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:33276 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {bd287250-3917-4d65-a238-eff1c80c9889} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 7 tab
most_se+ 3261 0.5 5.0 2723716 201840 ? Sl 16:11 1:21 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:33276 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {49eeb725-dc6f-46f4-9ac3-7b49de95e02c} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 6 tab
most_se+ 3233 0.3 3.3 2621068 133540 ? Sl 16:11 0:55 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:36915 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {5f07b2a7-e046-4056-8e7c-b5c091e23ddc} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 5 tab
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 1.9M 390M 1% /run
/dev/sda2 40G 8.2G 29G 22% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 392M 136K 392M 1% /run/user/1000
/dev/sr0 6.3G 6.3G 0 100% /media/most_senior_man/Ubuntu 24.04.4 LTS amd64
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 3914 1671 123 40 2306 2243
Swap: 0 0 0
---------- CPU Load ----------
20:56:14 up 4:49, 1 user, load average: 0.52, 0.64, 0.48
----- Total running processes: 220
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
most_se+ 3018 3.0 11.4 11788172 459664 ? Sl 16:10 8:46 /snap/firefox/7967/usr/lib/firefox/firefox
most_se+ 2054 3.0 9.5 3995868 380964 ? Ssl 16:09 8:53 /usr/bin/gnome-shell
most_se+ 3261 0.6 5.7 2746260 231164 ? Sl 16:11 1:50 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:33276 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {49eeb725-dc6f-46f4-9ac3-7b49de95e02c} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 6 tab
most_se+ 3268 0.9 5.4 2822016 219064 ? Sl 16:11 2:39 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:33276 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {bd287250-3917-4d65-a238-eff1c80c9889} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 7 tab
most_se+ 3233 0.3 3.3 2626188 133316 ? Sl 16:11 0:58 /snap/firefox/7967/usr/lib/firefox/firefox -contentproc -isForBrowser -prefsHandle 0:36915 -prefMapHandle 1:278246 -jsInitHandle 2:227672 -parentBuildID 20260309231353 -sandboxReporter 3 -chrootClient 4 -ipcHandle 5 -initialChannelId {5f07b2a7-e046-4056-8e7c-b5c091e23ddc} -parentPid 3018 -crashReporter 6 -crashHelper 7 -greomni /snap/firefox/7967/usr/lib/firefox/omni.ja -appomni /snap/firefox/7967/usr/lib/firefox/browser/omni.ja -appDir /snap/firefox/7967/usr/lib/firefox/browser 5 tab
2 changes: 2 additions & 0 deletions logs/user_info.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello Oluwasegun from Nigeria! You are an Adult.
Hello Oluwasegun from nigerian! You are an Adult.
24 changes: 24 additions & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#!/bin/bash

SOURCE_DIR=$1
BACKUP_DIR="../backups"
LOG_FILE="../logs/backup.log"

if [[ ! -d "$SOURCE_DIR" ]]; then
echo "Error: Directory does not exist" | tee -a "$LOG_FILE"
echo "Usage: $0 <Source directory>" | tee -a "$LOG_FILE"
exit 1
fi

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

tar -czf "$BACKUP_FILE" "$SOURCE_DIR"

echo "Backup created: $BACKUP_FILE" | tee -a "$LOG_FILE"

# Keep only last 5 backups
ls -t $BACKUP_DIR/backup_*.tar.gz | tail -n +6 | xargs -r rm

echo "Old backups cleaned up" | tee -a "$LOG_FILE"
41 changes: 41 additions & 0 deletions scripts/file_manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

LOG_FILE="../logs/file_manager.log"
ACTION=$1
FILE=$2

case "$ACTION" in
create)
if [[ -f "$FILE" ]]; then
echo "File already exists!" | tee -a "$LOG_FILE"
else
touch "$FILE"
echo "File created: $FILE" | tee -a "$LOG_FILE"
fi
;;
delete)
if [[ -f "$FILE" ]]; then
rm "$FILE"
echo "File deleted: $FILE" | tee -a "$LOG_FILE"
else
echo "File not found!" | tee -a "$LOG_FILE"
fi
;;

list)
ls -lh | tee -a "$LOG_FILE"
;;

rename)
NEW_NAME=$3
if [[ -f "$FILE" ]]; then
mv "$FILE" "$NEW_NAME"
echo "Renamed $FILE to $NEW_NAME" | tee -a "$LOG_FILE"
else
echo "File not found!" | tee -a "$LOG_FILE"
fi
;;
*)
echo "Usage: $0 {create|delete|list|rename} filename filename?" | tee -a "$LOG_FILE"
;;
esac
14 changes: 14 additions & 0 deletions scripts/process_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

LOG_FILE="../logs/process_monitor.log"
services=("nginx" "ssh" "docker")

for service in "${services[@]}"; do
if pgrep -x "$service" > /dev/null; then
echo "$service is Running" | tee -a "$LOG_FILE"
else
echo "$service is Stopped. Restarting..." | tee -a "$LOG_FILE"
# Simulate restart
echo "$service Restarted" | tee -a "$LOG_FILE"
fi
done
36 changes: 36 additions & 0 deletions scripts/run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail

LOG_FILE="../logs/app.log"

run_all() {
bash file_manager.sh list
bash system_check.sh
bash backup.sh .
bash process_monitor.sh
bash user_info.sh

}

menu() {
echo "1. Run all"
echo "2. System check"
echo "3. Backup"
echo "4. Exit"
}

while true; do
menu
read -p "Choose option: " choice

case $choice in
1) run_all | tee -a "$LOG_FILE" ;;
2) bash system_check.sh | tee -a "$LOG_FILE" ;;
3) bash backup.sh . | tee -a "$LOG_FILE" ;;
4) exit 0 ;;
*) echo "Invalid option" ;;
esac
done



31 changes: 31 additions & 0 deletions scripts/system_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

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

echo "===== SYSTEM REPORT =====" | tee -a "$LOG_FILE"

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

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"

# Disk warning
USAGE=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')
if (( USAGE > 80 )); then
echo "WARNING: Disk usage is above 80%" | tee -a "$LOG_FILE"
fi

# Process count
echo "----- Total running processes: $(ps aux | wc -l)" | tee -a "$LOG_FILE"

# Top 5 memory-consuming processes
echo "---------- Top 5 memory-consuming processes ----------" | tee -a "$LOG_FILE"
ps aux --sort=-%mem | head -n 6 | tee -a "$LOG_FILE"



31 changes: 31 additions & 0 deletions scripts/user_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

LOG_FILE="../logs/user_info.log"

read -p "Enter your name: " name
read -p "Enter your age: " age
read -p "Enter your country: " country

# Validate inputs
if [[ -z "$name" || -z "$age" || -z "$country" ]]; then
echo "Error: All fields are required" | tee -a "$LOG_FILE"
exit 1
fi

if ! [[ "$age" =~ ^[0-9]+$ ]]; then
echo "Error: Age must be numeric" | tee -a "$LOG_FILE"
exit 1
fi

# Determine age category
if (( age < 18 )); then
category="Minor"
elif (( age <= 65 )); then
category="Adult"
else
category="Senior"
fi

message="Hello $name from $country! You are an $category."

echo "$message" | tee -a "$LOG_FILE"