Using python script to get all triggers via Zabbix API

Multi tool use
Multi tool use












0















I am using Python Script with pyzabbix module to get all triggers via Zabbix API. Using the trigger.get() function to get all triggers list.
The Script works fine with all other functions like host.get() etc. But for this one it fails giving me 500 Internal Server Error. But when i specify certain object parameters for the same it runs.



Running it with some parameters specified for trigger.get() method then it works but i want to list out all triggers without using any of the parameters for the method triggers.get().



MY CODE :



from pyzabbix import ZabbixAPI


zapi = ZabbixAPI("http://Zabbix-Server-IP/zabbix")

zapi.login("username","password")

trigger=zapi.trigger.get() #Method to get all triggers from zabbix


ERROR



Traceback (most recent call last):
File "zabbix.py", line 69, in <module>
get_all_zabbix_host()
File "zabbix.py", line 16, in get_all_zabbix_host
trigger=zapi.trigger.get()
File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 157, in fn
args or kwargs
File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 109, in do_request
response.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:
http://Zabbix-Server-IP/zabbix/api_jsonrpc.php









share|improve this question





























    0















    I am using Python Script with pyzabbix module to get all triggers via Zabbix API. Using the trigger.get() function to get all triggers list.
    The Script works fine with all other functions like host.get() etc. But for this one it fails giving me 500 Internal Server Error. But when i specify certain object parameters for the same it runs.



    Running it with some parameters specified for trigger.get() method then it works but i want to list out all triggers without using any of the parameters for the method triggers.get().



    MY CODE :



    from pyzabbix import ZabbixAPI


    zapi = ZabbixAPI("http://Zabbix-Server-IP/zabbix")

    zapi.login("username","password")

    trigger=zapi.trigger.get() #Method to get all triggers from zabbix


    ERROR



    Traceback (most recent call last):
    File "zabbix.py", line 69, in <module>
    get_all_zabbix_host()
    File "zabbix.py", line 16, in get_all_zabbix_host
    trigger=zapi.trigger.get()
    File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 157, in fn
    args or kwargs
    File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 109, in do_request
    response.raise_for_status()
    File "/usr/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:
    http://Zabbix-Server-IP/zabbix/api_jsonrpc.php









    share|improve this question



























      0












      0








      0








      I am using Python Script with pyzabbix module to get all triggers via Zabbix API. Using the trigger.get() function to get all triggers list.
      The Script works fine with all other functions like host.get() etc. But for this one it fails giving me 500 Internal Server Error. But when i specify certain object parameters for the same it runs.



      Running it with some parameters specified for trigger.get() method then it works but i want to list out all triggers without using any of the parameters for the method triggers.get().



      MY CODE :



      from pyzabbix import ZabbixAPI


      zapi = ZabbixAPI("http://Zabbix-Server-IP/zabbix")

      zapi.login("username","password")

      trigger=zapi.trigger.get() #Method to get all triggers from zabbix


      ERROR



      Traceback (most recent call last):
      File "zabbix.py", line 69, in <module>
      get_all_zabbix_host()
      File "zabbix.py", line 16, in get_all_zabbix_host
      trigger=zapi.trigger.get()
      File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 157, in fn
      args or kwargs
      File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 109, in do_request
      response.raise_for_status()
      File "/usr/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
      raise HTTPError(http_error_msg, response=self)
      requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:
      http://Zabbix-Server-IP/zabbix/api_jsonrpc.php









      share|improve this question
















      I am using Python Script with pyzabbix module to get all triggers via Zabbix API. Using the trigger.get() function to get all triggers list.
      The Script works fine with all other functions like host.get() etc. But for this one it fails giving me 500 Internal Server Error. But when i specify certain object parameters for the same it runs.



      Running it with some parameters specified for trigger.get() method then it works but i want to list out all triggers without using any of the parameters for the method triggers.get().



      MY CODE :



      from pyzabbix import ZabbixAPI


      zapi = ZabbixAPI("http://Zabbix-Server-IP/zabbix")

      zapi.login("username","password")

      trigger=zapi.trigger.get() #Method to get all triggers from zabbix


      ERROR



      Traceback (most recent call last):
      File "zabbix.py", line 69, in <module>
      get_all_zabbix_host()
      File "zabbix.py", line 16, in get_all_zabbix_host
      trigger=zapi.trigger.get()
      File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 157, in fn
      args or kwargs
      File "/usr/lib/python2.7/site-packages/pyzabbix/__init__.py", line 109, in do_request
      response.raise_for_status()
      File "/usr/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
      raise HTTPError(http_error_msg, response=self)
      requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:
      http://Zabbix-Server-IP/zabbix/api_jsonrpc.php






      python zabbix






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 22:04







      Vipul Sharma

















      asked Jan 2 at 11:36









      Vipul SharmaVipul Sharma

      617




      617
























          1 Answer
          1






          active

          oldest

          votes


















          1














          As you said, the trigger.get() call without params should return all of the defined triggers (hosts and templates).



          A new zabbix system with 2 hosts and the default templates with a few additions (works with api 3.4 and 4.0):



          >>> from zabbix.api import ZabbixAPI
          >>> zabbixServer = 'http://localhost/zabbix/'
          >>> zabbixUser = 'admin'
          >>> zabbixPass = 'zabbix'

          >>> zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
          >>> triggers = zapi.trigger.get()
          >>> len(triggers)
          482
          >>> sys.getsizeof(triggers)
          4280


          The 500 Internal Server error is probably caused by an excessive response, for instance a result bigger than php's memory_limit.
          You should check first your httpd's error.log for something like:



          PHP Fatal error:  Allowed memory size of xxxxxxx bytes exhausted


          If this is the case, you should tune your /etc/httpd/conf.d/zabbix.conf (default for Centos) accordingly then restart httpd and retry.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54005622%2fusing-python-script-to-get-all-triggers-via-zabbix-api%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            As you said, the trigger.get() call without params should return all of the defined triggers (hosts and templates).



            A new zabbix system with 2 hosts and the default templates with a few additions (works with api 3.4 and 4.0):



            >>> from zabbix.api import ZabbixAPI
            >>> zabbixServer = 'http://localhost/zabbix/'
            >>> zabbixUser = 'admin'
            >>> zabbixPass = 'zabbix'

            >>> zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
            >>> triggers = zapi.trigger.get()
            >>> len(triggers)
            482
            >>> sys.getsizeof(triggers)
            4280


            The 500 Internal Server error is probably caused by an excessive response, for instance a result bigger than php's memory_limit.
            You should check first your httpd's error.log for something like:



            PHP Fatal error:  Allowed memory size of xxxxxxx bytes exhausted


            If this is the case, you should tune your /etc/httpd/conf.d/zabbix.conf (default for Centos) accordingly then restart httpd and retry.






            share|improve this answer




























              1














              As you said, the trigger.get() call without params should return all of the defined triggers (hosts and templates).



              A new zabbix system with 2 hosts and the default templates with a few additions (works with api 3.4 and 4.0):



              >>> from zabbix.api import ZabbixAPI
              >>> zabbixServer = 'http://localhost/zabbix/'
              >>> zabbixUser = 'admin'
              >>> zabbixPass = 'zabbix'

              >>> zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
              >>> triggers = zapi.trigger.get()
              >>> len(triggers)
              482
              >>> sys.getsizeof(triggers)
              4280


              The 500 Internal Server error is probably caused by an excessive response, for instance a result bigger than php's memory_limit.
              You should check first your httpd's error.log for something like:



              PHP Fatal error:  Allowed memory size of xxxxxxx bytes exhausted


              If this is the case, you should tune your /etc/httpd/conf.d/zabbix.conf (default for Centos) accordingly then restart httpd and retry.






              share|improve this answer


























                1












                1








                1







                As you said, the trigger.get() call without params should return all of the defined triggers (hosts and templates).



                A new zabbix system with 2 hosts and the default templates with a few additions (works with api 3.4 and 4.0):



                >>> from zabbix.api import ZabbixAPI
                >>> zabbixServer = 'http://localhost/zabbix/'
                >>> zabbixUser = 'admin'
                >>> zabbixPass = 'zabbix'

                >>> zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
                >>> triggers = zapi.trigger.get()
                >>> len(triggers)
                482
                >>> sys.getsizeof(triggers)
                4280


                The 500 Internal Server error is probably caused by an excessive response, for instance a result bigger than php's memory_limit.
                You should check first your httpd's error.log for something like:



                PHP Fatal error:  Allowed memory size of xxxxxxx bytes exhausted


                If this is the case, you should tune your /etc/httpd/conf.d/zabbix.conf (default for Centos) accordingly then restart httpd and retry.






                share|improve this answer













                As you said, the trigger.get() call without params should return all of the defined triggers (hosts and templates).



                A new zabbix system with 2 hosts and the default templates with a few additions (works with api 3.4 and 4.0):



                >>> from zabbix.api import ZabbixAPI
                >>> zabbixServer = 'http://localhost/zabbix/'
                >>> zabbixUser = 'admin'
                >>> zabbixPass = 'zabbix'

                >>> zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
                >>> triggers = zapi.trigger.get()
                >>> len(triggers)
                482
                >>> sys.getsizeof(triggers)
                4280


                The 500 Internal Server error is probably caused by an excessive response, for instance a result bigger than php's memory_limit.
                You should check first your httpd's error.log for something like:



                PHP Fatal error:  Allowed memory size of xxxxxxx bytes exhausted


                If this is the case, you should tune your /etc/httpd/conf.d/zabbix.conf (default for Centos) accordingly then restart httpd and retry.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 7 at 22:07









                Simone ZabberoniSimone Zabberoni

                721312




                721312
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54005622%2fusing-python-script-to-get-all-triggers-via-zabbix-api%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    hlSDs5E jjHi3SVKC6QZMWKY k34bm9W7dUSpnDHHSAVKUtDnUiapc7uF1m t3K6w8OSNFx4iz3Ag EsuRFcXreg5IoNX
                    OwrDtCbC4K0v7HJDYXlBqJL,2lsIWUI7nr5MtAP3,gZc7G,hQyOHKKI07T

                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas