Hey guys... Long time lurker here but I'm in need of some help. I came across this script that I want to modify but can't seem to figure it out... I'll post the script and then explain what I want.
<?
$url = 'http://127.0.0.1/status';
$get_data = file_get_contents($url);
preg_match_all("|<tr bgcolor=\"#ffffff\"><td><b>[^<]+</b><td>[^<]+<td>[^<]+<td>[^<]+<td>([^<]+)<td>[^<]+<td>[^<]+<td>[^<]+<td>[^<]+<td>[^<]+<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">[^<]+</font><td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">([^<]+)</font>|",$get_data,$matches);
$count = count($matches[2]);
echo "$count\n";
$domain_cpu = $domain_processes = array();
foreach ( $matches[2] as $index => $domain )
{
if ( $domain == '(unavailable)' )
{
continue;
}
$domain = preg_replace("/\Awww\./","",$domain);
$cpu = $matches[1][$index];
if ($domain_cpu[$domain])
{
$domain_cpu[$domain] += $cpu;
$domain_cpu[$domain] /= 2;
//echo "$domain_cpu[$domain] - $domain\n";
}
else
{
$domain_cpu[$domain] = $cpu;
}
$domain_processes[$domain]++;
}
?>
So, what I'm wanting to do is grab all domains that are alike ($matches[2]) and get their CPU ($matches[1]) and if there's more than one $matches[2], get the average number from $matches[1], if that makes any sense.
Thanks.