Webhook

Name
XMPP YoSiJo - Reports
Description
xmpps://netbox@anoxinon.me/yosijo

HTTP Request

HTTP method
POST
Payload URL
https://apprise-api.stage.anoxinon.de/notify/
HTTP content type
application/json
Secret

SSL

SSL verification
CA file path
Documents
None

Additional Headers

None

Body Template

{%- set ns = namespace(has_failures=false, has_warnings=false, body="") -%}

{# Titel und Einleitung vorbereiten #}
{%- set report_name = data.name | default("PlatformReport") -%}
{%- set ns.body = "## Der Report " ~ report_name ~ " wurde von " ~ (username | default('YoSiJo')) ~ " ausgefuehrt.[BR][BR]### Log:[BR]" -%}

{# 1. Suche in NetBox v4 Report-Tests #}
{%- if data is defined and data.tests is defined -%}
  {%- for test_name, test_results in data.tests.items() -%}
    {%- if test_results.log -%}
      
      {# Prüfen, ob in diesem Test Fehler oder Warnungen existieren #}
      {%- set test_has_issues = namespace(valid=false) -%}
      {%- for log_entry in test_results.log -%}
        {%- if log_entry[1] in ['failure', 'failed', 'warning'] -%}
          {%- set test_has_issues.valid = true -%}
          {%- if log_entry[1] in ['failure', 'failed'] -%}{% set ns.has_failures = true %}{%- else -%}{% set ns.has_warnings = true %}{%- endif -%}
        {%- endif -%}
      {%- endfor -%}

      {%- if test_has_issues.valid -%}
        {%- set ns.body = ns.body ~ "[BR]#### " ~ test_name ~ "[BR][BR]"-%}
        {%- for log_entry in test_results.log -%}
          {%- if log_entry[1] in ['failure', 'failed', 'warning'] -%}
            {%- set prefix = "❌ Fehler" if log_entry[1] in ['failure', 'failed'] else "⚠️ Warnung" -%}
            {%- set clean_path = log_entry[3] if log_entry[3].startswith('/') else '/' ~ log_entry[3] -%}
            {%- set target_url = "https://netbox.anoxinon.de" ~ clean_path -%}
            {%- set ns.body = ns.body ~ "- " ~ prefix ~ " - Name: " ~ log_entry[2] ~ "[BR]  Meldung: " ~ log_entry[4] ~ "[BR]  URL: " ~ target_url ~ "[BR]" -%}
          {%- endif -%}
        {%- endfor -%}
      {%- endif -%}

    {%- endif -%}
  {%- endfor -%}
{%- endif -%}

{# 2. Fallback für klassische Script-Logs #}
{%- if data is defined and data.result is defined and data.result.log is defined -%}
  {%- set script_has_issues = namespace(valid=false) -%}
  {%- for log in data.result.log -%}
    {%- if log.status in ['failure', 'failed', 'warning'] -%}
      {%- set script_has_issues.valid = true -%}
      {%- if log.status in ['failure', 'failed'] -%}{% set ns.has_failures = true %}{%- else -%}{% set ns.has_warnings = true %}{%- endif -%}
    {%- endif -%}
  {%- endfor -%}

  {%- if script_has_issues.valid -%}
    {%- set ns.body = ns.body ~ "[BR][BR]#### Allgemeines Script Log" -%}
    {%- for log in data.result.log -%}
      {%- if log.status in ['failure', 'failed', 'warning'] -%}
        {%- set prefix = "❌ Fehler" if log.status in ['failure', 'failed'] else "⚠️ Warnung" -%}
        {%- set clean_path = log.obj.get_absolute_url() if log.obj else '' -%}
        {%- set target_url = "https://anoxinon.de" ~ clean_path if clean_path else "https://netbox.anoxinon.de" -%}
        {%- set ns.body = ns.body ~ "[BR]- " ~ prefix ~ " - Name: " ~ (log.obj.name | default('Allgemein')) ~ "[BR]  Meldung: " ~ log.message ~ "[BR]  URL: " ~ target_url -%}
      {%- endif -%}
    {%- endfor -%}
  {%- endif -%}
{%- endif -%}

{# Titel-Präfix basierend auf dem schlimmsten Status bestimmen #}
{%- set title_prefix = "# ❌ NetBox Report: Fehlgeschlagene Checks in " if ns.has_failures else "# ⚠️ NetBox Report: Warnungen in " -%}
{%- set full_body = title_prefix ~ report_name ~ "[BR][BR]" ~ ns.body -%}

{
  "urls": "{%- if ns.has_failures or ns.has_warnings -%}xmpps://netbox:{{ '' | xmpp_apprise_password }}@anoxinon.me/yosijo{%- endif -%}",
  "body": "{{ full_body.replace('[BR]', '\\n') }}"
}

Tags

No tags assigned