Ad Widget

Collapse

Newbie: Monitoring Urbackup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmueko
    Junior Member
    • Sep 2020
    • 4

    #1

    Newbie: Monitoring Urbackup

    Hi, I am new to zabbix and want to monitor a urbackup-server (https://www.urbackup.org).
    There is an python api where is can produce json:

    Code:
    import urbackup_api
    
    server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "password")
    for client in server.get_status():
        print(client)
    pruduces:

    Code:
    {
    'client_version_string': '2.4.10',
    'delete_pending': '',
    'file_ok': False,
    'groupname': '',
    'id': 2,
    'image_ok': True,
    'ip': '-',
    'last_filebackup_issues': 4,
    'lastbackup': 1600873220,
    'lastbackup_image': 1600762213,
    'lastseen': 1600876692,
    'name': 'PC22',
    'online': False,
    'os_simple': 'windows',
    'os_version_string': 'Microsoft Windows 10 Pro (build 17134), 64-Bit',
    'processes': [],
    'status': 0
    }
    {
    'client_version_string': '2.4.10',
    'delete_pending': '',
    'file_ok': True,
    'groupname': '',
    'id': 3,
    'image_ok': True,
    'ip': '192.168.7.11',
    'last_filebackup_issues': 0,
    'lastbackup': 1600932918,
    'lastbackup_image': 1600710792,
    'lastseen': 1600934604,
    'name': 'SKC-SRV1',
    'online': True,
    'os_simple': 'windows',
    'os_version_string': 'Microsoft Windows Server 2012 R2 Standard (build 9600), 64-Bit',
    'processes': [],
    'status': 0
    }
    What is the best (and probably simple) way, to get this in zabbix? Is it possible, that it automatical expand, when I add backup-clients?
  • tmueko
    Junior Member
    • Sep 2020
    • 4

    #2
    OK, I finally managed to get data in Zabbix. This is, what I did:

    I created a file /usr/local/bin/urbackup-discovery.py


    Code:
    #!/usr/local/bin/python
    #!/usr/bin/env python
    #
    import urbackup_api
    import json
    import sys
    
    server = urbackup_api.urbackup_server(sys.argv[1],sys.argv[2],sys.argv[3])
    
    i = 0
    print ("[", end='')
    for client in server.get_status():
    if i > 0 : print("," , end='')
    print(json.dumps(client))
    i += 1
    print ("]", end='')
    Then I added it to UserParameter:
    Code:
    UserParameter=urbackup.discovery[*],/usr/local/bin/urbackup-discovery.py $1 $2 $3
    I created a template with this macros:
    {$UR_PASSWORD}, {$UR_URL}, {$UR_USER}
    and an item "urbackup discovery item"
    key: urbackup.discovery[{$UR_URL},{$UR_USER},{$UR_PASSWORD}]

    Next a discovery rule like
    Name: urbackup discovery
    key: urbackup.discovery

    LLD macros:
    {#U_ID}: $.id
    {#U_NAME}: $.name

    And item prototype like this:

    depended item of "urbackup.discovery"
    Name: urbackup last file backup of {#U_NAME}
    Key: urbackup.lastbackup[{#U_ID}]
    Preprocessing:
    JSONPath: $[?(@.id == {#U_ID})]..lastbackup.first()

    When I add the Template to a Host I have to define {$UR_PASSWORD}, {$UR_URL}, {$UR_USER} and its is working so far ... When I added the trigger, I can export the template and share ...

    Comment

    • steve.destivelle
      Senior Member
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Feb 2017
      • 304

      #3
      Hi Tmueko,

      I am interested by your template.

      Thanks.

      Regards,

      Steve
      "Estimez la taille de votre base de données Zabbix: http://tools.izi-it.io
      "Rejoignez le ZABBIX Discord francophone https://discordapp.com/invite/hvauXEQ"

      "izi-it.io / ZABBIX Certified Trainer / ZABBIX French Evangelist"

      Comment

      • steve.destivelle
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Feb 2017
        • 304

        #4
        I was able to retrieve the value, but my JSONPATH is not working perfectly.

        Here is my result for the discovery:
        [{"client_version_string": "2.2.6", "delete_pending": "", "file_ok": false, "groupname": "", "id": 2, "image_disabled": true, "image_ok": false, "ip": "-", "last_filebackup_issues": 0, "lastbackup": 0, "lastbackup_image": 0, "lastseen": 1605167864, "name": "XXXX", "online": false, "os_simple": "windows", "os_version_string": "Microsoft Windows 10 Professionnel (build 19041), 64 bits", "processes": [], "status": 0}
        ,{"client_version_string": "2.2.6", "delete_pending": "", "file_ok": true, "groupname": "", "id": 1, "image_disabled": true, "image_ok": false, "ip": "-", "last_filebackup_issues": 0, "lastbackup": 1605201927, "lastbackup_image": 0, "lastseen": 1605220607, "name": "XXXX", "online": true, "os_simple": "linux", "os_version_string": "Ubuntu 20.04 LTS; Kernel 5.4.0-42-generic x86_64", "processes": [], "status": 0}
        ]

        The JSONPATH:
        $[?(@.id == 2)].lastseen

        And the result:
        [
        1605167864
        ]
        "Estimez la taille de votre base de données Zabbix: http://tools.izi-it.io
        "Rejoignez le ZABBIX Discord francophone https://discordapp.com/invite/hvauXEQ"

        "izi-it.io / ZABBIX Certified Trainer / ZABBIX French Evangelist"

        Comment

        • tmueko
          Junior Member
          • Sep 2020
          • 4

          #5
          I had the same problem, thats why i ended in using "
          JSONPath: $[?(@.id == {#U_ID})]..lastbackup.first()
          ".
          here is my template so far (see attachment)

          Attached Files

          Comment

          • steve.destivelle
            Senior Member
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Feb 2017
            • 304

            #6
            Thanks.

            "Estimez la taille de votre base de données Zabbix: http://tools.izi-it.io
            "Rejoignez le ZABBIX Discord francophone https://discordapp.com/invite/hvauXEQ"

            "izi-it.io / ZABBIX Certified Trainer / ZABBIX French Evangelist"

            Comment

            • mrjd1981
              Junior Member
              • Jan 2021
              • 1

              #7
              Ok, i've been trying to make this work too. I got it to the point that discovery places the items for each client on the backup server, the json comes in as it should. But the values on each of the discovered items does not fill in on latest data.

              What am I missing?

              Comment

              • Badmight
                Junior Member
                • Nov 2021
                • 1

                #8
                tmueko, Would you consider creating a Github repo so more people could contribute to this?

                I, for one, had a UrBackup monitoring implementation for Zabbix on my todo list for years now, finally getting to it.

                Comment

                • zet
                  Junior Member
                  • Jan 2022
                  • 1

                  #9
                  The template has been improved, data elements and triggers have been added. The urbackup-discovery.py script has been improved. Enjoy. https://disk.yandex.ru/d/gIax0AhX4j_AjA

                  Comment

                  • magnored
                    Junior Member
                    • Jun 2022
                    • 1

                    #10

                    How do i capture the backup size?

                    Comment

                    • tmueko
                      Junior Member
                      • Sep 2020
                      • 4

                      #11
                      Originally posted by Badmight
                      tmueko, Would you consider creating a Github repo so more people could contribute to this?

                      I, for one, had a UrBackup monitoring implementation for Zabbix on my todo list for years now, finally getting to it.
                      Take the code and start a repo, please. I'm not very good in this

                      Comment

                      • DugongDelight
                        Junior Member
                        • Nov 2023
                        • 1

                        #12
                        I have taken the code kindly provided by tmueko and thrown it into a git-repo, plus added installation instructions of my own (because I am a new to this, and it wasn't obvious to me, so it might not be obvious to others).

                        How to monitor urbackup clients with zabbix. Contribute to kerryland/zabbix-urbackup development by creating an account on GitHub.

                        Comment

                        Working...