Zabbix2::API::Macro -- Zabbix usermacro objects
# create a new global macro (set its hostid attribute if you need a # host macro instead) my $macro = Zabbix2::API::Macro->new(root => $zabber, data => { macro => '{$SUPERMACRO}', value => 'ITSABIRD' }); $macro->create; # change its value $macro->value('ITSAPLANE'); $macro->update;
Handles CRUD for Zabbix usermacro objects.
Both global and host macro types are represented by this class. If the hostid attribute is undef or empty, then we assume it's a global macro.
hostid
This class' methods work transparently around the weird Zabbix macro API, which uses different methods on the same object depending on whether it's a global or host macro... except sometimes, for instance the usermacro.get method which can be called on both and will return different keys... And macros don't seem to have an exists method. It's kind of a mess.
usermacro.get
exists
This class' _prefix method is not a class method. The _prefix returned depends on the type of macro (global or host) which is a characteristic of an instance.
_prefix
say $macro->globalp ? 'a global macro' : 'a host macro';
Returns a true value when the macro is global, a false value otherwise.
say $macro->name;
Returns the macro's name, which is also how it's referred to in expressions, e.g. "{$SUPERMACRO}".
$macro->value('new value'); say $macro->value;
Mutator for the macro's value.
Zabbix2::API::CRUDE
Fabrice Gabolde <fga@cpan.org>
Copyright (C) 2011, 2014 SFR
This library is free software; you can redistribute it and/or modify it under the terms of the GPLv3.
To install Zabbix2::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zabbix2::API
CPAN shell
perl -MCPAN -e shell install Zabbix2::API
For more information on module installation, please visit the detailed CPAN module installation guide.