{"id":20555182,"url":"https://github.com/angela-d/prtg-toggle","last_synced_at":"2025-10-19T16:48:45.610Z","repository":{"id":112030365,"uuid":"177361539","full_name":"angela-d/prtg-toggle","owner":"angela-d","description":"Send custom alert toggles to PRTG via webhooks, that clear from your dashboard only once reviewed by admins. ","archived":false,"fork":false,"pushed_at":"2019-03-27T22:17:12.000Z","size":126,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T06:33:45.621Z","etag":null,"topics":["log-analysis","log-monitor","monitoring","monitoring-plugins","prtg","prtg-network-monitor","prtg-python","prtg-sensors","python3","sensor","webhook-api"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angela-d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-24T02:22:06.000Z","updated_at":"2024-03-26T07:21:18.000Z","dependencies_parsed_at":"2023-04-19T08:31:45.136Z","dependency_job_id":null,"html_url":"https://github.com/angela-d/prtg-toggle","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/angela-d/prtg-toggle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fprtg-toggle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fprtg-toggle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fprtg-toggle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fprtg-toggle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angela-d","download_url":"https://codeload.github.com/angela-d/prtg-toggle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fprtg-toggle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279853611,"owners_count":26235751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-19T02:00:07.647Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["log-analysis","log-monitor","monitoring","monitoring-plugins","prtg","prtg-network-monitor","prtg-python","prtg-sensors","python3","sensor","webhook-api"],"created_at":"2024-11-16T03:16:55.951Z","updated_at":"2025-10-19T16:48:45.566Z","avatar_url":"https://github.com/angela-d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PRTG Alert Toggle Webhook API\nUtilize static error alerts for custom log behavior with PRTG's webhook API.\n\nAn alert has been triggered (which will stick around until administratively cleared)\n\n![Sensor Alert](img/sensor-alert.png)\n\nAlert manually cleared by an Admin:\n\n![Sensor Cleared](img/sensor-cleared.png)\n\n## Requirements\n- GNU/Linux-based distro (Debian/Ubuntu/CentOS, etc) - may work in others, but only tested in a Linux environment\n- Python 3 (3.5.3+)\n- Pip3 (pre-installed on most distros)\n\nPython Packages (installable via Pip3 / requirements.txt):\n- Dataset v1.1.2+\n- Stuf v0.9.16\n\n## Setup\nFirst, configure your sensor so you can get an API token from PRTG.\n- Sensors \u003e Add Sensor \u003e Add/Create a Device (doesn't matter which) \u003e fill in details \u003e on the device \u003e Add Sensor \u003e HTTP Push Advanced\n- Name the sensor \u003e fill in details \u003e method: post \u003e create.. once created, click on the newly created channel \u003e settings \u003e copy/paste your token into the script's config\n\n**If your log is not currently in DD-MMM-YYYY:HH:MM:SS format:**\n- You *must* adjust the following line:\n```python\nvisit = datetime.strptime(date_str, '%d/%b/%Y:%H:%M:%S').strftime('%Y-%m-%d %H:%M:%S')\n```\n\n- And change the date format from (**strptime** field only):\n```python\n%d/%b/%Y:%H:%M:%S\n```\n\nTo whatever format your log uses.  [Python Date Variables](https://swalladge.github.io/strftime/)\n\n### Install Dependencies\nIf on Debian:\n- Pip3 should already be installed\n\nThen, install the Toggle script's dependencies:\n```bash\nsudo pip3 install -r requirements.txt\n```\n(substitute pip3 for pip if using a distro that has Python3 set as its default Python (on Debian, it is Python2, at the time of writing.)\n\n\n## To Use\n- Trigger the sensor by running the script from the cli: `/path/to/script/prtg-toggle --start` or `prtg-toggle --start` if you added a symlink\n- Go into channel settings and configure your thresholds.  \n\n**Modifying the Channel Settings and Setting the Alert/Warning Thresholds** (after first webhook is triggered):\n\n![Before](img/before.png)\n\nExample config:\n\n![After](img/after.png)\n\nThere might be a way to send these values with the json, but I did not find any documentation to list the variables PRTG would expect.\n\nThese settings throw my channel into Warning status with a webhook call of 3+ clicks from the same IP, error status on 4+.\n\n### Also Useful\nIf you want to view your databases created by this script in a GUI, try [SQLite Browser](https://sqlitebrowser.org/).\n\n\n***\n## Install\nThis script was written to work in part with an initial script that extracts only the behavioral data that's interesting, from access.log - if you point this script (PRTG Toggle) at an unmodified access log, you're going to get a lot of junk you don't care about coming through.\n\nI've included a sample [Shell script](sample-extraction.md) you can use for testing PRTG Toggle before setting this live on your production system.\n\n**Tell Toggle about an already processed log with activity you're interested in only, not a vanilla syslog or access log.**\n\n- Clone to your user's home directory (the user that will be running the script)\n```bash\ngit clone https://github.com/angela-d/prtg-toggle.git ~/prtg-toggle\n```\n\n- Best run via cron, to make toggle accessible globally, without requiring a path, add a symbolic link.  This will add a symlink to the home directory of the last non-sudo user that logged in; assuming you aren't running this as root (don't run as root):\n```bash\nsudo ln -s /home/$(last | grep \"logged in\" | grep -o '^\\S*')/prtg-toggle/prtg-toggle /usr/local/bin/prtg-toggle\n```\n\n## Customizing\nThere are a few default configuration entries in [prtg-toggle](prtg-toggle) -- ensure you modify the options between **# start config** and **# end config** to suit your environment.\n\n## Usage\nSetup a cron that is synced with your extraction script (runs every hour at the 40-minute mark).\n```bash\n40 * * * * /usr/local/bin/prtg-toggle\n```\n\n## Command-Line Options\n\n**Reset the Alarm**\nOnce an Admin has assessed the cause of the alarm, reset it\n```bash\nprtg-toggle --reset\n```\n\n**Clear the database**\nRun this when your extraction log resets\n```bash\nprtg-toggle --clear\n```\n\n**Run the script**\nRun this to start analyzing the extracted log (also is triggered by specifying no arguments)\n```bash\nprtg-toggle --start\n```\n\n**Help**\nSee available commands\n```bash\nprtg-toggle --help\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangela-d%2Fprtg-toggle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangela-d%2Fprtg-toggle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangela-d%2Fprtg-toggle/lists"}