zabbix / community-templates

Zabbix Community Templates repository
https://share.zabbix.com
MIT License
1.25k stars 1.77k forks source link

Varnish template improvements & v7 changes #348

Open linceaerian opened 3 months ago

linceaerian commented 3 months ago

Hello Maintainer(s),

I would suggest adding in the doc of the varnish template:

Varnish group / access

Please note that in order for the template to work, access must be given to your zabbix user to access varnishd.

Ex:

adduser zabbix varnish

Userparameter in place of system.run

In case people does not want to activate system.run, which can lead to vuln

If you prefer use UserParameter, you can:

Varnish JSON changes

Also I found that the JSON for some version of varnish is different, so maybe use a macro for the "get status" post processing to use in case the data use the new version.

Ex of data for varnish > 7.0

{"version":1,"timestamp":"2024-03-26T17:06:01","counters":{"MGT.uptime":{"description":"Management process uptime","flag":"c","format":"d","value":263150}}

I updated mine by adding "$.counters" in the post processing for get status.

Cache hit rate

The cache hit rate item should be updated to avoid division by 0 when no traffic, either in updating the JS (clean) or a catch in the post processing for failure (less clean).

Ex:

var values = JSON.parse(value);
var hit = values["MAIN.cache_hit"].value;
var miss = values["MAIN.cache_miss"].value;
var hitpass = values["MAIN.cache_hitpass"].value;
if (hit==0)
  return 100;
return hit / (hit + miss) * 100;

Same problem for "Cache hit rate 5m" => divide by zero.

Main sesssion drop

The stat MAIN.sess_drop has been renamed MAIN.sess_dropped.

Thanks for the template, have a good day :)