A tool for collecting and monitoring Android device and application metrics via ADB
393
A tool for collecting and monitoring Android device and application metrics via ADB. Repository available at dinip/adb_metrics
Clone the repository
git clone https://github.com/Dinip/adb_metrics.git
cd adb_metrics
Install the required dependencies
pip install -r requirements.txt
Copy the example environment file to .env and configure it
cp .env.example .env
Ensure ADB is installed and available in your PATH
The tool can be configured via:
.env file in the project rootADB_HOST="localhost"
ADB_PORT="5037"
INFLUXDB_URL="http://localhost:8086"
INFLUXDB_TOKEN="admin_token"
INFLUXDB_ORG="adb_monitoring"
INFLUXDB_BUCKET="device_metrics"
# Needed for InfluxDB 2 initial setup.
# Remove if using already existing InfluxDB 2 instance.
# Make sure you set secure password and admin token for production use.
# Update docker-compose-prod.yml as needed.
INFLUXDB_USERNAME="admin"
INFLUXDB_PASSWORD="password"
INFLUXDB_ADMIN_TOKEN="admin_token"
The project includes pre-configured Grafana dashboards to visualize your Android device metrics.
Make sure your .env file is properly configured with your InfluxDB settings:
INFLUXDB_ORG=your-organization
INFLUXDB_BUCKET=android_metrics
INFLUXDB_ADMIN_TOKEN=your-admin-token
Run the update references script to configure Grafana files with your environment settings:
cd grafana
chmod +x update_references.sh # Make the script executable (Linux/macOS only)
./update_references.sh # Linux/macOS
# or
bash update_references.sh # Windows with Git Bash or WSL
The script will replace template variables in the Grafana configuration files with your actual values from the .env
file.
Start Grafana with the provided configuration using docker-compose:
docker-compose up -d
Access Grafana at http://localhost:3000 to view your Android device metrics dashboard.
# Show current configuration
python -m adb_metrics.main config
# List connected devices
python -m adb_metrics.main devices
# Print global metrics only (no app-specific metrics)
python -m adb_metrics.main print
# Print metrics for specific app pattern
python -m adb_metrics.main print --app-pattern "*.bmw.*"
# Print metrics for multiple app patterns
python -m adb_metrics.main print --app-pattern "*.bmw.*" --app-pattern "*.microsoft.*"
# Persist metrics to InfluxDB (global metrics only)
python -m adb_metrics.main persist --interval 10
# Persist metrics for specific device and app pattern
python -m adb_metrics.main persist --device-id ABCD1234WXYZ --app-pattern "*.bmw.*" --interval 5
# Use ADB on a remote machine
python -m adb_metrics.main print --adb-host 192.168.1.100 --adb-port 5037
# List available devices first
python -m adb_metrics.main devices
# Then monitor a specific device by its ID
python -m adb_metrics.main print --device-id ABCD1234WXYZ
System CPU Usage:
System Memory:
Temperature:
When app patterns are provided, these additional metrics are collected:
App CPU Usage:
App Memory:
adb_metrics/main.py - Entry point and CLI interfaceadb_metrics/device/ - Device interaction and metrics collectionadb_metrics/data/ - Data persistence logicadb_metrics/config/ - Configuration managementMIT License
Content type
Image
Digest
sha256:850414e99…
Size
46.1 MB
Last updated
over 1 year ago
docker pull dinip/adb_metrics