I try to automate the discovery of my entire network, which is managed with puppet, and I want to use the zabbix network discovery feature instead of Puppetdb for mulitple reasons.
I've tried creating a userparameter named puppet.classes which return all classes as a comma separated values (ex: ,apache,mysql,zabbix,). This is called as Checks on the discovery rule.
Then set in my actions "Received value like ,apache," then "Link to templates: Apache". screenshot
Everything is fine with only few puppet classes, but the value is truncated in the database in my test environment:
[zabbix]> select dserviceid,dhostid,status,lastup,lastdown,value,dns from dservices where dcheckid=3 and type=9 and key_='puppet.classes' \G
*************************** 1. row ***************************
dserviceid: 9
dhostid: 3
status: 0
lastup: 1464103581
lastdown: 0
value: ,apache,apache::default_confd_files,apache::default_mods,apache::mod::alias,apache::mod::dir,apache::mod::filter,apache::mod::mime,apache::mod::php,apache::mod::prefork,apache::mod::ssl,apache::mod::status,apache::params,apache::service,apache::version,ap
dns:
After debugging quite a lot, i've finally found that discovery checks cannot be bigger than 255 bytes in
src/libs/zbxdbhigh/discovery.c
static void discovery_update_dservice(zbx_uint64_t dserviceid, int status, int lastup, int lastdown, const char *value)
{
char *value_esc;
value_esc = DBdyn_escape_string_len(value, DSERVICE_VALUE_LEN);
DBexecute("update dservices set status=%d,lastup=%d,lastdown=%d,value='%s' where dserviceid=" ZBX_FS_UI64, status, lastup, lastdown, value_esc, dserviceid);
zbx_free(value_esc);
}
include/db.h
#define DSERVICE_VALUE_LEN 255`
Using metadata with autoregistration will have the same limitation:
### Option: HostMetadata
# Optional parameter that defines host metadata.
# Host metadata is used at host auto-registration process.
# An agent will issue an error and not start if the value is over limit of 255 characters.
# If not defined, value will be acquired from HostMetadataItem.
#
# Mandatory: no
# Range: 0-255 characters
# Default:
# HostMetadata=
I could use the API and write a script that does this by myself, but this would be a quite big project, and i haven't find a project in the wild doing this. I would be glad to hear about if there is.
Also, I know I could create multiple discovery checks in the discovery rule but I would end up with 40+ checks in the discovery, and should add them manually every time we have a new template... I would like to have a solution where there is as little manipulation as possible to add a new template.
Does someone have bump into this problem, and got a scalable solution?
I'm using zabbix 3.0.3