Ad Widget

Collapse

count how many cameras have the status "empty"

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mateus_silva
    Junior Member
    • Aug 2023
    • 5

    #1

    count how many cameras have the status "empty"

    Hello

    I'm using ZAbbix 6.4 and I need to monitor an image recording device (NVR) and I would like to create an item that displays how many cameras have the "empty" status, an item that shows how many cameras have the "connected" status and an item that shows how many have the "unconnect" status. I am using the following template: link

    Once I have these items providing the correct count of the cameras' status I will then be able to insert this count into the NVR dashboard. Image below.

    Click image for larger version

Name:	inserting_itens.png
Views:	124
Size:	129.0 KB
ID:	494011

    This template uses Discovery Rule and Item Prototype to find cameras and is working correctly. I can see the IP address of the cameras, the name of the Camera and the status (Connecting, Conneted, Unconnect, Empty, Disable) of each camera. Images below

    Click image for larger version

Name:	info_cameras.png
Views:	170
Size:	87.5 KB
ID:	494009
    Click image for larger version

Name:	discovery_rule.png
Views:	125
Size:	113.7 KB
ID:	494010

    Is it possible to create this type of item that counts the number of cameras with the status Empty, Connected and Unconnect?
  • Answer selected by mateus_silva at 12-11-2024, 15:12.
    mateus_silva
    Junior Member
    • Aug 2023
    • 5

    I managed to solve it by creating a calculated item with a function that counts (sums) how many cameras have a status:​

    - sum(last_foreach(//remoteCam_status_empty[*]))
    - sum(last_foreach(//remoteCam_status_connected[*]))
    - sum(last_foreach(//remoteCam_status_unconnect[*]))

    So I created prototype items for each status in the Discovery Rule:

    Key -> remoteCam_status_empty[{#SNMPINDEX}]
    Key -> remoteCam_status_connected[{#SNMPINDEX}]
    Key -> remoteCam_status_unconnect[{#SNMPINDEX}]

    ​​​​​​​I also applied preprocessing to each prototype item where the value of the status in question is replaced by 1 and the other statuses are replaced by 0.

    Comment

    • ISiroshtan
      Senior Member
      • Nov 2019
      • 324

      #2
      I think it's possible, but giving you exact instruction how to do it is hard for me, as I have no personal lab zabbix atm and don't want to test this on production one. So mostly it is just a mental gymnastics in regards to how it should work, so typos and mistakes are possible

      In essence you would need to create a calculated item with usage of aggregated calculation. It should end something like (example for Empty):
      count(last_foreach(//remoteCam[status*]),"like","Empty")

      Comment

      • mateus_silva
        Junior Member
        • Aug 2023
        • 5

        #3
        I managed to solve it by creating a calculated item with a function that counts (sums) how many cameras have a status:​

        - sum(last_foreach(//remoteCam_status_empty[*]))
        - sum(last_foreach(//remoteCam_status_connected[*]))
        - sum(last_foreach(//remoteCam_status_unconnect[*]))

        So I created prototype items for each status in the Discovery Rule:

        Key -> remoteCam_status_empty[{#SNMPINDEX}]
        Key -> remoteCam_status_connected[{#SNMPINDEX}]
        Key -> remoteCam_status_unconnect[{#SNMPINDEX}]

        ​​​​​​​I also applied preprocessing to each prototype item where the value of the status in question is replaced by 1 and the other statuses are replaced by 0.

        Comment

        Working...