Introducing DevOpsFetch: A Comprehensive Server Monitoring Tool

augusthottie

augusthottie

Posted on August 2, 2024

Introducing DevOpsFetch: A Comprehensive Server Monitoring Tool

Welcome to DevOpsFetch! This is a Bash tool designed to streamline the process of retrieving and monitoring server information. With DevOpsFetch, you can easily display active ports, user logins, Nginx configurations, Docker images, and container statuses. Additionally, the tool includes a systemd service for continuous monitoring and logging, ensuring your server remains under constant observation.

Table of Contents

Features

DevOpsFetch offers a suite of features to help you monitor and manage your server effectively:

  • Display all active ports and services
  • Provide detailed information about a specific port
  • List all Docker images and containers
  • Provide detailed information about a specific Docker container
  • Display all Nginx domains and their ports
  • Provide detailed configuration information for a specific Nginx domain
  • List all users and their last login times
  • Provide detailed information about a specific user
  • Display activities within a specified time range
  • Continuous monitoring and logging with log rotation

Installation

Dependencies

Before you begin, ensure the following packages are installed on your system:

  • net-tools for netstat
  • docker.io
  • nginx
  • jq
  • finger

Setup

  1. Clone the repository:
   git clone https://github.com/AugustHottie/devopsfetch-stage5a.git
   cd devopsfetch
Enter fullscreen mode Exit fullscreen mode
  1. Run the installation script to set up dependencies and the systemd service:
   sudo ./install.sh
Enter fullscreen mode Exit fullscreen mode

This script will install the necessary dependencies, set up the devopsfetch command, and enable the devopsfetch systemd service.

Usage

Command-line Options

  • -p, --port : Display all active ports and services.
  • -p <port_number> : Display detailed information about a specific port.
  • -d, --docker : List all Docker images and containers.
  • -d <container_name> : Display detailed information about a specific Docker container.
  • -n, --nginx : Display all Nginx domains and their ports.
  • -n <domain> : Display detailed configuration information for a specific Nginx domain.
  • -u, --users : List all users and their last login times.
  • -u <username> : Display detailed information about a specific user.
  • -t, --time <start> <end> : Display activities within a specified time range.
  • -h, --help : Display usage instructions.

Display Active Ports

To display all active ports and services, run:

./devopsfetch.sh -p
Enter fullscreen mode Exit fullscreen mode

Port Information

To provide detailed information about a specific port, run:

./devopsfetch.sh -p <port_number>
Enter fullscreen mode Exit fullscreen mode

Example:

./devopsfetch.sh -p 80
Enter fullscreen mode Exit fullscreen mode

Docker Information

To list all Docker images and containers, run:

./devopsfetch.sh -d
Enter fullscreen mode Exit fullscreen mode

To provide detailed information about a specific Docker container, run:

./devopsfetch.sh -d <container_name>
Enter fullscreen mode Exit fullscreen mode

Example:

./devopsfetch.sh -d my_container
Enter fullscreen mode Exit fullscreen mode

Nginx Information

To display all Nginx domains and their ports, run:

./devopsfetch.sh -n
Enter fullscreen mode Exit fullscreen mode

To provide detailed configuration information for a specific Nginx domain, run:

./devopsfetch.sh -n <domain>
Enter fullscreen mode Exit fullscreen mode

Example:

./devopsfetch.sh -n example.com
Enter fullscreen mode Exit fullscreen mode

User Logins

To list all users and their last login times, run:

./devopsfetch.sh -u
Enter fullscreen mode Exit fullscreen mode

To provide detailed information about a specific user, run:

./devopsfetch.sh -u <username>
Enter fullscreen mode Exit fullscreen mode

Example:

./devopsfetch.sh -u myuser
Enter fullscreen mode Exit fullscreen mode

Time Range Activities

To display activities within a specified time range, run:

./devopsfetch.sh -t "<start_time>" "<end_time>"
Enter fullscreen mode Exit fullscreen mode

Example:

./devopsfetch.sh -t "2024-07-21 00:00:00" "2024-07-22 00:00:00"
Enter fullscreen mode Exit fullscreen mode

Logging

Logs are stored in the /var/log/devopsfetch.log directory. Log rotation is implemented to manage log file size. Logs are rotated daily, keeping up to 7 days of logs.

Help

To display the help message with usage instructions, run:

./devopsfetch.sh -h
Enter fullscreen mode Exit fullscreen mode

Full Script Code

To view the full script code, check my GitHub repo: DevOpsFetch GitHub Repository

By following this guide, you should be able to effectively install, configure, and use DevOpsFetch to monitor your server. For any issues or questions, refer to the comment section or consult the script documentation on my GitHub. Happy monitoring!🔍🚀

💖 💪 🙅 🚩
augusthottie
augusthottie

Posted on August 2, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related