# ServerStatus 感觉不错, 记录一下配置过程

- Link: https://yjyj.net/learn/centos/6230.html
- Published: 2021-10-23T20:18:30+08:00
- Author: 小 虾

⚡ 生猛大蝦编辑部 · 30 秒核心看点

 * 手动安装 ServerStatus 的核心是先编译服务端，再把网页文件放到站点目录。
 * 后台运行建议配合 screen，方便断线后继续管理进程和重启服务。
 * 客户端只要填对监控服务器 IP、用户名和密码，基本就能跑起来。

最近服务器有点多, 于是打算搞个探针监控一下, hostloc上看到ServerStatus的讨论比较多,
那就选它了!
 安装有2种方法, 由于已经先安装了宝塔, 就选择手动安装了. 跟着教程来【
克隆代码】:

    ```language-shell
    git clone https://github.com/cppla/ServerStatus.git
    ```

【服务端配置】:
 一、生成服务端程序

    ```language-shell
    cd ServerStatus/server
    make
    ./sergate
    ```

如果没错误提示，OK，ctrl+c关闭；如果有错误提示，检查35601端口是否被占用.
 二、拷贝
ServerStatus/status到网站目录 例如:

    ```language-shell
    sudo cp -r ServerStatus/web/* /www/wwwroot/s.obb7.com
    ```

三、运行服务端
 根据我自己的习惯

    ```language-shell
    yum -y install screen
    screen -S oye
    cd /home/ServerStatus/server
    ./sergate --config=config.json --web-dir=/www/wwwroot/s.obb7.com >/dev/null 2>&1
    ```

手动重启:

    ```language-shell
    查看进程: ps -ef | grep web
    Kill进程: kill -9 xxxx
    重新运行: ./sergate --config=config.json --web-dir=/www/wwwroot/s.obb7.com >/dev/null 2>&1
    ```

四、客户端运行

    ```language-shell
    wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.com/cppla/ServerStatus/master/clients/client-linux.py' && nohup python client-linux.py SERVER=监控服务器IP USER=用户名 PASSWORD=密码 >/dev/null 2>&1 &
    ```

五、配置服务端config

    ```language-shell
    {
                "username": "用户名",
                "name": "名字",
                "type": "?",
                "host": "host1",
                "location": "??",
                "password": "密码",
                "monthstart": 1
            }
    ```

这样基本上就完成了

❓ 延伸问答与排错指南（FAQ）

ServerStatus 手动安装最关键的一步是什么？

最关键的是先在 server 目录里编译生成服务端程序，确认没有报错后再继续。若提示异常，
优先检查 35601 端口是否被占用；编译成功后，再把 web 目录拷到网站根目录并启动服务
端。

客户端连接不上时该怎么排查？

先核对客户端命令里的 SERVER、USER、PASSWORD 是否与服务端配置一致，再确认服务端进程
是否在运行、端口是否可用。如果服务端已启动但仍无数据，通常是配置文件里的用户名或
密码填错。

为什么要用 screen 运行服务端？

因为服务端放在后台跑更稳，SSH 断开后进程也不会立刻退出。用 screen 启动后，后续查看
进程、kill 进程、重新运行都更方便，适合日常运维和临时重启。

📚 【[CentOS 学习](https://yjyj.net/category/learn/centos)】专栏延伸阅读与热门精选（
[全站文章归档](https://yjyj.net/archive)）：

 * [Centos7 防火墙管理](https://yjyj.net/learn/centos/6228.html)
 * [ssh 远程登陆指定端口](https://yjyj.net/learn/centos/6210.html)
 * [甲骨文(Oracle Linux)手动扩容命令](https://yjyj.net/learn/centos/6234.html)
 * [macOS 下 GoAccess 踩坑](https://yjyj.net/learn/centos/6262.html)
 * 热门必读[重置 Mac 的 SMC](https://yjyj.net/learn/7596.html)
 * 热门必读[CSS 盒模型边界重叠 (Margin Collapse) 原理与解决方案](https://yjyj.net/css/3536.html)
