Skip to content

This project automates the daily download of PRTG sensors graphs and sends them to Telegram using the PRTG API and a PowerShell script.

Notifications You must be signed in to change notification settings

mizitheji/PRTG-Graph-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PRTG-Graph-Automation

This project automates the daily download of PRTG sensors graphs and sends them to Telegram using the PRTG API and a PowerShell script.

It is designed to run unattended via Windows Task Scheduler on a PRTG server.


πŸš€ Features

  • Uses PRTG API Token (no username/password)
  • Downloads last 24h sensor graphs
  • Generates readable captions from filenames
  • Sends graphs to Telegram
  • Fully compatible with Windows Task Scheduler
  • Safe for non-interactive execution

πŸ“¦ Requirements

  • Windows Server with PRTG Network Monitor
  • PowerShell 5.1+
  • Telegram Bot Token & Chat ID
  • PRTG API Token

πŸ“² Telegram Bot Setup

This project sends graphs to Telegram using a bot.

Follow the full setup guide: docs/telegram-bot-setup.md


πŸ” PRTG API Token

Using an API token is recommended over username/password authentication.

Benefits

  • More secure
  • No password rotation issues
  • Works reliably with automation
  • Least-privilege friendly

Follow the full setup guide: docs/prtg-api-token.md


βš™οΈ Configuration

Edit the following variables inside: scripts/GraphAutomation.ps1

# PRTG
$BaseURL  = "https://example.com"
$ApiToken = $env:PRTG_API_TOKEN

# Telegram
$BotToken = $env:TELEGRAM_BOT_TOKEN
$ChatID   = $env:TELEGRAM_CHAT_ID

πŸ•’ Windows Task Scheduler Setup

The script is designed to run via Task Scheduler.

Program

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Arguments

-ExecutionPolicy Bypass -NonInteractive -File "C:\Program Files (x86)\PRTG Network Monitor\notifications\exe\GraphAutomation.ps1"

Start in (IMPORTANT)

C:\Program Files (x86)\PRTG Network Monitor\notifications\exe

πŸ” Task Scheduler – Security Options (CRITICAL)

Setting Value
Run whether user is logged on or not βœ…
Do not store password ❌ UNCHECKED
Run with highest privileges βœ…
User account Administrator / Service Account

πŸ“Œ Do NOT check β€œDo not store password” This will cause PowerShell, API calls, and Telegram sending to fail silently.

Follow the full setup guide: docs/task-scheduler.md


πŸ§ͺ Testing

πŸ” Environment Variables (IMPORTANT) Before running the script, set these once on the PRTG server. Run Powershell as Administrator.

setx PRTG_API_TOKEN "insert your PRTG_API_TOKEN" /M
setx TELEGRAM_BOT_TOKEN "insert your TELEGRAM_BOT_TOKEN" /M
setx TELEGRAM_CHAT_ID "insert your TELEGRAM_CHAT_ID" /M

Close powershell (MUST) if not the script will fail.

Open a new Powershell and run the script.

.\GraphAutomation.ps1

Then test from Task Scheduler:

Right click on the created task β†’ Run

Expected result:

  • Exit code: 0x0
  • Telegram message received

πŸ›‘οΈ Best Practices

  • Use a dedicated service account for scheduled tasks
  • Restrict API token permissions
  • Rotate Telegram bot tokens periodically
  • Enable Task Scheduler history for debugging

About

This project automates the daily download of PRTG sensors graphs and sends them to Telegram using the PRTG API and a PowerShell script.

Topics

Resources

Stars

Watchers

Forks