A TypeScript-based Infrastructure as Code (IaC) solution for monitoring UniFi networks across multiple environments. This tool provides automated monitoring, device status reporting, and synchronization with version control.
- 📊 Network Monitoring: Track device status, online/offline states, and network health
- 📝 Infrastructure as Code: Store network configurations in TypeScript for version control
- 🤖 Automated Monitoring: Daily checks of network configurations with GitHub Actions
- 📈 Change Tracking: Track all network changes in git history
- 🔒 Secure: API keys stored in GitHub Secrets
- Node.js 20 or later
- UniFi Site Manager API access
- GitHub repository for configuration management
-
Clone the repository:
git clone https://github.com/yourusername/unifi-monitor.git cd unifi-monitor
-
Install dependencies:
npm install
-
Create a
.env
file with your UniFi API keys:UNIFI_API_KEY_DEV=your_dev_api_key UNIFI_API_KEY_STAGE=your_stage_api_key UNIFI_API_KEY_PROD=your_prod_api_key
Configure your environments in src/config/environments.ts
:
export const environments = {
dev: {
name: "Development",
hostname: "dev-testing",
apiKey: process.env.UNIFI_API_KEY_DEV || "",
},
// ... other environments
};
- Monitor network status:
npm run test -- read dev # For development environment npm run test -- read stage # For staging environment npm run test -- read prod # For production environment
The project includes a GitHub Actions workflow:
- Daily Monitor (
.github/workflows/daily-run.yml
):- Runs daily at midnight UTC
- Checks all environments
- Commits any changes to git
Add the following secrets to your GitHub repository:
UNIFI_API_KEY_DEV
UNIFI_API_KEY_STAGE
UNIFI_API_KEY_PROD
unifi-monitor/
├── src/
│ ├── clients/ # API clients
│ ├── config/ # Configuration files
│ └── utils/ # Utility functions
├── scripts/ # Helper scripts
├── .github/workflows/ # GitHub Actions
└── package.json
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the ISC License.