当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::print_error方法代码示例

本文整理汇总了PHP中Utils::print_error方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::print_error方法的具体用法?PHP Utils::print_error怎么用?PHP Utils::print_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils的用法示例。


在下文中一共展示了Utils::print_error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check

 public function check()
 {
     $arrRes = Utils::get_cmd_res('ulimit -c');
     if ($arrRes[0] === '0') {
         Utils::print_error("没有打开coredump设置");
         return;
     }
     $arrRes = Utils::get_cmd_res('cat /proc/sys/kernel/core_pattern');
     $pattern = $arrRes[0];
     if (empty($pattern)) {
         return;
     }
     $dir_name = dirname($pattern);
     if ($dir_name === '.') {
         return;
     }
     if ($handle = @opendir($dir_name)) {
         $msg = '';
         $delimiter = '';
         while (false !== ($entry = readdir($handle))) {
             if ($entry == '.' || $entry == '..') {
                 continue;
             }
             $msg .= "{$delimiter}corefile: {$entry} ";
             $delimiter = "\n";
         }
         Utils::print_error($msg);
         closedir($handle);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:30,代码来源:linuxCoreDump.php

示例2: check

 public function check()
 {
     $c_user = Utils::get_current_uname();
     if ($c_user != 'root') {
         Utils::print_error("'" . __CLASS__ . "' need root privilege to run check");
         return;
     }
     $arrRes = Utils::get_cmd_res_split(" ps -efH | grep php-cgi | grep -v grep | awk '{print \$2}'");
     unset($arrRes[0]);
     $stack = array();
     foreach ($arrRes as $val) {
         $cmd = "pstack {$val[0]} | head -1 | awk '{print \$4}'";
         $hang_fun = Utils::get_cmd_res($cmd);
         $stack[] = $hang_fun[0];
     }
     $cnt_val = array_count_values($stack);
     arsort($cnt_val);
     $sum_process = count($arrRes);
     foreach ($cnt_val as $key => $val) {
         if ($key == '__accept_nocancel') {
             continue;
         }
         if ($val * 2 >= $sum_process) {
             $msg = "php process hang on system function '{$key}' ";
             Utils::print_error($msg);
         }
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:28,代码来源:phpHang.php

示例3: check

 public function check()
 {
     /*----------检查磁盘空间-------------*/
     $cmd = "df -h";
     $arrRes = array();
     exec($cmd, $arrRes);
     unset($arrRes[0]);
     foreach ($arrRes as $val) {
         $val = Utils::split_line_space($val);
         if ($val[4] == '100%') {
             $msg = 'space:' . $val[0] . "\t" . $val[4];
             Utils::print_error($msg);
         }
     }
     /*----------检查inode使用-------------*/
     $cmd = "df -i";
     $arrRes = array();
     exec($cmd, $arrRes);
     unset($arrRes[0]);
     foreach ($arrRes as $val) {
         $val = Utils::split_line_space($val);
         if ($val[4] == '100%') {
             $msg = 'inode:' . $val[0] . "\t" . $val[4];
             Utils::print_error($msg);
         }
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:27,代码来源:linuxHardDisk.php

示例4: check

 public function check()
 {
     $cmd = "ps -ef | grep 'php-cgi' | grep -v grep  | wc -l";
     $arrRes = Utils::get_cmd_res($cmd);
     $php_num = intval($arrRes[0]);
     if ($php_num == 0) {
         $msg = "there are no php process";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:10,代码来源:phpAlive.php

示例5: check

 public function check()
 {
     $cmd = "ps -ef | grep 'nginx: worker process' | grep -v grep  | wc -l";
     $arrRes = Utils::get_cmd_res($cmd);
     $nginx_num = intval($arrRes[0]);
     if ($nginx_num == 0) {
         $msg = "there are no nginx process";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:10,代码来源:nginxAlive.php

示例6: check

 public function check()
 {
     $cmd = "netstat -n  | grep SYN_RECV | wc -l";
     $arrRes = Utils::get_cmd_res($cmd);
     $syc_recv_num = intval($arrRes[0]);
     if ($syc_recv_num > 10) {
         $msg = "SYN_RECV  status num : {$syc_recv_num}, there may be a syn flood attack";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:10,代码来源:linuxSYNFlood.php

示例7: check

 public function check()
 {
     $arrRes = Utils::get_cmd_res('ulimit -n');
     $max_open_file = intval($arrRes[0]);
     $arrRes = Utils::get_cmd_res_split('sar -v 1');
     $open_file = $arrRes[3][2];
     if ($open_file * 100 / $max_open_file > 30) {
         $msg = "open file handle num : {$open_file}, max open handle num : {$max_open_file}";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:11,代码来源:linuxFileHandle.php

示例8: check

 public function check()
 {
     $arrRes = Utils::get_cmd_res(' mpstat -P ALL | wc -l');
     $cpu_num = $arrRes[0] - 4;
     $arrRes = Utils::get_cmd_res_split('uptime');
     $load_one_minute = trim($arrRes[0][7], ' ,');
     if ($load_one_minute > 2 * $cpu_num) {
         $msg = "cpu number: {$cpu_num}, load in 1 minute: {$load_one_minute}";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:11,代码来源:linuxCpuLoad.php

示例9: checkStatus

 public function checkStatus($log_line, $log_format)
 {
     $index = $log_format['$status'];
     $status = array();
     foreach ($log_line as $val) {
         $status[$val[$index]]++;
     }
     if ($status[200] != count($log_line)) {
         $msg = "http status num :\n" . var_export($status, true);
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:12,代码来源:nginxLog.php

示例10: check

 public function check()
 {
     $php_server_port = lnmpConfig::PHP_SERVER_PORT;
     $cmd = "netstat -n | grep ESTABLISHED | awk '{print \$4}' | grep :{$php_server_port} | wc -l";
     $arrRes = Utils::get_cmd_res($cmd);
     $concurrency = intval($arrRes[0]);
     //并发度
     if ($concurrency * 1000 > lnmpConfig::REQUEST_TIME_COST * lnmpConfig::SERVER_THROUGHPUT) {
         $msg = "the php connections is too many , connections:  {$concurrency} , time_cost : " . lnmpConfig::REQUEST_TIME_COST . "ms, throughput :" . lnmpConfig::SERVER_THROUGHPUT . "qps";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:12,代码来源:phpConnections.php

示例11: check

 public function check()
 {
     $web_server_port = lnmpConfig::WEB_SERVER_PORT;
     $cmd = "netstat -n | grep ESTABLISHED | awk '{print \$4}' | grep :{$web_server_port} | wc -l";
     $arrRes = Utils::get_cmd_res($cmd);
     $concurrency = intval($arrRes[0]);
     //并发度,不活跃进的连接也算作了并发度,在繁忙的服务器上,连接一般都是活跃的,所以误差不会很大, 长连接除外。
     if ($concurrency * 1000 > lnmpConfig::REQUEST_TIME_COST * lnmpConfig::SERVER_THROUGHPUT) {
         $msg = "the server connections is too many , connections:  {$concurrency} , time_cost : " . lnmpConfig::REQUEST_TIME_COST . "ms, throughput :" . lnmpConfig::SERVER_THROUGHPUT . "qps";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:12,代码来源:linuxConnections.php

示例12: check

 public function check()
 {
     $arrRes = Utils::get_cmd_res_split('free');
     $total = $arrRes[1][1];
     $free = $arrRes[2][3];
     $use_ratio = round(($total - $free) * 100 / $total, 1);
     if ($use_ratio > 80) {
         $used = $total - $free;
         $total = round($total / 1024, 0);
         $used = round($used / 1024, 0);
         $free = round($free / 1024, 0);
         $msg = "Memory, total: {$total}M,  used:{$used}M, free:{$free}M, {$use_ratio}% used";
         Utils::print_error($msg);
     }
     //是否要加下swap使用率
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:16,代码来源:linuxMemory.php

示例13: check

 public function check()
 {
     $arrRes = Utils::get_cmd_res_split('iostat -d -x 1 2');
     //计算最近的1s  IOWAIT也在这里查看
     for ($i = 6;; $i++) {
         $hd = $arrRes[$i];
         if (empty($hd[0])) {
             break;
         }
         if ($hd[11] >= 20) {
             $msg = "{$hd[0]} : {$hd[11]}, percentage of CPU time during which I/O requests were issued to the device, the IO is too high";
             Utils::print_error($msg);
         }
         $await = $hd[9];
         $svctm = $hd[10];
         if ($await > 5 * $svctm) {
             $msg = "await : {$await}, svctm:{$svctm}, the await time is greater than svctm much more, the IO is too high";
             Utils::print_error($msg);
         }
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:21,代码来源:linuxIO.php

示例14: check

 public function check()
 {
     $arrRes = Utils::get_cmd_res_split('vmstat 1 2');
     //计算最近的1s  IOWAIT也在这里查看
     $idle = $arrRes[3][14];
     if ($idle < 20) {
         $msg = "idle:{$idle}";
         Utils::print_error($msg);
     }
     $wa = $arrRes[3][15];
     if ($wa > 10) {
         $msg = "cpu wa:{$wa}, too many time spent waiting for IO";
         // iostat -x %util也会相应的高
         Utils::print_error($msg);
     }
     $si = $arrRes[3][6];
     $so = $arrRes[3][7];
     if ($si >= 200 || $so >= 200) {
         $msg = "si: {$si} , so: {$so} , the swap rate is too high, may not have enough memory";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:22,代码来源:linuxCpu.php

示例15: check

 public function check()
 {
     $mysql_info = lnmpConfig::$mysql_info;
     $link = mysql_connect($mysql_info['host'] . ':' . $mysql_info['port'], $mysql_info['user'], $mysql_info['pass']);
     if ($link === false) {
         $msg = "Failed to connect to MySQL: " . mysql_error();
         Utils::print_error($msg);
         exit;
     }
     $result = mysql_query("show processlist;");
     $sum_cnt = 0;
     $no_sleep_cnt = 0;
     while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
         if ($line['Command'] != 'Sleep') {
             $no_sleep_cnt++;
         }
         $sum_cnt++;
     }
     if ($sum_cnt > 3 && $no_sleep_cnt * 5 > $sum_cnt) {
         $msg = "Too many mysql threads is running";
         Utils::print_error($msg);
     }
 }
开发者ID:biggtfish,项目名称:lnmpcheck,代码行数:23,代码来源:mysqlThreadStatus.php


注:本文中的Utils::print_error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。