Ad Widget

Collapse

Export host list

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Buozinis
    Junior Member
    • May 2024
    • 9

    #1

    Export host list

    Hello,
    I've seen zabcon is one of the tools. I have tried to use it, but no luck. First faced issue with dependencies, then some other problems in a code. Might be because it is an old tool and don't work with modern systems.
    Is there is a way to pull host list from zabbix? It can be mysql queries, again found old solutions which I believe do not apply anymore for modern zabbix.
  • Answer selected by Buozinis at 02-07-2024, 14:28.
    vijayk
    Senior Member
    • May 2023
    • 305

    You can retrieve it via Zabbix API. I'm not expert in API but i'm using Power Bi to get hosts from Zabbix Server.
    The true power of Power BI continues to amaze me. With each monthly release, I learn new ways of unleashing the magic of Power BI. We at Spikefish Solutions have a diverse array of skill sets that we love to share with the IT community. With this post, we’ll show you how to connect Power BI Desktop to Zabbix! We recently set up Zabbix in our lab to monitor Checkpoint firewalls. As awesome as Zabbix is, we found it necessary to improve on its reporting and visualization capabilities. As Spikefish

    Comment

    • vijayk
      Senior Member
      • May 2023
      • 305

      #2
      You can retrieve it via Zabbix API. I'm not expert in API but i'm using Power Bi to get hosts from Zabbix Server.
      The true power of Power BI continues to amaze me. With each monthly release, I learn new ways of unleashing the magic of Power BI. We at Spikefish Solutions have a diverse array of skill sets that we love to share with the IT community. With this post, we’ll show you how to connect Power BI Desktop to Zabbix! We recently set up Zabbix in our lab to monitor Checkpoint firewalls. As awesome as Zabbix is, we found it necessary to improve on its reporting and visualization capabilities. As Spikefish

      Comment

      • Buozinis
        Junior Member
        • May 2024
        • 9

        #3
        Hello vijayk. Thank you for your response. It is a really nice blog post how to do it, but sorry to be a douchebag, I believe Power-Bi tool is a paid service. Does anyone knows free alternative to Power-Bi tool?

        Comment

        • Brambo
          Senior Member
          • Jul 2023
          • 245

          #4
          I use the API myself for backup of template, and as hosts are basically templates with an interface the method is probably the same.
          Make an API token with rights to the correct host groups etc. Make a POST to the API URL with the correct JSON body. I expect something like: '{"jsonrpc": "2.0","method": "host.get","params": {"output": "extend"},"id":1}'
          In the returned data there are host-id's which you can than use (if needed) to do another call for more details about this specific host.
          Building / making something yourself vs cost using PowerBI is something you should consider for yourself.

          Comment

          • Buozinis
            Junior Member
            • May 2024
            • 9

            #5
            Brambo thank you for your inputs. I tried another Json/API and it worked. Will keep reading API documentation on zabbix manual.

            Comment

            • Buozinis
              Junior Member
              • May 2024
              • 9

              #6
              One last request. Is it possible to output data to a file? Because now spams terminal

              Comment

              • Brambo
                Senior Member
                • Jul 2023
                • 245

                #7
                When you make the request, then you are in control to output it somewhere.
                Like I mentioned that I just it for templates, the way I do that is grab every individual template from a certain group. But before that I store the templates locally, I create a new Git Branch with the current date, use the template description to create a readme.md and commit everything.
                But I do everything with a powershell script and not with an item from within zabbix.

                Comment

                • Buozinis
                  Junior Member
                  • May 2024
                  • 9

                  #8
                  Hello, my colleague helped to find a solution.
                  Example:

                  Code:
                  curl -k --request POST \
                  --url 'https://example.com/zabbix/api_jsonrpc.php' \
                  --header 'Authorization: Bearer 198fac438d2c66232b1384f850a70aed583552be202c8b90aa 3dc56d7719975c' \
                  --header 'Content-Type: application/json-rpc' \
                  --data @data.json >> hosts.json
                  Then I get everything exported to hosts.json and then with python + pandas module I export data to csv file.

                  Comment

                  • dharam
                    Junior Member
                    • Oct 2024
                    • 26

                    #9
                    Hi,
                    I have the same requirement , can you help me to achieve this.

                    Comment

                    • Buozinis
                      Junior Member
                      • May 2024
                      • 9

                      #10
                      Hello dharam,
                      I will try to make steps to achieve this.
                      1. Create an API token and don't forget to save the token ID as you will need it later
                        Click image for larger version

Name:	Screenshot 2025-03-27 110059.png
Views:	1827
Size:	53.4 KB
ID:	501119
                      2. On your server log in and make a file data.json e.g. nano data.json and copy the bellow contents
                        Code:
                        {
                        	"jsonrpc": "2.0",
                        	"method": "host.get",
                        	"params": {
                        	"output": "extend"},
                        	"id":1
                        	}
                      3. make a curl request:
                        Code:
                        curl -k --request POST \
                        	--url 'https://10.143.1.153/zabbix/api_jsonrpc.php' \
                        	--header 'Authorization: Bearer 01d32e8b2f5089591b3dd091998b7060770ed5844466ae9ae4084c951233be18' \
                        	--header 'Content-Type: application/json-rpc' \
                        	--data @data.json >> hosts.json​
                        Authorization: Bearer - you need to put your TOKEN API id
                        --data @data.json >> hosts.json - from data.json file which you have made on step 2 it will put all output to a file hosts.json
                      4. And then with python and pandas I convert hotst.json to csv - link for tutorial https://learnpython.com/blog/python-json-to-csv/
                      ​​
                      Attached Files

                      Comment


                      • dharam
                        dharam commented
                        Editing a comment
                        Thank you for nice explanation!!!
                    Working...