show snmp host
Python
Copy
import json

"""
Modify these please
"""
url='http://<IP_Address>/ins'
switchuser='<User_ID>'
switchpassword='<Password>'

myheaders={'content-type':'application/json'}
payload={
  "ins_api":{
  "version": "1.0",
  "type": "cli_show",
  "chunk": "0",
  "sid": "1",
  "input": "show snmp host",
  "output_format": "json"
}

response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json()
output = json.dumps(response, indent=4, sort_keys=True)


{

    "ins_api": {
        "outputs": {
            "output": {
                "body": {
                    "TABLE_host": {
                        "ROW_host": [
                            {
                                "host": "10.157.150.137", 
                                "level": "noauth ", 
                                "port": "162  ", 
                                "secname": "public                          ", 
                                "type": "trap   ", 
                                "version": "v2c      "
                            }, 
                            {
                                "host": "172.22.49.19", 
                                "level": "noauth ", 
                                "port": "2162 ", 
                                "secname": "public                          ", 
                                "type": "trap   ", 
                                "version": "v2c      "
                            }, 
                            {
                                "host": "172.31.146.186", 
                                "level": "noauth ", 
                                "port": "2162 ", 
                                "secname": "public                          ", 
                                "type": "trap   ", 
                                "version": "v2c      "
                            }
                        ]
                    }
                }, 
                "code": "200", 
                "input": "show snmp host", 
                "msg": "Success"
            }
        }, 
        "sid": "eoc", 
        "type": "cli_show", 
        "version": "1.0"
    }
}