Skip to content

Instantly share code, notes, and snippets.

@alexnavis
Last active May 23, 2017 09:44
Show Gist options
  • Save alexnavis/4bd8a5e3b6c924f72ad51036f5e990ac to your computer and use it in GitHub Desktop.
Save alexnavis/4bd8a5e3b6c924f72ad51036f5e990ac to your computer and use it in GitHub Desktop.
SNMP Elixir / Erlang v3
:snmpm.start()
:snmpm.register_user('v3_default_user', :snmpm_user_default, nil, [])
# Public SNMP simulator - http://snmpsim.sourceforge.net/public-snmp-simulator.html
engine_id = "80004fb805636c6f75644dab22cc" |> Base.decode16!(case: :mixed) |> :binary.bin_to_list
user_name = 'usr-md5-none'
password = 'authkey1'
auth_key = :snmp.passwd2localized_key(:md5, password, engine_id)
ip_address = {104,236,166,95}
:snmpm.verbosity(:all, :trace)
:snmpm.register_usm_user(engine_id, user_name, [auth: :usmHMACMD5AuthProtocol, auth_key: auth_key, priv: :usmNoPrivProtocol, priv_key: []])
:snmpm.register_agent('v3_default_user', 'v3_agent', [engine_id: engine_id, address: ip_address, version: :v3, sec_model: :usm, sec_name: user_name, sec_level: :authNoPriv ])
# warm - up to sync engineBoot and engineTime for the first to cache the value in SNMPM ets tables
:snmpm.sync_get('v3_default_user', 'v3_agent', [], 2000)
:snmpm.sync_get('v3_default_user', 'v3_agent', [[1,3,6,1,2,1,1,1,0]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment