i've developped this patch to add the possibility to execute php script in zabbix item poller.
the script a retreve directly from database (and exported/imported with the zabbix export system) and executed in the zabbix process and is not a fork to execute external script....
is reaallly less impacting the zabbix server machine...
i use already existing fields in items table that are not actualy used to store the script: params.
in that way there no impact on existing zabbix 1.4.3 database. no update to the datamodele are need...
actualy i've developped this patch with 1.4.3 svn version retrive 2007/09/29 but i think that can work on 1.4.2 ref version.
to use it:
for exemple is to make ldapsearch to retrive internal counter of openldap server...
you can also retrive internal counter of mysql server...
and other thing that are possible to do with all php module that are avalable...
and with php sockets module the posibility are infinit...
etc...
Please give me any comments or suggestions.
Best Regard,
Mathieu
the script a retreve directly from database (and exported/imported with the zabbix export system) and executed in the zabbix process and is not a fork to execute external script....
is reaallly less impacting the zabbix server machine...
i use already existing fields in items table that are not actualy used to store the script: params.
in that way there no impact on existing zabbix 1.4.3 database. no update to the datamodele are need...
actualy i've developped this patch with 1.4.3 svn version retrive 2007/09/29 but i think that can work on 1.4.2 ref version.
to use it:
- patch zabbix with my patch.
- to compile php in embed sapi mode:
compile php embed sapi (the importante option are "--enable-embed"):
for exemple to have libphp5.so embeded library with snmp, ldap, curl and mysqli shared module.
Code:
./configure --enable-embed --prefix=/path/to/php/install/dir \ --with-snmp=shared --with-ldap=shared --enable-shared=yes \ --with-curl=shared --with-mysqli=shared
- to compile zabbix with php support:
compile zabbix with php (the importante option are "--with-php=..."):
compile and install zabbix.
Code:
./configure --prefix=/path/to/zabbix/install/dir
--enable-server --with-php=/path/to/php/install/dir
- importante think to know to execute zabbix server with php poller:
on linux if the directory of your libphp5.so are not in /etc/ld.so.conf you can add it and after execute ldconfig apply the change.
or in zabbix server start script you can add:
after that you can start zabbix_server...
or in zabbix server start script you can add:
on linux and other unix you can also use LD_LIBRARY_PATH env var to modify
library search path to php embed lib...
another important think you can specify where is you php.ini with PHPRC env var that point to php.ini dir.
library search path to php embed lib...
another important think you can specify where is you php.ini with PHPRC env var that point to php.ini dir.
after that you can start zabbix_server...
- to use php in zabbix item:
in php admin console add a new item and specify "PHP Internal Check" type.
and add your php code "PHP Internal check" edit zone.
samples:
and for this sample you can use this key: php.script1[public] (must be in form "<key unique name>[<args>]")
the most importante thing is the "return" operation, is the value that are returned to zabbix...
some variable a populated:
i've not tested yet but i think is possible to use "include" to include some global script thing...
and can be drived be the php.ini (spécifyed by PHPRC var for exemple to be spécifique to zabbix server) include dir...
with that you can imagine many possibility offerd by php language to do polling....and add your php code "PHP Internal check" edit zone.
samples:
PHP Code:
snmp_set_quick_print(1);
$snmp_retval = snmpget($zabbix_hostname, $zabbix_args, "IF-MIB::ifInOctets.1");
return $snmp_retval;
the most importante thing is the "return" operation, is the value that are returned to zabbix...
some variable a populated:
- zabbix_hostname = hostname or ip (if use_ip is set)
- zabbix_args = argument from item key (item key sample: php.script1[args1 args2 ...] the zabbix_args while be populated by "args1 args2 ...")
- zabbix_script_name = the key name (in previus sample: "php.script1").
i've not tested yet but i think is possible to use "include" to include some global script thing...
and can be drived be the php.ini (spécifyed by PHPRC var for exemple to be spécifique to zabbix server) include dir...
for exemple is to make ldapsearch to retrive internal counter of openldap server...
you can also retrive internal counter of mysql server...
and other thing that are possible to do with all php module that are avalable...
and with php sockets module the posibility are infinit...
etc...
Please give me any comments or suggestions.
Best Regard,
Mathieu
Comment