Ad Widget

Collapse

How to use {HOST.HOST} in JSONPath preprocessing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • schewe_bbn
    Junior Member
    • Aug 2022
    • 1

    #1

    How to use {HOST.HOST} in JSONPath preprocessing

    I'm monitoring a postgresql cluster that is running pgpool. To check the status of the backend database nodes I'm running
    Code:
    psql -h psql.mgmt.bbn.com -p 9898 -U zbx_monitor postgres -c "show pool_nodes" --csv
    This outputs the following:
    Code:
    node_id,hostname,port,status,pg_status,lb_weight,role,pg_role,select_cnt,load_balance_node,replication_delay,replication_state,replication_sync_state,last_status_change
    0,psql-01.mgmt.bbn.com,5432,up,up,0.333333,primary,primary,1028776,true,0,,,2022-08-19 11:16:06
    1,psql-02.mgmt.bbn.com,5432,down,down,0.333333,standby,unknown,0,false,0,,,2022-08-19 11:16:06
    2,psql-03.mgmt.bbn.com,5432,down,up,0.333333,standby,standby,0,false,0,streaming,sync,2022-08-19 11:16:06
    I can convert this to JSON pretty easily and find the data for a particular host by using a JSONPath of
    Code:
    $.[?(@.hostname == "psql-02.mgmt.bbn.com")].first()
    And then picking the value that I need. However I'd like to replace "psql-02.mgmt.bbn.com" with a variable representing the host that zabbix is currently monitoring.

    How do I go about doing this?

    Thank you
Working...