Linux 检查端口gps命令
由于是游戏业务,环境主要是Nginx+Tomcat+Java Program
gps脚本环境以及效果图如下:
- #!/bin/bash
- function Printf (){
- if [ $ == ];then
- printf '%-50s\n' "+-----------------+------------------+-----------------+"
- shift
- fi
- printf '%1s %-10s %1s %10s %1s %10s %1s\n' "|" "$1" "|" "$2" "|" "$3" "|"
- printf '%-50s\n' "+-----------------+------------------+-----------------+"
- }
- function GameStatus (){
- Port=$
- Path=$
- Name=$
- local SiteValue=$
- Ppid=$
- nc -vz 127.0.0.1 ${Port} >/dev/null >&
- if [ $? == ];then
- Status=$(echo -e "\e[32m OK \e[0m")
- else
- Status=$(echo -e "\e[31mError\e[0m")
- fi
- if [[ -z ${Ppid} ]];then
- if [ "$USER" == "root" ];then
- Pid=$(netstat -nltp | egrep -w "0.0.0.0:${Port}|0 :::${Port}" | awk '{print $7}' | sed 's#/.*##')
- else
- Pid=$(sudo netstat -nltp | egrep -w "0.0.0.0:${Port}|0 :::${Port}" | awk '{print $7}' | sed 's#/.*##')
- fi
- else
- Pid=$(ps -ef | grep -i "${Path}/" |grep -i "${Name}/" |grep -v "grep" | awk '{print $2}')
- fi
- printf '%-20s %-6s %-15s %-12s %-25s %-6s %-15s\n' "${Date}" "${Pid}" "${Name}" "${SiteValue}" "${Path}" "${Port}" "Status:[${Status}]"
- }
- function GameCheck (){
- GamePath=(/ccu/server /usr/local/tomcat /data/dandantang)
- GsPort=( )
- GameStatus /usr/local/nginx Nginx " "
- echo -e "\e[35m--------------------------------------------------------------------------------------------------------------------------------------------\e[0m"
- for (( i=;i<;i++ ))
- do
- GameStatus ${GsPort[$i]} ${GamePath[$i]} GameServer
- echo -e "\e[35m--------------------------------------------------------------------------------------------------------------------------------------------\e[0m"
- done
- }
- Online_check(){
- echo -e "\e[35m-------------------------- Online Info. ----------------------------\e[0m"
- local Ports="9200 9300"
- local Sum_online=
- for Port in $Ports
- do
- local Port_online=`netstat -ntp|awk -v a= \
- '/ESTABLISHED/&&$4~":'$Port'"{a+=1}END{print a}'`
- Sum_online=$(($Sum_online + $Port_online))
- case $Port in
- )
- Port_name="Gameserver1_port(9200):"
- ;;
- )
- Port_name="Gameserver2_port(9300):"
- ;;
- esac
- printf "%-25s%14s\n" "$Port_name" "$Port_online"
- done
- printf "%-25s%14s\n" "Gameonline:" "$Sum_online"
- }
- Date=`date '+[%Y-%m-%d %H:%M:%S]'`
- echo "Main Site:$(hostname)"
- echo -e "\e[35m--------------------------------------------------------------------------------------------------------------------------------------------\e[0m"
- GameCheck
- Online_check
gps
Linux 检查端口gps命令的更多相关文章
- linux——nmap端口扫描命令
先安装 nmap :apt-get install nmap 端口扫描命令nmap -sS 172.16.55.100nmap -Pn 172.16.55.100第一组渗透测试指令,用于情报收集. 要 ...
- linux 查看端口号命令
Linux下如果我们需要知道2809号端口的情况的话,我们可以这样,如下命令: $netstat -pan|grep 24800 tcp 0 0 0.0.0.0:24800 ...
- linux查看端口常用命令
netstat命令参数: -t : 指明显示TCP端口 -u : 指明显示UDP端口 -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序) -p ...
- Linux查看端口信息命令
netstat -tlnp|grep 端口 eg: netstat -tlnp|grep 9889
- linux查看主机端口进程命令
1.查看主机信息 # more /etc/hosts # Do not remove the following line, or various programs # that require ne ...
- 怎样在linux或者Unix上检查端口是否在使用
英文原文链接:https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/ Question 1: 怎样在lin ...
- Netstat -tln 命令是Linux查看端口使用情况
Netstat -tln 命令是Linux查看端口使用情况
- Linux下如何通过命令检查网卡是否插上网线
How To:Linux下如何通过命令检查网卡是否插上网线 主要工具为ethtool来检查,主要关注的字段为"Link detected",注意如下的输出,其中em4实际物理上 ...
- Linux系统使用ss命令查看端口状态
Linux系统使用ss命令查看端口状态 目录 1.可用工具 2.ss帮助 2.1 选项分类说明 2.2 过滤选项family 2.3 过滤选项state 2.4 状态之间的关系 3.ss的使用 3.1 ...
随机推荐
- pip ipython启动错误 Fatal error in launcher: Unable to create process using
完整的错误提示: C:\Users\yyy>ipython3Fatal error in launcher: Unable to create process using '"c:\u ...
- php之常用扩展总结
在此总结,开发中经常使用到的扩展,来进行日常PHP的开发工作 bcmath(精确数值处理) bz2 calendar Core ctype curl date dom ereg exif filein ...
- vue的三种传参方式
<template> <div> <router-link :to="{'name':'x',params:{'type':'users'}}"> ...
- mybatis出现NoSuchMethodException异常
今天在idea中调试项目(ssm搭建的项目)的时候,mybatis突然出现了NoSuchMethodException异常,具体的异常时: java.lang.NoSuchMethodExceptio ...
- cpp11_thread线程
一.进程与线程 cpu一般有m核n线程的说法,那么该cpu只能同时运行n个线程(线程中没有sleep). #include <thread> #include <mutex> ...
- Django Rest framework 框架之认证使用和源码执行流程
用这个框架需要先安装: pip3 install djangorestframework 如果写了一个CBV的东西,继承了View. # 继承Django里面View class APIView(Vi ...
- centos5 安装redmine
一.下载依赖包 yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel yum -y inst ...
- 工程师常犯的web后台界面用户体验错误
- jdbc 接口的用法 Statement和PreparedStatement的区别!
package cn.zhouzhou; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Resu ...
- tomcat 和jboss区别
参考http://blog.csdn.net/sz_bdqn/article/details/6762175