Nuxt Windows部署到Linux重新初始化依赖包

- mkdir -p /data/nodejs/htdocs/vue/nuxt/ycw
- /data/nodejs/htdocs/vue/nuxt/ycw
- wget http://192.168.180.91/CNMO/vue-nuxt2.tar
- tar xvf vue-nuxt2.tar
- npm i
- npm run build
- npm run start
- #########################################
- vi node_modules/nuxt/bin/nuxt-start
- host = "0.0.0.0"
- #########################################
- "config": {
- "nuxt": {
- "host": "127.0.0.1",
- "port": "3000"
- }
- },
- "config": {
- "nuxt": {
- "host": "0.0.0.0",
- "port": "3000"
- }
- },
- #########################################
- node node_modules/nuxt/bin/nuxt-start
- #########################################
- 如果出现错误无法启动
- ps | grep node
- kill <id>
Linux 搜索文件中的字符串

- [root@sd-cnmo-lidandan-web1 www]# find -type f -name '*.php'|xargs grep 'Plugin_Header'
PHP_遍历节日数组判断当前节日

- <?php
- /****** 获取版本号 || 获取Cookie ******/
- if (isset($_COOKIE["BUILD_NUMBER"])){
- $_Assets = "?v=".$_COOKIE['BUILD_NUMBER'];
- }else{
- $_Assets = "";
- }
- /********** 2018年度节日汇总 || 2017-12-19 *************
- 元旦 -- yuandan || - 201730、31-01
- 春节 -- chunjie || - 20180215-21
- 元宵节 -- yuanxiao || - 20180302
- 情人节 -- qingren || - 20180214
- 妇女节 -- funv || - 20180308
- 劳动节 -- laodong || - 20180501-
- 母亲节 -- muqin || - 20180513
- 儿童节 -- ertong || - 20180601
- 端午节 -- duanwu || - 20180616-18
- 父亲节 -- fuqin || - 20180616-18
- 七夕节 -- qixi || - 20180817
- 教师节 -- jiaoshi || - 20180910
- 中秋节 -- zhongqiu || - 20180922-24
- 国庆节 -- guoqing || - 20181001-07
- 圣诞节 -- shengdan || - 20181225
- 双11 -- 1111 || - 20181111
- 双12 -- 1212 || - 20181212
- 京东618 -- 618 || - 20180618
- 苏宁818 -- 818 || - 20180818
- *****************************************/
- $dayArr = array('yuandan=2017-12-30+1', //3天-跨
- 'yuandan=2018-01-01+0', //3天-跨
- 'chunjie=2017-02-15+6', //7天
- 'qingren=2018-02-14+0', //1天
- 'funv=2018-03-08+0', //1天
- 'laodong=2018-04-29+1', //3天-跨
- 'laodong=2018-05-01+0', //3天-跨
- 'muqin=2018-05-13+0', //1天
- 'ertong=2018-06-01+0', //1天
- 'duanwu=2018-06-16+2', //3天
- 'fuqin=2018-06-17+0', //1天
- 'qixi=2018-08-17+0', //1天
- 'jiaoshi=2018-09-10+0', //1天
- 'zhongqiu=2018-09-22+2', //3天
- 'guoqing=2018-10-01+6', //7天
- 'shengdan=2018-12-25+0', //1天
- 'd1111=2018-11-11+0', //1天
- 'd1212=2018-12-12+0', //1天
- 'd618=2018-06-18+0', //1天
- 'd818=2017-12-12+0'); //1天
- /**********************************************
- 遍历数组判断,添加Class标记
- **********************************************/
- $dayNux = count($dayArr);
- if(isset($_GET["day"])&&!emptyempty($_GET["day"])){
- $currentDate = $_GET["day"];
- }else{
- $currentDate = date('Ymd');
- }
- for($i=0;$i<$dayNux;++$i){
- $dayData = $dayArr[$i];
- $dayNums = substr(strrchr($dayData, "+"),1);
- $dayAlls = substr($dayData,0,strrpos($dayData,'+'));
- $dayStar = substr(strrchr($dayAlls, "="),1);
- $dayName = substr($dayAlls,0,strrpos($dayAlls,'='));
- $flagSt = $currentDate-(str_replace("-","",$dayStar));
- /****** 命中退出 ******/
- if($flagSt>-1&&$flagSt<=$dayNums){
- $dayClass=' '.$dayName;
- break;
- }else{
- if($i==$dayNux-1){
- $dayClass='';
- }
- }
- }
- ?>
111
- <?php
- /**
- * Ajax.class.php
- * ==============================================
- * Copy right 2016-2999 http://www.cnmo.com
- * ----------------------------------------------
- * 修改之前请加上修改人和修改日志
- * ==============================================
- * @param 手机中国 - 平台中心 - TECH
- * @return return_type
- * @author: zhangyang
- * @date: 2016-10-10
- * @version: v1.0.0
- */
- class Controller_Ajax extends CC_Core_Controller
- {
- /**
- * @func: 大家都在玩
- * @date: 2016-10-10
- * @author: zhangyang
- * @return: 大家都在玩
- */
- public function doGetAllPlay()
- {
- $platform = (int) $_REQUEST['platform'];
- $appInfo = Service_Home :: getAppList($platform, 0, 4);
- $gameInfo = Service_Home :: getGameList($platform, 0, 4);
- $allPlayInfo = CC_Kit_String :: iconv('gbk','utf-8',array('appList' => $appInfo,'gameList' => $gameInfo));
- echo json_encode($allPlayInfo);
- die;
- }
- /**
- * @desc: 获取投诉列表
- * @author: zhangyang
- * @date: 2016-10-10
- */
- public function doGetComplain()
- {
- $complain = Service_Home::getComplain();
- $complain = CC_Kit_String::iconv('gbk', 'utf-8', $complain);
- echo json_encode($complain);
- die;
- }
- /**
- * 活动包版
- * @author lidandan
- * @version 2016-12-28
- */
- // public function doActive()
- // {
- // $nowtime = date('Y-m-d H:i:s', time());
- // $status = 0;
- // if($nowtime >= '2016-12-30 10:00:00' && $nowtime <= '2017-01-02 23:59:59'){//奥运会包版
- // $status = 1;
- // }elseif($nowtime >= '2017-01-23 00:00:00' && $nowtime <= '2017-02-02 23:59:59'){//新年包版
- // $status = 2;
- // }elseif($nowtime >= '2017-02-10 16:00:00' && $nowtime <= '2017-02-12 23:59:59'){//元宵节
- // $status = 3;
- // }elseif($nowtime >= '2017-02-14 00:00:00' && $nowtime <= '2017-02-14 23:59:59'){//情人节
- // $status = 4;
- // }elseif($nowtime >= '2017-03-07 10:00:00' && $nowtime <= '2017-03-08 23:59:59'){//妇女节
- // $status = 5;
- // }elseif($nowtime >= '2017-04-01 13:30:00' && $nowtime <= '2017-04-04 23:59:59'){//清明节
- // $status = 6;
- // }elseif($nowtime >= '2017-04-27 12:00:00' && $nowtime <= '2017-05-02 12:00:00'){//五一
- // $status = 7;
- // }elseif($nowtime >= '2017-05-14 00:00:00' && $nowtime <= '2017-05-14 23:59:59'){//母亲节
- // $status = 8;
- // }elseif($nowtime >= '2017-05-27 12:00:00' && $nowtime <= '2017-05-30 23:59:59'){//端午
- // $status = 9;
- // }elseif($nowtime >= '2017-06-01 03:00:00' && $nowtime <= '2017-06-01 23:59:59'){//六一
- // $status = 10;
- // }elseif($nowtime >= '2017-06-18 00:00:00' && $nowtime <= '2017-06-18 23:59:59'){//父亲节
- // $status = 11;
- // }
- // echo $status;
- // exit;
- // }
- /**
- * 活动包版
- * @author liuxinxiu
- * @version 2017-12-20
- */
- public function doActive()
- {
- /********** 2018年度节日汇总 || 2017-12-19 *************
- =======================================
- 名称 代码(class) || 时间跨度
- =======================================
- 元旦 -- yuandan || - 20171230、31-01
- 春节 -- chunjie || - 20180215=>21
- 元宵节 -- yuanxiao || - 20180302=>02
- 情人节 -- qingren || - 20180214=>14
- 妇女节 -- funv || - 20180308=>08
- 劳动节 -- laodong || - 20180429、30-01
- 母亲节 -- muqin || - 20180513=>13
- 儿童节 -- ertong || - 20180601=>01
- 端午节 -- duanwu || - 20180616=>18
- 父亲节 -- fuqin || - 20180616=>18
- 七夕节 -- qixi || - 20180817=>17
- 教师节 -- jiaoshi || - 20180910=>10
- 中秋节 -- zhongqiu || - 20180922=>24
- 国庆节 -- guoqing || - 20181001=>07
- 圣诞节 -- shengdan || - 20181225=>25
- 双11 -- d1111 || - 20181111=>11
- 双12 -- d1212 || - 20181212=>12
- 京东618 -- d618 || - 20180618=>18
- 苏宁818 -- d818 || - 20180818=>18
- *****************************************/
- /******* 公共声明 ********/
- header('Content-type: text/json');
- $dayArr = array('yuandan=2017-12-22 12:00>2018-01-01 23:59', //3天-跨
- 'chunjie=2018-02-15 00:00>2018-02-21 23:59', //7天-跨
- 'qingren=2018-02-14 00:00>2018-02-14 23:59', //1天
- 'funv=2018-03-08 00:00>2018-03-08 23:59', //1天
- 'qingming=2018-04-05 00:00>2018-04-07 23:59', //3天-跨
- 'laodong=2018-04-29 00:00>2018-05-01 23:59', //3天-跨
- 'muqin=2018-05-13 00:00>2018-05-13 23:59', //1天
- 'ertong=2018-06-01 00:00>2018-06-01 23:59', //1天
- 'duanwu=2018-06-16 00:00>2018-06-18 23:59', //3天-跨
- 'fuqin=2018-06-17 00:00>2018-06-17 23:59', //1天-合
- 'qixi=2018-08-17 00:00>2018-08-17 23:59', //1天
- 'jiaoshi=2018-09-10 00:00>2018-09-10 23:59', //1天
- 'zhongqiu=2018-09-22 00:00>2018-09-24 23:59', //3天
- 'guoqing=2018-10-01 00:00>2018-10-07 23:59', //7天
- 'shengdan=2018-12-25 00:00>2018-12-25 23:59', //1天
- 'd1111=2018-11-11 00:00>2018-11-11 23:59', //1天
- 'd1212=2018-12-12 00:00>2018-12-12 23:59', //1天
- 'd618=2018-06-18 00:00>2018-06-18 23:59', //1天
- 'd818=2018-06-18 00:00>2018-08-18 23:59'); //1天
- /**********************************************
- 遍历数组判断,添加Class标记
- **********************************************/
- $dayNux = count($dayArr);
- if(isset($_GET["day"])&&!emptyempty($_GET["day"])){
- $currentDate = $_GET["day"];
- }else{
- $currentDate = date('Ymdhi');
- }
- for($i=0;$i<$dayNux;++$i){
- $dayData = $dayArr[$i];
- $dayEndx = substr(strrchr($dayData, ">"),1);
- $dayAlls = substr($dayData,0,strrpos($dayData,'>'));
- $dayStar = substr(strrchr($dayAlls, "="),1);
- $dayName = substr($dayAlls,0,strrpos($dayAlls,'='));
- $dStar = str_replace(array("-",":"," "),"",$dayStar);
- $dEndx = str_replace(array("-",":"," "),"",$dayEndx);
- /****** 命中退出 ******/
- if($currentDate>=$dStar && $currentDate<=$dEndx){
- $dayClass='"'.$dayName.'"';
- break;
- }else{
- if($i==$dayNux-1){
- $dayClass=0;
- }
- }
- }
- $jsonStr='{
- "status":1,
- "info":"请求成功!",
- "dayClass":'.$dayClass.'
- }';
- echo $jsonStr;
- exit;
- }
- }
- <?php
- $str = "我_们_的_=家+园";
- $str = str_replace(array("_","=","+"),"",$str);
- echo $str; //我们的家园
- ?>
PHP=HTTP请求并处理返回结果

- <?php
- echo '<h1 style="margin-top:100px;">xxxx--11-</h1>';
- echo $redis;
- /****** 获取最新版本号 ******/
- $optsJson = array(
- 'http'=>array(
- 'method'=>"GET",
- 'timeout'=>60,
- )
- );
- $contextJson = stream_context_create($optsJson);
- $dataJson =file_get_contents('http://statict.cnmo-img.com.cn/origin/assets.json', false, $contextJson);
- $arrJson = json_decode($dataJson,true);
- $buildNumber = $arrJson['BUILD_NUMBER'];
- //输出
- //var_dump($arr['BUILD_NUMBER']);
- echo $buildNumber;
- setcookie("Age","18");
- if(isset($buildNumber)&&!emptyempty($buildNumber)){
- setcookie("BUILD_NUMBER",$buildNumber, time()+3600*24);
- }else{
- setcookie("NULL",$buildNumber, time()+3600*24);
- }
- ?>
查看apache日志相关细节

查看apache日志相关细节
- 1、查看当天有多少个IP访问:
- awk '{print $1}' access_log.2017110800|sort|uniq|wc -l
- 2、查看某一个页面被访问的次数;
- grep "/index.php" access_log.2017110800 | wc -l
- 3、查看每一个IP访问了多少个页面:
- awk '{++S[$1]} END {for (a in S) print a,S[a]}' access_log.2017110800
- 4、将每个IP访问的页面数进行从小到大排序:
- awk '{++S[$1]} END {for (a in S) print S[a],a}' access_log.2017110800 | sort -n
- 5、查看某一个IP访问了哪些页面:
- grep ^111.111.111.111 access_log.2017110800| awk '{print $1,$7}'
- 6、去掉搜索引擎统计当天的页面:
- awk '{print $12,$1}' access_log.2017110800 | grep ^\"Mozilla | awk '{print $2}' |sort | uniq | wc -l
- 7、查看2009年6月21日14时这一个小时内有多少IP访问:
- awk '{print $4,$1}' access_log.2017110800 | grep 21/Jun/2009:14 | awk '{print $2}'| sort | uniq | wc -l
Linux shell 之 提取文件名和目录名的一些方法

很多时候在使用Linux的shell时,我们都需要对文件名或目录名进行处理,通常的操作是由路径中提取出文件名,从路径中提取出目录名,提取文件后缀名等等。例如,从路径/dir1/dir2/file.txt中提取也文件名file.txt,提取出目录/dir1/dir2,提取出文件后缀txt等。
下面介绍两种常用的方法来进行相关的操作。
一、使用${}
1、${var##*/}
该命令的作用是去掉变量var从左边算起的最后一个'/'字符及其左边的内容,返回从左边算起的最后一个'/'(不含该字符)的右边的内容。使用例子及结果如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: echo ${var##*/}
file.txt
从运行结果可以看到,使用该命令,可以提取出我们需要的文件名file.txt。
若使用时在shell程序文件中,可以使用变量来保存这个结果,再加以利用,如file=${var##*/}
2、${var##*.}
该命令的作用是去掉变量var从左边算起的最后一个'.'字符及其左边的内容,返回从左边算起的最后一个'.'(不含该字符)的右边的内容。使用例子及结果如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: echo ${var##*.}
txt
从运行结果可以看到,使用该命令,可以提取出我们需要的文件后缀。
如果文件的后缀不仅有一个,例如,file.tar.gz,命令${var##*.}仅能提取最后一个后缀,而我想提取tar.gz时该怎么办?那么就要用下面所说的${var#*.}命令了。
3、${var#*.}
该命令的作用是去掉变量var从左边算起的第一个'.'字符及其左边的内容,返回从左边算起第一个'.'(不含该字符)的右边部分的内容。使用例子及结果如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.tar.gz
liuxinxiu@HongKong: echo ${var#*.}
tar.gz
从运行结果可以看到,使用该命令,可以提取出文件的多个后缀。
4、${var%/*}
该命令的使用是去掉变量var从右边算起的第一个'/'字符及其右边的内容,返回从右边算起的第一个'/'(不含该字符)的左边的内容。使用例子及结果如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: echo ${var%/*}
/dir1/dir2
从运行的结果可以看到,使用该命令,可以提取出我们需要的文件所在的目录
5、${var%%.*}
该命令的使用是去掉变量var从右边算起的最后一个'.'字符及其右边的内容,返回从右边算起的最后一个'.'(不含该字符)的左边的内容。使用例子及结果如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: echo ${var%%.*}
/dir1/dir2/file
当我们需要建立一个与文件名相同名字(没有后缀)的目录与对应的文件相对应时,就可以使用该命令来进行操作。例如,解压文件的情况就与此类似,我们压缩文件file.zip时,会在与file.zip同级目录下建立一个名为file的目录。
6、${}总结
其实${}并不是专门为提取文件名或目录名的,它的使用是变量的提取和替换等等操作,它可以提取非常多的内容,并不一定是上面五个例子中的'/'或'.'。也就是说,上面的使用方法只是它使用的一个特例。
看到上面的这些命令,可能会让人感到非常难以理解和记忆,其实不然,它们都是有规律的。
#:表示从左边算起第一个
%:表示从右边算起第一个
##:表示从左边算起最后一个
%%:表示从右边算起最后一个
换句话来说,#总是表示左边算起,%总是表示右边算起。
*:表示要删除的内容,对于#和##的情况,它位于指定的字符(例子中的'/'和'.')的左边,表于删除指定字符及其左边的内容;对于%和%%的情况,它位于指定的字符(例子中的'/'和'.')的右边,表示删除指定字符及其右边的内容。这里的'*'的位置不能互换,即不能把*号放在#或##的右边,反之亦然。
例如:${var%%x*}表示找出从右边算起最后一个字符x,并删除字符x及其右边的字符。
看到这里,就可以知道,其实该命令的用途非常广泛,上面只是指针文件名和目录名的命名特性来进行提取的一些特例而已。
二、basename和dirname
${}并不是专门为提取文件名和目录名设计的命令,那么basename和dirname命令就是专门为做这一件事而已准备的了。
1、basename
该命令的作用是从路径中提取出文件名,使用方法为basename NAME [SUFFIX]。
1)从路径中提出出文件名(带后缀),例子如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: echo (basename $var)
file.txt
2)从上面命令的用法中可以看到,后缀(SUFFIX)是一个可选项。所以,若只想提取出文件名file,而不带有后缀,还可以在变量的后面加上后缀名,例子如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: echo (basename $var .txt)
file
2、dirname
该命令的作用是从路径中提取出目录名,使用方法为 dirname NAME
使用例子如下:
liuxinxiu@HongKong: var=/dir1/dir2/file.txt
liuxinxiu@HongKong: dirname $var
/dir1/dir2
这样就提取出了file.txt文件所在的目录。
注:该命令不仅能提取出普通文件所的目录,它能提取出任何文件所在的目录,例如目录所在的目录,如下:
liuxinxiu@HongKong: var=/dir1/dir2/
liuxinxiu@HongKong: dirname $var
/dir1
它提取出了目录dir2所在的目录dir1.
yui compressor 自动化压缩Shell(原创)

- #!/bin/bash
- if [ ! -n "$1" ] ;then
- echo "Error: you have not input a word!"
- ##### if [ $1 == "start" ] #######
- elif [ $# -lt 2 ] ; then
- echo "Error: number of parameters!"
- else
- #echo "Error: the word you input is $1"
- if [[ ! -d "$1" ]]; then
- mkdir "$1"
- echo "Error: Directory does not exist $1"
- elif [[ ! -d "$2" ]]; then
- mkdir "$1"
- echo "Error: Directory does not exist $2"
- else
- echo -e "=============== [www.cnmo.com] ================"
- ##### SubmitTime #######
- if [ ! -n "$3" ] ;then
- #echo "you have not input a word!"
- svntime=''
- else
- #echo "the word you input is $1"
- minx=$[ $3 * 60 ]
- #seldate=`-mtime $minx`
- seldate='-mmin -'$minx
- fi
- #find $1 -type f -mtime 0 \( -name '*css' -or -name '*js' \) -printf "%P\n" | while read file #按时间
- find $1 -type f $seldate \( -name '*css' -or -name '*js' \) -printf "%P\n" | while read file #按全部
- do
- ##### mkdir path #######
- npath=${file%/*}
- if [[ ! -d "$npath" ]]; then
- mkdir -p "$npath"
- fi
- #strA="helloworld"
- #strB="tpl"
- #if [[ $file =~ $strB ]]
- #then
- # echo "包含"
- #else
- # echo "不包含"
- #fi
- if [[ $file =~ "tpl" ]]
- then
- echo "目录: "$file" 包含/tpl/直接略过.."
- else
- ##### start yui #######
- dfile=$1"/"$file
- nfile=$2"/"$file
- yjar=/jar/yuicompressor-2.4.7.jar
- if [ "${file##*.}" = "css" ]; then
- java -jar $yjar --type css --charset gb2312 $dfile -o $nfile
- echo -e "ok[==>css]:"$nfile
- elif [ "${file##*.}" = "js" ]; then
- java -jar $yjar --type js --charset gb2312 $dfile -o $nfile
- #java -jar /jar/yuicompressor-2.4.2.jar --type js --charset gb2312 /data/svnroot/jenkins_SVN_data/old/origin/touch/315j.js -o /test/origin/touch/315j.js
- echo -e "ok[==>js]:"$nfile
- fi
- fi
- done
- fi
- fi
- java -jar /jar/yuicompressor-2.4.2.jar --type js --charset gb2312 /data/svnroot/jenkins_SVN_data/old/origin/touch/315j.js -o /test/origin/touch/315j.js
find / -amin -10 # 查找在系统中最后10分钟访问的文件
find / -atime -2 # 查找在系统中最后48小时访问的文件
find / -mmin -5 # 查找在系统中最后5分钟里修改过的文件
find / -mtime -1 #查找在系统中最后24小时里修改过的文件
netstat监控大量ESTABLISHED连接数和TIME_WAIT连接数题解决

查看网络连接数:
- net.ipv4.tcp_keepalive_time = 1200 #表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。
- net.ipv4.ip_local_port_range = 1024 65000 #表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000。
- net.ipv4.tcp_max_syn_backlog = 8192 #表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。
- net.ipv4.tcp_max_tw_buckets = 5000 #表示系统同时保持TIME_WAIT套接字的最大数量,如果超过这个数字,TIME_WAIT套接字将立刻被清除并打印警告信息。
- 默认为180000,改为5000。
- 对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量,但是对于 Squid,效果却不大。此项参数可以控制TIME_WAIT套接字的最大数量,避免Squid服务器被大量的TIME_WAIT套接字拖死。
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
*****
connectionTimeout="20000" 改为 connectionTimeout="100"acceptCount="100"改为acceptCount="5000"
Action.c(380): 错误 -26608: 对于“http://www.cnlogs.com/javame”,HTTP 状态代码=504 (Gateway Time-out)
- netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
解释: 返回结果示例: LAST_ACK 5 (正在等待处理的请求数) SYN_RECV 30 ESTABLISHED 1597 (正常数据传输状态) FIN_WAIT1 51 FIN_WAIT2 504 TIME_WAIT 1057 (处理完毕,等待超时结束的请求数) 状态:描述 CLOSED:无连接是活动的或正在进行 LISTEN:服务器在等待进入呼叫 SYN_RECV:一个连接请求已经到达,等待确认 SYN_SENT:应用已经开始,打开一个连接 ESTABLISHED:正常数据传输状态 FIN_WAIT1:应用说它已经完成 FIN_WAIT2:另一边已同意释放 ITMED_WAIT:等待所有分组死掉 CLOSING:两边同时尝试关闭 TIME_WAIT:另一边已初始化一个释放 LAST_ACK:等待所有分组死掉 使用这上面的命令是可以查看服务器的种连接状态,其中ESTABLISHED 就是并发连接状态的显示数的了。如果你不想查看到这么多连接状态,而仅仅只是想查看并发连接数,可以简化一下命令,即:
- netstat -nat|grep ESTABLISHED|wc -l
- 1164
这个返回的数字就是当前并发的连接数的了。
nginx日志统计分析

- [root@httpservera 20160329]# cut -d- -f 1 /usr/local/nginx/logs/20160329/access_2016032913.log |uniq -c | sort -rn | head -20
- 69 180.116.214.31
- 45 180.116.214.31
- 45 180.116.214.31
- 36 49.80.54.111
- 35 183.206.185.204
- 35 180.116.214.31
- 32 49.80.54.111
- 32 49.80.54.111
- 32 180.116.214.31
- 31 117.136.45.101
- 29 180.116.214.31
- 28 218.205.19.112
- 28 180.116.214.31
- 28 180.116.214.31
- 27 49.80.54.111
- 27 222.185.248.242
- 24 49.80.54.111
- 24 175.0.8.161
- 23 49.80.54.111
- 23 49.80.54.111
2,查看某一个页面被访问的次数
- [root@httpservera 20160329]# awk '{++S[$1]} END {for (a in S) print a,S[a]}' access_2016032913.log |uniq|sort -rn|more
- 223.94.229.51 148
- 223.73.166.191 1
- 223.68.252.103 156
- 223.68.167.66 2
- 223.68.106.138 43
- 223.67.99.72 7
- 223.67.153.173 12
- 223.66.93.152 15
- 223.66.38.31 103
- 223.65.191.181 1
- 223.65.191.135 11
- 223.65.190.71 13
- 223.65.141.78 3
- 223.64.63.71 31
- 223.64.63.229 7
- 223.64.62.242 59
- 223.64.62.23 27
- 223.64.62.216 1
- 223.64.62.160 40
- 223.64.61.136 28
- 223.64.60.80 13
- 223.64.60.21 12
- 223.64.237.37 187
- 223.64.209.247 2
- 223.64.158.4 15
- [root@httpservera 20160329]# grep ^223.147.39.194 17 access_2016032913.log |awk '{print $1,$7}' grep: 17: No such file or directory
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //thirdpartyapi/appaction/app_action/action_send_batch.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //customer/customerInfo/getCustUnReadMsgInfo.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- access_2016032913.log:223.147.39.194 //remind/redDot/checkRedDot.json
- [root@httpservera 20160329]# awk '{print $12,$1}' access_2016032913.log | grep ^\"Mozilla | awk '{print $2}' |sort | uniq | wc -l
- 35
- [root@httpservera 20160329]# awk '{print $4,$1}' access_2016032913.log | grep 29/Mar/2016:13 | awk '{print $2}'| sort | uniq | wc -l
- 1926
- 1.根据访问IP统计UV
- awk '{print $1}' access.log|sort | uniq -c |wc -l
- 2.统计访问URL统计PV
- awk '{print $7}' access.log|wc -l
- 3.查询访问最频繁的URL
- awk '{print $7}' access.log|sort | uniq -c |sort -n -k 1 -r|more
- 4.查询访问最频繁的IP
- awk '{print $1}' access.log|sort | uniq -c |sort -n -k 1 -r|more
- 5.根据时间段统计查看日志
- cat access.log| sed -n '/14\/Mar\/2015:21/,/14\/Mar\/2015:22/p'|more
- [root@iZ237lzm354Z logs]# vim /opt/shell/nginx_log.sh
- #! /bin/bash
- #Power by guojinbao
- date=`date +%Y-%m-%d-%H-%M-%S`
- logfile="/guojinbao/nginx/logs/access.log"
- logdir=/guojinbao/nginx/logs
- pid=`cat /usr/local/nginx/logs/nginx.pid`
- if [ ! -d $logdir ]; then
- mkdir -p $logdir
- fi
- /bin/mv $logfile $logdir/access_${date}.log
- kill -HUP $pid