Last active
December 16, 2025 17:14
-
-
Save benschweizer/dc3fe74c04e487e373c5f69abf038f36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| # <xbar.title>StatusPage.io</xbar.title> | |
| # <xbar.version>v1.0.0</xbar.version> | |
| # <xbar.author>Stephen Yeargin</xbar.author> | |
| # <xbar.author.github>stephenyeargin</xbar.author.github> | |
| # <xbar.desc>Show a StatusPage.io's Status in BitBar</xbar.desc> | |
| # <xbar.dependencies>ruby</xbar.dependencies> | |
| # <xbar.image>http://i.imgur.com/FsD4zDD.png</xbar.image> | |
| # https://doers.statuspage.io/api/v1/incidents/ | |
| require 'open-uri' | |
| require 'json' | |
| # BEGIN Configuration # | |
| statuspage_id = '1s5n5g5wh9fr' # e.g. 4y7j9y37gcns | |
| url = "https://#{statuspage_id}.statuspage.io/api/v2/summary.json" | |
| # END Configuration # | |
| status_map = { | |
| operational: { | |
| name: 'Operational', | |
| color: 'gold' | |
| }, | |
| scheduled: { | |
| name: 'Scheduled Maintenance', | |
| color: 'black' | |
| }, | |
| under_maintenance: { | |
| name: 'Active Maintennce', | |
| color: 'black' | |
| }, | |
| degraded_performance: { | |
| name: 'Degraded Performance', | |
| color: 'yellow' | |
| }, | |
| partial_outage: { | |
| name: 'Partial Outage', | |
| color: 'orange' | |
| }, | |
| major_outage: { | |
| name: 'Major Outage', | |
| color: 'red' | |
| }, | |
| monitoring: { | |
| name: 'Monitoring', | |
| color: 'yellow' | |
| } | |
| } | |
| indicator_map = { | |
| none: { | |
| name: 'Operational', | |
| color: 'black' | |
| }, | |
| # degraded: { | |
| # name: 'Degraded Performance', | |
| # color: 'yellow' | |
| # }, | |
| # partial: { | |
| # name: 'Partial Outage', | |
| # color: 'orange' | |
| # }, | |
| maintenance: { | |
| name: 'Service Under Maintenance', | |
| color: 'black' | |
| }, | |
| minor: { | |
| name: 'Minor Outage', | |
| color: 'orange' | |
| }, | |
| major: { | |
| name: 'Major Outage', | |
| color: 'red' | |
| } | |
| } | |
| incident_map = { | |
| none: { | |
| name: 'No Incident', | |
| color: 'black' | |
| }, | |
| maintenance: { | |
| name: 'Maintenance', | |
| color: 'orange' | |
| }, | |
| minor: { | |
| name: 'Minor Incident', | |
| color: 'orange' | |
| }, | |
| major: { | |
| name: 'Major Incident', | |
| color: 'red' | |
| }, | |
| critical: { | |
| name: 'Major Incident', | |
| color: 'red' | |
| }, | |
| monitoring: { | |
| name: 'Monitoring', | |
| color: 'yellow' | |
| } | |
| } | |
| begin | |
| raise 'Missing configuration.' if statuspage_id == 'YOUR_ID_HERE' | |
| summary = JSON.parse(open(url).read) | |
| if summary['incidents'].length > 0 then | |
| incidents = summary['incidents'].first | |
| # puts "STACKIT" \ | |
| # "|color=#{incident_map[incidents['impact'].to_sym][:color]}" | |
| puts "STACKIT" \ | |
| "|color=#{status_map[incidents['status'].to_sym][:color]}" | |
| else | |
| if summary['status']['indicator'] == "none" then | |
| puts "STACKIT" | |
| else | |
| puts "#{summary['status']['description']} " \ | |
| "|color=#{indicator_map[summary['status']['indicator'].to_sym][:color]}" | |
| end | |
| end | |
| puts '---' # incidents | |
| summary['incidents'].each do |incidents| | |
| next unless incidents['status'] != 'operational' | |
| # puts "#{incident_map[incidents['impact'].to_sym][:name]}: " \ | |
| # "#{incidents['status']}"\ | |
| # "|color=#{incident_map[incidents['impact'].to_sym][:color]}|href=#{summary['page']['url']}" | |
| puts "#{incidents['name']} (#{incidents['status']})"\ | |
| "|color=#{incident_map[incidents['status'].to_sym][:color]}|href=#{summary['page']['url']}" | |
| end | |
| puts '---' # components | |
| summary['components'].each do |component| | |
| next unless component['status'] != 'operational' | |
| puts "#{status_map[component['status'].to_sym][:name]}: "\ | |
| "#{component['name']}"\ | |
| "|color=#{status_map[component['status'].to_sym][:color]}" | |
| end | |
| puts '---' | |
| puts "Open: #{summary['page']['url']}|href=#{summary['page']['url']}" | |
| rescue StandardError => e | |
| puts e.message | |
| raise | |
| exit 1 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment