DevOpsFetch is a powerful command-line tool designed for DevOps professionals to quickly retrieve and display system information, including active ports, Docker containers, Nginx configurations, user logins, and system activities within specified time ranges.
- Active port and service monitoring
- Docker image and container management
- Nginx domain and configuration inspection
- User login tracking
- Time-based activity logging
- Continuous monitoring via systemd service
- Formatted output for improved readability
To install DevOpsFetch, follow these steps:
-
Clone this repository: git clone [https://github.com/fortis-07/devOps-fetch.git]
-
cd devopsfetch
-
Run the installation script:
sudo bash ./dev5_install.shThis script will:
- Install necessary dependencies (jq, nginx, docker.io)
- Copy the DevOpsFetch script to /usr/local/bin/
- Set up a systemd service for continuous monitoring
- Configure log rotation
After installation, you can configure the systemd service by editing its unit file:
sudo nano /etc/systemd/system/devopsfetch.serviceYou can modify the ExecStart line to change how often the tool runs or what command it executes.
After making changes, reload the systemd daemon and restart the service:
sudo systemctl daemon-reload
sudo systemctl restart devopsfetch.serviceDevOpsFetch can be used with various command-line flags:
- Display all active ports:
devopsfetch -p- Display information for a specific port:
devopsfetch -p 80- List all Docker images and containers:
devopsfetch -d- Display information for a specific container:
devopsfetch -d my_container_name- Display all Nginx domains and their ports:
devopsfetch -n#- Display configuration for a specific domain
devopsfetch -n example.com- List all users and their last login times:
devopsfetch -u- Display system activities within a specified time range:
devopsfetch -t "2023-07-24 00:00:00" "2023-07-24 23:59:59"- Display usage instructions:
devopsfetch -hDevOpsFetch uses systemd for logging. Logs are stored in the system journal and a dedicated log file.
To view the systemd service logs:
sudo journalctl -u devopsfetch.serviceTo view the dedicated log file:
sudo cat /var/log/devopsfetch.logIf you encounter issues:
- Check the service status:
sudo systemctl status devopsfetch.service- View recent logs:
sudo journalctl -u devopsfetch.service -n 50 --no-pager- Ensure the script has correct permissions:
sudo chmod +x /usr/local/bin/devopsfetch- Verify the script content:
sudo cat /usr/local/bin/devopsfetch- If changes are made to the script, restart the service:
sudo systemctl restart devopsfetch.serviceConfiguration and Permissions
-
Verify Paths and Permissions: Ensure all file paths are accurate and accessible. Confirm you have the appropriate permissions to execute the script and access required system information.
-
Privilege Requirements: Some operations within the script may necessitate root or sudo privileges. Ensure you execute commands with the necessary level of access.
-
Function Testing: Test each function in isolation to validate its operation before integrating it into the main script.
-
Configuration Adjustment: Modify configurations to align with your specific environment and requirements.