Show content of an exec notification

Exec notifications are new to BVQ 2022H2.3. They allow to call any application when the notification is triggered.
Use this for example to create special actions whenever an alert occurs. Send to Icinga, create an snmp alert ...

You will receive information from the BVQ server which typically needs to be parsed and routed to another place.

To make this information visible we created a little batch script which stories this information in files.
This document describes how this script works.

Set the Notification

In BVQ set the notification like this and use it for an alert.

The notification will start the following app from the filesystem:

cmd.exe /c  C:\Temp\Notification\Not_Start.cmd ${text} ${attachment}


You can also start a power shell or any other kind of application like bash or csh, ...

PowerShell -ExecutionPolicy (Bypass or restricted) Start Powershell C:\Temp\Notification\not_test.ps1 ${text} ${attachment}

Create the script file

Whenever the Notification is called the following cmd file will be started.

It will create 3 files:

  • Temporary File.txt: the temporary file names and where they are stored.
  • Parameter.txt: content of the first parameter which we did connect to the variable ${text }
  • Parameter_attachment.txt content of the second parameter which we did connect to the variable ${attachment }
     
File: C:\Temp\Notification\Not_Start.cmd
cd C:\Temp\Notification
Echo Files %1, %2 > TemporaryFiles.txt
type %1 > Parameter_text.txt
type %2 > Parameter_attachment.txt

Output from the exec cmd

Content of TemporaryFiles.txt
Files C:\Users\bvq\AppData\Local\Temp\notification-text5857477359543130750.txt, C:\Users\bvq\AppData\Local\Temp\notification-attachment8823469455559475286.txt 
Content  of Parameter_text.txt, Parameter_attachment.txt is empty for alerts
{
  "bvqNotification" : {
    "timeCreated" : 1673023494,
    "timeCreatedFormatted" : "2023-01-06 17:44:54 MEZ",
    "prefix" : "Uncritical test",
    "type" : "Incident",
    "environment" : "Demo server workshop1",
    "contact" : "BVQ Team Wiesbaden\nBuilding\nRoom",
    "comment" : "Use this for testing purposes"
  },
  "alertRule" : {
    "name" : "Cluster time zone not 384 Mainz/Wiesbaden - MP1",
    "description" : "<p>Violation of best practice recommendation detected!\nThe cluster is not running in the specified timezone.\n\nSUGGESTED ACTION:\nUse command 'settimezone -timezone </p><p><br></p>",
    "categories" : [ "Severity/Medium", "Storage/SVC/Configuration" ],
    "objectType" : "SVC Cluster",
    "selectionPath" : "BVQ/SVC Cluster",
    "schedule" : "0 */15 * * * ?",
    "slaInterval" : null,
    "slaIntervalSeconds" : null
  },
  "affectedObjects" : [ {
    "object" : {
      "name" : "SWV3",
      "systemName" : "SWV3",
      "systemIPv4" : "x.x.x.x",
      "systemIPv6" : null,
      "primaryKey" : "svc_cluster!000000E02040022A",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b53/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "swv2",
      "systemName" : "swv2",
      "systemIPv4" : "x.x.x.x",
      "systemIPv6" : null,
      "primaryKey" : "svc_cluster!0000010020E0023E",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b45/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "svc1",
      "systemName" : "svc1",
      "systemIPv4" : "10."x.x.x.x",
      "systemIPv6" : null,
      "primaryKey" : "svc_cluster!00000200616006A8",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b47/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "LABDR-FS5200",
      "systemName" : "LABDR-FS5200",
      "systemIPv4" : "x.x.x.x",
      "systemIPv6" : null,
      "primaryKey" : "svc_cluster!00000202E0A1FFA0",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b4b/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "svc3",
      "systemName" : "svc3",
      "systemIPv4" : "10."x.x.x.x",
      "systemIPv6" : "x:x:x:x:x:x:x",
      "primaryKey" : "svc_cluster!0000020320A0348E",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b49/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "svc4",
      "systemName" : "svc4",
      "systemIPv4" : "x.x.x.x",
      "systemIPv6" : null,
      "primaryKey" : "svc_cluster!000002042040737E",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b4d/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "FS9100",
      "systemName" : "FS9100",
      "systemIPv4" : "x.x.x.x",
      "systemIPv6" : null,
      "primaryKey" : "svc_cluster!00000204212003A0",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b51/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  }, {
    "object" : {
      "name" : "svc2",
      "systemName" : "svc2",
      "systemIPv4" : "x.x.x.x",
      "systemIPv6" : "x:x:x:x:x:x:x",
      "primaryKey" : "svc_cluster!AFFE020420407D02",
      "link" : "http://localhost/ui/alerting/overview/details/63b8404fcc00e7167ced9b4f/topology"
    },
    "alertLevel" : {
      "change" : "Warn -> Error",
      "current" : "Error",
      "previous" : "Warn",
      "previousDuration" : "15 seconds",
      "previousDurationSeconds" : 15
    },
    "condition" : {
      "currentValues" : [ {
        "name" : "timezone",
        "value" : "384 Europe/Paris",
        "valueFormatted" : "384 Europe/Paris"
      } ],
      "hasMatched" : true,
      "reason" : "timezone != \"384 Mainz/Wiesbaden\"",
      "occurrenceCounter" : null
    }
  } ]
}