Working example of creating an Alert using script?

Hi
I tried to test the https://github.com/greenbone/gvm-tools/blob/master/scripts/start-alert-scan.gmp.py script. The alert is created but with no customization (email(s), subject, message, etc).
Is this script correct?

Thanks

Ok, something on the example is wrong, I think…
Something like this works for me:

    recipient_email="me@mydomain.com"
    sender_email="gvmd@mydomain.com"
    alert_name=recipient_email

    res = gmp.create_alert(
      alert_name,
      comment="On demand alert",
      event=AlertEvent.TASK_RUN_STATUS_CHANGED,
      event_data={"status": "Done"},
      method=gmp.types.AlertMethod.EMAIL,
      method_data={
            "message": "Task '$n': $e",
            "notice": "2",
            "from_address": sender_email,
            "subject": "[OpenVAS-Manager] Task",
            "notice_attach_format": "c402cc3e-b531-11e1-9163-406186ea4fc5",
            "to_address": recipient_email,
            },
      condition=gmp.types.AlertCondition.ALWAYS
      )

Hi and thank you for your question.

I will have a deeper look into the script you have mentioned. Right now it looks like you are right and the script is actually not adding the customisations to the alert.
I will give you a hint if the script is working as expected again.

1 Like