Ad Widget

Collapse

Get latest value 24 hours ago

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ZabbixAutomaton
    Junior Member
    • Mar 2019
    • 1

    #1

    Get latest value 24 hours ago

    Im working on a python script that does some analysis. This script uses the following zabbix api to get last value of an item:

    ```
    getlastvalue = {
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
    "output": "extend",
    "hostids": "10084",
    "search": {
    "key_": "vfs.fs.size[/var/log,used]"
    },
    "sortfield": "name"
    },
    "auth": mytoken,
    "id": 1
    }

    ```

    My script analyzes the response and produces this feedback:

    ```
    LatestValue:499728384 LatestValueEpoch:1553573850 HowLongAgo:33secs ItemID:51150
    ```

    Now, I wish to know what the value of the item was 24 hours ago...meaning 24 hours from the LatestValueEpoch time. This is where Im having an issue. I think I may not be using the right json. But here's what I've been using:

    ```
    historyget = {
    "jsonrpc": "2.0",
    "method": "history.get",
    "params": {
    "output": [
    "itemid",
    "extend"
    ],
    "time_from" : "",
    "time_to" : "",
    "itemids": [
    "23715"
    ]
    },
    "auth": mytoken,
    "id": 1
    }
    ```

    I replace the value of time_from and time_to in my script to reflect yesterday's time (24 hours ago exactly from the current time). But the response I get isnt what I want. What am i doing wrong here?
  • brunohl
    Senior Member
    Zabbix Certified Specialist
    • Mar 2019
    • 215

    #2
    What is the API response?

    Comment

    Working...