Ad Widget

Collapse

read custom dashboard screen with api

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Firmbyte
    Junior Member
    • Nov 2018
    • 2

    #1

    read custom dashboard screen with api

    *Zabbix newbie here.

    My place of work use Zabbix, with Custom screens, and I'm trying to read the info on them. The custom screen shows processes that are running on server, separated by server. I've been using screen.get and screenitem.get but not getting the information that is displayed on the page.....only getting this type of info, see below. How can I get the actual information that is displayed on the page? it's in text.

    screenitemid : 3054
    screenid : 226
    resourcetype : 11
    resourceid : 0
    width : 500
    height : 50
    x : 0
    y : 3
    colspan : 1
    rowspan : 1
    elements : 0
    valign : 2
    halign : 1
    style : 0
    url : http://00.00.0.00/info/v.html
    dynamic : 0
    sort_triggers : 0
    application :
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    screen.get and screenitem.get are APIs that get what settings are done for the screen.
    It is not an API to retrieve images and data displayed on the screen.

    Comment


    • Firmbyte
      Firmbyte commented
      Editing a comment
      Problem solved...
      $Itemget = @{
      jsonrpc = "2.0"
      method = "item.get"
      params = @{
      output = "extend"
      itemids = $itemlist
      sortfield = "name"
      }
      auth = $session.result
      id = $session.id
      } | ConvertTo-Json

      Invoke-RestMethod "$site/api_jsonrpc.php" -ContentType "application/json" -Body $itemget -Method Post
  • Firmbyte
    Junior Member
    • Nov 2018
    • 2

    #3
    I solved the problem using the query below, including 2 functions to convert the lastclock to locatime and another to get the Host name from the hostid.

    Code:
    $Itemget = @{
        jsonrpc = "2.0"
        method = "item.get"
        params = @{
            output = "extend"
            itemids = $itemlist
            sortfield = "name"
        }
        auth = $session.result
        id = $session.id
    }  | ConvertTo-Json
    
    $Results = Invoke-RestMethod "$site/api_jsonrpc.php" -ContentType "application/json" -Body $itemget -Method Post
    ForEach($item in $Results.result) {
                    $output += [PSCustomObject] @{
                        Itemid = $item.itemid ;
                        Host = Get-HostNamefromId($item.hostid) ;
                        Lastclock = Convert-FromUnixdate($item.lastclock) ;
                        Lastvalue = $item.lastvalue ;
                        Prevvalue = $item.Prevvalue ;
                        }
        }
    $output

    Comment

    Working...