show snmp
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",
  "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": {
    "type": "cli_show",
    "version": "1.0",
    "sid": "eoc",
    "outputs": {
      "output": {
        "input": "show snmp",
        "msg": "Success",
        "code": "200",
        "body": {
          "sys_contact": "",
          "sys_location": "",
          "snmp_input_packets": "3 SNMP packets input",
          "bad_snmp_version": "        0 Bad SNMP versions",
          "unknown_community_name": "  0 Unknown community name",
          "illegal_community_name": "  0 Illegal operation for community name supplied",
          "encoding_Err": "    0 Encoding errors",
          "req_var_nums": "    3 Number of requested variables",
          "alt_var_nums": "    0 Number of altered variables",
          "get_req_in": "      0 Get-request PDUs",
          "getnext_req_in": "  2 Get-next PDUs",
          "set_req_in": "      0 Set-request PDUs",
          "noname_pdu_in": "   0 No such name PDU",
          "badval_pdu_in": "   0 Bad value PDU",
          "ro_pdu_in": "       0 Read Only PDU",
          "genral_err_in": "   0 General errors",
          "get_resp_in": "     0 Get Responses",
          "unknown_ctx": "     0 Unknown Context name",
          "snmp_output_packets": "155 SNMP packets output",
          "trap_pdu": "        152 Trap PDU",
          "toobig_err": "      0 Too big errors (Maximum packet size 1500)",
          "noname_pdu_out": "  0 No such name errors",
          "badval_pdu_out": "  0 Bad values errors",
          "genral_err_out": "  0 General errors",
          "get_req_out": "     0 Get Requests",
          "getnext_req_out": " 0 Get Next Requests",
          "set_req_out": "     0 Set Requests",
          "get_resp_out": "    3 Get Responses",
          "silent_drops": "    0 Silent drops",
          "max_pkt_size": "Max packetsize: 1500",
          "tcp_auth_status": "SNMP Tcp Authentication Flag : Enabled.",
          "protocol_status": "SNMP protocol : Enabled",
          "TABLE_snmp_users": {
            "ROW_snmp_users": [
              {
                "user": "test                ",
                "auth": "md5   ",
                "priv": "des(no)       ",
                "TABLE_groups": {
                  "ROW_groups": {
                    "group": "network-operator    "
                  }
                }
              },
              {
                "user": "admin               ",
                "auth": "md5   ",
                "priv": "des(no)       ",
                "TABLE_groups": {
                  "ROW_groups": {
                    "group": "network-admin       "
                  }
                }
              }
            ]
          },
          "TABLE_snmp_community": {
            "ROW_snmp_community": {
              "community_name": "public",
              "grouporaccess": "network-operator    ",
              "context": "",
              "aclfilter": ""
            }
          },
          "TABLE_snmp_contexts": {
            "ROW_snmp_contexts": [
              {
                "context_name": "1",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "1"
              },
              {
                "context_name": "2",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "2"
              },
              {
                "context_name": "3",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "3"
              },
              {
                "context_name": "4",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "4"
              },
              {
                "context_name": "5",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "5"
              },
              {
                "context_name": "6",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "6"
              },
              {
                "context_name": "7",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "7"
              },
              {
                "context_name": "8",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "8"
              },
              {
                "context_name": "9",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "9"
              },
              {
                "context_name": "10",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "10"
              },
              {
                "context_name": "vlan-1",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "1"
              },
              {
                "context_name": "vlan-2",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "2"
              },
              {
                "context_name": "vlan-3",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "3"
              },
              {
                "context_name": "vlan-4",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "4"
              },
              {
                "context_name": "vlan-5",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "5"
              },
              {
                "context_name": "vlan-6",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "6"
              },
              {
                "context_name": "vlan-7",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "7"
              },
              {
                "context_name": "vlan-8",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "8"
              },
              {
                "context_name": "vlan-9",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "9"
              },
              {
                "context_name": "vlan-10",
                "proto_instanceid": "",
                "vrf": "",
                "topology": "",
                "vlan": "10"
              }
            ]
          }
        }
      }
    }
  }
}