Jump to content

Building dynamic arrays with snmpwalkoid() info


jpavleck

Recommended Posts

Greetings All!

I'm trying to build a webpage that will pull out server information using snmpget and snmpwalkoid, among other things.

Most of the things I poll are fairly static, so in that regards I simply snmpwalkoid('server', 'community', 'oid') and then create another array that has my info to spit out like "System Name:" etc etc.
I then use array_combine($my_array, $theOIDArray) and run through them spitting out the keys & values.

But, with other things, like processors and hard drives, the snmpwalkoid may return multiple items - and in that case my array_combine won't work since it will just break.

I'm a total PHP newbie here, and I'm not sure the best way to approach this. I'd like to use the snmpwalkoid array VALUES with my own KEYS, then spit it out to the web. Here's what the array from snmpwalkoid() will look like, the exact OID is the key, the return is the value.

CPQIDA-MIB::cpqDaPhyDrvCntlrIndex.0.128: 0
CPQIDA-MIB::cpqDaPhyDrvCntlrIndex.0.129: 0
CPQIDA-MIB::cpqDaPhyDrvIndex.0.128: 128
CPQIDA-MIB::cpqDaPhyDrvIndex.0.129: 129
CPQIDA-MIB::cpqDaPhyDrvModel.0.128: "COMPAQ BD07286224 "
CPQIDA-MIB::cpqDaPhyDrvModel.0.129: "COMPAQ BD07286224 "
CPQIDA-MIB::cpqDaPhyDrvFWRev.0.128: "HPB6"
CPQIDA-MIB::cpqDaPhyDrvFWRev.0.129: "HPB6"
CPQIDA-MIB::cpqDaPhyDrvBay.0.128: 0
CPQIDA-MIB::cpqDaPhyDrvBay.0.129: 1
CPQIDA-MIB::cpqDaPhyDrvStatus.0.128: ok
CPQIDA-MIB::cpqDaPhyDrvStatus.0.129: ok
CPQIDA-MIB::cpqDaPhyDrvFactReallocs.0.128: -1
CPQIDA-MIB::cpqDaPhyDrvFactReallocs.0.129: -1

Now how can I combine that with:

$arrCpqDaPhyDrvIndex = array( 1 => 'Controller Index:', 'Drive Index:', 'Drive Model:', 'Firmware Revision:', 'Drive Bay Location:', 'Drive Status:', 'Spare Sectors:');

So I can get output that will look like this:

Drive A Controller Index: 0
Drive A Drive Index: 128
Drive A Drive Model: "COMPAQ BD07286224"
Drive A Firmware Revision: "HPB6"
Drive A Drive Bay Location: 0
Drive A Drive Status: ok
Drive A Spare Sectors: -1

Drive B Controller Index: 0
Drive B Drive Indes: 129
etc, etc, etc.

I'm assuming I might have to do something with the drive index number.. .But like I said, I'm very new to this all can't figure out how to combine the 2 pieces of info I need. Once I figure this out, I'll be able to play with the data more and smooth it to the way I'd like to. Any help would be wonderful - thanks!



Jeremy
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.