Ad Widget

Collapse

How to create only one ITEM for Check multiple container status

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manuel Simpson
    Junior Member
    • Jan 2025
    • 10

    #1

    How to create only one ITEM for Check multiple container status

    Hi everybody, I'm new with Zabbix. I added a host with a Docker installation, and configured Docker plugin on Agent Zabbix 2. Now in my server I can see all items of data. My problem is that I need to create a Dashboard with some kind of widget that show something like:
    | Container Name | Status | (running or stopped)
    The problem is that there are 1 item for each container with de running state but is so complex add one by one, even when all the time we create new containers.
    I tryed create a discovery rule as I read but give an error that told me that an Item with this key exists, so I can't generate the rule for create an Item. And don't know how can I write the key for dinamically incorporate all containers in the host.
    As I say, I'm new on Zabbix.
    Thanks in advance.
  • kyus
    Senior Member
    • Feb 2024
    • 172

    #2
    If you are in Zabbix 7 you can use the honeycomb widget for that. Set the host group to be your docker hosts and use the item pattern like Container * Status

    Comment

    • Manuel Simpson
      Junior Member
      • Jan 2025
      • 10

      #3
      Hi Kyus, thanks for help, another question, the widget honeycomb shows status (ex. "running") but in the Host identification all "bee cells" (bad english) are named as my host name (ex. Host 1), I need identify by container name (ex. Container A) but all containers are in same host.
      Thanks in advance

      Comment

      • kyus
        Senior Member
        • Feb 2024
        • 172

        #4
        In the discovery rule "Containers discovery", from "Docker by Zabbix agent 2" template.

        Edit the item "Container {#NAME}: Status". Add {#NAME} to the description of the item, that way the description will have the name of the container.

        In your Honeycomb widget, go to the advanced configuration and change the "Type" of the primary label to "Text", then add this text: {ITEM.DESCRIPTION}

        Comment

        • Manuel Simpson
          Junior Member
          • Jan 2025
          • 10

          #5
          Worked perfect! Thanks
          Just two more questions.
          1.- On the item pattern I put: "Container * Status" and I got all Status cell, but also appear "Container {#NAME} : Health Status" (because of my pattern) but when I try to put some regex for remove it not work. Support regex this section or I must setup some other section?
          2.- Which item I should use to get cells with colours like: Green for running, Yellow for exited, Red for Stopped. In Thresholds section on advanced mode must be numeric data but Status get text.

          Thanks again

          Comment

          • kyus
            Senior Member
            • Feb 2024
            • 172

            #6
            Yeah, thresholds won't work with characters. I guess you could add a preprocessing step to replace the strings returned for numbers and then add a value mapping on the item, but idk... Feels like a really werid workaround.

            To not display the Health status, you'll have to test some expressions, if you have some pattern in your container names it'll probably be easier. Other option would be to go back to the discovery rule and change the item name to ....Status Health

            Comment

            • Manuel Simpson
              Junior Member
              • Jan 2025
              • 10

              #7
              Thanks again!

              Comment

              • kyus
                Senior Member
                • Feb 2024
                • 172

                #8
                Just for the sake of curiosity, did you test those workarounds?

                Comment

                • Manuel Simpson
                  Junior Member
                  • Jan 2025
                  • 10

                  #9
                  Yes, also many of your answers helps me to understand zabbix, is my first project and I'm not familiarized with zabbix docs because there are many elements that I don't know. And the IA instructions mix answers with other versions and miss too much concepts. Really don't helps.

                  To resume my steps:
                  Created a Discovery Rule and call my custom UserParameter to get container list with: ContainerName, ShortName, NumericStatus (defined by me)
                  Created Item Prototype that call another custom UserParameter to get just numeric status (same as I defined before)
                  Created a Value Mapping for set labels for each numeric status. So 1: running, 2: paused, 3:exited/stopped and related to Item prototype in Value map field. (This step helps me to show labels on the center of each honycomb cell).
                  Finally created a HoneyComb Widget in Dashboard and configured threshold with colours.
                  Add a screenshot to be more graphic
                  Click image for larger version

Name:	imagen.png
Views:	195
Size:	106.0 KB
ID:	498594

                  Now, I need create a remote control to start/stop containers from Dashboard, some idea? :-)

                  Comment

                  • kyus
                    Senior Member
                    • Feb 2024
                    • 172

                    #10
                    If you have some triggers for exited/stopped containers, you can define trigger actions to execute scripts in your host... But being able to start and stop the containers as you wish, maybe you could create a script (in Zabbix) using {MANUALINPUT}.
                    To execute remote commands you need to adjust AllowKey parameter in agent conf.

                    Here's some docs that will be of use:




                    Comment

                    • Manuel Simpson
                      Junior Member
                      • Jan 2025
                      • 10

                      #11
                      Hi kyus, sorry to quote you, but I would need to know if you can help me with this.

                      Thanks!.

                      Comment

                      Working...