Post

Afas Status Page

When your company is a user of the software Afas, you want to get the status of it in your N-Central to more easily see if it is reporting any issues. Afas Software publishes it’s status on the page https://afasstatus.nl, however if you look at that page, you can’t see any way to subscribe by mail (except mention in an article on the help pages) or rss feed.

When you start to dig deeper into the inner workings of this page, you can find a reference to a subpage /json

If you visit that page you immediately see that this page returns a json object with it’s current state, like for example

1
{"typeId":"1","typeName":"goed","typeMsg":"Er is geen storing bekend.","eventId":null}

As you can see in this example, all we need is the typeId and the eventId. Based on my own observations, if typeId is 1, all systems are green, when it returns a 2 or 3, a warning or maintenance is scheduled and when it returns 4, it’s a major issue.

When you want to get the correct info from this json object, the code you need for this is as following:

1
2
3
4
5
6
7
8
9
10
11
$BaseURI = "https://afasstatus.nl"
$AfasData = (Invoke-WebRequest -Uri "$BaseURI/json").Content
$AfasJSON = ConvertFrom-Json -InputObject $AfasData
$Status = $AfasJSON.typeId
if ($Status -eq 1)
{
    $URL = "$BaseURI"
}
else {
    $URL = "$BaseURI/details/event:$($AfasJSON.eventId)"
}

As you can see in the script above, i even know (based on my own observations of the workings when an outage, maintenance or warning is active) the details can be found on the URL that is created in the else section of the if statement.

Download AMP for direct import into N-Central: GitHub

Download PS1 file: GitHub

This post is licensed under CC BY 4.0 by the author.