Would you like to learn how to use Zabbix Userparameter feature? In this tutorial, we are going to show you how to configure Zabbix Userparameter and create a custom script to monitor a computer running Windows.

• Zabbix version: 3.4.12
• Windows version: 7 Enterprise

The computer running Windows must have the Zabbix agent installed.

Hardware List:

The following section presents the list of equipment used to create this Zabbix tutorial.

Every piece of hardware listed above can be found at Amazon website.

Zabbix Playlist:

On this page, we offer quick access to a list of videos related to Zabbix installation.

Don't forget to subscribe to our youtube channel named FKIT.

Tutorial - Create a Windows Script

First, you need to install the Zabbix agent on the computer running Windows.

•  Zabbix agent installation on Windows.

Next, let's create a script that will give us the answer that Zabbix agent was not able to give.

In our example, we want to know who is logged on the Windows computer at the moment.

Open the notepad and create a BATCH SCRIPT named check_username.bat with the following content.

@echo off
FOR /F "tokens=2 delims=={}" %%A IN ('WMIC ComputerSystem Get UserName /format:list') DO (
echo %%A
)

Save the script named check_username.bat inside the C:\Zabbix folder.

Open a DOS prompt and try to execute the check_username.bat script.

C:\>c:
C:\>cd zabbix
C:\zabbix>check_user.bat

TECHEXPERT\administrator

In our example, the script when executed displayed the username of the user logged in this computer.

In our example, the user Administrator is currently using this computer.

This script was created for Windows 7 and will not work on Windows server editions.

The script is not the important part of this tutorial, you will have to create scripts or commands that are fit to your needs.

Now we need to integrate our script to the Zabbix agent.

Open the Notepad application and edit the zabbix_agentd.win.conf configuration file.

The file zabbix_agentd.win.conf is locate inside the C:\Zabbix folder.

Here is the file, before our configuration

Server=127.0.0.1,200.200.200.200
ServerActive=200.200.200.200
Logfile=C:\zabbix\zabbix_agent.log

Here is the new file with our configuration.

Server=127.0.0.1,200.200.200.200
ServerActive=200.200.200.200
Logfile=C:\zabbix\zabbix_agent.log
UserParameter=computer.windows.user,c:\zabbix\check_user.bat

To finish our configuration you need to restart the Zabbix Agent running in this computer.

If you don't know how to restart the Zabbix agent, you can restart the computer.

Now, the Zabbix server can contact this computer and request the following information:  computer.windows.user

The Zabbix agent installed on the Windows computer must inform the user that is currently logged on.

To test our configuration, enter the following command on the Zabbix server console:

# zabbix_get -s 192.168.0.50 -p 10050 -k "computer.windows.user"

TECHEXPERT\administrator

As you can see, The Zabbix server is able to remotely get this information from the Agent.

Tutorial - Zabbix UserParameter Configuration

Now, we need to access the Zabbix server dashboard and add the Windows computer as a Host.

Open your browser and enter the IP address of your web server plus /zabbix.

In our example, the following URL was entered in the Browser:

• http://35.162.85.57/zabbix

On the login screen, use the default username and default password.

• Default Username: Admin
• Default Password: zabbix

zabbix login

After a successful login, you will be sent to the Zabbix Dashboard.

zabbix dashboard

On the dashboard screen, access the Configuration menu and select the Host option.

zabbix add host

On the top right of the screen, click on the Create host button.

Zabbix Create Host

On the Host configuration screen, you will have to enter the following information:

• Host Name - Enter a Hostname to monitor.
• Visible Hostname - Repeat the hostname.
• New group - Enter a name to identify a group of similar devices.
• Agent Interface - Enter the IP address of the Hostname.

Here is the original image, before our configuration.

zabbix linux - Antes

Here is the new image with our configuration.

Zabbix Windows 7

Click on the Add button to include this host on the Zabbix database.

On the dashboard screen, access the Configuration menu and select the Host option.

zabbix add host

Locate and click on the hostname that you created before.

In our example, we selected the hostname: WINDOWS7

On the Host properties screen, access the Applications tab.

Zabbix Windows Service Application menu

On the top right part of the screen, click on the Create application button.

Zabbix Windows7 Application

On the Host applications screen, create a new application named Windows.

Windows Application

After finishing the Application creation, access the Items tab.

Zabbix Item Tab

On the top right part of the screen, click on the Create item button.

On the Item creation screen, you need to configure the following items:

• Name: Enter an identification to the Userparameter item.
• Type: Zabbix Agent
• Key: A custom key to your Userparameter
• Type of Information: Our example uses Text
• Update interval: 60 Seconds
• Application: Windows

Zabbix monitor Userparameter

Click on the Add button and finish the Item creation.

Wait 5 minutes.

In order to test your configuration, access the Monitoring menu and click on the Latest data option.

Zabbix Latest data

Use the filter configuration to select the desired hostname.

In our example, we selected the hostname WINDOWS7.

Click on the Apply button.

Zabbix filter windows 7

You should be able to see the results of your Userparameter monitoring using Zabbix.

Congratulations! You have configured the Zabbix Userparameter feature.