Skip to content

A thin layer of Elixir poured atop net-snmp utilities

License

Unknown, WTFPL licenses found

Licenses found

Unknown
LICENSE.EX_DOC
WTFPL
COPYING.WTFPL
Notifications You must be signed in to change notification settings

yeongsheng-tan/net-snmp-elixir

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

net-snmp-elixir

Build Status

A thin layer of Elixir poured atop net-snmp utilities. To be used with snmp-mib-elixir.

See the API documentation.

To use:

iex> credential = NetSNMP.credential :v2c, "public"
[version: "2c", community: "public"]

iex> agent = URI.parse "snmp://192.0.2.2"
%URI{authority: "192.0.2.2", fragment: nil, host: "192.0.2.2", path: nil,
 port: nil, query: nil, scheme: "snmp", userinfo: nil}

iex> sysname_object = SNMPMIB.object ".1.3.6.1.2.1.1.5", :string, ""
%SNMPMIB.Object{oid: [1, 3, 6, 1, 2, 1, 1, 5], type: 4, value: ""}

iex> sysname_object |> SNMPMIB.index(0) |> NetSNMP.get(agent, credential)
[ok: %SNMPMIB.Object{oid: [1, 3, 6, 1, 2, 1, 1, 5, 0], type: 4, value: "R1"}]


iex> ip_net_to_media_table_object = SNMPMIB.object "1.3.6.1.2.1.4.22", :any, nil
[ok: %SNMPMIB.Object{oid: [1, 3, 6, 1, 2, 1, 4, 22], type: 0, value: nil}]

iex> NetSNMP.walk ip_net_to_media_table_object, agent, credential
[ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,1,2,192,0,2,1], type: 2, value: 2},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,1,2,192,0,2,2], type: 2, value: 2},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,2,2,192,0,2,1], type: 4, value: "66:fb:30:37:c3:81"},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,2,2,192,0,2,2], type: 4, value: "c2:1:39:f3:0:0"},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,3,2,192,0,2,1], type: 4, value: "192.0.2.1"},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,3,2,192,0,2,2], type: 4, value: "192.0.2.2"},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,4,2,192,0,2,1], type: 2, value: 3},
 ok: %SNMPMIB.Object{oid: [1,3,6,1,2,1,4,22,1,4,2,192,0,2,2], type: 2, value: 4}]


iex> ip_cidr_route_table_object = SNMPMIB.object "1.3.6.1.2.1.4.24.4", :any, nil
%SNMPMIB.Object{oid: [1, 3, 6, 1, 2, 1, 4, 24, 4], type: 0, value: nil}

iex> NetSNMP.table ip_cidr_route_table_object, agent, credential
[%{age: "313", dest: "192.0.2.2", ifindex: "2", info: "SNMPv2-SMI::zeroDotZero",
   mask: "255.255.255.254", metric1: "0", metric2: "-1", metric3: "-1",
   metric4: "-1", metric5: "-1", nexthop: "0.0.0.0", nexthopas: "0", proto: "2",
   status: "1", tos: "0", type: "3"},
 %{age: "2", dest: "192.0.2.33", ifindex: "6", info: "SNMPv2-SMI::zeroDotZero",
   mask: "255.255.255.255", metric1: "0", metric2: "-1", metric3: "-1",
   metric4: "-1", metric5: "-1", nexthop: "0.0.0.0", nexthopas: "0", proto: "2",
   status: "1", tos: "0", type: "3"}]

For now, this assumes you (1) have net-snmp utilities installed and (2) snmpget, snmpset, etc. are in your $PATH.

About

A thin layer of Elixir poured atop net-snmp utilities

Resources

License

Unknown, WTFPL licenses found

Licenses found

Unknown
LICENSE.EX_DOC
WTFPL
COPYING.WTFPL

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 99.8%
  • Shell 0.2%