MACADMINSCONFERENCE
AT PENN STATE®
The awesome world of SimpleNetworkManagementProtocol
François Joannette – FJ Consultant Manuel Deschambault – Symbiotic System Design
Feedback http://j.mp/psumac2015-132
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond…. extending… crazy stuff… Manuel?
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
sysUpTime —> .1.3.6.1.2.1.3
DISMAN-EVENT-MIB::sysUpTimeInstance
.1.3.6.1.2.1.1.3.0
Timeticks: (450831) 1:15:08.31
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond….
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• What is SNMP?
• Ports, firewall and NAT
• Components
• Versions
• MIB and OIDs
• Commands
• Must check out
• Going beyond…. extending… crazy stuff… Manuel?
MACADMINSCONFERENCE
AT PENN STATE®
Q&A
Feedback http://j.mp/psumac2015-132
MACADMINSCONFERENCE
AT PENN STATE®
How to make SimpleNetworkManagementProtocol
useful on the Macintosh
Manuel Deschambault Support Tool Architect
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Activate SNMP
• Configure SNMP
• Extend SNMP
Query
Traps
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Activate SNMP
• Configure SNMP
• Extend SNMP
Query
Traps X
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Activate SNMP
• Configure SNMP
• Extend SNMP
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Activate SNMP
• Almost always off
• Only need to activate
• Configure SNMP
• Extend SNMP
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Activate SNMP
• Configure SNMP
• Monolithic config file
• Not easy to manage
• Not easy to automate
• Extend SNMP
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
/etc/snmp
snmpd.conf
Standard anatomy of SNMP folder
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
New anatomy of SNMP folder
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
New anatomy of SNMP folder
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
MACADMINSCONFERENCE
AT PENN STATE®
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
New anatomy of SNMP folder
• Only configs requiring snmpd.conf editing
MACADMINSCONFERENCE
AT PENN STATE®
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
New anatomy of SNMP folder
• Only configs requiring snmpd.conf editing
• Code any configs needed into text files
MACADMINSCONFERENCE
AT PENN STATE®
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
New anatomy of SNMP folder
• Only configs requiring snmpd.conf editing
• Code any configs needed into text files
• Edit autoconfig.sh parser accordingly
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMP
Monolithic & not manageable
move /etc/snmp/snmpd.conf to /etc/snmp/snmp.conf.previous
set default values for:-rocommunity (public)-syslocation (not specified)-syscontact (not specified)
read:-/etc/snmp/Components/rocommunity.txt-/etc/snmp/Components/syslocation.txt-/etc/snmp/Components/syscontact.txt
are values valid?
override defaults
use defaults
YesNo
list all scripts in /etc/snmp/Components/Extensions
push rocommunity > /etc/snmp/snmpd.confpush syslocation >> /etc/snmp/snmpd.confpush syscontact >> /etc/snmp/snmpd.conf
for each script do:
extract the OID
compose the OID
push "extend <OID> <name> <script path> >> /etc/snmp/snmpd.conf
is it last one
take next script
Yes
No
restart net-snmp daemon
extract the name
autoconfig.sh parser script
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMPNot easy to automate
New anatomy of SNMP folder
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMPNot easy to automate
New anatomy of SNMP folder
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
• Set as watch folder with launchd task
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMPNot easy to automate
New anatomy of SNMP folder
/etc/snmp
Components
snmpd.conf
rocommunity.txt
syscontact.txt
syslocation.txt
Extensions examplescript.sh
autoconfig.sh
• Set as watch folder with launchd task
• Run autoconfig.sh script when modified
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMPNot easy to automate
Demo
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Activate SNMP
• Configure SNMP
• Extend SNMP
• Not a lot of pertinent data by default
• Net-SNMP agent can be extended to add useful data to our queries
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
• Benefits of extending the Net-SNMP agent
• Format of extension scripts
• Output of extension scripts
• Net-SNMP extensions vs remote SSH commands
• Standardizing
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
• Benefits of extending the Net-SNMP agent
• Returns the output of ANY script via SNMP query
• Allows very granular data to be returned
• Format of extension scripts
• Output of extension scripts
• Net-SNMP extensions vs remote SSH commands
• Standardizing
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
• Benefits of extending the Net-SNMP agent
• Format of extension scripts
• extend <OID> <name> <script path>
• Name get ascii encoded in OID, keep very short
• Output of extension scripts
• Net-SNMP extensions vs remote SSH commands
• Standardizing
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
• Benefits of extending the Net-SNMP agent
• Format of extension scripts
• Output of extension scripts
• Returns a table (1 or more values if multiple components)
• Returns a single exit value, even if multiple values in table
• Net-SNMP extensions vs remote SSH commands
• Standardizing
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocolConfigure SNMPNot easy to automate
Demo
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
• Benefits of extending the Net-SNMP agent
• Format of extension scripts
• Output of extension scripts
• Net-SNMP extensions vs remote SSH commands
• Standardizing
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
Net-SNMP extension for S.M.A.R.T. Status
SNMP Query
SNMP Server
Net-SNMP extension model
Method comparison
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
SSH command sent to Mac to get S.M.A.R.T. status SNMP Server
Remote SSH model
Method comparison
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPMethod comparison
Pros
Net-SNMP extensions Remote SSH commands
• Does not require SNMP setup of Mac• All development done on SNMP server• Data encrypted by default• Modifications can be stored in
expansion packs depending on NMS
• Very little setup on NMS server side• NMS server expansion pack can be
cross platform if OID structure is
followed also on Linux machines• Data encrypted if SNMPv3 used• Net-SNMP setup can be automated
within current deployment/
management solution• SSH can be disabled on Mac
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMP
Net-SNMP extension for S.M.A.R.T. Status
SNMP Query
SNMP Server
Net-SNMP extension model
Method comparison
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPMethod comparison
Cons
Net-SNMP extensions Remote SSH commands
• Requires SSH enabled with credentials• NMS server admin must be able to
script all platforms to monitor• Heavy processor load on NMS server
with large device count• Must make a separate expansion pack
per platform to monitor
• Configuration burden is mostly on the
computer to monitor
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPStandardizing
• What we would want to standardize
• Benefits of standardizing
• How to put this in play
• Contact me to sign-up / be updated
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPStandardizing
• What we would want to standardize
• OID structure per data point (on 43776.99)
• Scripts
• Benefits of standardizing
• How to put this in play
• Contact me to sign-up / be updated
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPStandardizing
• What we would want to standardize
• Benefits of standardizing
• Benefit from expertise of coders/scripters world wide
• NMS expansion packs can be shared, making deployment very fast and easy
• How to put this in play
• Contact me to sign-up / be updated
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPStandardizing
• What we would want to standardize
• Benefits of standardizing
• How to put this in play
• I will host an open source project for this later this summer or in the fall
• Contact me to sign-up / be updated
MACADMINSCONFERENCE
AT PENN STATE®
ConsultantFrançois Joannette
FJ Consultant
Manuel DeschambaultSupport Tool Architect
Symbiotic System Design
Feedback http://j.mp/psumac2015-132
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Extra marks (if time permits) a.k.a. “brown nosing section”
Extend SNMP
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol
• Extra marks (if time permits) a.k.a. “brown nosing section”
• What about roaming machines?
• Making extension scripts that work off the LAN
• Calling those scripts on a schedule when off the LAN
• Modifications to the anatomy of the SNMP folder
Extend SNMPRoaming solution
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
• Identifying two classes of data point
• Identifying the scripts we want to work when roaming
• Knowing if the script is called by SNMP server or while roaming
• Acting on alert
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
• Identifying two classes of data point
• Classify each data point as performance metric or status
• Isolate status scripts since those will reflect failures to alert on
• Identifying the scripts we want to work when roaming
• Knowing if the script is called by SNMP server or while roaming
• Acting on alert
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
• Identifying two classes of data point
• Identifying the scripts we want to work when roaming
• Name the extension scripts that return status data as SA_<name of script>.sh (for Stand Alone)
• Knowing if the script is called by SNMP server or while roaming
• Acting on alert
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
• Identifying two classes of data point
• Identifying the scripts we want to work when roaming
• Knowing if the script is called by SNMP server or while roaming
• When script is called by the scheduled launchd task, pass it a variable. If this is empty, then the script was called by SNMP query and is on the LAN.
• Acting on alert
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
roamingcheck.sh was executed per schedule
get /etc/snmp/snmpserver.txt
Is it empty
?
Machine not configured for roaming.
Exit script
Does IP
ping?
SNMP Server can be reached.
Exit script
List and execute all scripts in/etc/snmp/Components/Extensions
that start with SA_
Exit script
YesNoYes
No
roamingcheck.sh script
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
Start of script StandAlone=$1 Gather Data Point
Was threshold exceeded
?theExit=1
Generate the alert message
Pass message to/etc/snmp/roamalert.sh
echo data point
How was script
executed?
More data
points?
End of script
Exit with exit code
Yes
theExit=0
echo data point
No
SNMP Query
Roaming
No
Yes
SA_Example.sh script
MACADMINSCONFERENCE
AT PENN STATE®
SimpleNetworkManagementProtocol Extend SNMPRoaming solution
• Identifying two classes of data point
• Identifying the scripts we want to work when roaming
• Knowing if the script is called by SNMP server or while roaming
• Acting on alert
• roamalert.sh script is called with error message
• personalize roamalert.sh to execute the alert mechanism of your choice
MACADMINSCONFERENCE
AT PENN STATE®
François Joannette – FJ Consultant Manuel Deschambault – Symbiotic System Design
Feedback http://j.mp/psumac2015-132