A comprehensive web-based application for troubleshooting MongoDB connection and performance issues, deployed on OpenLiberty.
- 🔌 Connection Testing: Test MongoDB connections with detailed diagnostics
- 🔍 Query Executor: Run MongoDB queries directly from the web interface
- 📊 Performance Statistics: View database and server statistics
- 🛠️ Network Tools: Includes comprehensive network troubleshooting utilities
- 🐚 MongoDB Shell: mongosh client included in the container
- 🌐 Modern UI: Clean, responsive web interface
- Frontend: HTML5, CSS3, JavaScript
- Backend: Java Servlet (Jakarta EE 9.1)
- Application Server: OpenLiberty
- Database Driver: MongoDB Java Driver 4.11.1
- Container: Docker with UBI base image
- Docker
- Maven (for local development)
- Java 21+ (for local development)
- Access to quay.io (for pushing images)
-
Build the Docker image:
# Linux/Mac chmod +x build-and-push.sh ./build-and-push.sh --build-only # Windows PowerShell .\build-and-push.ps1 -BuildOnly
-
Run the container:
docker run -p 9080:9080 quay.io/istrate/mongo-troubleshoot:latest
-
Access the application: Open your browser to
http://localhost:9080
-
Build with Maven:
cd tshot mvn clean package -
Run with Liberty:
mvn liberty:dev
-
Access the application: Open your browser to
http://localhost:9080
# Set environment variables
export QUAY_NAMESPACE=istrate
export QUAY_USERNAME=your-username
export QUAY_PASSWORD=your-password
# Build and push
./build-and-push.sh
# Or with options
./build-and-push.sh --tag v1.0.0
./build-and-push.sh --build-only
./build-and-push.sh --test# Set environment variables
$env:QUAY_NAMESPACE = "istrate"
$env:QUAY_USERNAME = "your-username"
$env:QUAY_PASSWORD = "your-password"
# Build and push
.\build-and-push.ps1
# Or with options
.\build-and-push.ps1 -Tag v1.0.0
.\build-and-push.ps1 -BuildOnly
.\build-and-push.ps1 -TestEnter your MongoDB connection string in the format:
mongodb://username:password@host:port/database?authSource=admin
Click "Test Connection" to verify connectivity and measure response time.
- Enter the database name
- Enter the collection name
- Write your query in JSON format (e.g.,
{"status": "active"}) - Click "Execute Query" to run the query
- Enter the database name
- Click "Get Statistics" to view:
- Database statistics
- Server status
- Performance metrics
The container includes several network troubleshooting tools:
mongosh- MongoDB Shellcurl- HTTP clientwget- File downloadertelnet- Network connectivity testingnc(netcat) - Network utilitynmap- Network scannertcpdump- Packet analyzertraceroute- Route tracingdig- DNS lookupnslookup- DNS queryping- Network connectivitynetstat/ss- Network statisticsip- Network configuration
# Connect to running container
docker exec -it <container-name> bash
# Test MongoDB connection
/opt/tools/test-mongo-connection.sh mongodb-host 27017
# MongoDB health check
/opt/tools/mongo-health-check.sh "mongodb://user:pass@host:27017/db"
# Network diagnostics
/opt/tools/network-diagnostics.sh
# Use mongosh directly
mongosh "mongodb://localhost:27017"
# Test network connectivity
nc -zv mongodb-host 27017
telnet mongodb-host 27017
ping mongodb-host
traceroute mongodb-host
# DNS lookup
nslookup mongodb-host
dig mongodb-host
# Check network configuration
ip addr show
ip route show
netstat -tulnapiVersion: apps/v1
kind: Deployment
metadata:
name: mongo-troubleshoot
spec:
replicas: 1
selector:
matchLabels:
app: mongo-troubleshoot
template:
metadata:
labels:
app: mongo-troubleshoot
spec:
containers:
- name: mongo-troubleshoot
image: quay.io/istrate/mongo-troubleshoot:latest
ports:
- containerPort: 9080
name: http
- containerPort: 9443
name: https
livenessProbe:
httpGet:
path: /health
port: 9080
initialDelaySeconds: 60
periodSeconds: 30
readinessProbe:
httpGet:
path: /health
port: 9080
initialDelaySeconds: 30
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: mongo-troubleshoot
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 9080
name: http
selector:
app: mongo-troubleshootDeploy with:
kubectl apply -f deployment.yamlversion: '3.8'
services:
mongo-troubleshoot:
image: quay.io/istrate/mongo-troubleshoot:latest
ports:
- "9080:9080"
- "9443:9443"
environment:
- WLP_LOGGING_CONSOLE_LOGLEVEL=info
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60sWLP_LOGGING_CONSOLE_FORMAT- Log format (default: json)WLP_LOGGING_CONSOLE_LOGLEVEL- Log level (default: info)WLP_LOGGING_CONSOLE_SOURCE- Log sources
Edit src/main/liberty/config/server.xml to customize:
- HTTP/HTTPS ports
- Features
- Logging levels
- CORS settings
- Authentication: This tool does not include built-in authentication. Deploy behind a secure gateway or add authentication.
- Network Access: Restrict network access to trusted users only.
- Connection Strings: Never expose MongoDB credentials in logs or UI.
- Production Use: This tool is designed for troubleshooting. Use with caution in production environments.
# Check logs
docker logs <container-name>
# Check if port is already in use
netstat -an | grep 9080 # Linux/Mac
Get-NetTCPConnection -LocalPort 9080 # Windows- Verify MongoDB is accessible from the container
- Check firewall rules
- Verify connection string format
- Use network tools in the container:
docker exec -it <container-name> bash /opt/tools/test-mongo-connection.sh <mongodb-host> 27017
Check Liberty logs:
docker exec -it <container-name> cat /logs/messages.logtshot/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/ibm/mas/tshot/
│ │ │ ├── MongoTroubleshootServlet.java
│ │ │ ├── CertificateManager.java
│ │ │ ├── CertificateUploadServlet.java
│ │ │ └── ConfigServlet.java
│ │ ├── liberty/
│ │ │ └── config/
│ │ │ └── server.xml
│ │ └── webapp/
│ │ ├── index.html
│ │ └── WEB-INF/
├── Dockerfile
├── pom.xml
├── build-and-push.sh
├── build-and-push.ps1
└── README.md
Contributions are welcome! Please ensure:
- Code follows Java conventions
- UI is responsive and accessible
- Docker image builds successfully
- Documentation is updated
Free to use
For issues and questions:
- Check the troubleshooting section
- Review container logs
- Use the included network diagnostic tools