Ad Widget

Collapse

item.get selectPreprocessing trim - not sure how to implement API call

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gessel
    Junior Member
    • Mar 2017
    • 24

    #1

    item.get selectPreprocessing trim - not sure how to implement API call

    Following an example, getting latest data for a host via the API and Perl is pretty straight forward:

    Code:
    $json = {
    jsonrpc=> '2.0',
    method => 'item.get',
    params =>
    {
    output => ['itemid','name','key_','lastvalue'],
    host => "Group Temp",
    sortfield => 'name'
    },
    id => 3,
    auth => "$authID",
    };
    $response = $client->call($url, $json);

    which is super nice and all but returns values to 4 decimal places and only two are significant

    I noticed selectPreprocessing "Left trim" would suggest that I can preprocess the API call to return values left trimmed to drop the last two digits, but I'm not sure how. The 4.x API documentation doesn't have an example, the 5.x documentation example isn't obvious to me.

    Does anyone have implementation examples? Seems like a convenient feature.

    -David
  • gessel
    Junior Member
    • Mar 2017
    • 24

    #2
    I assume selectPreprocessing calls a routine to perform some task on the data between extracting it via the API and handing it off to the calling routine. For example - the value retrieved is "11" but the custom multiplier is 0.1 so the value returned by the call would be "1.1" Or for example, if the value returned is 27.1200 but if the last two decimals are not significant one might request a "trim" function so they're not returned and so one doesn't have to call a separate data grooming function in the requesting routine, something that is helpful and convenient (thanks devs!)

    But I just don't know how to format the call. I have to pass the the type of preprocessing requested and some parameter to format that preproccssing type. So is it something like

    selectPreprocessing => '2' "0"; ?

    Further, trim functions vary (lisp different from java different from C++, though I assume given the front end is in PHP that this is probably the PHP variant ) which would imply that that it calls "rtrim" with the "string" being the returned value from the API call and it should accept $character_mask from the API request... but... well... I just don't know how to format that call.

    Comment

    • gessel
      Junior Member
      • Mar 2017
      • 24

      #3
      Oh - that makes sense - if there's custom processing as part of the zabbix side configuration you can get that with the API, not actually perform the preprocessing with the API call. Thanks! that's a very helpful explanation!

      Comment

      Working...