コンテンツへスキップ

Server Status監視システムの構築

2021年8月23日

ServerStatus-Hotaru

クラウドプローブ、マルチサーバープローブ、クラウド監視、マルチサーバークラウド監視。

ServerStatus-Toyo最新版をベースに若干修正したものです。

特徴

サービス・クライアントスクリプトが対応するシステム:CentOS 7、Debian 7、Ubuntu 14.04 以上、Arch Linux。

クライアント対応 Python バージョン:Python 2.7 - Python 3。

Golangクライアント:クライアント環境で Python が使用できない場合、Golang で作成されたクライアントを使用できます。

オープンソース:https://github.com/cokemine/ServerStatus-goclient

トラフィック計算:クライアントはオプションで vnStat を使用して月次トラフィック計算が可能で、最新版 vnStat を自動コンパイル・インストールします(Arch Linux ではリポジトリから最新版をインストール)。vnStat を使用しない場合、デフォルトの計算方法は再起動後にゼロリセットされます。ServerStatus は GPLv2 ライセンスの vnStat と強結合していません。

フロントエンドは Vue 3.0 と SemanticUI で構築されています。修正が必要な場合は自行ビルドを推奨します。

オープンソースフロントエンド:https://github.com/cokemine/hotaru_theme

インストール方法

サーバー側

# サーバーインストール
wget https://raw.githubusercontent.com/cokemine/ServerStatus-Hotaru/master/status.sh

# サーバー起動
bash status.sh s

クライアント側

# クライアント起動
bash status.sh c

手動インストール(サーバー側)

mkdir -p /usr/local/ServerStatus/server

apt install wget unzip curl vim build-essential

cd /tmp

wget https://github.com/cokemine/ServerStatus-Hotaru/archive/master.zip

unzip master.zip

cd ./ServerStatus-Hotaru-master/server

# バイナリファイルをコンパイル生成
make

chmod +x sergate

mv sergate /usr/local/ServerStatus/server

# 設定ファイルを修正
vim /usr/local/ServerStatus/server/config.json

# フロントエンドをダウンロード
cd /tmp && wget https://github.com/cokemine/Hotaru_theme/releases/latest/download/hotaru-theme.zip

unzip hotaru-theme.zip

# サイトのルートディレクトリに設定
mv ./hotaru-theme /usr/local/ServerStatus/web

# デフォルトポート 35601
nohup ./sergate --config=config.json --web-dir=/usr/local/ServerStatus/web --port=35601 > /tmp/serverstatus_server.log 2>&1 &

手動インストール(クライアント側)

Psutil 版クライアントを使用すると Windows など他のプラットフォームでも ServerStatus クライアントを実行できます。

# pip が未インストールの場合
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

python pip install psutil

# status-psutil.py を修正
python status-psutil.py

Linux 版クライアントは大半の Linux ディストリビューションに対応しており、通常は psutil 版クライアントは不要です。

apt install python3 python3-pip wget

pip3 install psutil

wget https://raw.githubusercontent.com/cokemine/ServerStatus-Hotaru/master/clients/status-psutil.py

# クライアント設定ファイルを修正
vim status-psutil.py

python3 status-psutil.py
# https://raw.githubusercontent.com/cokemine/ServerStatus-Hotaru/master/clients/status-client.py デフォルト版(psutil 不要)

フロントエンドの更新

デフォルトではサーバー更新時にフロントエンドは更新されません。更新すると自作カスタマイズが消えるためです。

rm -rf /usr/local/ServerStatus/web/*

wget "https://github.com/cokemine/hotaru_theme/releases/download/latest/hotaru-theme.zip"

unzip hotaru-theme.zip

mv ./hotaru-theme/* /usr/local/ServerStatus/web/

service status-server restart
# systemctl restart status-server

フラグアイコンについて

現在、スクリプトによるフラグアイコンは ISO 3166-1 標準の国/地域のみ対応しており、EU などは追加できない場合がありますが、フロントエンド側には該当フラグが存在します。手動で追加する必要があるかもしれません。方法は /usr/local/ServerStatus/server/config.json を修正し、変更したいサーバーの region を必要なものに変更します。

また、フロントエンドは以下の特殊フラグも備えており、上記と同様の修正で使用可能です。

Transgender flag: trans Rainbow flag: rainbow Pirate flag: pirate

Toyo版からの移行方法

Toyo 版または他の ServerStatus を使用している場合、config ファイルをバックアップし、本バージョンのサーバーを再コンパイル・インストールしてください。

設定ファイル: /usr/local/ServerStatus/server/config.json をバックアップし、region を自行追加。

{
   "username": "Name",
   "password": "Password",
   "name": "Your Servername",
   "type": "KVM",
   "host": "None",
   "location": "杭州",
   "disabled": false,
   "region": "CN"
},

設定ファイルを差し替えて ServerStatus を再起動します。

前の記事
Huawei eNSPインストールパッケージ
次の記事
授業管理ソフトウェアの研究