SNMP V3 host addition via API

Hello All,

I am trying to add SNMP v3 host via API, Can someone help with attributes which need to be mentioned while calling web API.

Thanks in Advance.

Regards,
DD

Hi,
first you can add a system with the needed attributes as a template. After that, use API to get this host information. Important: Use effective_attributes=1
In the jason output you can find the needed attributes.

Cheers,
Christian

Thanks @ChristianM I will check and update.

Regards,
DD

Tried but devices getting added in SNMP V2 with community.

Got below response from properly added host in snmp v3.

{‘result’: {‘attributes’: {‘ipaddress’: ‘127.0.0.1’, ‘tag_snmp’: ‘snmp-v2’, ‘snmp_community’: (‘noAuthNoPriv’, ‘test1’), ‘tag_agent’: ‘no-agent’}, ‘hostname’: ‘test1’, ‘path’: ‘test’}, ‘result_code’: 0}

I have tried below command. Host added but in Snmp-V2.

curl --insecure “http://10.10.10.10/prod/check_mk/webapi.py?action=add_host&_username=automation&_secret=xxxxxxxxxxxxxxxx” -d ‘request={“folder”:“test”,“hostname”:“FW238”,“attributes”:{“site”:“prod”,“ipaddress”:“10.10.10.15”,“tag_agent”:“no-agent”,“alias”:“prod-fw”,“tag_snmp”:“snmp-v2”,“snmp_community”:"(‘noAuthNoPriv’, ‘sec1’)"}}’

Is there any issue with command. Please suggest.

Regards,
DD

Hi,

you payload is not ok. Please change tag_snmp to tag_snmp_ds and use a list instead of tuple:

"snmp_community": ["noAuthNoPriv", "sec1"],

Here the working payload:

'request={"folder":"test","hostname":"FW238","attributes":{"site":"demo","ipaddress":"10.10.10.15","tag_agent":"no-agent","alias":"prod-fw","tag_snmp_ds":"snmp-v2","snmp_community":["noAuthNoPriv", "sec1"]}}'

Cheers,
Christian

Hi,

I have tried mentioned payload but getting unknown hosttag for tag_snmp_ds.

{“result”: “Check_MK exception: Unknown host tag group snmp_ds”, “result_code”: 1}

I am using 1.5.p021 raw version. Sorry to mentioned it late.

Regards,
DD

Hi,

please look at the effective attributes to find the correct tag for version 1.5.

Cheers,
Christian

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.