Skip to content

andyg2/poe_monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PoE Camera Monitor

This Python project monitors IP cameras and power cycles their PoE port via SNMP if they stop responding to ping.

image

Features

  • 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

Requirements

  • Python 3.12+
  • Windows/Linux
  • Managed PoE switch with SNMP enabled

Installation

  1. Clone or download this repo
  2. Create a virtual environment:
python -m venv venv
venv\Scripts\activate   # Windows
source venv/bin/activate # Linux/macOS
  1. Install dependencies:
pip install -r requirements.txt

Usage

Run 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.

Configuration

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

Notes

  • Use Python 3.12 with pysnmp 5.x

Background Execution

You can run the PoE monitor in the background so it starts automatically or runs at system boot.

Windows – Scheduled Task

  1. Open Task Scheduler.

  2. Click Create Task…

  3. General tab:

    • Name: PoE Camera Monitor
    • Select: “Run whether user is logged on or not”
    • Check: “Run with highest privileges”
  4. Triggers tab:

    • Click New…
    • Begin the task: At startup (or set a schedule)
  5. 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
  6. Conditions and Settings tabs:

    • Adjust as needed (e.g., “Wake the computer to run this task”)
  7. Click OK and enter your credentials.

Your script will now run automatically in the background.


Linux/macOS – cronjob

  1. Open a terminal.
  2. Edit your crontab:
crontab -e
  1. 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>&1

Adjust /usr/bin/python3 and the script path to your environment. >> ... 2>&1 logs output to a file so you can debug errors.

  1. Save and exit. The script will start automatically at boot.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors