jpavleck Posted May 30, 2006 Share Posted May 30, 2006 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: 0CPQIDA-MIB::cpqDaPhyDrvCntlrIndex.0.129: 0CPQIDA-MIB::cpqDaPhyDrvIndex.0.128: 128CPQIDA-MIB::cpqDaPhyDrvIndex.0.129: 129CPQIDA-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: 0CPQIDA-MIB::cpqDaPhyDrvBay.0.129: 1CPQIDA-MIB::cpqDaPhyDrvStatus.0.128: okCPQIDA-MIB::cpqDaPhyDrvStatus.0.129: okCPQIDA-MIB::cpqDaPhyDrvFactReallocs.0.128: -1CPQIDA-MIB::cpqDaPhyDrvFactReallocs.0.129: -1Now 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: 0Drive A Drive Index: 128Drive A Drive Model: "COMPAQ BD07286224"Drive A Firmware Revision: "HPB6"Drive A Drive Bay Location: 0Drive A Drive Status: okDrive A Spare Sectors: -1Drive B Controller Index: 0Drive B Drive Indes: 129etc, 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 Quote Link to comment https://forums.phpfreaks.com/topic/10804-building-dynamic-arrays-with-snmpwalkoid-info/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.