0)) usleep(100000); $stats = file($statfile); foreach ($stats as $line) { if (strpos($line, 'success') !== false) { $parts = preg_split("/[\s:]+/", trim($line)); $named[0] = $parts[1]; } elseif (strpos($line, 'referral') !== false) { $parts = preg_split("/[\s:]+/", trim($line)); $named[1] = $parts[1]; } elseif (strpos($line, 'nxrrset') !== false) { $parts = preg_split("/[\s:]+/", trim($line)); $named[2] = $parts[1]; } elseif (strpos($line, 'nxdomain') !== false) { $parts = preg_split("/[\s:]+/", trim($line)); $named[3] = $parts[1]; } elseif (strpos($line, 'recursion') !== false) { $parts = preg_split("/[\s:]+/", trim($line)); $named[4] = $parts[1]; } elseif (strpos($line, 'failure') !== false) { $parts = preg_split("/[\s:]+/", trim($line)); $named[5] = $parts[1]; } } return $named; } function get_squid($host, $comunity) { $cmd = "/usr/bin/snmpget -v1 -c {$comunity} {$host} ". ".1.3.6.1.4.1.3495.1.3.2.1.1 .1.3.6.1.4.1.3495.1.3.2.1.2 ". ".1.3.6.1.4.1.3495.1.3.2.1.3 .1.3.6.1.4.1.3495.1.3.2.1.4 ". ".1.3.6.1.4.1.3495.1.3.2.1.5 .1.3.6.1.4.1.3495.1.3.2.1.10 ". ".1.3.6.1.4.1.3495.1.3.2.1.11 .1.3.6.1.4.1.3495.1.3.2.1.12 ". ".1.3.6.1.4.1.3495.1.3.2.1.13 .1.3.6.1.4.1.3495.1.3.2.1.14 ". "-O qs"; exec($cmd, $poll); foreach ($poll as $line) { $parts = preg_split("/[\s:]+/", trim($line)); $squid[] = $parts[1]; } return $squid; } function get_conntrack() { $retval = array(); $retval['total'] = 0; $retval['assured'] = 0; $retval['unreplied'] = 0; $retval['tcp'] = 0; $retval['udp'] = 0; $retval['unknown'] = 0; $retval['stat']['NONE'] = 0; $retval['stat']['SYN_SENT'] = 0; $retval['stat']['SYN_RECV'] = 0; $retval['stat']['ESTABLISHED'] = 0; $retval['stat']['FIN_WAIT'] = 0; $retval['stat']['CLOSE_WAIT'] = 0; $retval['stat']['LAST_ACK'] = 0; $retval['stat']['TIME_WAIT'] = 0; $retval['stat']['CLOSE'] = 0; $retval['stat']['LISTEN'] = 0; $retval['local'] = 0; $retval['nated'] = 0; $max = file('/proc/sys/net/ipv4/ip_conntrack_max'); $retval['max'] = (int)$max[0]; $conn = file('/proc/net/ip_conntrack'); foreach ($conn as $line) { $flags = 0x0; $retval['total']++; $parts = preg_split("/[\s:]+/", trim($line)); if (strpos($line, '[ASSURED]') !== false) { $retval['assured']++; } if (strpos($line, '[UNREPLIED]') !== false) { $retval['unreplied']++; $flags |= 0x1; } if (strpos($line, 'tcp') !== false) { $retval['tcp']++; $retval['stat'][$parts[3]]++; if (!($flags & 0x1)) { // dst1 != src2 || src1 != dst2 if (substr($parts[5], 4) != substr($parts[10], 4) || substr($parts[4], 4) != substr($parts[11], 4)) $retval['nated']++; else $retval['local']++; } } else if (strpos($line, 'udp') !== false) { $retval['udp']++; if (!($flags & 0x1)) { // dst1 != src2 || src1 != dst2 if (substr($parts[4], 4) != substr($parts[9], 4) || substr($parts[3], 4) != substr($parts[10], 4)) $retval['nated']++; else $retval['local']++; } } else { $retval['unknown']++; } } return $retval; } function get_netstat($file) { $stat = file($file); $retval = preg_split("/[\s:]+/", trim($stat[1])); foreach ($retval as $key => $val) $retval[$key] = hexdec($val); return $retval; } } ?>