This Python project monitors IP cameras and power cycles their PoE port via SNMP if they stop responding to ping.
- Web interface (Flask) to add/delete cameras
- Background monitoring loop that pings each camera
- Power cycles PoE port using SNMP v2c if consecutive failures reach threshold
- Works with Netgear FS728TP and similar managed PoE switches
- Fully compatible with Python 3.12 + pysnmp 5.x
- Python 3.12+
- Windows/Linux
- Managed PoE switch with SNMP enabled
- Clone or download this repo
- Create a virtual environment:
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Linux/macOS- Install dependencies:
pip install -r requirements.txtRun the script:
python poe_monitor.py- Web UI:
http://localhost:5000 - Add cameras with IP and PoE port index
- Background monitor pings each camera every 10s (configurable)
- Power cycles cameras after 3 consecutive ping failures (configurable)
Press CTRL+C to stop.
Edit variables at the top of poe_monitor.py:
SWITCH_IP = "192.168.1.10" # Your PoE switch IP
COMMUNITY = "private" # SNMP community
PING_INTERVAL = 10 # seconds
FAIL_THRESHOLD = 3 # consecutive failures
POE_OFF_TIME = 10 # seconds to keep PoE off
DB_FILE = "cameras.db" # SQLite DB file- Use Python 3.12 with pysnmp 5.x
You can run the PoE monitor in the background so it starts automatically or runs at system boot.
-
Open Task Scheduler.
-
Click Create Task…
-
General tab:
- Name:
PoE Camera Monitor - Select: “Run whether user is logged on or not”
- Check: “Run with highest privileges”
- Name:
-
Triggers tab:
- Click New…
- Begin the task: At startup (or set a schedule)
-
Actions tab:
- Click New…
- Action: Start a program
- Program/script:
C:\Python312\python.exe - Add arguments:
C:\TEMP\poe_monitor\poe_monitor.py - Start in:
C:\TEMP\poe_monitor
-
Conditions and Settings tabs:
- Adjust as needed (e.g., “Wake the computer to run this task”)
-
Click OK and enter your credentials.
Your script will now run automatically in the background.
- Open a terminal.
- Edit your crontab:
crontab -e- Add a line to run at boot:
@reboot /usr/bin/python3 /home/user/poe_monitor/poe_monitor.py >> /home/user/poe_monitor/poe_monitor.log 2>&1Adjust
/usr/bin/python3and the script path to your environment.>> ... 2>&1logs output to a file so you can debug errors.
- Save and exit. The script will start automatically at boot.