Re: ftplib connection fails with multiple nics

2009-10-19 Thread Shantanu Joshi
Sean DiZazzo  writes:

> On Oct 16, 4:51 pm, Sean DiZazzo  wrote:
>> Hi all,
>>
>> I'm trying to connect to an ftp site from a windows machine with two
>> nics going to two different networks, but I keep getting the below
>> exception:
>>
>> Traceback (most recent call last):
>>   File "ftp.pyo", line 70, in connect
>>   File "ftp.pyo", line 17, in __init__
>>   File "ftplib.pyo", line 131, in connect
>>   File "socket.pyo", line 498, in create_connection
>> gaierror: [Errno 10093] getaddrinfo failed
>>
>> I think it is because of the two nics, because the code runs fine on
>> other machines.  Any ideas on how to fix this?
>>
>> TIA.
>>
>> ~Sean
>
> What does socket.getaddrinfo() rely on??

First, check if you can ping the FTP server from your client machine.

getaddrinfo relies on either DNS, /etc/hosts, or NIS, depending on how your
system is configured (check the hosts entry in /etc/nsswitch.conf).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: udp package header

2009-03-23 Thread Shantanu Joshi
mete  writes:

> Hi all,
> I got a problem. İ want to send udp package and get this package (server and 
> clinet ). it's easy to python but i want to look the udp header how can i 
> do ?

Check out Scapy (http://www.secdev.org/projects/scapy/).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Translating pysnmp oids to human readable strings

2009-03-09 Thread Shantanu Joshi
SpamMePlease PleasePlease  writes:

> On Fri, Mar 6, 2009 at 2:14 PM, Shantanu Joshi  wrote:
>>
>> SpamMePlease PleasePlease  writes:
>>
> .. snip
> 
> The thing is that I have copied the file (as you may see, I did 'ls
> -lA' on it. If the file wasnt there, the error message was different.
> Also, the setMibPath doesent seem to work, as I tried to set up it to
> any value, and right after that I was performing getMibPath which was
> giving me unchanged default paths. Keep in mind, that whole path setu
> up code has executed without any error.
> So, what is correct and working way to supply my code with that
> converted mib file?

Works for me.

> [shant...@tiamat:~/Documents/snmp]$ ls
> AV-AES-MIB.mib
> [shant...@tiamat:~/Documents/snmp]$ smidump AV-AES-MIB.mib -k > 
> AV-AES-MIB.txt
> smidump: module `AV-AES-MIB.mib' contains errors, expect flawed output
> [shant...@tiamat:~/Documents/snmp]$ build-pysnmp-mib AV-AES-MIB.txt > 
> AV-AES-MIB.py
> [shant...@tiamat:~/Documents/snmp]$ ls
> AV-AES-MIB.mib  AV-AES-MIB.txt  AV-AES-MIB.py
> [shant...@tiamat:~/Documents/snmp]$ sudo cp AV-AES.py 
> /usr/lib/python2.5/site-packages/pysnmp/v4/smi/mibs/instances
> [shant...@tiamat:~/Documents/snmp]$ ls 
> /usr/lib/python2.5/site-packages/pysnmp/v4/smi/mibs/instances
> AV-AES-MIB.py __SNMP-FRAMEWORK-MIB.py   __SNMP-MPD-MIB.pyc 
> __SNMP-USER-BASED-SM-MIB.py   __SNMP-VIEW-BASED-ACM-MIB.pyc  __init__.py
> __PYSNMP-USM-MIB.py   __SNMP-FRAMEWORK-MIB.pyc  __SNMP-TARGET-MIB.py   
> __SNMP-USER-BASED-SM-MIB.pyc  __SNMPv2-MIB.py__init__.pyc
> __PYSNMP-USM-MIB.pyc  __SNMP-MPD-MIB.py __SNMP-TARGET-MIB.pyc  
> __SNMP-VIEW-BASED-ACM-MIB.py  __SNMPv2-MIB.pyc
> [shant...@tiamat:~/Documents/snmp]$ 
> [shant...@tiamat:~/Documents/snmp]$ ipython
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38) 
> Type "copyright", "credits" or "license" for more information.
> 
> IPython 0.8.4 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help  -> Python's own help system.
> object?   -> Details about 'object'. ?object also works, ?? prints more.
> 
> In [1]: from pysnmp.smi import builder, view
> 
> In [2]: mibBuilder = builder.MibBuilder().loadModules('AV-AES-MIB')
> 
> In [3]: mibViewController = view.MibViewController(mibBuilder)
> 
> In [4]: oid, label, suffix = 
> mibViewController.getNodeName((1,3,6,1,4,1,6889,2,27,2,2,2))
> 
> In [5]: print oid 
> (1, 3, 6, 1, 4, 1, 6889, 2, 27, 2, 2)
> 
> In [6]: print label
> ('iso', 'org', 'dod', 'internet', 'private', 'enterprises', [...])
> 
> In [7]: print suffix
> (2,)
> 
> In [8]: 

I think you should check that the file you are generating is correct,
and can be read properly. If that doesn't help, you should try on the
pysnmp-users mailing list at http://sourceforge.net/mail/?group_id=14735. 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread Shantanu Joshi

SpamMePlease PleasePlease  writes:

>
> I actually tried to load the new file with following code:
>
> print builder.MibBuilder().getMibPath()
> mibBuilder = builder.MibBuilder().loadModules('jnx-bgpmib2')
>
> but I am experiencing the error:
>
> rivendell # python snmp.py
> ('/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances',
> '/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs')
> Traceback (most recent call last):
>   File "snmp.py", line 7, in ?
> mibBuilder = builder.MibBuilder().loadModules('jnx-bgpmib2')
>   File "//usr/lib/python2.4/site-packages/pysnmp/v4/smi/builder.py",
> line 82, in loadModules
> raise error.SmiError(
> pysnmp.smi.error.SmiError: MIB module
> "/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances/jnx-bgpmib2.py"
> load error: MIB file ".py" not found in search path
> rivendell# ls -lA
> /usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances/jnx-bgpmib2.py
> -rw-r--r-- 1 root root 2687 Mar  6 06:50
> /usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances/jnx-bgpmib2.py
>
> Any clue what about is done wrong?

The pysnmp library is not able to find your generated file. Either copy
your generated file to 
/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances 
or call setMibPath on the mibBuilder instance before calling loadModules
to add the current directory (or whatever directory holds your generated
file).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread Shantanu Joshi

SpamMePlease PleasePlease  writes:

> On Fri, Mar 6, 2009 at 6:56 AM, Shantanu Joshi  wrote:
>> You need to parse the MIB file to get the human-readable names
>> corresponding to the OIDs. The pysnmp library already provides this
>> functionality. I haven't used this feature myself (I mainly use pysnmp
>> to automate SNMP walk requests, like the one in your code), but the
>> documentation at found the below example at
>> http://pysnmp.sourceforge.net/docs/4.1.x/index.html#MIB-SERVICES.
>>
>>
>>>>> from pysnmp.smi import builder, view
>>>>>
>>>>> mibBuilder = builder.MibBuilder().loadModules('SNMPv2-MIB')
>>>>> mibViewController = view.MibViewController(mibBuilder)
>>>>>
>>>>> oid,label,suffix = 
>>>>> mibViewController.getNodeName((1,3,6,1,2,'mib-2',1,'sysDescr'))
>>>>> print oid
>> (1, 3, 6, 1, 2, 1, 1, 1)
>>>>> print label
>> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'system', 'sysDescr')
>>>>> print suffix
>> ()
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> Yes, I have seen that, but I cant get it working as expected (or it
> doesent to what expected at all). I cant make it return values like:
> jnxBgpM2PeerIdentifier.0.ipv4.38.101.161.119.1.38.101.161.118 (the one
> of many I got from snmpwalk) but instead I am getting bunch of words
> like iso, internet, mgmt, which is no way close to desired effect.
> Still no luck - anybody with a clue?


Every node in a MIB file is rooted at iso.org.dod.internet. 
jnxBgpM2PeerIdentifier has OID .1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1 
(if I've got the right MIB, I searched for jnxBgpM2PeerIdentifier on 
Google and got the BGP4-V2-MIB-JUNIPER MIB file). The .1.3.6.1.4.1
corresponds to iso.org.dod.internet.private.enterprises, so you can
safely skip that part. The next value 2636, is uniquely assigned to 
Juniper, and the rest is up to whatever scheme Juniper uses to prepare 
mibs.

The pysnmp library doesn't know anything about BGP4-V2-MIB-JUNIPER MIB,
since it is not one of the standard MIBS, so it will parse everything up
to what is defined in the standard mibs and return the rest in numeric
form. There was a paragraph on the page I linked which described how to
prepare MIB files for consumption by pysnmp. Did you try that? 


--
http://mail.python.org/mailman/listinfo/python-list


Re: Translating pysnmp oids to human readable strings

2009-03-05 Thread Shantanu Joshi
You need to parse the MIB file to get the human-readable names
corresponding to the OIDs. The pysnmp library already provides this
functionality. I haven't used this feature myself (I mainly use pysnmp
to automate SNMP walk requests, like the one in your code), but the
documentation at found the below example at 
http://pysnmp.sourceforge.net/docs/4.1.x/index.html#MIB-SERVICES.


>>> from pysnmp.smi import builder, view
>>>
>>> mibBuilder = builder.MibBuilder().loadModules('SNMPv2-MIB')
>>> mibViewController = view.MibViewController(mibBuilder)
>>> 
>>> oid,label,suffix = 
>>> mibViewController.getNodeName((1,3,6,1,2,'mib-2',1,'sysDescr'))
>>> print oid
(1, 3, 6, 1, 2, 1, 1, 1)
>>> print label
('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'system', 'sysDescr')
>>> print suffix
()
--
http://mail.python.org/mailman/listinfo/python-list