本文整理汇总了PHP中unix::PROCESS_MEMORY方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::PROCESS_MEMORY方法的具体用法?PHP unix::PROCESS_MEMORY怎么用?PHP unix::PROCESS_MEMORY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::PROCESS_MEMORY方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkProcess1
function checkProcess1(){
$unix=new unix();
$pid=$unix->PIDOF_PATTERN("bin/process1");
if($pid<5){return null;}
$process1=$unix->PROCCESS_TIME_MIN($pid);
$mem=$unix->PROCESS_MEMORY($pid);
Myevents("process1: $pid ($process1 mn) memory:$mem Mb",__FUNCTION__);
if($mem>30){
@copy("/var/log/artica-postfix/process1.debug","/var/log/artica-postfix/process1.killed".time().".debug");
system("/bin/kill -9 $pid");
$unix->send_email_events(
"artica process1 (process1) Killed",
"Process1 use too much memory $mem MB","watchdog");
}
if($process1>2){
@copy("/var/log/artica-postfix/process1.debug","/var/log/artica-postfix/process1.killed".time().".debug");
system("/bin/kill -9 $pid");
$unix->send_email_events(
"artica process1 (process1) Killed",
"Process1 run since $process1 Pid: $pid and exceed 2 minutes live","watchdog");
}
}
示例2: php_cgi_array
function php_cgi_array()
{
$unix = new unix();
$pgrep = $unix->find_program("pgrep");
$php_cgi = $unix->find_program("php-cgi");
$cmd = "{$pgrep} -l -f \"{$php_cgi}\" 2>&1";
exec("{$pgrep} -l -f \"{$php_cgi}\" 2>&1", $results);
writelogs_framework("{$cmd} ->" . count($results) . " line", __FUNCTION__, __FILE__, __LINE__);
while (list($num, $ligne) = each($results)) {
if (preg_match("#\\/pgrep#", $ligne)) {
continue;
}
if (preg_match("#([0-9]+)\\s+#", $ligne, $re)) {
$pid = $re[1];
$PPID = $unix->PPID_OF($pid);
$rss0 = $unix->PROCESS_MEMORY($pid, true);
$vm0 = $unix->PROCESS_CACHE_MEMORY($pid, true);
$TTL = $unix->PROCESS_TTL_TEXT($pid);
$PPID2 = $unix->PPID_OF($PPID);
if ($PPID2 > 0) {
if ($PPID2 != $pid) {
$PPID = $PPID2;
}
}
$ARRAY[$PPID][$pid]["RSS"] = $unix->PROCESS_MEMORY($pid, true);
$ARRAY[$PPID][$pid]["VM"] = $unix->PROCESS_CACHE_MEMORY($pid, true);
$ARRAY[$PPID][$pid]["TTL"] = $unix->PROCESS_TTL_TEXT($pid, true);
}
}
echo "<articadatascgi>" . base64_encode(serialize($ARRAY)) . "</articadatascgi>";
}
示例3: GetMemoriesOf
function GetMemoriesOf($pid)
{
$unix = new unix();
$rss = $unix->PROCESS_MEMORY($pid, true);
$vm = $unix->PROCESS_CACHE_MEMORY($pid, true);
exec("pgrep -P {$pid}", $results);
$count = 0;
while (list($num, $ligne) = each($results)) {
$ligne = trim($ligne);
if ($ligne < 1) {
continue;
}
$count = $count + 1;
$rss = $rss + $unix->PROCESS_MEMORY($ligne, true);
$vm = $vm + $unix->PROCESS_CACHE_MEMORY($ligne, true);
}
if ($count == 0) {
$count = 1;
}
$l[] = "master_pid={$pid}";
$l[] = "master_memory={$rss}";
//$l[]="master_cached_memory=$vm";
$l[] = "processes_number={$count}";
return implode("\n", $l);
}
示例4: instance_memory
function instance_memory()
{
$instance_id = $_GET["instance_id"];
$pidfile = "/var/run/mysqld/mysqld{$instance_id}.pid";
$unix = new unix();
$pid = multi_get_pid($instance_id);
writelogs_framework("{$pidfile} -> {$pid}", __FUNCTION__, __FILE__, __LINE__);
if ($unix->process_exists($pid)) {
$rss = $unix->PROCESS_MEMORY($pid, true);
$vm = $unix->PROCESS_CACHE_MEMORY($pid, true);
}
echo "<articadatascgi>" . base64_encode(serialize(array($rss, $vm))) . "</articadatascgi>";
}
示例5: mod_status
function mod_status($servername = null)
{
$unix = new unix();
if ($servername == "_default_") {
return;
}
$unix->hostname_g();
$hostname = $unix->hostname_g();
$hosnenc = md5($unix->hostname_g());
$conf[] = "# Status from " . $unix->hostname_g();
$conf[] = "<Location >";
$curl = $unix->find_program("curl");
$TEMP_FILE = $unix->FILE_TEMP();
$cmdline = "{$curl} --interface 127.0.0.1 http://localhost/{$hosnenc}/{$hosnenc}-status >{$TEMP_FILE}";
if ($GLOBALS["VERBOSE"]) {
echo $cmdline . "\n";
}
shell_exec($cmdline);
$q = new mysql();
$pid = array();
$access = null;
$total_traffic = null;
$total_traffic_unit = null;
$traffic_sec = 0;
$traffic_request = 0;
$request_s = 0;
$UPTIME = null;
$total_mem = 0;
$datas = explode("\n", @file_get_contents($TEMP_FILE));
@unlink($TEMP_FILE);
while (list($num, $ligne) = each($datas)) {
if ($GLOBALS["VERBOSE"]) {
echo "Parsing line...`{$ligne}`\n";
}
if (preg_match("#<dt>Server uptime:\\s+(.+?)</dt>#", $ligne, $re)) {
$UPTIME = trim($re[1]);
if ($GLOBALS["VERBOSE"]) {
echo "*************\nUPTIME = {$UPTIME}\n";
}
continue;
}
if (preg_match("#Total accesses:\\s+([0-9]+)\\s+-\\s+Total Traffic:\\s+([0-9\\.]+)\\s+([a-zA-Z]+)#i", $ligne, $re)) {
$access = $re[1];
$total_traffic = $re[2];
$total_traffic = UnitToBytes($total_traffic, strtoupper($re[3]));
if ($GLOBALS["VERBOSE"]) {
echo "*************\n{$access} - {$total_traffic}\n";
}
continue;
}
if (preg_match("#([0-9\\.]+)\\s+requests\\/sec\\s+-\\s+([0-9\\.]+)\\s+(.+)\\/second\\s+-\\s+([0-9\\.]+)\\s+(.+?)\\/request#", $ligne, $re)) {
$request_s = $re[1];
if (substr($request_s, 0, 1) == ".") {
$request_s = "0{$request_s}";
}
$traffic_sec = UnitToBytes($re[2], $re[3]);
$traffic_request = UnitToBytes($re[4], $re[5]);
continue;
}
if (preg_match("#<td><b>[0-9]+-[0-9]+</b></td><td>([0-9]+)</td><td>#", $ligne, $re)) {
$pid[$re[1]] = $re[1];
}
}
if (count($pid) > 0) {
while (list($num, $ligne) = each($pid)) {
$total = $unix->PROCESS_MEMORY($num, true);
if ($GLOBALS["VERBOSE"]) {
echo "Current PID: {$num} {$total} KB\n";
}
$total_mem = $total_mem + $total;
}
}
if ($GLOBALS["VERBOSE"]) {
echo "\n\n ***************************************************************************************************************";
echo "Access: {$access} total-traffic:{$total_traffic} bytes UPTIME={$UPTIME} Total memory used: {$total_mem} Bytes\n";
echo "Access: requests/seconds: {$request_s} traffic/sec:{$traffic_sec} trafic per request:{$traffic_request} bytes:\n";
echo "\n\n ***************************************************************************************************************";
}
if (!is_numeric($total_traffic)) {
if ($GLOBALS["VERBOSE"]) {
echo "No traffic return null\n";
}
return;
}
$UPTIME = str_replace("</td>", "", $UPTIME);
$UPTIME = str_replace("</dt>", "", $UPTIME);
if ($GLOBALS["VERBOSE"]) {
echo "MEMORY: " . FormatBytes($total_mem) . "\n";
}
$HASH["total_traffic"] = $total_traffic;
$HASH["total_mem"] = $total_mem * 1024;
$HASH["requests_second"] = $request_s;
$HASH["traffic_second"] = $traffic_sec;
$HASH["traffic_request"] = $traffic_request;
$HASH["UPTIME"] = $UPTIME;
$table_name = "apache_stats_" . date('Ym');
$q = new mysql();
$sql = "SELECT AVG(total_traffic) as total_traffic,\n\t\t\tAVG(total_memory) as total_memory,\n\t\t\tAVG(requests_second) as requests_second,\n\t\t\tAVG(traffic_second) as traffic_second,\n\t\t\tAVG(traffic_request) as traffic_request FROM `{$table_name}`";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
$HASH["AVG"]["total_traffic"] = $ligne["total_traffic"];
//.........这里部分代码省略.........