由于是游戏业务,环境主要是Nginx+Tomcat+Java Program

gps脚本环境以及效果图如下:

  1. #!/bin/bash
  2.  
  3. function Printf (){
  4. if [ $ == ];then
  5. printf '%-50s\n' "+-----------------+------------------+-----------------+"
  6. shift
  7. fi
  8. printf '%1s %-10s %1s %10s %1s %10s %1s\n' "|" "$1" "|" "$2" "|" "$3" "|"
  9. printf '%-50s\n' "+-----------------+------------------+-----------------+"
  10. }
  11.  
  12. function GameStatus (){
  13. Port=$
  14. Path=$
  15. Name=$
  16. local SiteValue=$
  17. Ppid=$
  18. nc -vz 127.0.0.1 ${Port} >/dev/null >&
  19. if [ $? == ];then
  20. Status=$(echo -e "\e[32m OK \e[0m")
  21. else
  22. Status=$(echo -e "\e[31mError\e[0m")
  23. fi
  24. if [[ -z ${Ppid} ]];then
  25. if [ "$USER" == "root" ];then
  26. Pid=$(netstat -nltp | egrep -w "0.0.0.0:${Port}|0 :::${Port}" | awk '{print $7}' | sed 's#/.*##')
  27. else
  28. Pid=$(sudo netstat -nltp | egrep -w "0.0.0.0:${Port}|0 :::${Port}" | awk '{print $7}' | sed 's#/.*##')
  29. fi
  30. else
  31. Pid=$(ps -ef | grep -i "${Path}/" |grep -i "${Name}/" |grep -v "grep" | awk '{print $2}')
  32. fi
  33. printf '%-20s %-6s %-15s %-12s %-25s %-6s %-15s\n' "${Date}" "${Pid}" "${Name}" "${SiteValue}" "${Path}" "${Port}" "Status:[${Status}]"
  34. }
  35.  
  36. function GameCheck (){
  37. GamePath=(/ccu/server /usr/local/tomcat /data/dandantang)
  38. GsPort=( )
  39. GameStatus /usr/local/nginx Nginx " "
  40. echo -e "\e[35m--------------------------------------------------------------------------------------------------------------------------------------------\e[0m"
  41. for (( i=;i<;i++ ))
  42. do
  43. GameStatus ${GsPort[$i]} ${GamePath[$i]} GameServer
  44. echo -e "\e[35m--------------------------------------------------------------------------------------------------------------------------------------------\e[0m"
  45. done
  46. }
  47.  
  48. Online_check(){
  49. echo -e "\e[35m-------------------------- Online Info. ----------------------------\e[0m"
  50. local Ports="9200 9300"
  51. local Sum_online=
  52. for Port in $Ports
  53. do
  54. local Port_online=`netstat -ntp|awk -v a= \
  55. '/ESTABLISHED/&&$4~":'$Port'"{a+=1}END{print a}'`
  56. Sum_online=$(($Sum_online + $Port_online))
  57. case $Port in
  58. )
  59. Port_name="Gameserver1_port(9200):"
  60. ;;
  61. )
  62. Port_name="Gameserver2_port(9300):"
  63. ;;
  64. esac
  65. printf "%-25s%14s\n" "$Port_name" "$Port_online"
  66. done
  67.  
  68. printf "%-25s%14s\n" "Gameonline:" "$Sum_online"
  69. }
  70.  
  71. Date=`date '+[%Y-%m-%d %H:%M:%S]'`
  72. echo "Main Site:$(hostname)"
  73. echo -e "\e[35m--------------------------------------------------------------------------------------------------------------------------------------------\e[0m"
  74. GameCheck
  75. Online_check

gps

Linux 检查端口gps命令的更多相关文章

  1. linux——nmap端口扫描命令

    先安装 nmap :apt-get install nmap 端口扫描命令nmap -sS 172.16.55.100nmap -Pn 172.16.55.100第一组渗透测试指令,用于情报收集. 要 ...

  2. linux 查看端口号命令

    Linux下如果我们需要知道2809号端口的情况的话,我们可以这样,如下命令: $netstat -pan|grep 24800 tcp        0      0 0.0.0.0:24800   ...

  3. linux查看端口常用命令

    netstat命令参数: -t : 指明显示TCP端口 -u : 指明显示UDP端口 -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序) -p ...

  4. Linux查看端口信息命令

    netstat -tlnp|grep 端口 eg: netstat -tlnp|grep 9889

  5. linux查看主机端口进程命令

    1.查看主机信息 # more /etc/hosts # Do not remove the following line, or various programs # that require ne ...

  6. 怎样在linux或者Unix上检查端口是否在使用

     英文原文链接:https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/ Question 1: 怎样在lin ...

  7. Netstat -tln 命令是Linux查看端口使用情况

    Netstat -tln 命令是Linux查看端口使用情况

  8. Linux下如何通过命令检查网卡是否插上网线

    How To:Linux下如何通过命令检查网卡是否插上网线   主要工具为ethtool来检查,主要关注的字段为"Link detected",注意如下的输出,其中em4实际物理上 ...

  9. Linux系统使用ss命令查看端口状态

    Linux系统使用ss命令查看端口状态 目录 1.可用工具 2.ss帮助 2.1 选项分类说明 2.2 过滤选项family 2.3 过滤选项state 2.4 状态之间的关系 3.ss的使用 3.1 ...

随机推荐

  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 ...

  2. php之常用扩展总结

    在此总结,开发中经常使用到的扩展,来进行日常PHP的开发工作 bcmath(精确数值处理) bz2 calendar Core ctype curl date dom ereg exif filein ...

  3. vue的三种传参方式

    <template> <div> <router-link :to="{'name':'x',params:{'type':'users'}}"> ...

  4. mybatis出现NoSuchMethodException异常

    今天在idea中调试项目(ssm搭建的项目)的时候,mybatis突然出现了NoSuchMethodException异常,具体的异常时: java.lang.NoSuchMethodExceptio ...

  5. cpp11_thread线程

    一.进程与线程 cpu一般有m核n线程的说法,那么该cpu只能同时运行n个线程(线程中没有sleep). #include <thread> #include <mutex> ...

  6. Django Rest framework 框架之认证使用和源码执行流程

    用这个框架需要先安装: pip3 install djangorestframework 如果写了一个CBV的东西,继承了View. # 继承Django里面View class APIView(Vi ...

  7. centos5 安装redmine

    一.下载依赖包 yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel yum -y inst ...

  8. 工程师常犯的web后台界面用户体验错误

  9. jdbc 接口的用法 Statement和PreparedStatement的区别!

    package cn.zhouzhou; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Resu ...

  10. tomcat 和jboss区别

    参考http://blog.csdn.net/sz_bdqn/article/details/6762175