fork download
  1. #!/bin/bash
  2.  
  3. # Linux Server Performance Diagnostic Checklist
  4. #
  5. # Technical reference:
  6. # Server optimization service:
  7. # https://i...content-available-to-author-only...t.com/server-optimization-service/
  8. #
  9. # This script performs read-only checks.
  10. # It does not modify system configuration.
  11.  
  12. echo "=============================================="
  13. echo " Linux Server Performance Diagnostic"
  14. echo "=============================================="
  15.  
  16. echo
  17. echo "[1] System Uptime and Load"
  18. echo "----------------------------------------------"
  19. uptime
  20.  
  21. echo
  22. echo "[2] CPU Information"
  23. echo "----------------------------------------------"
  24. nproc 2>/dev/null
  25. lscpu 2>/dev/null | grep -E \
  26. '^(CPU\(s\)|Model name|CPU MHz|Architecture)' \
  27. | head -n 10
  28.  
  29. echo
  30. echo "[3] Memory Usage"
  31. echo "----------------------------------------------"
  32. free -m
  33.  
  34. echo
  35. echo "[4] Top CPU-Consuming Processes"
  36. echo "----------------------------------------------"
  37. ps aux --sort=-%cpu | head -n 15
  38.  
  39. echo
  40. echo "[5] Top Memory-Consuming Processes"
  41. echo "----------------------------------------------"
  42. ps aux --sort=-%mem | head -n 15
  43.  
  44. echo
  45. echo "[6] Filesystem Capacity"
  46. echo "----------------------------------------------"
  47. df -h
  48.  
  49. echo
  50. echo "[7] Inode Usage"
  51. echo "----------------------------------------------"
  52. df -i
  53.  
  54. echo
  55. echo "[8] Disk and Block Device Information"
  56. echo "----------------------------------------------"
  57. lsblk 2>/dev/null
  58.  
  59. echo
  60. echo "[9] Disk I/O Statistics"
  61. echo "----------------------------------------------"
  62.  
  63. if command -v iostat >/dev/null 2>&1; then
  64. iostat -xz 1 2
  65. else
  66. echo "iostat is not installed."
  67. echo "Install the sysstat package on a test server if required."
  68. fi
  69.  
  70. echo
  71. echo "[10] Virtual Memory Statistics"
  72. echo "----------------------------------------------"
  73.  
  74. if command -v vmstat >/dev/null 2>&1; then
  75. vmstat 1 3
  76. fi
  77.  
  78. echo
  79. echo "[11] Listening Network Services"
  80. echo "----------------------------------------------"
  81. ss -lntp 2>/dev/null
  82.  
  83. echo
  84. echo "[12] Failed Systemd Services"
  85. echo "----------------------------------------------"
  86. systemctl --failed --no-pager 2>/dev/null
  87.  
  88. echo
  89. echo "[13] Running Services"
  90. echo "----------------------------------------------"
  91. systemctl list-units \
  92. --type=service \
  93. --state=running \
  94. --no-pager 2>/dev/null | head -n 40
  95.  
  96. echo
  97. echo "[14] Web Server Status"
  98. echo "----------------------------------------------"
  99.  
  100. systemctl is-active nginx 2>/dev/null || true
  101. systemctl is-active apache2 2>/dev/null || true
  102. systemctl is-active httpd 2>/dev/null || true
  103.  
  104. echo
  105. echo "[15] Database Service Status"
  106. echo "----------------------------------------------"
  107.  
  108. systemctl is-active mysql 2>/dev/null || true
  109. systemctl is-active mariadb 2>/dev/null || true
  110.  
  111. echo
  112. echo "[16] Recent System Errors"
  113. echo "----------------------------------------------"
  114. journalctl -p err -n 30 --no-pager 2>/dev/null
  115.  
  116. echo
  117. echo "[17] Recent Kernel Warnings and Errors"
  118. echo "----------------------------------------------"
  119. dmesg --level=err,warn 2>/dev/null | tail -n 30
  120.  
  121. echo
  122. echo "[18] Largest Files in /var"
  123. echo "----------------------------------------------"
  124.  
  125. if [ -d /var ]; then
  126. find /var -type f -printf '%s %p\n' 2>/dev/null \
  127. | sort -nr \
  128. | head -n 15
  129. fi
  130.  
  131. echo
  132. echo "[19] Performance Review Checklist"
  133. echo "----------------------------------------------"
  134. echo "[ ] CPU saturation investigated"
  135. echo "[ ] Load average reviewed"
  136. echo "[ ] Memory pressure checked"
  137. echo "[ ] Swap activity reviewed"
  138. echo "[ ] Disk I/O latency investigated"
  139. echo "[ ] Filesystem capacity checked"
  140. echo "[ ] Inode usage checked"
  141. echo "[ ] High-resource processes identified"
  142. echo "[ ] Failed services investigated"
  143. echo "[ ] Web server performance reviewed"
  144. echo "[ ] Database performance reviewed"
  145. echo "[ ] Network listeners reviewed"
  146. echo "[ ] System logs checked"
  147. echo "[ ] Recent configuration changes reviewed"
  148.  
  149. echo
  150. echo "=============================================="
  151. echo " Diagnostic collection completed"
  152. echo "=============================================="
Success #stdin #stdout 0.09s 7000KB
stdin
Standard input is empty
stdout
==============================================
 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
==============================================