#!/usr/bin/php 1 AND glpi_plugin_fusioninventory_configsecurities.id=glpi_plugin_fusinvsnmp_unmanageds.plugin_fusinvsnmp_configsecurities_id "; $result = $DB->query($sql); while ($host=$DB->fetchArray($result)) { $filePath = sprintf("%s/%s-%s.walk", $outputDir, $host['ip'], preg_replace('/[^a-zA-Z0-9,_-]/', '_', $host['sysdescr'])); switch ($host['snmpversion']) { case 1: $snmpversion = '1'; break; case 2: $snmpversion = '2c'; break; default: printf("unsupported SNMP version: '%s'\n", $host['snmpversion']); continue; } $cmd = sprintf("%s -v %s -t 30 -Cc -c %s %s .1", $snmpwalkCmd, $snmpversion, $host['community'], $host['ip']); // print $cmd."\n"; printf("---\nscanning %s\n", $host['ip']); $fileFd = fopen($filePath, "w"); $cmdFd = popen($cmd, "r"); while (!feof($cmdFd)) { fwrite($fileFd, fgets($cmdFd)); } print "done\n"; pclose($cmdFd); fclose($fileFd); $st = stat($filePath); if ($st['size'] == 0) { unlink($filePath); } else { printf("file %s generated\n", $filePath); } }