MID INTERNSHIP TASK: Building devopsfetch for Server Information Retrieval and Monitoring.

Introduction

Welcome to the documentation for DevOpsFetch, a powerful yet straightforward monitoring tool designed to meet the requirements of HNG Internship Task 5. At first glance, the task of creating a system to monitor various aspects of a server environment may seem simple. However, achieving this requires close attention to detail and a comprehensive understanding of different system components.

DevOpsFetch encapsulates this challenge, providing an intuitive solution that monitors:

  • Active network ports
  • Docker container statuses
  • Nginx configurations and domains
  • User login activities
  • System activities within specified time ranges

This documentation will guide you through the installation, configuration, and usage of DevOpsFetch. With clear instructions and practical examples, you’ll find that what initially seemed complex can be managed efficiently with the right approach and tools. Let’s dive in and simplify your monitoring tasks with DevOpsFetch.

Installation and Configuration

Prerequisites

Ensure your system has the necessary dependencies:

  • jq
  • lsof
  • net-tools
  • nginx
  • docker.io

Installation Steps

  1. Clone and Run the Installer Script:
git clone https://github.com/Oviawe007/HNG-Task-5.git
cd HNG-Task-5.git
Enter fullscreen mode
Exit fullscreen mode

Make the script executable:

chmod +x devopsfetch.sh
chmod +x install.sh
Enter fullscreen mode
Exit fullscreen mode

Run the script:

sudo ./install.sh
Enter fullscreen mode
Exit fullscreen mode

2. Check the Installation:

  • Verify that the devopsfetch.sh script is installed in > /opt/devopsfetch/
    and is executable.
  • Confirm that a symbolic link to devopsfetch.sh is created at > /usr/local/bin/devopsfetch.
  • Ensure the devopsfetch.service file is created in > /etc/systemd/system/.

3. Check the Service:

sudo systemctl status devopsfetch.service
Enter fullscreen mode
Exit fullscreen mode

Configuration

The service is configured to run devopsfetch.sh every hour by default. You can modify the service configuration in

/etc/systemd/system/devopsfetch.service if needed.

Usage Examples

Run devopsfetch.sh as a root user with the appropriate flags to fetch the desired information.

  • Show Help:
sudo ./devopsfetch.sh -h
Enter fullscreen mode
Exit fullscreen mode

devopsfetch help

  • Get Active Ports:
sudo ./devopsfetch.sh -p
Enter fullscreen mode
Exit fullscreen mode
  • Get Specific Port Info:
sudo ./devopsfetch.sh -p [PORT]
# Example: sudo ./devopsfetch.sh -p 39781
Enter fullscreen mode
Exit fullscreen mode

port info

  • Get Docker Info:
sudo ./devopsfetch.sh -d all
Enter fullscreen mode
Exit fullscreen mode

docker info

  • Get Specific Docker Container Info:
sudo ./devopsfetch.sh -d [CONTAINER_NAME]
# Example: sudo ./devopsfetch.sh -d my_container
Enter fullscreen mode
Exit fullscreen mode
  • Get Nginx Info:
sudo ./devopsfetch.sh -n all
Enter fullscreen mode
Exit fullscreen mode
  • Get Specific Nginx Domain Info:
sudo ./devopsfetch.sh -n [DOMAIN]
# Example: sudo ./devopsfetch.sh -n example.com
Enter fullscreen mode
Exit fullscreen mode
  • Get User Logins:
sudo ./devopsfetch.sh -u all
Enter fullscreen mode
Exit fullscreen mode

login info

  • Get Specific User Info:
sudo ./devopsfetch.sh -u [USER]
# Example: sudo ./devopsfetch.sh -u ubuntu
Enter fullscreen mode
Exit fullscreen mode

ubuntu info

  • Get Activities in Time Range:
sudo ./devopsfetch.sh -t [START_TIME] [END_TIME]
# Example: sudo ./devopsfetch.sh -t "2024-07-22 10:00:00" "2024-07-22 11:00:00"
Enter fullscreen mode
Exit fullscreen mode

Time info

Logging Mechanism

  • Log Rotation Configuration
    The installation script sets up log rotation for > /var/log/syslog
    to ensure logs do not consume excessive disk space. The log rotation configuration is defined in > /etc/logrotate.d/devopsfetch.

View Logs

To retrieve and view logs, you can use the journalctl command:

sudo journalctl -u devopsfetch.service
Enter fullscreen mode
Exit fullscreen mode

This command will display the logs for the DevOpsFetch service, allowing you to monitor its activities and debug if necessary.

Summary

DevOpsFetch provides a comprehensive solution for monitoring various system and application metrics, including active ports, Docker containers, Nginx configurations, and user logins. By following the installation steps and using the provided command-line flags, you can effectively gather and analyze the information needed to maintain and troubleshoot your system. The logging mechanism ensures that you have a record of all activities for further analysis and auditing.

Leave your questions and feedback in the comments.
Thank you.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top