Hello,
I was needing a item to summarize items gived by a discovering rule. So I made this in php. This script makes query to the zabbix database with the followings filters:
It looks for hostid and then for any itemid that match the Key Wildcard and summarize the last value for each one. The query filters items disabled and unsupported.
The restrictions are:
Install
To install the script just drop "sumarizar" file in the path of external scripts that is configured in the zabbix server configuration file.
There are two files in the attachment. One is the php script, and the other one is the bash script to run the php script. Please, note that you have to configure the followings parameters in the files:
In "sumarizar" file you must complete the path to the php file in the line number 3:
In "sumarizar.php" you have to complete the connection data to your zabbix db in the line number 13:
For example,
Using it
Create an "External Check" Item in zabbix and in the key field put the followings values:
I hope you find it useful.
Be free to make modifications and if you improve it please share it with others.
Bye!
I was needing a item to summarize items gived by a discovering rule. So I made this in php. This script makes query to the zabbix database with the followings filters:
- {HOSTNAME}
- KEY Wildcard
It looks for hostid and then for any itemid that match the Key Wildcard and summarize the last value for each one. The query filters items disabled and unsupported.
The restrictions are:
- All items to be summarize must have the same check interval to avoid mistakes with sql query.
- The summarize items must be part of the same host
- A dbuser with permission to make querys on the zabbix db.
Install
To install the script just drop "sumarizar" file in the path of external scripts that is configured in the zabbix server configuration file.
There are two files in the attachment. One is the php script, and the other one is the bash script to run the php script. Please, note that you have to configure the followings parameters in the files:
In "sumarizar" file you must complete the path to the php file in the line number 3:
Code:
php /path/to/php/script/sumarizar.php $1 $2
Code:
$base= new mysqli("host-db","user-db","pass-user-db","db-name");
- host-db could be "localhost"
- user-db could be "username"
- pass-user-db could be "password"
- db-name could be "zabbix"
Using it
Create an "External Check" Item in zabbix and in the key field put the followings values:
Code:
sumarizar["{HOSTNAME}","key wildcard"]
Be free to make modifications and if you improve it please share it with others.
Bye!