Instances
Hello.
I ran into the same problem. After some hours of investigating I think that the problem is in PHP object/instances. It seems like the compiler doesn't know function self::$instance->__login(), because it arises at runtime by self::__init() (both in function login).
Also if I run ZabbixAPI::debugEnabled(TRUE), that debug state doesn't stay set (following functions have self::$instance->debug undefined).
I'm sorry, I don't understand OOP in PHP much, so I'm only guessing.
Martin
Ad Widget
Collapse
Need help with API
Collapse
X
-
Ok ) Thanks a lot anyway - therefore I broke my brains about this for two days and nobody can helpLeave a comment:
-
That a question that I can not answer.. I don't know and I didn't take a look inside the code (didn't have the time, and as you may know, bosses only want results, they didn't care about libraries problems. For me this works, so I could continue developing third party integrations into zabbix)
Maybe we should ask Andrew Farley about this.. Tomorrow I'll ask him about this.. If I get an answer, I'll post it here.
Cheer.Leave a comment:
-
It's very interesting - seems that with uncommented ZabbixAPI::debugEnabled(TRUE); everything all right -But without uncommented line I haveCode:Server running Zabbix API Version: 1.3 <br>User IDs found: 1,2,3,4 <br>Retrieved maximum of five hosts: Array ( [0] => Array ( [maintenances] => Array ( [0] => Array ( [maintenanceid] => 0 ) ) [hostid] => 10017 [proxy_hostid] => 0 [host] => Zabbix Server [dns] => [useip] => 1 [ip] => 127.0.0.1 [port] => 10050 [status] => 1 [disable_until] => 0 [error] => [available] => 1 [errors_from] => 0 [lastaccess] => 0 [inbytes] => 0 [outbytes] => 0 [useipmi] => 0 [ipmi_port] => 623 [ipmi_authtype] => 0 [ipmi_privilege] => 2 [ipmi_username] => [ipmi_password] => [ipmi_disable_until] => 0 [ipmi_available] => 0 [snmp_disable_until] => 0 [snmp_available] => 0 [maintenanceid] => 0 [maintenance_status] => 0 [maintenance_type] => 0 [maintenance_from] => 0 [ipmi_ip] => [ipmi_errors_from] => 0 [snmp_errors_from] => 0 [ipmi_error] => [snmp_error] => ) ... <br>Updated userid 1 with refresh value of 1000!Thanks for help, but WHY commented line about debugging may prevent the login? What is it?Code:PHP Fatal error: Call to undefined method stdClass::__login() in /usr/share/zabbix/ZabbixAPI.class.php on line 99
Leave a comment:
-
Thanks for replay, I will do it and answer soon. My user is in api group, and where can I see if api_access enabled?Leave a comment:
-
Hi:
First, check that your user olex is member of the api access usergroup. Check that have api_access enabled.
Also, in order to work, I needed to uncomment the line
ZabbixAPI::debugEnabled(TRUE);
Give it a try and comment.
Cheers.Leave a comment:
-
Maybe I don't know well what to do with this class.Just one minute ago I tried with Andrew Farley's API class and everything worked like a charm..
And, at least for me, the jsonRPCClient that I mentioned before, don't work.
Thanks to all for your help.
When I try to use example I haveCode:<?php require_once("ZabbixAPI.class.php"); // This enables debugging, this is rather verbose but can help debug problems //ZabbixAPI::debugEnabled(TRUE); // This logs into Zabbix, and returns false if it fails ZabbixAPI::login('http://192.168.1.51/zabbix','olex','fjhfhjkjkffk') or die('Unable to login: '.print_r(ZabbixAPI::getLastError(),true)); // This gets the version of the zabbix server $version = ZabbixAPI::fetch_string('apiinfo','version') or die('Unable to get Zabbix Version: '.print_r(ZabbixAPI::getLastError(),true)); echo "Server running Zabbix API Version: $version\n<br>";
I don't no, what kind of problem it is. Can anyone help me?Code:php /usr/share/zabbix/example.php PHP Fatal error: Call to undefined method stdClass::__login() in /usr/share/zabbix/ZabbixAPI.class.php on line 99
Leave a comment:
-
zabbix-1-8-api-php-class-v1-0
Just one minute ago I tried with Andrew Farley's API class and everything worked like a charm..
And, at least for me, the jsonRPCClient that I mentioned before, don't work.
Thanks to all for your help.Leave a comment:
-
Here again:
Checked with perl client and logged successful as first try:
So, anyone had sucess trying to login to API within a PHP Jason-RPC client?? if yes, which client?Code:$VAR1 = bless( { 'error_class' => 'JSON::RPC::Common::Procedure::Return::Version_2_0::Error', 'version' => '2.0', 'id' => '1', 'result' => '0e6e3c5c97d364f12cae03653bc2b19b' }, 'JSON::RPC::Common::Procedure::Return::Version_2_0' );
Thanks again.Leave a comment:
-
Hi:
I'm going to try with a perl client, because I think that it might be a problem because of the php client: this was in my error.log:
Undefined variable: debug in /var/www/html/jsonRPCClient.php on line 145
PHP Notice: Undefined index: id in /var/www/html/jsonRPCClient.php on line 151
PHP Notice: Undefined index: id in /var/www/html/jsonRPCClient.php on line 152
I'll post my results after trying with the perl client.
thanks again.Leave a comment:
-
Enable debug mode for jsonRPCClient and copy here requests sent by client and server answers.Leave a comment:
-
now trying with ldap
I couldn't get to work with http, but as I'll need to use ldap authentication, I just configured zabbix to work against our ldap server.
In the http fronted, if I try to login with our ldap accounts, and even with zabbix internal acounts, it works fine.
But, again, no success with api login. I'm trying with an ldap account which in Zabbix belongs to group "Api Access" and even with an internal zabbix user that also belongs to group "Api access". Both users are enabled.
Did someone connect to zabbix API through PHP? I'm using "jsonRPCClient".
Thanks for your help.Leave a comment:
-
Orgional Zabbix Admin Password
Try using the login option with the original Zabbix user's password. Also make sure you have the API enabled for the user you are using.
-PaulLeave a comment:
Leave a comment: