#!/bin/bash # Linux Server Performance Diagnostic Checklist # # Technical reference: # Server optimization service: # https://i...content-available-to-author-only...t.com/server-optimization-service/ # # This script performs read-only checks. # It does not modify system configuration. echo "==============================================" echo " Linux Server Performance Diagnostic" echo "==============================================" echo echo "[1] System Uptime and Load" echo "----------------------------------------------" uptime echo echo "[2] CPU Information" echo "----------------------------------------------" nproc 2>/dev/null lscpu 2>/dev/null | grep -E \ '^(CPU\(s\)|Model name|CPU MHz|Architecture)' \ | head -n 10 echo echo "[3] Memory Usage" echo "----------------------------------------------" free -m echo echo "[4] Top CPU-Consuming Processes" echo "----------------------------------------------" ps aux --sort=-%cpu | head -n 15 echo echo "[5] Top Memory-Consuming Processes" echo "----------------------------------------------" ps aux --sort=-%mem | head -n 15 echo echo "[6] Filesystem Capacity" echo "----------------------------------------------" df -h echo echo "[7] Inode Usage" echo "----------------------------------------------" df -i echo echo "[8] Disk and Block Device Information" echo "----------------------------------------------" lsblk 2>/dev/null echo echo "[9] Disk I/O Statistics" echo "----------------------------------------------" if command -v iostat >/dev/null 2>&1; then iostat -xz 1 2 else echo "iostat is not installed." echo "Install the sysstat package on a test server if required." fi echo echo "[10] Virtual Memory Statistics" echo "----------------------------------------------" if command -v vmstat >/dev/null 2>&1; then vmstat 1 3 fi echo echo "[11] Listening Network Services" echo "----------------------------------------------" ss -lntp 2>/dev/null echo echo "[12] Failed Systemd Services" echo "----------------------------------------------" systemctl --failed --no-pager 2>/dev/null echo echo "[13] Running Services" echo "----------------------------------------------" systemctl list-units \ --type=service \ --state=running \ --no-pager 2>/dev/null | head -n 40 echo echo "[14] Web Server Status" echo "----------------------------------------------" systemctl is-active nginx 2>/dev/null || true systemctl is-active apache2 2>/dev/null || true systemctl is-active httpd 2>/dev/null || true echo echo "[15] Database Service Status" echo "----------------------------------------------" systemctl is-active mysql 2>/dev/null || true systemctl is-active mariadb 2>/dev/null || true echo echo "[16] Recent System Errors" echo "----------------------------------------------" journalctl -p err -n 30 --no-pager 2>/dev/null echo echo "[17] Recent Kernel Warnings and Errors" echo "----------------------------------------------" dmesg --level=err,warn 2>/dev/null | tail -n 30 echo echo "[18] Largest Files in /var" echo "----------------------------------------------" if [ -d /var ]; then find /var -type f -printf '%s %p\n' 2>/dev/null \ | sort -nr \ | head -n 15 fi echo echo "[19] Performance Review Checklist" echo "----------------------------------------------" echo "[ ] CPU saturation investigated" echo "[ ] Load average reviewed" echo "[ ] Memory pressure checked" echo "[ ] Swap activity reviewed" echo "[ ] Disk I/O latency investigated" echo "[ ] Filesystem capacity checked" echo "[ ] Inode usage checked" echo "[ ] High-resource processes identified" echo "[ ] Failed services investigated" echo "[ ] Web server performance reviewed" echo "[ ] Database performance reviewed" echo "[ ] Network listeners reviewed" echo "[ ] System logs checked" echo "[ ] Recent configuration changes reviewed" echo echo "==============================================" echo " Diagnostic collection completed" echo "=============================================="
Standard input is empty
==============================================
Linux Server Performance Diagnostic
==============================================
[1] System Uptime and Load
----------------------------------------------
15:28:53 up 815 days, 8:17, 0 users, load average: 3.42, 3.32, 3.34
[2] CPU Information
----------------------------------------------
1
[3] Memory Usage
----------------------------------------------
total used free shared buff/cache available
Mem: 15964 848 2294 3 12821 14775
Swap: 7811 75 7736
[4] Top CPU-Consuming Processes
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
1006 1473592 43.2 0.3 97364 53684 ? S 2025 313880:00 python3 /usr/local/spoj-ideone/bin-new/run.py
1005 1473442 43.1 0.3 97612 52704 ? S 2025 313432:57 python3 /usr/local/spoj-ideone/bin-new/run.py
1008 1473838 43.0 0.3 101172 56128 ? R 2025 312872:46 python3 /usr/local/spoj-ideone/bin-new/run.py
1007 1473702 42.9 0.3 100840 56700 ? S 2025 312053:53 python3 /usr/local/spoj-ideone/bin-new/run.py
1001 2082369 22.6 0.6 133016 102236 ? R Apr22 43580:57 python3 /usr/local/spoj-spoj/bin-new/run.py
1004 2082672 22.3 0.4 106432 75200 ? S Apr22 43045:42 python3 /usr/local/spoj-spoj/bin-new/run.py
1002 2082429 22.2 0.4 108988 77940 ? S Apr22 42924:59 python3 /usr/local/spoj-spoj/bin-new/run.py
1003 2082499 22.2 0.5 120792 89416 ? S Apr22 42920:20 python3 /usr/local/spoj-spoj/bin-new/run.py
root 1 0.0 0.0 168176 9504 ? Ss 2024 1145:54 /sbin/init nopti noibrs noibpb nospectre_v2
root 2 0.0 0.0 0 0 ? S 2024 1:04 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 2024 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 2024 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I< 2024 0:00 [slub_flushwq]
root 6 0.0 0.0 0 0 ? I< 2024 0:00 [netns]
[5] Top Memory-Consuming Processes
----------------------------------------------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
1001 2082369 22.6 0.6 133016 102236 ? S Apr22 43580:57 python3 /usr/local/spoj-spoj/bin-new/run.py
1003 2082499 22.2 0.5 120792 89416 ? S Apr22 42920:20 python3 /usr/local/spoj-spoj/bin-new/run.py
1002 2082429 22.2 0.4 108988 77940 ? S Apr22 42924:59 python3 /usr/local/spoj-spoj/bin-new/run.py
1004 2082672 22.3 0.4 106432 75200 ? S Apr22 43045:42 python3 /usr/local/spoj-spoj/bin-new/run.py
1007 1473702 42.9 0.3 100840 56700 ? S 2025 312053:53 python3 /usr/local/spoj-ideone/bin-new/run.py
1008 1473838 43.0 0.3 101172 56128 ? S 2025 312872:46 python3 /usr/local/spoj-ideone/bin-new/run.py
1006 1473592 43.2 0.3 97364 53684 ? S 2025 313880:00 python3 /usr/local/spoj-ideone/bin-new/run.py
1005 1473442 43.1 0.3 97612 52704 ? S 2025 313432:57 python3 /usr/local/spoj-ideone/bin-new/run.py
root 336 0.0 0.2 58200 39468 ? Ss 2024 309:05 /lib/systemd/systemd-journald
syslog 1175 0.0 0.0 28916 15280 ? Ss 2024 157:39 /usr/sbin/exim4 -bd -q30m
message+ 673 0.0 0.0 16456 10108 ? Ss 2024 18:16 /sbin/rpcbind -f -w
root 1 0.0 0.0 168176 9504 ? Ss 2024 1145:54 /sbin/init nopti noibrs noibpb nospectre_v2
1003 1177 0.0 0.0 91924 8520 ? S 2024 13:25 python3 /usr/local/spoj-spoj/bin-new/run.py
root 3186565 0.0 0.0 158624 7536 ? S<l 15:28 0:00 /usr/bin/secrun/secrun -t 5 -w 11 -m 2147483647 -p 30 -o 65536 -s 33554432 -C /usr/local/spoj-chroots/multigeneral201903 -U /usr/local/spoj-ideone/checker-7/var/testers.db -K /usr/local/spoj-ideone/checker-7/var/killers.db -n 200 --writable 0 --enable-network 0 --tmpdir-size 33554432 --tmpdir-exec 0 --cp-before-src /usr/local/spoj-ideone/checker-7/tmp/95624115 --cp-before-dst ~/prog.sh --skip-umount --env TMPDIR_GLOBAL=/tmp/ --env WORKSPACE=/tmp/ --use-acct-stats 0 --fds 10-0 --fds 11-1 --fds 12-2 --result-fd 4 -- /bin/bash -c exec /bin/bash ./prog.sh
[6] Filesystem Capacity
----------------------------------------------
Filesystem Size Used Avail Use% Mounted on
tmpfs 32M 0 32M 0% /tmp/6hBxhS
[7] Inode Usage
----------------------------------------------
Filesystem Inodes IUsed IFree IUse% Mounted on
tmpfs 2043479 1 2043478 1% /tmp/6hBxhS
[8] Disk and Block Device Information
----------------------------------------------
[9] Disk I/O Statistics
----------------------------------------------
iostat is not installed.
Install the sysstat package on a test server if required.
[10] Virtual Memory Statistics
----------------------------------------------
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 77532 2348536 1260988 11868468 0 0 4 23 0 0 43 1 56 0 0
1 0 77532 2348288 1260988 11868676 0 0 0 81 3245 3167 26 1 73 0 0
2 0 77532 2348288 1260988 11868680 0 0 0 458 3388 3337 28 1 66 5 0
[11] Listening Network Services
----------------------------------------------
State Recv-Q Send-Q Local Address:Port Peer Address:Port
[12] Failed Systemd Services
----------------------------------------------
[13] Running Services
----------------------------------------------
[14] Web Server Status
----------------------------------------------
[15] Database Service Status
----------------------------------------------
[16] Recent System Errors
----------------------------------------------
-- No entries --
[17] Recent Kernel Warnings and Errors
----------------------------------------------
[18] Largest Files in /var
----------------------------------------------
93720576 /var/lib/snapd/seed/snaps/core_6818.snap
56475648 /var/lib/snapd/seed/snaps/lxd_10601.snap
53488444 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_disco_universe_binary-amd64_Packages
34406192 /var/cache/apt/pkgcache.bin
34364962 /var/cache/apt/srcpkgcache.bin
28553689 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_disco_universe_i18n_Translation-en
6534396 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_disco_main_binary-amd64_Packages
3256320 /var/lib/command-not-found/commands.db
3094703 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_disco_main_i18n_Translation-en
2157050 /var/cache/debconf/templates.dat-old
2157050 /var/cache/debconf/templates.dat
1878609 /var/lib/dpkg/info/racket-common.md5sums
1867158 /var/lib/dpkg/info/keyboard-configuration.config
1756231 /var/lib/dpkg/info/librados2.symbols
1574879 /var/lib/mlocate/mlocate.db
[19] Performance Review Checklist
----------------------------------------------
[ ] CPU saturation investigated
[ ] Load average reviewed
[ ] Memory pressure checked
[ ] Swap activity reviewed
[ ] Disk I/O latency investigated
[ ] Filesystem capacity checked
[ ] Inode usage checked
[ ] High-resource processes identified
[ ] Failed services investigated
[ ] Web server performance reviewed
[ ] Database performance reviewed
[ ] Network listeners reviewed
[ ] System logs checked
[ ] Recent configuration changes reviewed
==============================================
Diagnostic collection completed
==============================================