(snmp code) perl to python

S

Shabbir Ahmed

hi hope all are doing good, i have code written in perl which quries
too many devices and then stores the result in mysqldb, whiel shifting
to python and googling i heared of and studied google asynch python
code, now i wanted to use it n convert my perl code to it but i have
some problem.

1. this class creates forks every snmp query and returns un ordered
result without any information that which oid returned which result,
where as in my code i query all only if a parent oid returns true, now
i dont know how to read specific oid.

algo of perl code,

read all the ips and communities from mysql then fork function for
every router so that all the equipment are queried at once, it creates
that much saperate process of equipment ips,

function that is forked:
loop for all the interfaces: check if the inteface is up
-> if so read the interface ips.
-> save result in mysql tables.

kindly help me convert this code to python or make this logic in
python.
 
L

lkcl

hi hope all are doing good, i have code written in perl which quries
too many devices and then stores the result in mysqldb, whiel shifting
to python and googling i heared of and studied google asynch python
code, now i wanted to use it n convert my perl code to it but i have
some problem.

1. this class creates forks every snmp query and returns un ordered
result without any information that which oid returned which result,
where as in my code i query all only if a parent oid returns true, now
i dont know how to read specific oid.

algo of perl code,

read all the ips and communities from mysql then fork function for
every router so that all the equipment are queried at once, it creates
that much saperate process of equipment ips,

function that is forked:
loop for all the interfaces: check if the inteface is up
-> if so read the interface ips.
-> save result in mysql tables.

kindly help me convert this code to python or make this logic in
python.

if the code is particularly long (greater than 2,000 lines) then you
might wish to look at java2py.py and use it as the basis to write a
"dumb" assistant in doing much of the code-conversion:

http://pyjamas.svn.sourceforge.net/...a2py.py?revision=1572&content-type=text/plain

this program is _not_ parser-based (yacc, ply, oMeta2) it is line-
based and state-based. specific assumptions are made about the code
layout (braces in K&R formatting style for example) and, thanks to the
high code-quality of the code it was used to translate (GWT) this was
not in the slightest bit a problem.

so, _in combination with a code-cleaner_ such as "indent", which
regularises the formatting of whatever god-awful-looking perl you want
to translate, the approach indicated by java2py.py will save you a lot
of time and mistakes.

think about it, even if the code you want to translate is 500 lines.
that's 500+ lines you need to rewrite, whereas something as simple as
267 lines of python could help automate that process of conversion.

l.
 
J

John Bokma

Shabbir Ahmed said:
hi hope all are doing good, i have code written in perl which quries
too many devices and then stores the result in mysqldb, whiel shifting
to python and googling i heared of and studied google asynch python
code, now i wanted to use it n convert my perl code to it but i have
some problem.

So now you have two problems: a) your Perl code doesn't work as you want and b)
your lack of Python coding skills.
read all the ips and communities from mysql then fork function for
every router so that all the equipment are queried at once, it creates
that much saperate process of equipment ips,

If thats a problem, why not fork a worker pool of a limited number of
processes? An other options might be to use POE.
kindly help me convert this code to python or make this logic in
python.

Like I already wrote, you have now 2 problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top