In the lab – Using the Zabbix monitoring platform

Just stumbled across the Zabbix monitoring platform (http://zabbix.com ) while working with a customer in Austin this week, so I figured I'll set it up in my lab an test it out for a bit.

Overview

Shorthand story, Zabbix is an open source Enterprise monitoring platform. It handles real-time monitoring of clients, servers, virtual machines and network devices. It has agents you can install on most operating systems: Windows, Mac, Linux and few more, and there are also agentless monitoring methods available as well.

Quick start guide

For lab and test, you can simply download a readymade virtual appliance so I downloaded the appliance (VHDX file) for Windows Server 2012 Hyper-V from http://www.zabbix.com/download, and created a generation 1 VM on my Windows Server 2016 Hyper-V host.

Zabbix002
The zabbix download page.

Server Config

After booting the server, I logged in with the default user/password (user: appliance, password: zabbix) and installed a decent text editor (Nano/Pico), by running the following command:

sudo apt-get install Nano

Then I used the pico text editor to change from dhcp to static ip by configuring the /etc/network/interfaces file as follows:

iface eth0 inet static
address 192.168.1.205
netmask 255.255.255.0
gateway 192.168.1.1

Then restarted the network by running the following command: sudo ifdown eth0 && sudo ifup eth0

Next step was to login to the admin portal, http://192.168.1.205/zabbix and create a host group (hosts are the machines you want to monitor).

Install agents

After that, I deployed 10 Windows 7 VMs with MDT, and installed the Zabbix agent as part of the process. I got a nice agent install script from Kevin Glover, which he kindly allowed me to post on my blog. The command line I used to run the script is as follows: powershell.exe -ExecutionPolicy Bypass -File Install-ZabbixAgent.ps1 -WindowStyle Hidden

Note: By default the agents are using port 10050 TCP, so I created a GPO that opened that port inbound in the firewall for my clients.

In addition, I modified the Server and ServerActive lines in the temp_zabbix_agentd.conf file with my zabbix server IP. This file is just a template that is being copied by the script to the client. Here is my sample.

# This is a config file for ViaMonstra Zabbix agent daemon (Windows)
# To get more information about Zabbix, go to http://www.zabbix.com
 
### Logging
LogFile=c:\Program Files\Zabbix\logs\zabbix_agentd.log
LogFileSize=8
# DebugLevel=2
 
### Remote Commands
EnableRemoteCommands=1
LogRemoteCommands=1
 
### Server
Server=192.168.1.205
ServerActive=192.168.1.205
 
### Identifier
HostnameItem=system.hostname
HostMetadataItem=system.uname
UnsafeUserParameters=1

Then I downloaded the Zabbix agents, and added them to my MDT application in addition to the PowerShell script.

image

My Zabbix MDT application.

Here is the Zabbix agent install script from Kevin Glover:

<#   
.SYNOPSIS   
    Application to deploy the Zabbix Agent
     
.DESCRIPTION 
    This application deploy's the zabbix agent via SCCM or running the application locally.
     
.PARAMETER 
 
.NOTES   
    Name: Install-Zabbix-Agent
    Author: Kevin Glover
    DateUpdated: 2-22-2016
    Version: 1.0.1
 
#>
 
#_______________________________________________________________________________
#__________________ GLOBALS ____________________________________________________
#_______________________________________________________________________________
$ReportErrorShowExceptionClass = $true
$Error.Clear()
$Global:cred = $null
 
# Zabbix install paths
$zabbixPaths = @{"root" = "c:\Program Files\Zabbix\";
                "bin" = "c:\Program Files\Zabbix\bin\";
                "configs" = "c:\Program Files\Zabbix\config\";
                "logs" = "c:\Program Files\Zabbix\logs\";
                "scipts" = "c:\Program Files\Zabbix\scripts\"
            }
             
     
# Create zabbix agent directory strucutre
$rootDir = Test-Path -Path $zabbixPaths.get_item("root")    
if (!(Test-Path -Path $zabbixPaths.get_item("root"))){
    New-Item -Path $zabbixPaths.get_item("root") -type directory | Out-Null;
    New-Item -Path $zabbixPaths.get_item("bin") -type directory | Out-Null;
    New-Item -Path $zabbixPaths.get_item("configs") -type directory | Out-Null;
    New-Item -Path $zabbixPaths.get_item("logs") -type directory | Out-Null;
    New-Item -Path $zabbixPaths.get_item("scipts") -type directory | Out-Null
}
     
    # Modify configuration for location awarness. Copy file to local zabbix directory
     
    # Set variables
    #$proxyServer = $proxyServer.get_item($networkLocation)    
    $serverItem = [string]"Server="+$proxyServer
    $serverActiveItem = [string]"ServerActive="+$proxyServer
    $templateConfigFile = [string]'temp_zabbix_agentd.conf'
    $destinationConfigPath = $zabbixPaths.get_item("configs")
     
    # Check if config path exists
    if (!(Test-Path -Path $destinationConfigPath)){
        mkdir -Path $destinationConfigPath -Force;
    }
    # Injest temp_zabbix_agentd.conf file and output host usable config file.
     
    # Create temp .conf file so that host usable config file can be written.
    $destinationConfigFile = New-Item -Path $destinationConfigPath -Name 'zabbix_agentd.conf' -ItemType File
 
    $destinationConfigFile = Get-ChildItem -Path $destinationConfigFile
    (Get-Content $templateConfigFile) | Foreach-Object {
    $_ -replace 'Server=', $serverItem -replace 'ServerActive=', $serverActiveItem
    } | Set-Content $destinationConfigFile
 
# Copy zabbix executable
if (!(Test-path -Path $zabbixPaths.get_item("bin"))){
    mkdir -Path $zabbixPaths.get_item("bin") -Force;
    Copy-Item 'zabbix_agentd.exe' -Destination $zabbixPaths.get_item("bin") -Force
}
else {Copy-Item 'zabbix_agentd.exe' -Destination $zabbixPaths.get_item("bin") -Force
}
 
# Install Zabbix Agent
if (!(Test-Path "c:\Program Files\Zabbix\bin\zabbix_agentd.exe")){
    return 1612 #ERROR_INSTALL_SOURCE_ABSENT
    break
}
else {
    # Set Parameters
    $parameters = "--install -c "+'"'+$destinationConfigFile+'"'
    # Install application
    $install = Start-Process "c:\Program Files\Zabbix\bin\zabbix_agentd.exe" -ArgumentList $parameters -Wait -OutVariable $installLog
}
 
# Check status of service install
$serviceStatus = Get-WmiObject -Class Win32_Service -Filter "Name='Zabbix Agent'"
if (!($serviceStatus)){
    return 1601 #ERROR_INSTALL_FAILURE
    break
}
elseif ($serviceStatus.State -eq 'Stopped'){
     
    # Check if configuration path is correct so that the service will start
    $servicePath = [string]'"C:\Program Files\Zabbix\bin\zabbix_agentd.exe" --config "C:\Program Files\Zabbix\config\zabbix_agentd.conf"'
    if ($serviceStatus.PathName -ne $servicePath){
        return 1601 #ERROR_INSTALL_FAILURE
        break
    }
    else {
        Start-Service -Name $serviceStatus.Name
        return 0 #ERRROR_SUCCESS 
    }
}

Adding hosts and assigning templates

Once the agents where deployed, I added the clients (hosts) to the Zabbix admin console. I've ben told it's possible to configure the Zabbix agent to automatically register itself, by I haven't configured that just yet, so I simply added the hosts directly in the admin console via their DNS names.

As part of the process you also need to tell the Zabbix agent what data to collect, which is done by assigning templates to it. In my lab I made it simple, and assigned one of the default templates, the "Template OS Windows" template. And after a while, I could see all the Zabbix agents showing up.

Zabbix001

My clients (hosts), added to the Zabbix console.

Zabbix003

Part of the "Template OS Windows" template.

 

Viewing the data

Once the clients start to report in, you can see some data being reported in.

Zabbix004

Next steps

Next step is figuring out how to enable the inventory, but that's for another day.

/ Johan

About the author

Johan Arwidmark

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

>