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
- Clone and Run the Installer Script:
git clone https://github.com/Oviawe007/HNG-Task-5.git
cd HNG-Task-5.git
Make the script executable:
chmod +x devopsfetch.sh
chmod +x install.sh
Run the script:
sudo ./install.sh
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
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
- Get Active Ports:
sudo ./devopsfetch.sh -p
- Get Specific Port Info:
sudo ./devopsfetch.sh -p [PORT]
# Example: sudo ./devopsfetch.sh -p 39781
- Get Docker Info:
sudo ./devopsfetch.sh -d all
- Get Specific Docker Container Info:
sudo ./devopsfetch.sh -d [CONTAINER_NAME]
# Example: sudo ./devopsfetch.sh -d my_container
- Get Nginx Info:
sudo ./devopsfetch.sh -n all
- Get Specific Nginx Domain Info:
sudo ./devopsfetch.sh -n [DOMAIN]
# Example: sudo ./devopsfetch.sh -n example.com
- Get User Logins:
sudo ./devopsfetch.sh -u all
- Get Specific User Info:
sudo ./devopsfetch.sh -u [USER]
# Example: sudo ./devopsfetch.sh -u ubuntu
- 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"
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
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.