Server Stats Script

Server Stats is a Bash script that provides a snapshot of key system information, such as uptime, installed software versions, resource usage, logged-in users, and running services.

Features

  • Displays system time and uptime.
  • Shows installed OS and kernel.
  • Shows installed software versions for:
    • Nginx
    • Apache
    • PHP
    • Node.js
    • MariaDB
    • MySQL
    • MS SQL
    • Apache Cassandra
    • Apache Solr
    • MongoDB
    • Redis
    • RavenDB
  • Notifies about system updates and security patches.
  • Shows logged-in users and their active sessions.
  • Displays open public network ports.
  • Displays network traffic.
  • Reports CPU and memory usage, including per-core utilization.
  • Reports disk space usage.
  • Lists top 10 memory and CPU-consuming processes.
  • Ability to turn features on/off.

Screenshot

Requirements

The script requires mpstat from sysstat to be installed to fetch CPU info:

sudo apt install sysstat  # For Debian/Ubuntu
sudo dnf install sysstat  # For Fedora
sudo yum install sysstat  # For CentOS/RHEL

Usage

1. Set up configuration file

  • Copy the example config file:
cp server-stats.conf.example server-stats.conf

2. Make the script executable:

chmod +x server-stats.sh

3. Run the script:

./server-stats.sh

Configuration

Edit server-stats.conf and set variables to ‘on’ to enable features, or leave them empty to disable. Example:

TIME=on   #Feature is turned on.
TIME=     #Feature is turned off.

Automatically Execute on SSH Login

If you want the script to run automatically every time you log in via SSH, follow these steps:

1. Open your shell profile in a text editor:

nano ~/.bashrc

Or if you use zsh:

nano ~/.zshrc

2. Add the following line at the end of the file (replace the path with your actual path):

~/scripts/server-stats/server-stats.sh

3. Save and exit (in nano: press CTRL + X, then Y, then Enter).

4. Apply the changes:

source ~/.bashrc

Get the Script

server-stats

https://github.com/PaulSorensen/server-stats

Provides a snapshot of key system information.

Last Updated: April 14, 2025

Categories: Scripts