Ad Widget

Collapse

Retrieving multiple key/value pairs from zabbix agent in a single request.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • igormorgado
    Junior Member
    • Oct 2015
    • 1

    #1

    Retrieving multiple key/value pairs from zabbix agent in a single request.

    ( DAMN TIMEOUT! I had to rewrite all this.. pff.. ok.. )

    Hi there, I'm monitoring a NFS4 server and retrieving many useful informations using UserParameters as se can see:

    Code:
    # cat /etc/zabbix/zabbix_agentd.d/nfs4.conf 
    UserParameter=nfs4.null,nfsstat -l -4 | sed -n '/null:/ s/.*: *//gp'
    UserParameter=nfs4.compound,nfsstat -l -4 | sed -n '/compound:/ s/.*: *//gp'
    UserParameter=nfs4.access,nfsstat -l -4 | sed -n '/access:/ s/.*: *//gp'
    UserParameter=nfs4.close,nfsstat -l -4 | sed -n '/close:/ s/.*: *//gp'
    UserParameter=nfs4.commit,nfsstat -l -4 | sed -n '/commit:/ s/.*: *//gp'
    UserParameter=nfs4.create,nfsstat -l -4 | sed -n '/create:/ s/.*: *//gp'
    UserParameter=nfs4.delegreturn,nfsstat -l -4 | sed -n '/delegreturn:/ s/.*: *//gp'
    UserParameter=nfs4.getattr,nfsstat -l -4 | sed -n '/getattr:/ s/.*: *//gp'
    UserParameter=nfs4.getfh,nfsstat -l -4 | sed -n '/getfh:/ s/.*: *//gp'
    UserParameter=nfs4.lock,nfsstat -l -4 | sed -n '/lock:/ s/.*: *//gp'
    UserParameter=nfs4.locku,nfsstat -l -4 | sed -n '/locku:/ s/.*: *//gp'
    UserParameter=nfs4.lookup,nfsstat -l -4 | sed -n '/lookup:/ s/.*: *//gp'
    UserParameter=nfs4.open,nfsstat -l -4 | sed -n '/open:/ s/.*: *//gp'
    UserParameter=nfs4.open_conf,nfsstat -l -4 | sed -n '/open_conf:/ s/.*: *//gp'
    UserParameter=nfs4.open_dgrd,nfsstat -l -4 | sed -n '/open_dgrd:/ s/.*: *//gp'
    UserParameter=nfs4.putfh,nfsstat -l -4 | sed -n '/putfh:/ s/.*: *//gp'
    UserParameter=nfs4.putrootfh,nfsstat -l -4 | sed -n '/putrootfh:/ s/.*: *//gp'
    UserParameter=nfs4.read,nfsstat -l -4 | sed -n '/read:/ s/.*: *//gp'
    UserParameter=nfs4.readdir,nfsstat -l -4 | sed -n '/readdir:/ s/.*: *//gp'
    UserParameter=nfs4.readlink,nfsstat -l -4 | sed -n '/readlink:/ s/.*: *//gp'
    UserParameter=nfs4.remove,nfsstat -l -4 | sed -n '/remove:/ s/.*: *//gp'
    UserParameter=nfs4.rename,nfsstat -l -4 | sed -n '/rename:/ s/.*: *//gp'
    UserParameter=nfs4.renew,nfsstat -l -4 | sed -n '/renew:/ s/.*: *//gp'
    UserParameter=nfs4.savefh,nfsstat -l -4 | sed -n '/savefh:/ s/.*: *//gp'
    UserParameter=nfs4.secinfo,nfsstat -l -4 | sed -n '/secinfo:/ s/.*: *//gp'
    UserParameter=nfs4.setattr,nfsstat -l -4 | sed -n '/setattr:/ s/.*: *//gp'
    UserParameter=nfs4.setcltid,nfsstat -l -4 | sed -n '/setcltid:/ s/.*: *//gp'
    UserParameter=nfs4.setcltidconf,nfsstat -l -4 | sed -n '/setcltidconf:/ s/.*: *//gp'
    UserParameter=nfs4.write,nfsstat -l -4 | sed -n '/write:/ s/.*: *//gp'
    UserParameter=nfs4.rellockowner,nfsstat -l -4 | sed -n '/rellockowner:/ s/.*: *//gp'
    This is ok, working and everyone is happy (). But of course this is a waste of resources since I can do this in a single line with:

    Code:
    # /usr/sbin/nfsstat -l -4 | awk '{ FS = "[: \t]+" }  !/total|----|^$/   { print "nfs4." $4 "\t" $5}'
    nfs4.null	38
    nfs4.compound	2682108721
    nfs4.access	650081771
    nfs4.close	154149357
    nfs4.commit	17392
    nfs4.create	19751
    nfs4.delegreturn	24865186
    nfs4.getattr	2448990936
    nfs4.getfh	206240268
    nfs4.lock	79275
    nfs4.locku	79274
    nfs4.lookup	90619501
    nfs4.open	184580224
    nfs4.open_conf	3215081
    nfs4.open_dgrd	2610
    nfs4.putfh	2681947709
    nfs4.putrootfh	1777
    nfs4.read	68251808
    nfs4.readdir	97105933
    nfs4.readlink	585961
    nfs4.remove	318588
    nfs4.rename	58720
    nfs4.renew	6624275
    nfs4.savefh	58720
    nfs4.secinfo	7
    nfs4.setattr	784665
    nfs4.setcltid	1781
    nfs4.setcltidconf	1781
    nfs4.write	13073091
    nfs4.rellockowner	79274
    Is there any way to feed Zabbix with that? I know about zabbix_sender, but I don't like this approach since I want the requests coming from server to the agent instead the opposite.

    I'm looking a way to request a bunch of key/values pairs to zabbix

    PS: Using Zabbix 2.2.
  • nscruman
    Junior Member
    • Mar 2016
    • 5

    #2
    I was looking for something similar and I can't stand forum posts with no answers, so thought I would post a link even if it is long after the fact.

    I think what you are trying to do is what this person did -

    http://serverfault.com/questions/558...-from-userland

    This is the punchline -
    # NFS stats
    UserParameter=nfs.v3.server[*],nfsstat -s -l | awk 'BEGIN {FS=": *"}/v3 server.*$1:/ {print $$2}'

    I have no clue if this works (yet) but it seems awfully close to what you did.

    Comment

    Working...