Ad Widget

Collapse

speedtest to zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomdom
    Member
    • Nov 2021
    • 38

    #1

    speedtest to zabbix

    Hello, everyone, for help, and the topic is quite, please.

    I would like to monitor the internet speed in zabbix, I have a script that connects to the server and finally creates the speedtest-zabbix.tmp file. get values from a file into zabbix. How to make?

    I'd like the script on one of the ubuntu machines in system cron.

    Speedtest-zabbix.tmp result

    Code:
    root@win:/etc/zabbix/script# cat speedtest-zabbix.tmp
    
    - speedtest.download 40673092.37615933
    
    - speedtest.upload 47363871.16292844
    
    - speedtest.wan.ip xxx.xxx.xxx.xxx
    
    - speedtest.ping 90.132
    
    - speedtest.srv.name RFC Ogólnopolski dostawca Internetu i Telewizji
    
    - speedtest.srv.city Bydgoszcz
    
    - speedtest.srv.km 228.2
    Edit:

    I found another script, the data is downloaded in json, the download and upload values would like to download to zabbix
    Code:
    {"type":"result","timestamp":"2021-11-24T09:34:54Z","ping":{"jitter":1.367,"latency":9.0 700000000000003},"download":{"bandwidth":5104332," bytes":74175048,"elapsed":15000},"upload":{"bandwi dth":5537088,"bytes":76930542,"elapsed":15015},"pa cketLoss":1.0101010101010102,"isp":"TK Telekom sp. z o.o.","interface":{"internalIp":"172.18.0.2","name ":"eth0","macAddr":"02:42:AC:12:00:02","isVpn":fal se,"externalIp":"xxx.xxx.xxx.xxx"},"server":{"id":1 4781,"name":"Powszechna Agencja Informacyjna S.A.","location":"Warszawa","country":"Poland","ho st":"speedtest.pagi.pl","port":8080,"ip":"212.69.6 4.212"},"result":{"id":"da3fe3ea-d3d3-4f65-bc1c-da78e1ad9848","url":"https://www.speedtest.net/result/c/da3fe3ea-d3d3-4f65-bc1c-da78e1ad9848"}}
    Last edited by tomdom; 24-11-2021, 11:39.
  • Oz_Joris
    Junior Member
    • Sep 2021
    • 19

    #2
    Hello,

    In order to understand your problem, you already have a script that works and returns the results of the speedtest when you run it ?

    I hope I can help you, Oz_Joris

    Comment

    • tomdom
      Member
      • Nov 2021
      • 38

      #3
      Hi,

      That's right, I have a script and it works fine, we receive json data.

      2screen. When I download data one by one it is OK
      3screen . The problem arises when I want to download three parameters at once.

      My configuration:


      Click image for larger version  Name:	Zrzut ekranu 2021-11-24 o 13.00.21.png Views:	0 Size:	55.3 KB ID:	435433




      2.

      Click image for larger version  Name:	Zrzut ekranu 2021-11-24 o 13.01.27.png Views:	0 Size:	82.7 KB ID:	435434



      3.

      Click image for larger version  Name:	Zrzut ekranu 2021-11-24 o 13.04.48.png Views:	0 Size:	93.0 KB ID:	435435


      json which it receives

      Code:
       zabbix_agentd -t internet.speedtest
      
      internet.speedtest [t|{"download": 25200208.08506609, "upload": 31925272.91652513, "ping": 29.702, "server": {"url": "http://speedtest.metronet.cz:8080/speedtest/upload.php", "lat": "50.4125", "lon": "14.9064", "name": "Mlada Boleslav", "country": "Czech Republic", "cc": "CZ", "sponsor": "METRONET s.r.o.", "id": "12021", "host": "speedtest.metronet.cz:8080", "d": 471.6851653244463, "latency": 29.702}, "timestamp": "2021-11-24T11:05:55.129616Z", "bytes_sent": 39936000, "bytes_received": 31948272, "share": null, "client": {"ip": "xxx.xxx.xxx.xxxx", "lat": "52.2394", "lon": "21.0362", "isp": "TK Telekom sp. z o.o.", "isprating": "3.7", "rating": "0", "ispdlavg": "0", "ispulavg": "0", "loggedin": "0", "country": "PL"}}]
      Please help.

      Comment

      • Oz_Joris
        Junior Member
        • Sep 2021
        • 19

        #4
        the problem seems to be syntactic, isn't it possible to process the result of the script with an
        Code:
         internet.speedtest | cut -d ' -f3 | cut -d ',' -f1
        for example for the first value?

        Hoping to help you, Oz_Joris

        Comment

        • Oz_Joris
          Junior Member
          • Sep 2021
          • 19

          #5
          and if you really want to keep an element in JSON processing, can you send the whole error message please

          Comment

          • ISiroshtan
            Senior Member
            • Nov 2019
            • 324

            #6
            Yeah, preprocessing works a bit different.

            You run 1st step preprocessing, it modifies value. Modified value passed to 2nd step preprocessing, it modifies data and passes it to 3rd step, etc...

            So after 1st step is run you have data 4022786.16674396. This data no longer contains JSON, so 2nd step pre-processing fails to find JSONPath you asking for.

            What you want to do instead: setup 3 dependent item, choosing speedtest as master item. In each of dependent items you setup a single pre-processing step, different one for each item.

            As result you have 3 different items, each have unique preprocessing step representing download, upload and ping respectively.

            Comment

            • tomdom
              Member
              • Nov 2021
              • 38

              #7
              I created 3 different items for download, upload and ping. This is how I was able to download the data. Thanks for your help, gentlemen

              Click image for larger version

Name:	Zrzut ekranu 2021-11-24 o 18.20.48.png
Views:	2351
Size:	53.1 KB
ID:	435477

              Comment

              • cyber
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Dec 2006
                • 4807

                #8
                This was not exactly as suggested, but whatever floats your boat..
                Currently you are doing 3 polls and possibly get 3 different values for each.
                What was suggested is doing 1 query and add "Dependent items" to it. so you would distribute values from that one query to items and they would be acquired from same session.
                you should probably have a bit more colorful picture.. Did not bother to make triggers..

                Click image for larger version  Name:	internet.png Views:	0 Size:	20.6 KB ID:	435502
                Last edited by cyber; 25-11-2021, 10:30. Reason: typos...

                Comment

                • maarguello
                  Junior Member
                  • Apr 2023
                  • 19

                  #9
                  Hi guys,

                  I'd like to implement a monitoring service to get the bandwidth every 1 hr, since a Windows machine and send the results to zabbix server


                  Any idea to implement something like this?

                  I heard about use the agent2, but I'm not clear on how to do it..​

                  Comment

                  • tomdom
                    Member
                    • Nov 2021
                    • 38

                    #10
                    Hi,

                    A quick tutorial for you, but on Linux you can run it on the server where you have zabbix server running



                    ps. If I violate the regulations with an external link, I apologize.

                    Comment

                    • maarguello
                      Junior Member
                      • Apr 2023
                      • 19

                      #11
                      Hi tomdom.

                      Thank for help me with this matter.

                      I just read and i found a way to do it.

                      1. a bat file exporting the values
                      speedtest.exe -f json >speedtest.json
                      2.editing the config agent file on windows and add
                      UserParameter=speedtest.download,powershell -command C:\Users\cdr\test.bat ; Get-Content 'C:\Users\cdr\speedtest.json'

                      now my problem is get all values as keys.

                      Click image for larger version  Name:	image.png Views:	0 Size:	37.8 KB ID:	471530

                      Click image for larger version  Name:	image.png Views:	0 Size:	53.2 KB ID:	471532



                      Click image for larger version  Name:	image.png Views:	0 Size:	23.6 KB ID:	471531

                      ​here I'm not clear how to solved.
                      Last edited by maarguello; 03-10-2023, 21:32.

                      Comment

                      • tomdom
                        Member
                        • Nov 2021
                        • 38

                        #12
                        Maarguello, I think you are using the wrong Preprocessing parameter

                        use this to find the right key


                        in my case it looks like this and works

                        Download:

                        Click image for larger version

Name:	image.png
Views:	1952
Size:	67.5 KB
ID:	471547


                        TEST
                        Click image for larger version

Name:	image.png
Views:	1907
Size:	53.2 KB
ID:	471548


                        Preprocessing

                        Click image for larger version

Name:	image.png
Views:	1916
Size:	28.3 KB
ID:	471549

                        I also get the speedtest data from the json file


                        Comment

                        • cyber
                          Senior Member
                          Zabbix Certified SpecialistZabbix Certified Professional
                          • Dec 2006
                          • 4807

                          #13
                          Notice the "The process cannot access the file because it is used by another process." ?
                          That seems to be part of you return value, which in turn screws it up being a proper json... Find that reason you have it there and after that you may succeed...

                          Comment

                          • maarguello
                            Junior Member
                            • Apr 2023
                            • 19

                            #14
                            Thank you guys for help. The issue has been resolved thanks for your comments.​

                            Comment

                            Working...