Файл: wmon_dist/lib/wmon.php
Строк: 52
<?php
class wmon {
public static function config($key,$default=NULL)
{
global $config;
return isset($config[$key]) ? $config[$key] : $default;
}
public static function varname($name)
{
return preg_replace('/[^a-z0-9_]/i','_',$name);
}
public static function check_service($service)
{
return (bool)shell_exec('ps ax -o '%c %P' | awk '{if (($2 == 1) && ($1 == "''.$service.''")) print $0}'');
}
public static function cpu_model_name()
{
foreach(explode("n",shell_exec('cat /proc/cpuinfo')) as $line)
{
$tmp = explode(':',$line,2);
if(trim($tmp[0])=='model name') return trim($tmp[1]);
}
return '';
}
public static function uptime()
{
return shell_exec('uptime');
}
public static function partitions()
{
$data = shell_exec('df -hP | grep -vE ''.self::config('partitions_exclude').'' | awk '{ print $1 " " $6 " " $2 " " $3 " " $4 " " $5 }'');
return explode("n", $data);
}
public static function top()
{
return preg_replace('/ +/', ' ',shell_exec('ps axeo "%C %U %c" --sort -pcpu | head -n 7 | tail -n 6'));
}
public static function internet()
{
return (bool)shell_exec('ping -c 1 google.com > /dev/null 2>&1 && echo 1');
}
}