Ad Widget

Collapse

Resources for Help Parsing JSON For Discovery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benderisgreat
    Junior Member
    • Dec 2020
    • 6

    #1

    Resources for Help Parsing JSON For Discovery

    In our environment, we have a lot of servers, each of which can have any number of PHP-FPM versions running each with their own set of pools.

    My goal is to either have discovery items for either each version, or for each pool (debating which one is more useful)

    In any case, I have written a script for Zabbix to run remotely on each server that sends back a JSON string.

    For the initial output, it is formatted as follow and easily rearrangeable:

    {
    "php_versions": {
    "7.2.34": {
    "nobody": {
    "pool": "nobody",
    "process manager": "ondemand",
    "start time": 1608664688,
    "start since": 695189,
    "accepted conn": 12090,
    "listen queue": 0,
    "max listen queue": 0,
    "listen queue len": 0,
    "idle processes": 0,
    "active processes": 0,
    "total processes": 0,
    "max active processes": 1,
    "max children reached": 0,
    "slow requests": 0,
    "processes": []
    },
    "pool2": {
    "pool": "pool2",
    "process manager": "ondemand",
    "start time": 1608664688,
    "start since": 695189,
    "accepted conn": 225,
    "listen queue": 0,
    "max listen queue": 0,
    "listen queue len": 0,
    "idle processes": 0,
    "active processes": 0,
    "total processes": 0,
    "max active processes": 4,
    "max children reached": 0,
    "slow requests": 0,
    "processes": []
    }
    },
    "7.3.25": {
    "nobody73": {
    "pool": "nobody73",
    "process manager": "ondemand",
    "start time": 1608664686,
    "start since": 695191,
    "accepted conn": 119,
    "listen queue": 0,
    "max listen queue": 0,
    "listen queue len": 0,
    "idle processes": 0,
    "active processes": 0,
    "total processes": 0,
    "max active processes": 1,
    "max children reached": 0,
    "slow requests": 0,
    "processes": []
    },
    ...

    To the questions:

    What are some good resources for how to make a discovery rule from this returned data? I am kind of at a loss currently. I put the system.run command in as the key for a discovery rule, tried to make a preprocessing rule, hit test but it doesn't seem to be trying to use data returned from the command, just the command string itself.

    Is it recommended to do any overall data calculations (like, number of pools, total cpu use per version, etc) on the agent side (if it is even possible to do on the server side)?

    The current data structure is so if a version of php or a pool is locked up or taking all resources we can just restart the right php version - but there are a lot of ways to do it and even looking at it in prettyprint I might just add the version in with the pool statistics and take out a level.


Working...