Re: SNMP ??

2011-08-30 Thread Shantanu Bhadoria
I need to work with embedded linux devices. hah!! something else to look
into.
So I am not exactly looking for Server Admin. Not that it should make much
of a difference. :P

On Wed, Aug 24, 2011 at 4:38 PM, Shantanu Bhadoria wrote:

> Hey Folks,
> Is there a good guide book or reference to get started on SNMP? some link
> or a book that can get a person from beginner to advanced state? How much
> time would you generally give for starting on SNMP in Perl for a Perl
> veteran but a SNMP newbie?
> thanks!
>


Re: SNMP ??

2011-08-30 Thread David Cantrell
On Wed, Aug 24, 2011 at 12:38:37PM +0100, Peter Corlett wrote:

> The book's getting a bit long in the tooth now, but Perl for System
> Administration was useful to get me up and running doing various sysadminny
> things including SNMP early in my career:
> 
> http://oreilly.com/catalog/9781565926097
> 
> (In fact, I might bring my now-unused copy along to what appears to be
> turning into a bookswap social next month.)

I've got a copy of that to get rid of too :-)

-- 
David Cantrell | top google result for "internet beard fetish club"

  Good advice is always certain to be ignored,
  but that's no reason not to give it-- Agatha Christie


Re: SNMP ??

2011-08-24 Thread Andrew Suffield
On Wed, Aug 24, 2011 at 04:38:39PM +0530, Shantanu Bhadoria wrote:
> a book that can get a person from beginner to advanced state?

I think the only advanced state of SNMP is a feeling of nausea.

It's not complicated at all. It's just nasty.


Re: SNMP ??

2011-08-24 Thread Ben Tisdall
>> On Wed, Aug 24, 2011 at 04:38:39PM +0530, Shantanu Bhadoria wrote:
>>>
>>> Hey Folks,
>>> Is there a good guide book or reference to get started on SNMP?

I found this useful when I needed to write Nagios plugins that spoke
snmp (in Perl, natch):

http://www.cuddletech.com/articles/snmp/


Re: SNMP ??

2011-08-24 Thread Dave Cross

Quoting Peter Corlett :


On Wed, Aug 24, 2011 at 04:38:39PM +0530, Shantanu Bhadoria wrote:

Hey Folks,
Is there a good guide book or reference to get started on SNMP? some link or
a book that can get a person from beginner to advanced state? How much time
would you generally give for starting on SNMP in Perl for a Perl veteran but
a SNMP newbie?
thanks!


The book's getting a bit long in the tooth now, but Perl for System
Administration was useful to get me up and running doing various sysadminny
things including SNMP early in my career:

http://oreilly.com/catalog/9781565926097


That's probably why they published a (lightly retitled) second edition  
a couple of years ago.


  http://oreilly.com/catalog/9780596006396/

Dave...



Re: SNMP ??

2011-08-24 Thread Alistair McGlinchy
Shantanu

On 24 August 2011 12:08, Shantanu Bhadoria  wrote:

> Is there a good guide book or reference to get started on SNMP?


The Oreilly book ( http://oreilly.com/catalog/9780596008406 ) is OK but I
don't recommend it if you want to learn SNMP V3. My review is here
http://london.pm.org/reviews/essential_snmp.html

The http://www.net-snmp.org/ site has lots of really useful information and
software (but I am not a fan of the perl snmp module that comes with it).
Instead  I recommend the Net::SNMP module for writing SNMP polling clients.
The non-blocking calls are incredibly efficient and get_table and
get_entries methods keep your code focused at a higher level.


> How much time
> would you generally give for starting on SNMP in Perl for a Perl veteran
> but
> a SNMP newbie?
>

If you are a competent programmer then simple useful SNMP programming should
take an afternoon (eg collecting network utilisation stats). Writing your
own systems management tools will be more dependant on requirements.

I found it much easier to learn with a graphical SNMP mib browser that
compiles MIBs nicely and, of course, Wireshark.  MGSoft's MIB browser is
very pretty but expensive and shows each OID's descriptions nicely and
presents tables as, well, tables.


HTH

Alistair


Re: SNMP ??

2011-08-24 Thread Peter Corlett
On Wed, Aug 24, 2011 at 04:38:39PM +0530, Shantanu Bhadoria wrote:
> Hey Folks,
> Is there a good guide book or reference to get started on SNMP? some link or
> a book that can get a person from beginner to advanced state? How much time
> would you generally give for starting on SNMP in Perl for a Perl veteran but
> a SNMP newbie?
> thanks!

The book's getting a bit long in the tooth now, but Perl for System
Administration was useful to get me up and running doing various sysadminny
things including SNMP early in my career:

http://oreilly.com/catalog/9781565926097

(In fact, I might bring my now-unused copy along to what appears to be
turning into a bookswap social next month.)



SNMP ??

2011-08-24 Thread Shantanu Bhadoria
Hey Folks,
Is there a good guide book or reference to get started on SNMP? some link or
a book that can get a person from beginner to advanced state? How much time
would you generally give for starting on SNMP in Perl for a Perl veteran but
a SNMP newbie?
thanks!


Re: Efficient sorting of SNMP oids

2009-11-01 Thread Ask Bjørn Hansen


On Oct 31, 2009, at 15:17, Dave Hodgkinson wrote:

Using Sort::Key::OID or sort::maker would have been great, except  
that
we need to deploy the script to a rather large number of servers  
and it
is traditionally long and painful to get modules approved and  
deployed

in our machines.


Then build it in to your own dist tree.


Yeah; that's what we do.   We have a git submodule (cpan/) with our  
application, so when we upgrade or install a module it gets branched/ 
merged/tracked/code-reviewed/managed just like any other application  
change we make.


We have a helper script[1] that starts the CPAN shell with  
INSTALL_BASE appropriately configured to make it easy.



 - ask

[1] 
http://git.develooper.com/?p=combust.git;a=blob;f=bin/cbcpan;h=b69b81829e43450344f9dc35349151cf2750e6b5;hb=HEAD


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Uri Guttman
> "AV" == Avleen Vig  writes:

  AV> On Oct 31, 2009, at 22:17, Dave Hodgkinson  wrote:
  >> 
  >> Then build it in to your own dist tree.

  AV> Or better yet, extract the key functionality you need from the module
  AV> and mak it part of your script! Easy. 

and one more idea. sort::maker actually generates source code for its
sorts and you can print that out. then you cut/paste that generated code
into your program. the only issue i see is how to handle varying length
OIDs. but i leave that as an exercise to the reader.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Philip Newton
2009/11/1 Avleen Vig :
> On Oct 31, 2009, at 22:17, Dave Hodgkinson  wrote:
>
>>
>> On 31 Oct 2009, at 20:56, B Maqueira wrote:
>>>
>>> Using Sort::Key::OID or sort::maker would have been great, except that
>>> we need to deploy the script to a rather large number of servers and it
>>> is traditionally long and painful to get modules approved and deployed
>>> in our machines.
>>
>> Then build it in to your own dist tree.
>
> Or better yet, extract the key functionality you need from the module and mak 
> it part of your script! Easy.

That's what I was going to suggest. Behold the power of open source, etc.

Cheers,
Philip
-- 
Philip Newton 


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Avleen Vig

On Oct 31, 2009, at 22:17, Dave Hodgkinson  wrote:



On 31 Oct 2009, at 20:56, B Maqueira wrote:


Using Sort::Key::OID or sort::maker would have been great, except  
that
we need to deploy the script to a rather large number of servers  
and it
is traditionally long and painful to get modules approved and  
deployed

in our machines.



Then build it in to your own dist tree.


Or better yet, extract the key functionality you need from the module  
and mak it part of your script! Easy. 


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Dave Hodgkinson


On 31 Oct 2009, at 20:56, B Maqueira wrote:


Using Sort::Key::OID or sort::maker would have been great, except that
we need to deploy the script to a rather large number of servers and  
it

is traditionally long and painful to get modules approved and deployed
in our machines.



Then build it in to your own dist tree.

--
Dave HodgkinsonMSN: daveh...@hotmail.com
Site: http://www.davehodgkinson.com  UK: +44 7768 490620
Blog: http://www.davehodgkinson.com/blog
Photos: http://www.flickr.com/photos/davehodg










Re: Efficient sorting of SNMP oids

2009-10-31 Thread B Maqueira
Peter Corlett wrote:
> On 31 Oct 2009, at 16:03, B Maqueira wrote:
>> I need to sort eficiently a large array (~9000) of SNMP OIDs.
>>
>> I am currently trying the following code:
>>
>> my @sorted_oids = map { $_->[0] }
>>  sort { $a->[1] cmp $b->[1] }
>> map { [$_, pack('w*', split(/\./,
>> $_))]  } @oids;
>>
>> But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
>> than 1.3.6.1.4.1.2333.3.2.8080.1.1.1
>>
>> Any ideas?
>
> That's because "w" format is a BER encoding, and this does not map
> integers into strings such that ordering is maintained. For example,
> 16383 encodes to "\xff\x7f", but 16384 encodes to "\x81\x80\x00" which
> string-sorts earlier.
>
> Relatively few encodings *do* maintain that ordering. Big-endian
> fixed-width does. So I'd use "N*" instead in your pack format, mainly
> because I'm not entirely sure whether the components of SNMP OIDs can
> ever be greater than 65535 and thus whether I could thus get away with
> "n*" to halve the storage required.
>
>
Thank you all for the advice.

Using Sort::Key::OID or sort::maker would have been great, except that
we need to deploy the script to a rather large number of servers and it
is traditionally long and painful to get modules approved and deployed
in our machines.

Using "N*" certainly did the trick. I guess I must read the RFC for OIDs
+ work out what is the range covered using N*. But right now I have some
oids looking like BASE.8129.1.10.1402551989 and
BASE.61003.1.10.2138245292 that seem to be working fine.

Again, huge thanks to you all for your replies!
 


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Dave Hodgkinson


On 31 Oct 2009, at 16:03, B Maqueira wrote:


Dear all,

I need to sort eficiently a large array (~9000) of SNMP OIDs.

I am currently trying the following code:

my @sorted_oids = map { $_->[0] }
 sort { $a->[1] cmp $b->[1] }
map { [$_, pack('w*', split(/\./,
$_))]  } @oids;

But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
than 1.3.6.1.4.1.2333.3.2.8080.1.1.1

Any ideas?


Convert them to 256 bit (or whatver integers), sort and convert back? :)

--
Dave HodgkinsonMSN: daveh...@hotmail.com
Site: http://www.davehodgkinson.com  UK: +44 7768 490620
Blog: http://www.davehodgkinson.com/blog
Photos: http://www.flickr.com/photos/davehodg










Re: Efficient sorting of SNMP oids

2009-10-31 Thread Peter Corlett

On 31 Oct 2009, at 16:03, B Maqueira wrote:

I need to sort eficiently a large array (~9000) of SNMP OIDs.

I am currently trying the following code:

my @sorted_oids = map { $_->[0] }
 sort { $a->[1] cmp $b->[1] }
map { [$_, pack('w*', split(/\./,
$_))]  } @oids;

But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
than 1.3.6.1.4.1.2333.3.2.8080.1.1.1

Any ideas?


That's because "w" format is a BER encoding, and this does not map  
integers into strings such that ordering is maintained. For example,  
16383 encodes to "\xff\x7f", but 16384 encodes to "\x81\x80\x00" which  
string-sorts earlier.


Relatively few encodings *do* maintain that ordering. Big-endian fixed- 
width does. So I'd use "N*" instead in your pack format, mainly  
because I'm not entirely sure whether the components of SNMP OIDs can  
ever be greater than 65535 and thus whether I could thus get away with  
"n*" to halve the storage required.





Re: Efficient sorting of SNMP oids

2009-10-31 Thread Uri Guttman
> "RF" == Richard Foley  writes:

  RF> Should that be a numerical sort via the spaceship operator?
  RF>   <=> instead of cmp

nope, since he is trying to compare a long string of the packed
OIDs. you can't compare woth <=> anything other than normal integers or
floats.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Uri Guttman
>>>>> "BM" == B Maqueira  writes:

  BM> Dear all,
  BM> I need to sort eficiently a large array (~9000) of SNMP OIDs.

  BM> I am currently trying the following code:

  BM> my @sorted_oids = map { $_->[0] }
  BM>   sort { $a->[1] cmp $b->[1] }
  BM>  map { [$_, pack('w*', split(/\./,
  BM> $_))]  } @oids;

  BM> But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
  BM> than 1.3.6.1.4.1.2333.3.2.8080.1.1.1

sort::maker could do that and generate a faster sort with the GRT. just
generate an array of integers (or shorts) and pack them for the
key. similar to what you have there.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -


Re: Efficient sorting of SNMP oids

2009-10-31 Thread Richard Foley
Should that be a numerical sort via the spaceship operator?

<=> instead of cmp

--
Richard Foley
Ciao - shorter than aufwiedersehen

http://www.rfi.net/

On Saturday 31 October 2009 17:03:15 B Maqueira wrote:
> Dear all,
> 
> I need to sort eficiently a large array (~9000) of SNMP OIDs.
> 
> I am currently trying the following code:
> 
> my @sorted_oids = map { $_->[0] }
>   sort { $a->[1] cmp $b->[1] }
>  map { [$_, pack('w*', split(/\./,
> $_))]  } @oids;
> 
> But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
> than 1.3.6.1.4.1.2333.3.2.8080.1.1.1
> 
> Any ideas?
> 
> _
> Dr Braudel Maqueira
> brau...@ferrarihaines.com
> 




Re: Efficient sorting of SNMP oids

2009-10-31 Thread Anton Berezin
On Sat, Oct 31, 2009 at 04:03:15PM +, B Maqueira wrote:
> Dear all,
> 
> I need to sort eficiently a large array (~9000) of SNMP OIDs.
> 
> I am currently trying the following code:
> 
> my @sorted_oids = map { $_->[0] }
>   sort { $a->[1] cmp $b->[1] }
>  map { [$_, pack('w*', split(/\./,
> $_))]  } @oids;
> 
> But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
> than 1.3.6.1.4.1.2333.3.2.8080.1.1.1
> 
> Any ideas?

http://search.cpan.org/~salva/Sort-Key-OID-0.05/  looks like the ticket...

\Anton.
-- 
Matters of elegance ought to be left to the tailor and to the cobbler.
  -- L. Boltzmann


Efficient sorting of SNMP oids

2009-10-31 Thread B Maqueira
Dear all,

I need to sort eficiently a large array (~9000) of SNMP OIDs.

I am currently trying the following code:

my @sorted_oids = map { $_->[0] }
  sort { $a->[1] cmp $b->[1] }
 map { [$_, pack('w*', split(/\./,
$_))]  } @oids;

But this fails since it outputs 1.3.6.1.4.1.2333.3.2.61001.1.10 before
than 1.3.6.1.4.1.2333.3.2.8080.1.1.1

Any ideas?

_
Dr Braudel Maqueira
brau...@ferrarihaines.com