Ad Widget

Collapse

Monitoring Diskspace from a Json output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Swaffy10
    Junior Member
    • Oct 2019
    • 2

    #1

    Monitoring Diskspace from a Json output

    I have been tasked with seeing if Zabbix 4.2 can monitor a server clusters disk space, now that may sound like a simple task but I cannot use the Zabbix agent, and the only status I can read is a Json output as shown below.

    [{"shards":"415","disk.indices":"45.7gb","disk.used ":"64.3gb","disk.avail":"132.4gb","disk.total":"19 6.7gb","disk.percent":"32","host":"192.168.3.166", "ip":"192.168.3.166","node":"FJ1aTby"}, {"shards":"416","disk.indices":"45.4gb","disk.used ":"64.2gb","disk.avail":"132.4gb","disk.total":"19 6.7gb","disk.percent":"32","host":"192.168.2.134", "ip":"192.168.2.134","node":"nGy0AaE"}, {"shards":"415","disk.indices":"44gb","disk.used": "62.3gb","disk.avail":"134.3gb","disk.total":"196. 7gb","disk.percent":"31","host":"192.168.1.165","i p":"192.168.1.165","node":"mOkDi8u"}, {"shards":"415","disk.indices":"45.9gb","disk.used ":"64.3gb","disk.avail":"132.4gb","disk.total":"19 6.7gb","disk.percent":"32","host":"192.168.3.147", "ip":"192.168.3.147","node":"0tgwN5c"}, {"shards":"415","disk.indices":"46.5gb","disk.used ":"66.3gb","disk.avail":"130.3gb","disk.total":"19 6.7gb","disk.percent":"33","host":"192.168.2.166", "ip":"192.168.2.166","node":"W2uMftY"}, {"shards":"415","disk.indices":"46.3gb","disk.used ":"65gb","disk.avail":"131.7gb","disk.total":"196. 7gb","disk.percent":"33","host":"192.168.1.162","i p":"192.168.1.162","node":"Di5mfU0"}, {"shards":"416","disk.indices":"44.9gb","disk.used ":"63.7gb","disk.avail":"133gb","disk.total":"196. 7gb","disk.percent":"32","host":"192.168.1.139","i p":"192.168.1.139","node":"CbLHvlq"}, {"shards":"415","disk.indices":"45.4gb","disk.used ":"64.5gb","disk.avail":"132.2gb","disk.total":"19 6.7gb","disk.percent":"32","host":"192.168.1.167", "ip":"192.168.1.167","node":"8oXIke8"}] I can read this status into a text item, then i was hoping to create a Dependant item for each host, pre-process the 'disk.total' value using JSONPath and thats where I fell down.
    I tried various JSONPath parameters like $.disk.percent, $.[disk.percent], $.["disk.percent"] all threw errors like:-
    'Preprocessing failed for: [{"shards":"415","disk.indices":"46.2gb","disk.used ":"64.8gb","disk.avail":"131.8gb","disk.total" ...
    1. Failed: cannot extract value from json by path "$."disk.percent"": unsupported character in json path starting with: "."disk.percent""'

    1. can anyone suggest a better way of doing this?
    2. Can JSONPath even be used to get a item with a . in it?

    Many Thanks!
  • Swaffy10
    Junior Member
    • Oct 2019
    • 2

    #2
    Brilliant, thanks very much Splitek.

    Comment

    Working...