Skip to content

Calculated Items

Video Lecture

Calculated Items Calculated Items

Description

I create 3 calculated items and graph them in this video.

But first, we need to create a user parameter as our base item that we will be doing calculations on.

The user parameter will show how many MySQL commands have been executed since it was last restarted.

I will be using the Zabbix agent on the Zabbix server to demonstrate this example.

Example Base Item

Add the user parameter to the Zabbix agent configuration on the Zabbix server.

UserParameter=mysql.questions, mysqladmin status | cut -f4 -d":" | cut -f1 -d"S"

We can test this new user parameter by using the command

zabbix_agentd -t mysql.questions

However, zabbix_agentd in my example is being run using the root user. We need to test if the zabbix user is able to run the user parameter.

sudo -H -u zabbix bash -c 'zabbix_agentd -t mysql.questions'

You are likely to get a mysqladmin access denied error.

We can add a specific credentials file for the zabbix_agentd process.

Create the folder /var/lib/zabbix if it doesn't all ready exist.

#
mkdir /var/lib/zabbix

And then cd into it.

#
cd /var/lib/zabbix

Create a new file named .my.cnf

#
nano .my.cnf

And add the text below replacing the user and password with the values used by your own Zabbix servers database user as can be found in your /etc/zabbix/zabbix_server.conf file.

[client]
user='zabbix'
password='password'

Save, and restart the Zabbix agent and check its status

#
#
service zabbix-agent restart
service zabbix-agent status

Try again,

sudo -H -u zabbix bash -c 'zabbix_agentd -t mysql.questions'

And it should now work.

We can now continue to set this up in the Zabbix UI.

Key Value
Name MySQL Questions Running Total
Type Zabbix Agent
Key mysql.questions
Type numeric

Example Calculated Item 1

Key Value
Name Changes MySql Questions
Type Calculated
Key mysqlchanges
Formula change(/Zabbix server/mysql.questions)

Example Calculated Item 2

Key Value
Name Average of Changes of MySql Questions
Type Calculated
Key avgmysqlchanges
Formula avg(/Zabbix server/mysqlchanges,#5)

Example Calculated Item 3

Key Value
Name Forecast of Changes of MySql Questions
Type Calculated
Key forecastmysqlchanges
Formula forecast(/Zabbix server/mysqlchanges,1h,10m,"exponential")

Other Resources

Calculated Items

Supported Functions

Aggregate Functions

Comments