Ad Widget

Collapse

Using Discovery and Dependent Items for SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yScrappy
    Junior Member
    • Apr 2013
    • 3

    #1

    Using Discovery and Dependent Items for SQL

    Hi ...

    I'm hoping someone can point me to a doc / example of doing this, since I'm drawing a blank ... I've searched Google, as well as gone through the various templates on share.zabbix.com ...

    I have a Discovery rule that gets me a list of databases, that works fine ... that was easy. What I want to do next is to monitor table bloat ( postgresql ) on the tables within the database, so I created an item that queries the database for all tables in a database, and their bloat:

    UserParameter=pgsql.table.bloat.discovery[*],/bin/echo -n '{"data":['; psql -qAtX -f scripts/get_table_bloat.sql d4tf1q7m4n8dr2 | while IFS="|" read table tbloat wastedbytes; do /bin/echo -n "{ "{#TABLENAME}": "$table", "{#BLOAT}", "$tbloat", "{#BYTES}", "$wastedbytes"},"; done | sed -e 's:\},$:\}:'; /bin/echo -n ']}'
    What I want to do is create a DEPENDENT ITEM that takes that one query / item and fans it out to multiple items, which I believe is possible ... but I'm not sure how to form the dependent item ... I did what I thought made sense, but when I try to add it tells me:

    • Invalid key "{#TABLENAME}" for item prototype "{#TABLENAME} bloat ( % )" on "PostgreSQL Simple Template": incorrect syntax near "{#TABLENAME}".
    I did it first where my dscovery rule was the above userparameter and then an item prototype for getting the bloat, but having zabbix-agent query the database 900 times a minute continuously when I *could* get the same out of one query and letting Zabbix use that one result would be so much more efficient ...

    Does anyone have a sample of doing something like this, with an SQL query, that I could look at ... or some advice on a better way to do it ... ?

    Thx
  • DaveL
    Junior Member
    • Nov 2018
    • 3

    #2
    Hello yScrappy,
    I'm just trying to do the same thing (not on table bloat but with prices from the ERP) and I only found your post.
    Did you find a solution ?

    Comment

    Working...