Ad Widget

Collapse

Zaebator - Zabbix PHP Api

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nike-17
    Junior Member
    • Oct 2011
    • 7

    #1

    Zaebator - Zabbix PHP Api

    hello
    i just create Zaebator https://github.com/nike-17/Zaebator
    ZAEBATOR - is a skeleton for this JSON-RPC API. Right now i do only user authentication - but it's no problem to implement other methods. You can do it by your self or feel free to ask my ([email protected]).
    Let me know if you find this project useful
    Nikita Groshin
  • nike-17
    Junior Member
    • Oct 2011
    • 7

    #2
    New features

    Right now you can:
    • Login
    • Get Graph Object
    • Render Graph Image


    i add service layer - now you can get graph image (miss in official API)
    EXAMPLE
    Code:
    <?
    
    require './../library/Zaebator.php';
    $option = array(
    	'url' => 'http://zabbixhost/zabbix/api_jsonrpc.php',
    	'user' => 'user',
    	'password' => 'password'
    );
    $zaebator = new Zaebator($option);
    
    $zaebator->userAuthenticate();
    
    
    $params = array(
    	"hostids" => array('6666666666666666666')
    );
    
    $result = $zaebator->graphGet($params);
    
    $graphcontent = array();
    
    foreach ($result as $item) {
    	$graphid = $item['graphid'];
    	$content = Zaebator_Service_Graph::getGraphImageById($zaebator, $graphid);
    	$base64 = base64_encode($content);
    	$graphcontent[] = ('data: image/png ; base64,' . $base64);
    }
    
    foreach ($graphcontent as $graph) {
    	echo "<img src='{$graph}' >";
    }
    Please let me know is it useful?

    Comment

    • nike-17
      Junior Member
      • Oct 2011
      • 7

      #3
      is anybody alive here?

      maybe i write in wrong tread?
      or nobody don't care?

      Comment

      • nelsonab
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2006
        • 1233

        #4
        The patches area may not be the best place for this, perhaps the cookbook. Also in my experience from writing Zabcon, you won't really hear much from people until two things happen 1) end users have a need and 2) your program fulfils those needs. Zabcon was around for about 1 year before people started to use it. Now that Zabcon is about 2 years old there is a solid base of people, and features are starting to come along.

        Bottom line, it takes time and patience, keep developing and moving forward. Or you could always join another project, such as Zabcon, and help out. :-)
        RHCE, author of zbxapi
        Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
        Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

        Comment

        • Yello
          Senior Member
          • Apr 2011
          • 309

          #5
          Hi,
          What are your objectives with this work? There is already a PHP api module out there. Are you looking to do something different? Or do it better?


          Regards,
          Dave

          Comment

          • LeoCombes
            Member
            • Mar 2011
            • 32

            #6
            Nike, this could solve my problem?

            Comment

            • nike-17
              Junior Member
              • Oct 2011
              • 7

              #7
              Originally posted by Yello
              Hi,
              What are your objectives with this work? There is already a PHP api module out there. Are you looking to do something different? Or do it better?


              Regards,
              Dave
              i just need at my work some kind of OOP wrapper under zabbix api

              Comment

              • nike-17
                Junior Member
                • Oct 2011
                • 7

                #8
                yes!!

                Originally posted by LeoCombes
                Nike, this could solve my problem?

                http://www.zabbix.com/forum/showthread.php?t=23969
                yes shore you can do sommthing like this

                Code:
                require './../library/Zaebator.php';
                $option = array(
                'url' => 'http://zabbixhost/zabbix/api_jsonrpc.php',
                'user' => 'user',
                'password' => 'password'
                );
                $zaebator = new Zaebator($option);
                
                $zaebator->userAuthenticate();
                
                
                $params = array(
                "hostids" => array('6666666666666666666')
                );
                
                $result = $zaebator->graphGet($params);
                
                $graphcontent = array();
                
                foreach ($result as $item) {
                $graphid = $item['graphid'];
                $content = Zaebator_Service_Graph::getGraphImageById($zaebator, $graphid);
                $base64 = base64_encode($content);
                $graphcontent[] = ('data: image/png ; base64,' . $base64);
                }
                
                foreach ($graphcontent as $graph) {
                echo "<img src='{$graph}' >";
                }

                Comment

                • Axilla
                  Senior Member
                  • Aug 2010
                  • 130

                  #9
                  I'm trying to get this to work, but to no avail, I want to retrieve graphs for PDF generation, I have a php file with the following code

                  Code:
                  <?
                  require 'Zaebator.php';
                  error_reporting(E_ALL);
                  $option = array(
                          'url' => 'https://url/zabbix/api_jsonrpc.php',
                                  'user' => 'login',
                                  'password' => 'pass'
                                  );
                                  $zaebator = new Zaebator($option);
                  
                                  $zaebator->userAuthenticate();
                  
                  
                                  $params = array(
                                          "hostids" => array('10064')
                                          );
                  
                                  $result = $zaebator->graphGet($params);
                  
                                  $graphcontent = array();
                  
                                  foreach ($result as $item) {
                                          $graphid = $item['421'];
                                          $content = Zaebator_Service_Graph::getGraphImageById($zaebator, $graphid);
                                          $base64 = base64_encode($content);
                                          $graphcontent[] = ('data: image/png ; base64,' . $base64);
                                  }
                  
                                  foreach ($graphcontent as $graph) {
                                          echo "<img src='{$graph}' >";
                                  }
                  but when I visit the page all I see is the following:

                  'https://url/zabbix/api_jsonrpc.php', 'user' => 'login', 'password' => 'password' ); $zaebator = new Zaebator($option); $zaebator->userAuthenticate(); $params = array( "hostids" => array('10064') ); $result = $zaebator->graphGet($params); $graphcontent = array(); foreach ($result as $item) { $graphid = $item['421']; $content = Zaebator_Service_Graph::getGraphImageById($zaebato r, $graphid); $base64 = base64_encode($content); $graphcontent[] = ('data: image/png ; base64,' . $base64); } foreach ($graphcontent as $graph) { echo "[X]Broken Image"; }


                  my file and Zaebator.php are in the same directory with the Zaebator folder in the same directory.. What am I doing wrong?

                  Comment

                  • jordan.emersive
                    Junior Member
                    • Jul 2013
                    • 4

                    #10
                    eventget Filter not working/help

                    Hey There,

                    I know this is an old thread, but I have some questions about the PHP API that was built (Love it btw). Thanks to this API I have been able to build a rather awesome wallboard for my company! I can provide some screenshots if you are interested in seeing what I have done...

                    I have run into a problem with the eventget function and the 'filter' option. These are currently my parameters:

                    Code:
                    		
                    $eventrec = $api->eventGet(array(
                    				'output' => 'extend',
                    				'acknowledged' => '0',
                    				'selectTriggers' => 'extend',
                    				'selectHosts' => 'extend',
                    				'object' => '0',
                    				'source' => '0',
                    				'select_acknowledges' => 'extend',
                    				'select_alerts' => 'extend',
                    				'value' => '0',
                    				'preservekeys' =>  '1',
                    				'filter' => array('host' => 'Emersive-AKL DynDNS),
                    				'sortfield' => 'eventid',
                    				'sortorder' => 'DESC',
                    				'limit' => '600'
                    			));
                    The problem I am having, is that the filter option does not appear to be adhered to, it just gets ignored! I am suspecting this is because the 'Host' key resides inside another array (Hosts). I am unsure how I am suppose to correctly reference this key. I am able to get the filter to work for such keys as 'eventid' 'source' 'clock' and 'value' but these keys all reside in main array.

                    Is there something I am doing wrong, or will this API not function to filter out keys within returned arrays?

                    Any help is greatly appreciated



                    Edit--

                    I just realised that this ended up on the wrong Thread... sorry about that.
                    Last edited by jordan.emersive; 10-09-2013, 23:35. Reason: Wrong Thread

                    Comment

                    Working...