Quick Hits: Tracking The Status of GitHub Using PowerShell

This evening I noticed that GitHub, a site for collaborating and sharing code that I use for all of my projects, was down for an unknown reason. The site showed the dreaded ‘Unicorn of 503’ and I was left without access much like everyone else attempting to not only access the site, but also those attempting to send updates for their repos.

githubdown

Now, I could sit at my computer and hit the refresh button dozens of times until I see something other than the fabled unicorn…or I can take advantage of a web api to make a call to return some JSON that PowerShell just happens to enjoy to provide a quick way to monitor the situation.

The available URLs that we can use are below:

URL Purpose
https://status.github.com/api/status.json View Current Status
https://status.github.com/api/messages.json View Recent Status Messages
https://status.github.com/api/last-message.json View Current Status Message
https://status.github.com/api/daily-summary.json View Daily Summary

Using each of these are as simple as using Invoke-RestMethod and bringing back the data. Let’s take a look at the current status and see how things are going.

Invoke-RestMethod https://status.github.com/api/status.json

image

Note the time listed is in Zulu, meaning that if we wanted to know our own time, we need to do a little work with that by just calling Get-Date with that string as the parameter.

Invoke-RestMethod https://status.github.com/api/status.json | Select-Object Status, @{L='Updated';E={Get-Date $_.last_updated}}

image

That looks a lot better!

Moving on we can look at the other approaches and see what they have to offer.

Invoke-RestMethod https://status.github.com/api/last-message.json
Invoke-RestMethod https://status.github.com/api/messages.json

image

The Daily Status api actually gives you a roundup of every status (shown as a count for Major, Minor and Good) that goes all the way back to February 7 2010, which is pretty cool.

Invoke-RestMethod https://status.github.com/api/daily-summary.json

image

…Eventually we get to the bottom with the current date.

image

So there you go! Go out and track the status of GitHub with PowerShell and come up with your own approaches to report when the status changes!

This entry was posted in powershell and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s