Ad Widget

Collapse

adding snmp hosts via api

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rtesen
    Junior Member
    • Oct 2025
    • 3

    #1

    adding snmp hosts via api

    Hi,
    I'm trying to add hosts via api.
    I don't understand how I can add these without specifying snmp details?
    In my script, I'm adding a template for all hosts in a specific location, that contains snmp community, bulk, snmp version macros, and nothing else.
    But when adding the hosts via api with this template, the only way I can sucessfully add snmp hosts via api is when I specifiy these details via api. And I do not want that, since I have different snmp groups that needs to be added.
    Example output when only trying to pass 'bulk' via api:
    "interfaces": [
    {
    "type": 2,
    "main": 1,
    "useip": 1,
    "ip": "10.10.10.10",
    "dns": "",
    "port": "161",
    "details": {
    "bulk": 1
    }
    }
    ],
    "groups": [
    {
    "groupid": 34
    },
    {
    "groupid": 23
    }
    ],
    "templates": [
    {
    "templateid": 10771
    },
    {
    "templateid": 10809
    }
    ]
    }
    → Error detail: Zabbix API error: {'code': -32602, 'message': 'Invalid params.', 'data': 'Incorrect arguments passed to function.'}
    Traceback (most recent call last):
    File "generate_zabbix_hosts.py", line 166, in <module>
    main()

    It also fails when omitting the entire "details" block from the interface.
    Any advice for me regarding this?
  • rtesen
    Junior Member
    • Oct 2025
    • 3

    #2
    I'm on version 7.0.18 btw.

    Comment

    • rtesen
      Junior Member
      • Oct 2025
      • 3

      #3
      Some R'n'R helped, modifying the details bit did the trick:

      "details": {
      "bulk": 1,
      "community": {$SNMP_COMMUNITY},
      "version": 2

      Comment

      Working...