SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
SNMP::Class!
 Athanasios Douitsis
Very Brief SNMP Intro

 •  SNMP agent (daemon - responding to requests)
 •  SNMP management station (making of requests)
 •  UDP, port 161  
 •  SNMP PDUs: SNMP GET , GET-NEXT, GETBULK,
    notifications, SNMP-SET, etc
     o  Basic Encoding Rules (BER)
 •  Structure of Management Information (SMIv2, ASN.1
    subset)
     o  Types (integer, string, etc)
     o  MIBs (standard, vendor-specific)
           Managed Object Semantics 
           Managed Object Hierarchy

    
                      SNMP::Class
                 2
Very Brief SNMP Intro Example

Piece of knowledge:
 .1.3.6.1.2.1.2.2.1.5.15 = 100000000 (k-v pair)

•  Object ID (OID): .1.3.6.1.2.1.2.2.1.5.15 
   o  Object: .1.3.6.1.2.1.2.2.1.5 or .iso(1).org(3).dod(6).internet
      (1).mgmt(2).mib-2(1).interfaces(2).ifTable(2).ifEntry(1).ifSpeed(5) or
      simply ifSpeed
          Semantics: "the speed of an interface" 
          Type: Gauge32 (32-bit integer)
   o  Instance: .15 (row 15 in interface table)

•  Value: 100.000.000 (100M) === 100Mbps for ifSpeed 

                                     SNMP::Class
                              3
Writing network management tools

Network management tools using SNMP:

•  Small complexity, i.e. a nagios plugin

•  Medium complexity, i.e. a topology discovery tool

•  (Very) High complexity, i.e. a Network Management System
   (NMS) (mostly commercial systems)


Burden of using SNMP properly for small or medium size
software

                             SNMP::Class
                4
Problem Statement
•  Perl : Availability of high performance, high quality libraries
   for SNMP
    o  Net-SNMP: SNMP.pm (XS, very fast, used by
       SNMP::Class)
    o  Net::SNMP (pure Perl)
•  Usage of SNMP libraries for querying managed devices
   (routers, switches, servers, etc)
•  Typical network management tool:
    1. retrieval of info from device(s) by library
    2. organization of library returned data into suitable
       structure
    3. Conversions of data as necessary
    4. Processing, calculations on data

                              SNMP::Class
                      5
Problem Statement (2)
Impedance mismatch between the programming language (not
just Perl) and the SNMP-SMI world

Issues:
 •  OIDs returned in various forms (ifType, .1.3.6...)  
 •  Data types of values returned not always directly usable
     o  IP addresses, Mac addresses, Gauges, Enumerations
     o  Varying between libraries
 •  Error codes from library (end of mib, timeout, etc)
 •  SNMP agents
     o  Bugs in older implementations 
           missing OIDs
           broken loops, etc
     o  Difference between GET-NEXT and GET-BULK
 •   Usability of structure of returned data (array, hash, etc) --->
    considerable effort
        SNMP::Class
                      6
Problem Statemement (3)
Some examples of cumbersomeness:
my ($instance) = ($key =~ /^ifSpeed.(d+)$/)	
my ($instance) = ($key =~ /^.1.3.6.1.2.1.2.2.1.5.(d+)$/)	


my $bridge_id = uc join(':',(unpack 'n(H2)*',$value)[1..6]);	



for my   $key (%kv) {	
    if   ($key =~ /^ifDescr.(d+)$/) {	
          $descriptions{$1} = $kv{$key};	
    }	
}	
for my   $key (%kv) {	
    if   ($key =~ /^ifType.(d+)$/) {	
          say "interface ".$descriptions{$1}." is a ".$kv{$key}	
    }	
}	


                                 SNMP::Class
                      7
SNMP::Class goals 
•  Usage of existing excellent libraries for Perl
•  Minimization of programmer-required knowledge of SNMP
   esoteric (and arcane) details
•  Brief syntax for clarity and brevity, DWIM as much as
   possible
•  Easy connection setup with agents, provision of sensible
   defaults
•  Automatic optimization of communication with agents,
   automatic handling of agent bugs
•  Orthogonal error reporting, proper usage of exceptions 
•  Effortless navigation/querying of structure of returned data
   from agents
•  Automatic encapsulation of values, taking into account
   OID semantics, type (MIB and PDU), display-hint
•  Ultimately, complete encapsulation of SNMP
                            SNMP::Class
                     8
Library Overview - Connection Setup
my $c = SNMP::Class->new('myrouter.mydomain');	

•  Probing of SNMP version (try 2, then 1)
•  Querying of sysName.0




                            SNMP::Class
          9
Library Overview - OIDs
•  OID: A series of integers
    o  representable by a label (example: 'ifType')
•  Complete encapsulation of the OID (creation, addition,
   comparing, etc)

my $oid1 = SNMP::Class::OID->new('.1.3.6.1.4.1');	

my $oid2 = SNMP::Class::OID->new('interfaces');	

$oid2->contains('ifDescr'); #true	

my $oid3 = SNMP::Class::OID->new('ifDescr')->add(15); #ifDescr.15	


•  Also, automatic separation of instance when possible

$oid3->get_instance_oid; #returns a .15 oid	


                              SNMP::Class
                     10
Library Overview - Varbinds
•  Varbind: An OID with a value (SNMP::Class::Varbind)
•  Value connected with the specific OID semantically!
•  Attribute raw_value for all varbinds
    o  Just the bytes, completely unprocessed
•  Method value for most varbinds
    o  What is expected by a human
•  Varbind enhancement methods
   •  depending on OID semantics
   •  Automatically available


Examples:
$iftype->raw_value #6	
$iftype->value #'ethernetCsmacd', enum of 6	

$designated_bridge->raw_value; #8 bytes,unprintable 	
$bridge_id->value; # '80:00:00:06:28:84:D7:40'	
$bridge_id->mac_address #'00:06:28:84:D7:40'	
$bridge_id->priority #32768	
                             SNMP::Class
                 11
Library Overview - Querying of agent

$c->add('system','interfaces');	

•  Walking of system and intefaces trees on agent
    o  If SNMPv2 available, usage of GETBULK
•  Query result storage inside $c (separate result objects
   possible as well)
    o  $c: connection object and result object




                            SNMP::Class
                     12
Library Overview - The ResultSet
ResultSet -  a set of OID-value pairs (varbinds)
•  Filtering of set through methods

$rs->filter_label('ifSpeed'); #keep only ifSpeed OIDs	

•  Method chaining (returning of new ResultSets)

$rs->filter_label('ifSpeed')->filter_instance(3)	

•  Method autoloading with OID label names

$rs->ifSpeed(3) #same as previous, more clear     	
•  Generic filter (grep) available:
$rs->filter(sub { 	
    return 1 if $_->get_label eq 'ifSpeed';   	
    return	
});	
                              SNMP::Class
               13
Library Overview - The ResultSet (2)

•  More advanced filtering 

#Find speed of interface 'eth0'      	
say $rs->filter_label('ifSpeed')->filter_instance($rs-
>filter_label('ifDescr')->filter_value('eth0')-
>get_instance_oid)->value; 	
#the same, much more clearly and briefly:    	
say $rs->find('ifDescr' => 'eth0')->ifSpeed->value;	
#Keep the instance for which the ifDescr equals 'eth0', then
keep only the ifSpeed. 	



                              SNMP::Class
               14
Library Overview - The ResultSet (3)
 •  Iteration over contents, detection of list context

#print the description of each interface         	
for($rs->ifDescr) {     	
    say $_->value   	
}	
 •  Filter and map methods
     o  Used exactly as list grep and map with BLOCK

my $new_rs = $rs->filter(sub { ..... });         	
my $new_rs = $rs->map(sub { ..... });        	
    




                              SNMP::Class
                15
Library Overview - The ResultSet (4)

•  Final touch: Resultset with 1 varbind:

$rs->ifDescr(3)->item(0)->value;       	
#the same:	
$rs->ifDescr(3)->value;   	
Varbind methods valid on 1-item ResultSets.

•  Overloading also possible, but:
   o  Awkward behavior when using list context
   o  Awkward behavior when using operators like '.'



                              SNMP::Class
              16
Library Implementation (so far)
Built using Moose.pm 
Class & Role Hierarchy:
•  Classes:
   o    SNMP::Class - Session object (mostly empty, gaining functionality from
        Role::ResultSet and Role::Implementation::Net-SNMP)
   o    SNMP::Class::ResultSet - Results object (ditto)
   o    SNMP::Class::OID - An OID 
           SNMP::Class::Varbind - A varbind (OID+value)
•  Roles:
   o    SNMP::Class::Role::ResultSet - resultset behavior
   o    SNMP::Class::Role::Implementation - SNMP Instrumentation (abstract
        part, not usable by itself)
           SNMP::Class::Role::Implementation::NetSNMP  - Instrumentation
            lower part using Net-SNMP (applied to SNMP::Class objects)
           SNMP::Class::Role::Implementation::Dummy - Another
            instrumentation, dummy this time
   o    SNMP::Class::Varbind::XXXXX - Varbind enhancement roles, (application
        to plain varbinds)

                                    SNMP::Class
                            17
Library Roles (2)
SNMP::Class is-a:
 •  SNMP::Class::Role::Implementation::NetSNMP
 •  SNMP::Class::Role::ResultSet

Hence, full usability (SNMP Session + Result) available through
a single object.
my $s = SNMP::Class->new('myhost');   	
$s->add('system');	
say $s->sysName->value;	
#or   	
say SNMP::Class->new('myhost')->add('system')->sysName->value;   	


                              SNMP::Class
                       18
Varbind Enhancement Roles 
Added functionality (new methods or override methods) for
SNMP::Class::Varbind objects through SNMP::Class::Varbind::
roles
Example:

#coming from SNMP::Class::Varbind   	
$bridge_id->raw_value; #8 bytes,unprintable     	
$bridge_id->value; # '80:00:00:06:28:84:D7:40'      	
#coming from SNMP::Class::Varbind::BridgeId    	
$bridge_id->mac_address #'00:06:28:84:D7:40'    	
$bridge_id->priority #32768     	
 •  Applying of role at runtime, trigger when OID and value of Varbind
    are known
__PACKAGE__->meta->apply($_[0]);	
 •  Applying of multiple roles possible
 •  Default Varbind 'value' method and other methods overridable by
    roles
                        SNMP::Class
                       19
Code!

     https://github.com/aduitsis/snmp-class

•  Stuff in current presentation almost fully implemented
•  Many many varbind enhancement roles missing
   (implementation on a need basis)
•  Only instrumentation so far from Net-SNMP
•  MIB parsing also from Net-SNMP
•  Obviously, bugs present
•  Built with Moose
•  Usage of Log::Log4Perl for logging
•  Test suite - but not 100% coverage


                            SNMP::Class
                     20
Future Directions

•  Second instrumentation wrapper from Net::SNMP (Pure
   Perl)
•  MIB parser other than from Net-SNMP
•  More Varbind enhancement roles
•  More performance fixes
•  Fix any bugs observed
•  Need to address snmpset functionality 
•  Encapsulation of entire MIBs, hide SNMP completely.
    o  (also see the very good SNMP::Info module on CPAN) 




                           SNMP::Class
                  21
Thank you for your attention

      aduitsis@cpan.org

Mais conteúdo relacionado

Mais procurados

D Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance ProblemsD Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
MySQLConference
 

Mais procurados (20)

Variables: names, bindings, type, scope
Variables: names, bindings, type, scopeVariables: names, bindings, type, scope
Variables: names, bindings, type, scope
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Adventures in TclOO
Adventures in TclOOAdventures in TclOO
Adventures in TclOO
 
C# for beginners
C# for beginnersC# for beginners
C# for beginners
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!
 
Runtime
RuntimeRuntime
Runtime
 
iOS Session-2
iOS Session-2iOS Session-2
iOS Session-2
 
12 virtualmachine
12 virtualmachine12 virtualmachine
12 virtualmachine
 
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance ProblemsD Trace Support In My Sql Guide To Solving Reallife Performance Problems
D Trace Support In My Sql Guide To Solving Reallife Performance Problems
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of Lambdas
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Scala eXchange opening
Scala eXchange openingScala eXchange opening
Scala eXchange opening
 
Java
JavaJava
Java
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 

Destaque

Snmp by akhilesh verma
Snmp by akhilesh vermaSnmp by akhilesh verma
Snmp by akhilesh verma
Akki Verma
 
SNMP Network Tracker Project
SNMP Network Tracker ProjectSNMP Network Tracker Project
SNMP Network Tracker Project
Praveen Mathews
 
Introdunction To Network Management Protocols SNMP & TR-069
Introdunction To Network Management Protocols SNMP & TR-069Introdunction To Network Management Protocols SNMP & TR-069
Introdunction To Network Management Protocols SNMP & TR-069
William Lee
 

Destaque (20)

Nagios Conference 2011 - Mike Weber - Training: Getting Started With SNMP
Nagios Conference 2011 - Mike Weber - Training: Getting Started With SNMPNagios Conference 2011 - Mike Weber - Training: Getting Started With SNMP
Nagios Conference 2011 - Mike Weber - Training: Getting Started With SNMP
 
Snmp
SnmpSnmp
Snmp
 
SNMP Overview (SNMP 소개)
SNMP Overview (SNMP 소개)SNMP Overview (SNMP 소개)
SNMP Overview (SNMP 소개)
 
Weblogic snmp
Weblogic snmpWeblogic snmp
Weblogic snmp
 
SNMP Network Management the Essentials
SNMP Network Management the EssentialsSNMP Network Management the Essentials
SNMP Network Management the Essentials
 
Snmp by akhilesh verma
Snmp by akhilesh vermaSnmp by akhilesh verma
Snmp by akhilesh verma
 
Snmp
SnmpSnmp
Snmp
 
Snmpv3
Snmpv3Snmpv3
Snmpv3
 
SNMP Network Tracker Project
SNMP Network Tracker ProjectSNMP Network Tracker Project
SNMP Network Tracker Project
 
SNMP : Simple Network Mediated (Cisco) Pwnage
SNMP : Simple Network Mediated (Cisco) PwnageSNMP : Simple Network Mediated (Cisco) Pwnage
SNMP : Simple Network Mediated (Cisco) Pwnage
 
Protocol snmp
Protocol snmpProtocol snmp
Protocol snmp
 
SNMP
SNMPSNMP
SNMP
 
Introdunction To Network Management Protocols SNMP & TR-069
Introdunction To Network Management Protocols SNMP & TR-069Introdunction To Network Management Protocols SNMP & TR-069
Introdunction To Network Management Protocols SNMP & TR-069
 
SNMP Demystified Part-II
SNMP Demystified Part-IISNMP Demystified Part-II
SNMP Demystified Part-II
 
Simple Network Management Protocol
Simple Network Management ProtocolSimple Network Management Protocol
Simple Network Management Protocol
 
SNMP
SNMPSNMP
SNMP
 
Snmp
SnmpSnmp
Snmp
 
Introduction to SNMP
Introduction to SNMPIntroduction to SNMP
Introduction to SNMP
 
Andrew Nelson - Zabbix and SNMP on Linux
Andrew Nelson - Zabbix and SNMP on LinuxAndrew Nelson - Zabbix and SNMP on Linux
Andrew Nelson - Zabbix and SNMP on Linux
 
28 Network Management_SNMP
28 Network Management_SNMP28 Network Management_SNMP
28 Network Management_SNMP
 

Semelhante a Snmp class

Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...
Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...
Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...
Spark Summit
 

Semelhante a Snmp class (20)

OSMC 2017 | SNMP explained by Rob Hassing
OSMC 2017 | SNMP explained by Rob HassingOSMC 2017 | SNMP explained by Rob Hassing
OSMC 2017 | SNMP explained by Rob Hassing
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 
Learning Puppet basic thing
Learning Puppet basic thing Learning Puppet basic thing
Learning Puppet basic thing
 
Perl basics for pentesters part 2
Perl basics for pentesters part 2Perl basics for pentesters part 2
Perl basics for pentesters part 2
 
Getting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::CGetting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::C
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2
 
2013 london advanced-replication
2013 london advanced-replication2013 london advanced-replication
2013 london advanced-replication
 
Keeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETLKeeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETL
 
R Jobs on the Cloud
R Jobs on the CloudR Jobs on the Cloud
R Jobs on the Cloud
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
DEF CON 27 - workshop - HUGO TROVAO and RUSHIKESH NADEDKAR - scapy dojo v1
DEF CON 27 - workshop - HUGO TROVAO and RUSHIKESH NADEDKAR - scapy dojo v1DEF CON 27 - workshop - HUGO TROVAO and RUSHIKESH NADEDKAR - scapy dojo v1
DEF CON 27 - workshop - HUGO TROVAO and RUSHIKESH NADEDKAR - scapy dojo v1
 
Profiling Ruby
Profiling RubyProfiling Ruby
Profiling Ruby
 
SISY 2008
SISY 2008SISY 2008
SISY 2008
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
 
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
 
Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...
Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...
Spark as the Gateway Drug to Typed Functional Programming: Spark Summit East ...
 
Overview of Apache SystemML by Berthold Reinwald and Nakul Jindal
Overview of Apache SystemML by Berthold Reinwald and Nakul JindalOverview of Apache SystemML by Berthold Reinwald and Nakul Jindal
Overview of Apache SystemML by Berthold Reinwald and Nakul Jindal
 

Último

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Último (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 

Snmp class

  • 2. Very Brief SNMP Intro •  SNMP agent (daemon - responding to requests) •  SNMP management station (making of requests) •  UDP, port 161  •  SNMP PDUs: SNMP GET , GET-NEXT, GETBULK, notifications, SNMP-SET, etc o  Basic Encoding Rules (BER) •  Structure of Management Information (SMIv2, ASN.1 subset) o  Types (integer, string, etc) o  MIBs (standard, vendor-specific)   Managed Object Semantics    Managed Object Hierarchy      SNMP::Class 2
  • 3. Very Brief SNMP Intro Example Piece of knowledge:  .1.3.6.1.2.1.2.2.1.5.15 = 100000000 (k-v pair) •  Object ID (OID): .1.3.6.1.2.1.2.2.1.5.15  o  Object: .1.3.6.1.2.1.2.2.1.5 or .iso(1).org(3).dod(6).internet (1).mgmt(2).mib-2(1).interfaces(2).ifTable(2).ifEntry(1).ifSpeed(5) or simply ifSpeed   Semantics: "the speed of an interface"    Type: Gauge32 (32-bit integer) o  Instance: .15 (row 15 in interface table) •  Value: 100.000.000 (100M) === 100Mbps for ifSpeed  SNMP::Class 3
  • 4. Writing network management tools Network management tools using SNMP: •  Small complexity, i.e. a nagios plugin •  Medium complexity, i.e. a topology discovery tool •  (Very) High complexity, i.e. a Network Management System (NMS) (mostly commercial systems) Burden of using SNMP properly for small or medium size software SNMP::Class 4
  • 5. Problem Statement •  Perl : Availability of high performance, high quality libraries for SNMP o  Net-SNMP: SNMP.pm (XS, very fast, used by SNMP::Class) o  Net::SNMP (pure Perl) •  Usage of SNMP libraries for querying managed devices (routers, switches, servers, etc) •  Typical network management tool: 1. retrieval of info from device(s) by library 2. organization of library returned data into suitable structure 3. Conversions of data as necessary 4. Processing, calculations on data SNMP::Class 5
  • 6. Problem Statement (2) Impedance mismatch between the programming language (not just Perl) and the SNMP-SMI world Issues: •  OIDs returned in various forms (ifType, .1.3.6...)   •  Data types of values returned not always directly usable o  IP addresses, Mac addresses, Gauges, Enumerations o  Varying between libraries •  Error codes from library (end of mib, timeout, etc) •  SNMP agents o  Bugs in older implementations    missing OIDs   broken loops, etc o  Difference between GET-NEXT and GET-BULK •   Usability of structure of returned data (array, hash, etc) ---> considerable effort SNMP::Class 6
  • 7. Problem Statemement (3) Some examples of cumbersomeness: my ($instance) = ($key =~ /^ifSpeed.(d+)$/) my ($instance) = ($key =~ /^.1.3.6.1.2.1.2.2.1.5.(d+)$/) my $bridge_id = uc join(':',(unpack 'n(H2)*',$value)[1..6]); for my $key (%kv) {     if ($key =~ /^ifDescr.(d+)$/) {         $descriptions{$1} = $kv{$key};     } } for my $key (%kv) {     if ($key =~ /^ifType.(d+)$/) {         say "interface ".$descriptions{$1}." is a ".$kv{$key}     } } SNMP::Class 7
  • 8. SNMP::Class goals  •  Usage of existing excellent libraries for Perl •  Minimization of programmer-required knowledge of SNMP esoteric (and arcane) details •  Brief syntax for clarity and brevity, DWIM as much as possible •  Easy connection setup with agents, provision of sensible defaults •  Automatic optimization of communication with agents, automatic handling of agent bugs •  Orthogonal error reporting, proper usage of exceptions  •  Effortless navigation/querying of structure of returned data from agents •  Automatic encapsulation of values, taking into account OID semantics, type (MIB and PDU), display-hint •  Ultimately, complete encapsulation of SNMP SNMP::Class 8
  • 9. Library Overview - Connection Setup my $c = SNMP::Class->new('myrouter.mydomain'); •  Probing of SNMP version (try 2, then 1) •  Querying of sysName.0 SNMP::Class 9
  • 10. Library Overview - OIDs •  OID: A series of integers o  representable by a label (example: 'ifType') •  Complete encapsulation of the OID (creation, addition, comparing, etc) my $oid1 = SNMP::Class::OID->new('.1.3.6.1.4.1'); my $oid2 = SNMP::Class::OID->new('interfaces'); $oid2->contains('ifDescr'); #true my $oid3 = SNMP::Class::OID->new('ifDescr')->add(15); #ifDescr.15 •  Also, automatic separation of instance when possible $oid3->get_instance_oid; #returns a .15 oid SNMP::Class 10
  • 11. Library Overview - Varbinds •  Varbind: An OID with a value (SNMP::Class::Varbind) •  Value connected with the specific OID semantically! •  Attribute raw_value for all varbinds o  Just the bytes, completely unprocessed •  Method value for most varbinds o  What is expected by a human •  Varbind enhancement methods •  depending on OID semantics •  Automatically available Examples: $iftype->raw_value #6 $iftype->value #'ethernetCsmacd', enum of 6 $designated_bridge->raw_value; #8 bytes,unprintable  $bridge_id->value; # '80:00:00:06:28:84:D7:40' $bridge_id->mac_address #'00:06:28:84:D7:40' $bridge_id->priority #32768 SNMP::Class 11
  • 12. Library Overview - Querying of agent $c->add('system','interfaces'); •  Walking of system and intefaces trees on agent o  If SNMPv2 available, usage of GETBULK •  Query result storage inside $c (separate result objects possible as well) o  $c: connection object and result object SNMP::Class 12
  • 13. Library Overview - The ResultSet ResultSet -  a set of OID-value pairs (varbinds) •  Filtering of set through methods $rs->filter_label('ifSpeed'); #keep only ifSpeed OIDs •  Method chaining (returning of new ResultSets) $rs->filter_label('ifSpeed')->filter_instance(3) •  Method autoloading with OID label names $rs->ifSpeed(3) #same as previous, more clear •  Generic filter (grep) available: $rs->filter(sub {      return 1 if $_->get_label eq 'ifSpeed';     return }); SNMP::Class 13
  • 14. Library Overview - The ResultSet (2) •  More advanced filtering  #Find speed of interface 'eth0' say $rs->filter_label('ifSpeed')->filter_instance($rs- >filter_label('ifDescr')->filter_value('eth0')- >get_instance_oid)->value; #the same, much more clearly and briefly: say $rs->find('ifDescr' => 'eth0')->ifSpeed->value; #Keep the instance for which the ifDescr equals 'eth0', then keep only the ifSpeed.  SNMP::Class 14
  • 15. Library Overview - The ResultSet (3) •  Iteration over contents, detection of list context #print the description of each interface for($rs->ifDescr) {      say $_->value  } •  Filter and map methods o  Used exactly as list grep and map with BLOCK my $new_rs = $rs->filter(sub { ..... }); my $new_rs = $rs->map(sub { ..... });      SNMP::Class 15
  • 16. Library Overview - The ResultSet (4) •  Final touch: Resultset with 1 varbind: $rs->ifDescr(3)->item(0)->value; #the same: $rs->ifDescr(3)->value; Varbind methods valid on 1-item ResultSets. •  Overloading also possible, but: o  Awkward behavior when using list context o  Awkward behavior when using operators like '.' SNMP::Class 16
  • 17. Library Implementation (so far) Built using Moose.pm  Class & Role Hierarchy: •  Classes: o  SNMP::Class - Session object (mostly empty, gaining functionality from Role::ResultSet and Role::Implementation::Net-SNMP) o  SNMP::Class::ResultSet - Results object (ditto) o  SNMP::Class::OID - An OID    SNMP::Class::Varbind - A varbind (OID+value) •  Roles: o  SNMP::Class::Role::ResultSet - resultset behavior o  SNMP::Class::Role::Implementation - SNMP Instrumentation (abstract part, not usable by itself)   SNMP::Class::Role::Implementation::NetSNMP  - Instrumentation lower part using Net-SNMP (applied to SNMP::Class objects)   SNMP::Class::Role::Implementation::Dummy - Another instrumentation, dummy this time o  SNMP::Class::Varbind::XXXXX - Varbind enhancement roles, (application to plain varbinds) SNMP::Class 17
  • 18. Library Roles (2) SNMP::Class is-a: •  SNMP::Class::Role::Implementation::NetSNMP •  SNMP::Class::Role::ResultSet Hence, full usability (SNMP Session + Result) available through a single object. my $s = SNMP::Class->new('myhost'); $s->add('system'); say $s->sysName->value; #or say SNMP::Class->new('myhost')->add('system')->sysName->value; SNMP::Class 18
  • 19. Varbind Enhancement Roles  Added functionality (new methods or override methods) for SNMP::Class::Varbind objects through SNMP::Class::Varbind:: roles Example: #coming from SNMP::Class::Varbind $bridge_id->raw_value; #8 bytes,unprintable  $bridge_id->value; # '80:00:00:06:28:84:D7:40' #coming from SNMP::Class::Varbind::BridgeId $bridge_id->mac_address #'00:06:28:84:D7:40' $bridge_id->priority #32768   •  Applying of role at runtime, trigger when OID and value of Varbind are known __PACKAGE__->meta->apply($_[0]); •  Applying of multiple roles possible •  Default Varbind 'value' method and other methods overridable by roles SNMP::Class 19
  • 20. Code! https://github.com/aduitsis/snmp-class •  Stuff in current presentation almost fully implemented •  Many many varbind enhancement roles missing (implementation on a need basis) •  Only instrumentation so far from Net-SNMP •  MIB parsing also from Net-SNMP •  Obviously, bugs present •  Built with Moose •  Usage of Log::Log4Perl for logging •  Test suite - but not 100% coverage SNMP::Class 20
  • 21. Future Directions •  Second instrumentation wrapper from Net::SNMP (Pure Perl) •  MIB parser other than from Net-SNMP •  More Varbind enhancement roles •  More performance fixes •  Fix any bugs observed •  Need to address snmpset functionality •  Encapsulation of entire MIBs, hide SNMP completely. o  (also see the very good SNMP::Info module on CPAN)  SNMP::Class 21
  • 22. Thank you for your attention aduitsis@cpan.org