Monitoring Azure Health Dashboard RSS with Zabbix

Posted: September 8, 2018 in Azure

I used this powershell script as starting point.

Install powershell in Zabbix server.

Copy azure_rss.ps1 to /opt/zabbix/azure_rss (make that folder if it doesn’t exists,give zabbix user ownership)

 

azure_rss.ps1:

 

CLS
$a= $hsg.Content
[xml]$ret = $hsg.Content.TrimStart("")
#$ret.rss.channel.item | Select-Object *
#write-host ""
if($ret.rss.channel.item.category -eq $null){
        #write-host $ret.rss.channel.title
        #write-host $ret.rss.channel.title " On : "  $ret.rss.channel.pubDate
        write-output "All services are working properly" > /tmp/out.txt
       }
Else
    {
    $c = $ret.rss.channel.title + " On : " + $ret.rss.channel.pubDate"Issue Category : " + $ret.rss.channel.item.category + $ret.rss.channel.title + " On : " + $ret.rss.channel.pubDate + " Details : " + $ret.rss.channel.item.title + $ret.rss.channel.item.description
    write-output $c > /tmp/out.txt
    #write-host $ret.rss.channel.title " On : "  $ret.rss.channel.pubDate
    #Write-Host "Issue Category : " $ret.rss.channel.item.category
    #write-host ""
    #write-host ""
}
rv hsg, ret

 

I had to redirect output to text file because some hex symbols in output.

copy trap.sh to /opt/zabbix/azure_rss (“azure” is zabbix host)

trap.sh:

#!/bin/bash
pwsh /opt/zabbix/azure_rss/azure_rss.ps1
var=$(cat "/tmp/out.txt")
zabbix_sender -z localhost -p 10051 -s "azure" -k status.azure -o "$var"

Create cron job to run script on interval you predefined

 

 

On Zabbix server, create item:

name:status.azure

Type:Zabbix trapper

key:status.azure

Type of information:Text

 

Create Trigger:

Expression: {hostname:status.azure.str(“Issue Category”)}=1

Because full string output will be lengthy , full error message won’t be visible so we must click-Monitoring-latest data-specify host to see full script output.

Advertisements

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s