} } } $var = array(); $var['stratum'] = isset($ntpd['stratum']) ? $ntpd['stratum'] : 'U'; $var['offset'] = isset($ntpd['offset']) ? $ntpd['offset'] : 'U'; $var['frequency'] = isset($ntpd['frequency']) ? $ntpd['frequency'] : 'U'; if ($newstats_style) { $var['jitter'] = isset($ntpd['clk_jitter']) ? $ntpd['clk_jitter'] : 'U'; $var['noise'] = isset($ntpd['sys_jitter']) ? $ntpd['sys_jitter'] : 'U'; $var['stability'] = isset($ntpd['clk_wander']) ? $ntpd['clk_wander'] : 'U'; } else { $var['jitter'] = isset($ntpd['jitter']) ? $ntpd['jitter'] : 'U'; $var['noise'] = isset($ntpd['noise']) ? $ntpd['noise'] : 'U'; $var['stability'] = isset($ntpd['stability']) ? $ntpd['stability'] : 'U'; } $var['uptime'] = isset($ntpd['timesincereset']) ? $ntpd['timesincereset'] : 'U'; $var['buffer_recv'] = isset($ntpd['receivebuffers']) ? $ntpd['receivebuffers'] : 'U'; $var['buffer_free'] = isset($ntpd['freereceivebuffers']) ? $ntpd['freereceivebuffers'] : 'U'; $var['buffer_used'] = isset($ntpd['usedreceivebuffers']) ? $ntpd['usedreceivebuffers'] : 'U'; $var['packets_drop'] = isset($ntpd['droppedpackets']) ? $ntpd['droppedpackets'] : 'U'; $var['packets_ignore'] = isset($ntpd['ignoredpackets']) ? $ntpd['ignoredpackets'] : 'U'; $var['packets_recv'] = isset($ntpd['receivedpackets']) ? $ntpd['receivedpackets'] : 'U'; $var['packets_sent'] = isset($ntpd['packetssent']) ? $ntpd['packetssent'] : 'U'; foreach ($var as $item => $count) { echo $count . "\n"; } } //end doSNMPv2() doSNMPv2($vars, $vars2, $newstats_style);
} } } $var['corrupt-packets'] = isset($pdns['corrupt-packets']) ? $pdns['corrupt-packets'] : "U"; $var['deferred-cache-inserts'] = isset($pdns['deferred-cache-inserts']) ? $pdns['deferred-cache-inserts'] : "U"; $var['deferred-cache-lookup'] = isset($pdns['deferred-cache-lookup']) ? $pdns['deferred-cache-lookup'] : "U"; $var['latency'] = isset($pdns['latency']) ? $pdns['latency'] : "U"; $var['packetcache-hit'] = isset($pdns['packetcache-hit']) ? $pdns['packetcache-hit'] : "U"; $var['packetcache-miss'] = isset($pdns['packetcache-miss']) ? $pdns['packetcache-miss'] : "U"; $var['packetcache-size'] = isset($pdns['packetcache-size']) ? $pdns['packetcache-size'] : "U"; $var['qsize-q'] = isset($pdns['qsize-q']) ? $pdns['qsize-q'] : "U"; $var['query-cache-hit'] = isset($pdns['query-cache-hit']) ? $pdns['query-cache-hit'] : "U"; $var['query-cache-miss'] = isset($pdns['query-cache-miss']) ? $pdns['query-cache-miss'] : "U"; $var['recursing-answers'] = isset($pdns['recursing-answers']) ? $pdns['recursing-answers'] : "U"; $var['recursing-questions'] = isset($pdns['recursing-questions']) ? $pdns['recursing-questions'] : "U"; $var['servfail-packets'] = isset($pdns['servfail-packets']) ? $pdns['servfail-packets'] : "U"; $var['tcp-answers'] = isset($pdns['tcp-answers']) ? $pdns['tcp-answers'] : "U"; $var['tcp-queries'] = isset($pdns['tcp-queries']) ? $pdns['tcp-queries'] : "U"; $var['timedout-packets'] = isset($pdns['timedout-packets']) ? $pdns['timedout-packets'] : "U"; $var['udp-answers'] = isset($pdns['udp-answers']) ? $pdns['udp-answers'] : "U"; $var['udp-queries'] = isset($pdns['udp-queries']) ? $pdns['udp-queries'] : "U"; $var['udp4-answers'] = isset($pdns['udp4-answers']) ? $pdns['udp4-answers'] : "U"; $var['udp4-queries'] = isset($pdns['udp4-queries']) ? $pdns['udp4-queries'] : "U"; $var['udp6-answers'] = isset($pdns['udp6-answers']) ? $pdns['udp6-answers'] : "U"; $var['udp6-queries'] = isset($pdns['udp6-queries']) ? $pdns['udp6-queries'] : "U"; foreach ($var as $item => $count) { echo $count . "\n"; } } doSNMPv2($vars);
foreach ($var as $item => $value) { $tmp .= ";" . $value; } array_push($res, $tmp); } return $res; } function makeCacheFile($data, $cache) { $fp = fopen($cache, 'w'); foreach ($data as $item => $value) { fwrite($fp, $value . "\n"); } fclose($fp); } function readCacheFile($cache) { if (file_exists($cache)) { $data = file($cache); foreach ($data as $item => $value) { echo trim($value) . "\n"; } } } if ($cmd == "makeCache") { $servers = get_list($config); $data = doSNMPv2($servers); makeCacheFile($data, $cache); } else { readCacheFile($cache); }
} } } $var = array(); $var['mess_recv'] = isset($stats['mess_recv']) ? $stats['mess_recv'] : "U"; $var['mess_rejected'] = isset($stats['mess_rejected']) ? $stats['mess_rejected'] : "U"; $var['mess_relay'] = isset($stats['mess_relay']) ? $stats['mess_relay'] : "U"; $var['mess_sent'] = isset($stats['mess_sent']) ? $stats['mess_sent'] : "U"; $var['mess_waiting'] = isset($stats['mess_waiting']) ? $stats['mess_waiting'] : "U"; $var['spam'] = isset($stats['spam']) ? $stats['spam'] : "U"; $var['virus'] = isset($stats['virus']) ? $stats['virus'] : "U"; foreach ($var as $item => $count) { echo $count . "\n"; } } function clearStats($mailstats) { if (file_exists($mailstats)) { $fp = fopen($mailstats, 'w'); fwrite($fp, "mess_recv:0\n"); fwrite($fp, "mess_rejected:0\n"); fwrite($fp, "mess_relay:0\n"); fwrite($fp, "mess_sent:0\n"); fwrite($fp, "mess_waiting:0\n"); fwrite($fp, "spam:0\n"); fwrite($fp, "virus:0\n"); fclose($fp); } } doSNMPv2($mailstats); //clearStats($mailstats);