Page MenuHomeDevCentral

Allow to send notifications from the command line
Open, HighPublic

Description

Problem we want to solve

A script takes some hours to complete. It runs in background. The script caretaker wants to be notified when the script is done.

Plan

Provide a notification utility accessible in CLI, so it's as easy as:

python3 broadwayvenues && notifyme "Broadway venues successfully processed."

Then, the utility send a payload to the notification center:

{
    source: "harmonia@ysul.nasqueron.org",
    message: "Broadway venues successfully processed."
}

The notification center then could:

  • send a notification to a different queue on the broker than for public notifications, so it can be processed by another application
  • send a mail (but notifyme could directly do echo '' | mail -t "Broadway venues successfully processed." user@domail.tld)

Command example

./your-awesome-command --service GitHub --project Nasqueron --group Operations --type commit --text "dereckson committed ..." --link https://...

More information

From who?

  • service: "GitHub",
    • ℹ️ The notification's source service (e.g. GitHub, Phabricator, Jenkins)

For whom?

  • project: "Nasqueron",
    • ℹ️ The notification's target project (e.g. Wikimedia, Nasqueron, Wolfplex)
  • group: "Operations",
    • ℹ️ The notification's target group (e.g. Tasacora, Operations)

WHAT? (optional)

  • type: "commit",
    • ℹ️ The notification's type (e.g. "commits", "task")
  • text: "dereckson committed Revoke unused SSH keys for dereckson",
    • 🚨 Default value: "" (empty string)
    • ℹ️ The notification's text
  • link: "https://github.com/nasqueron/operations/commit/95b800c2a259be0c4727c004f8ad918e8062b93b",
    • 🚨 Default value: "" (empty string)
    • ℹ️ The notification's URL, to be used as the main link for widgets / @var string

Event Timeline

Another use is for D372: it would be interesting to report nginx has been restarted and Let's encrypt certificates renewed.

Ideally, that would allow to trigger the production tests.

dereckson raised the priority of this task from Wishlist to High.Aug 23 2016, 14:55
dereckson added a project: User-Dereckson.

Needed at operations level by D372.

[ This task isn't in my immediate radar. ]

inidal updated the task description. (Show Details)

New use case identified for fantoir-datasource pipeline

In T1750, we build a pipeline to import through rDS the FANTOIR database in PostgreSQL.

The pipeline can use this tool to notify a new FANTOIR version has been imported and report issues.

Configuration file

The notification-push command can be preconfigured through a configuration file for default values:

  • Notifications Center endpoint
  • Default values for notification fields

For example:

...
default_notification:
  project: Nasqueron
  group: ops
  service: login
...

./notification-push --type ssh_login --text "foo is connected" --link bastion-001.nasqueron.org

The final notification will combine both information:

servicelogin
projectNasqueron
groupops
typessh_login
textfoo is connected
linkbastion-001.nasqueron.org

If a value is defined in the configuraiton file and given as argument, the argument wins:

./notification-push --group security --type ssh_login --text "foo is connected" --link bastion-001.nasqueron.org

servicelogin
projectNasqueron
groupsecurity
typessh_login
textfoo is connected
linkbastion-001.nasqueron.org

Location

Configuration file should be located at one of the following place:

  • current directory (so we've a solution for Windows too): .notification-push.yml
  • user-level, XDG style: $HOME/.config/notification-push.yml
  • system-level, UNIX style: /usr/local/etc/notification-push.yml
  • system-level, Linux style: /etc/notification-push.yml

If several configuration files exist, they are taken by that order, so a user one will have priority to a system one.