smokepingをセットアップする

スポンサーリンク

smokepingのセットアップの記事が、あるにはあるけど微妙に分かりにくいので、自分用にメモ。slaveが使えるようにも設定します。osは Rocky Linux 9なので、dnfで入れられず非常に面倒でしたw

初心者が書いてるので、信用はしないでください。利用は自己責任でお願いします。

環境

OS: Rocky Linux 9
webサーバ: nginx(smokepingでは定番のapacheは使わない)
selinuxは有効

まずはとりあえずこれ

sudo dnf update -y

ソースコードをダウンロード

mkdir /etc/smokeping
cd /etc/smokeping
sudo wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.8.2.tar.gz
sudo tar xvfz smokeping-2.8.2.tar.gz
cd smokeping-2.8.2/

configureします

sudo dnf install rrdtool perl-rrdtool
sudo ./configure --prefix=/etc/smokeping
sudo gmake install

fpingをinstall

sudo dnf install fping

設定

cd ..
cd etc/
sudo cp config.dist config
sudo vi config

# 変更箇所のみ書きます
*** General ***
owner = 名前
contact = メアド
cgiurl = https://ご自由に/smokeping.cgi
#sendmail = /path/to/sendmail

*** Probes ***
+ FPing6
binary = /usr/sbin/fping
protocol = 6

*** Slaves ***
secrets=/etc/smokeping/etc/smokeping_secrets

+<slaveのFQDN>
display_name = 名前
location = 場所
color = ff0000

*** Targets ***
menu = Top
title = タイトル
remark = 文章

+ Youtube
menu = YouTube v4
title = YouTube v4
host = youtube.com
slaves = <slaveのFQDN>

+ Youtubev6
menu = YouTube v6
title = YouTube v6

probe = FPing6
host = youtube.com

slaves = <slaveのFQDN>

:wq

webの設定
nginxのconfigにはこちらを使用しますhttps://github.com/vazhnov/smokeping_nginx/blob/main/best.conf

cd ..
sudo ln -s htdocs/ /var/www/お好みのフォルダ
sudo mv htdocs/smokeping.fcgi.dist htdocs/smokeping.cgi
sudo vi /etc/nginx/conf.d/コンフィグ名.conf

server {
	listen 80;
	server_name smokeping.example.com;
        
        location / {
                return 301 https://$host$request_uri;
        }
}

server {
        listen 443 ssl http2;
        server_name smokeping.example.com;

        ssl_certificate /etc/letsencrypt/live/example.jp/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.jp/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/example.jp/fullchain.pem;

	location = /smokeping/smokeping.cgi {
		fastcgi_intercept_errors on;

		fastcgi_param	SCRIPT_FILENAME      /etc/smokeping/htdocs/smokeping.cgi;
		fastcgi_param	QUERY_STRING		$query_string;
		fastcgi_param	REQUEST_METHOD		$request_method;
		fastcgi_param	CONTENT_TYPE		$content_type;
		fastcgi_param	CONTENT_LENGTH		$content_length;
		fastcgi_param	REQUEST_URI		$request_uri;
		fastcgi_param	DOCUMENT_URI		$document_uri;
		fastcgi_param	DOCUMENT_ROOT		$document_root;
		fastcgi_param	SERVER_PROTOCOL		$server_protocol;
		fastcgi_param	GATEWAY_INTERFACE	CGI/1.1;
		fastcgi_param	SERVER_SOFTWARE		nginx/$nginx_version;
		fastcgi_param	REMOTE_ADDR		$remote_addr;
		fastcgi_param	REMOTE_PORT		$remote_port;
		fastcgi_param	SERVER_ADDR		$server_addr;
		fastcgi_param	SERVER_PORT		$server_port;
		fastcgi_param	SERVER_NAME		$server_name;
		fastcgi_param	HTTPS			$https if_not_empty;

		fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap-nginx.sock;
	}

	location ^~ /smokeping/ {
		alias /var/www/smokeping.example.com;
		index smokeping.cgi;
		gzip off;
	}

	location / {
		return 301 https://$server_name/smokeping/smokeping.cgi;
	}

        location /smokeping/sm.cgi {
                return 301 https://$server_name/smokeping/smokeping.cgi;
        }
}

:wq

sudo dnf install fcgiwrap
sudo systemctl start [email protected]
sudo systemctl enable [email protected]

sudo systemctl restart nginx

sudo chown -R nginx:nginx htdocs/
sudo grep "nginx" /var/log/audit/audit.log | audit2allow -M smokeping
semodule -i smokeping.pp
cd
sudo mkdir /etc/smokeping/cache
sudo mkdir /etc/smokeping/data
sudo mkdir /etc/smokeping/var
sudo mv /etc/smokeping/etc/smokeping_secrets.dist /etc/smokeping/etc/smokeping_secrets
sudo chmod 640 /etc/smokeping/etc/smokeping_secrets
sudo chown -R nginx:nginx /etc/smokeping/cache
sudo ln -s /etc/smokeping/cache/ /etc/smokeping/htdocs/cache
sudo chown -R nginx:nginx /etc/smokeping/htdocs


cd /etc/smokeping/
sudo chown -R nginx:nginx cache/
sudo chown -R nginx:nginx data/
sudo chown -R nginx:nginx var/
sudo chown nginx:nginx /etc/smokeping/etc/smokeping_secrets

smokepingの起動

sudo vi /usr/lib/systemd/system/smokeping.service

[Unit]
Description=Latency Logging and Graphing System
After=syslog.target network.target

[Service]
ExecStart=/etc/smokeping/bin/smokeping --nodaemon
ExecReload=/bin/kill -HUP $MAINPID
StandardError=syslog

[Install]
WantedBy=multi-user.target

:wq

sudo systemctl daemon-reload
sudo systemctl enable --now smokeping.service

参考

【メモ】SmokePingでlatency視覚化はじめました(1)導入編 | Pocketstudio.jp log3
◆Smokeping を入れてみました。 SmokePing - About

コメント

タイトルとURLをコピーしました