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 Linux.

• Zabbix version: 3.4.12
• Linux: Ubuntu 18.04

The computer running Linux 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 - Configure UserParameter on Zabbix Agent

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

•  Zabbix agent installation on Linux.

Next, we need to find a Linux command that will help us to monitor something that Zabbix agent was not able.

In our example, we want to know the number of accounts created on the Linux computer.

Use the following command to get the number of accounts created on the Linux Computer.

# cat /etc/passwd | wc -l

33

In our example, this command is telling us that our Linux computer has 33 accounts created.

It is time to integrate this command to the Zabbix agent.

Now, you should find the location of the zabbix_agentd.conf file on your system.

You need to edit the zabbix_agentd.conf file.

# updatedb
# locate zabbix_agentd.conf
# vi /usr/local/etc/zabbix_agentd.conf

Here is the original file, before our configuration.

LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1,200.200.200.200
ServerActive=200.200.200.200

Here is the new file with our configuration.

LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1,200.200.200.200
ServerActive=200.200.200.200
UserParameter=computer.linux.usercount,cat /etc/passwd | wc -l

To finish the configuration, you need to restart the Zabbix Agent running on this computer.

If our Zabbix agent installation tutorial was used, you may restart the Zabbix agent using the following command:

# /etc/init.d/zabbix-agent restart

Now, the Zabbix server should be able to contact this computer and request the number of accounts created on the system using the key: computer.linux.usercount

The Zabbix agent installed on the Linux computer will inform the number of accounts created on the system.

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

# zabbix_get -s 192.168.0.150 -p 10050 -k "computer.linux.usercount"

33

In our example, the Linux computer running the Zabbix agent is using the IP address: 192.168.0.150.

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 Linux 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 Linux Host

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: LINUX-SERVER-01

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 Linux Service Application

On the Host applications screen, create a new application named Linux

Linux 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 the key value used on the zabbix_agentd.conf file.
• Type: Zabbix Agent
• Key: Create a custom key to your Userparameter
• Type of Information: Number (unsigned)
• Update interval: 60 Seconds
• Application: Linux

Zabbix Userparam monitor linux

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 LINUX-SERVER-01.

Click on the Apply button.

Zabbix Linux service Filter

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

Zabbix Userparameter Result

Congratulations! You have configured the Zabbix Userparameter feature.