Avatar of Rich Rumble
Rich Rumble
Flag for United States of America asked on

Convert open(IN, file) to memory/array instead of using pre-existing files

I'd like to take the following scripts and combine them, as well as change the behaviour slightly. Instead of the data being parsed/matched from pre-existing files, I'd like to SNMPWALK the data, place it in memory, then do the parsing/matching of that data, and then write that data to disk and or a MySql DB.

This is basically the script I want to change, again instead of reading in files, read in data stored in memory from a snmpwalk...

So we'd do a snmpwalk to get the data, then store to memory (not sure how to really) I'm not sure the best way to walk via perl. Currently I have a cron job that simply runs a shell script to dump the data to directories like this:
snmpwalk -v 2c -c Public -O n device.example.com . >file1.txt
snmpwalk -v 2c -c Public -O n device.example.com . >file2.txt
snmpwalk -v 2c -c Public -O n device.example.com . >file3.txt
snmpwalk -v 2c -c Public -O n device.example.com . >file4.txt
snmpwalk -v 2c -c Public -O n device.example.com . >file5.txt

Then after that cron job completes, I run the script in the above link to match/aggregate the data together for each interface, and it writes that file to disk. I'd like to run the 5 snmpwalks above, then parse that data together and wite it to disk, or even more preferred is to a mysql table.

Avatar of undefined
Last Comment
Rich Rumble

8/22/2022 - Mon

@result = `snmpwalk -v 2c -c Public -O n device.example.com .`;

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Rich Rumble

that works very well, thanks!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck