wtfutil / wtf

The personal information dashboard for your terminal
http://wtfutil.com
Mozilla Public License 2.0
15.69k stars 800 forks source link

Feature Request - Slack status (or any other curl-able website status) #476

Closed saicrazyfire closed 5 years ago

saicrazyfire commented 5 years ago

What problem does this solve?

Find the status of certain websites like Slack. I can curl the status by doing this:

curl -s https://status.slack.com/api/v2.0.0/current

How do envision it working?

The module should have a title field and pretty print certain JSON attributes

For Slack, the JSON response of above is:

{
  "status": "ok",
  "date_created": "2019-06-21T14:00:30-07:00",
  "date_updated": "2019-06-21T14:00:30-07:00",
  "active_incidents": []
}

I would like the module to print the status, last checked (date_updated) and any incidents, if any

Seanstoppable commented 5 years ago

I thought this would be an interesting candidate for using cmdrunner, and thought I would give it a try.

By using jq, on OSX, I can create the following shell script:

#!/bin/sh

curl -s https://status.slack.com/api/v2.0.0/current | jq -r '"Status: " + (if (.status == "active") then "Active Incident" else "Ok" end),"Last Updated: " + .date_updated,if (.active_incidents[] | length) > 0 then "Active Incidents\n" + .active_incidents[] .title else "" end'

Then,adding the following to the config:

     slack_status:
        cmd: "slack_status_check.sh"
        enabled: true
        type: "cmdrunner"
        position:
          top: 5
          left: 0
          height: 3
          width: 4
        refreshInterval: 30

I get the following widget:

Screen Shot 2019-06-26 at 10 54 44 PM
saicrazyfire commented 5 years ago

Wow, jq is really powerful; did not know you could do all that. Very handy, thanks! And it came at the right time, Slack is currently experiencing a major outage 😱

saicrazyfire commented 5 years ago

Do you know if the cmdrunner type has an optional title field? I'd like to not have the filename as the title

Seanstoppable commented 5 years ago

We do not, but I agree with your observation. I'll work on making this possible, for friendlier titles.

Seanstoppable commented 5 years ago

You should now be able to set title for cmdrunner @saicrazyfire

senorprogrammer commented 5 years ago

@Seanstoppable's example has been merged into the documentation here: https://wtfutil.com/modules/cmdrunner/statuspages/