Monday 26 October 2015

Exchange 2010 monitoring database by Zabbix


             In his article I would like share my experience in monitoring  and gathering mailbox databases's statistics in  Exchange 2010 enviroment by Zabbix monitoring system.

            As for me the main problem that I have met was execution time powershell script. Especially loading Exchange 2010 snapin Microsoft.Exchange.Management.PowerShell.E2010 that really increased running time. My first version of solution have used template on Zabbix side and two scripts at agent side, one for discovery purpose other for getting items parameters. Also I set maximum Timeout=30 in Zabbix agent configuration file zabbix_agentd.win.conf .

c:\zabbix\zabbix_agentd.win.conf

### Option: Timeout
#             Spend no more than Timeout seconds on processing
#
# Mandatory: no
# Range: 1-30
# Default:
# Timeout=3
Timeout=30

This solution has worked successfully for one year. But one time powershell scripts started work longer than 30 seconds and as result  Zabbix stopped getting items parameters. I tried to fix it but unfortunately unsuccessful. If you know how to fix it could you share with me I will appreciate it.
     
            So, I have created new solution in short way changing just scripts without touching Zabbix template.  I have wrote  powershell script Get-ExchangeDbStatus.ps1 that generate csv file that contains needed info about mailbox and launch by scheduler every 5 minutes on Exchange server. Two other scripts Get-ExchangeDbDiscovery.ps1 use for discovery function and Get-ExchangeDb.ps1  getting items parameters. I prefer to keep custom user parameters in separate file therefore I configured zabbix_agentd.win.conf  like below.

### Option: Include
#             You may include individual files in the configuration file.
#
# Mandatory: no
# Default:
# Include=
Include=c:\zabbix\zabbix_agentd.userparams.conf

            Configuration file zabbix_agentd.userparams.conf  contains two user parameters.  

#Exchange 2010 MailBox Server Role
UserParameter = exchange.db.discovery[*],powershell.exe  -NoLogo -NoProfile "C:\Zabbix\Get-ExchangeDbDiscovery.ps1"
UserParameter = exchange.db[*],powershell.exe  "C:\Zabbix\Get-ExchangeDb.ps1" "$1" "$2"


            This solution was tested in Exchange 2010 and Zabbix 2.4.0.
Template, scripts and user parameters config you can find on GitHub