Hello,
I will start with a little bit of background on what I’m trying to do. I’m running an snmpwalk command to retrieve the version of software running on 8 servers. This is the code I’m currently using to check the versions…
[php] exec(‘snmpwalk -v2c server01.cluster1.mydomain.com -c attask .1.4.7.1.3 -Ovq’,$cluster1,$return1);
exec(‘snmpwalk -v2c server02.cluster1.mydomain.com -c attask .1.4.7.1.3 -Ovq’,$cluster1,$return2);
exec(‘snmpwalk -v2c server02.cluster1.mydomain.com -c attask .1.4.7.1.3 -Ovq’,$cluster1,$return3);
[/php]
etc…
Instead of having this eight times is there a way I can loop through this command for each server and store it in a variable? (like using foreach or something??)
After this command gathers all the server versions it runs a foreach and loops to make sure they are all the same. (because the versions get stored in the $cluster1 variable.)
The reason I ask is because servers get added over time and it would be easier to make a small change instead of adding several lines every time we boot up a new server.