Ad Widget

Collapse

Counting of Elements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manni
    Junior Member
    • Jan 2014
    • 7

    #1

    Counting of Elements

    Hello,

    I'm trying a trivial check to do. The target is to count the number of interfaces with a specific Regex within ifAlias or ifDescr. So I tried with a discovery rule within a host and see all Interfaces.

    Now I need a calculated Item to see and graph the number of interfaces.

    I tried with:

    count(KeyofCheck.last(0), 600)
    count(KeyofCheck, 600)
    count(KeyofCheck[*].last(0), 600)
    count(KeyofCheck[all].last(0), 600)

    but nothing works correctly. At the moment I have 9 elements with KeyofCheck[interfaceID].

    Sometimes I got the error, that zabbix cannot evaluate the formula and sometimes I've got the error that the item 600 does not exists.

    Is there any mistake in the documentation? It states func(key, parameter) for calculated Items and that's what I'm doing.

    Kind Regards,
    Kay
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    I'm pretty sure that cannot be done unfortunately. Zabbix has no concept for "keyOfCheck[*]". You would most likely have to write a custom script like
    "select count(1) from items where key_ like "keyOfCheck[%]" or similar.

    Take special care since "select count()" DB calls on InnoDB are sometimes quite costly and slow. Maybe
    Code:
    echo "select key_ from items where key_ like 'keyOfCheck[%]' | mysql | wc -l
    is less time and memory consuming.

    Comment

    Working...