Ad Widget

Collapse

API 1.8.4 / wrong macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alain Ganuchaud
    Member
    Zabbix Certified Trainer

    • Mar 2009
    • 49

    #1

    API 1.8.4 / wrong macro

    Hello,

    I updated zabbix with 1.8.4, I am using php scripts to do various things through APIs using zabbix-1-8-api-php-class-v1-0 from Andrew Farley. I can't get working one of them which creates macros at host level.

    API complains that macro begins with { ??

    Thanks for help
    Alain

    --

    Below is the php code ...........

    ZabbixAPI::query('usermacro','massAdd',array('host s'=>array('hostid'=>"$hid"),'macros'=>array('macro '=>"{\$ALERTLOGPATH}",'value'=>"/usr/lib/oracle/xe/app/oracle/admin/XE/bdump/alert_XE.log")))
    or die('Unable to update: '.print_r(ZabbixAPI::getLastError(),true));

    Below is the Debug Output .............

    CURL URL: https://server/api_jsonrpc.php
    <br>CURL Options: Array
    (
    [19913] => 1
    [13] => 30
    [78] => 5
    [81] =>
    [64] =>
    [52] => 1
    [74] => 1
    [10023] => Array
    (
    [0] => Content-Type: application/json-rpc
    [1] => User-Agent: ZabbixAPI v1.0 - http://andrewfarley.com/zabbix_php_api
    )

    [10036] => POST
    [10015] => {"auth":"b1a6055e545c63fa7bcf6b6d97051396","method ":"usermacro.massAdd","id":1,"params":{"hosts":{"h ostid":"10050"},"macros":{"macro":"{$ALERTLOGPATH} ","value":"eeeeeeeee"}},"jsonrpc":"2.0"}
    [10102] => gzip
    )
    Got response from API: ({"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"[ CUserMacro::massAdd ] [{]: Wrong macro"},"id":1})
    Response decoded: (Array
    (
    [jsonrpc] => 2.0
    [error] => Array
    (
    [code] => -32602
    [message] => Invalid params.
    [data] => [ CUserMacro::massAdd ] [{]: Wrong macro
    )

    [id] => 1
    )
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Looks like a bug. Open a ticket https://support.zabbix.com please, this way the resolution on this can be tracked.

    When submitting please be sure to include as much information about your call, and all debug data possible.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • Alain Ganuchaud
      Member
      Zabbix Certified Trainer

      • Mar 2009
      • 49

      #3
      Thanks, this is done.

      Key: ZBX-3419
      URL: https://support.zabbix.com/browse/ZBX-3419

      Comment

      Working...