エレクトロニクス

 設定メモです。最初にクライアント側(サーバ機でもクライアントを動かす)の設定。pluginのいくつかは参考にしたURLからダウンロードしたものやその改造版です。BME280は秋月電子通商さんのAE-BME280 (K-09421)を使用しています。Raspberry Pi4だけで処理可能なレベルの小規模(<10台)なLAN内向けの設定です。  いまさらMunin?という疑問もあるかもしれませんけど実績があるのとELKなど最近のツールでは負荷が重すぎるorセンサなどとのカスタムI/F作成が面倒なため試行錯誤の結果Muninとなっています。Munin用pluginがまだ出回っていたり、多少古くても若干の手直しで使えるレベルなので助かっています。

sudo apt-get install -y munin-node
sudo vi /etc/munin/munin-node.conf
allow ^192\.168\.xxx\.yyy$
allow ^::ffff:192\.168\.xxx\.yyy$

cd /etc/munin/plugins
sudo rm nfs* swap
sudo rm entropy cpuspeed
cd ~/munin_plugin
sudo cp chrony* /usr/share/munin/plugins/
sudo chmod 755 /usr/share/munin/plugins/chrony*
sudo cp bme280i2c.py /usr/share/munin/plugins/
sudo cp bme280_non2 /usr/share/munin/plugins/
sudo chmod 755 /usr/share/munin/plugins/bme280_non2
sudo cp dnsmasq /usr/share/munin/plugins/
sudo chmod 755 /usr/share/munin/plugins/dnsmasq
sudo cp healthcheck_ping /usr/share/munin/plugins/
sudo chmod 755 /usr/share/munin/plugins/healthcheck_ping
sudo cp healthcheck_url /usr/share/munin/plugins/
sudo chmod 755 /usr/share/munin/plugins/healthcheck_url
sudo cp rrdcached /usr/share/munin/plugins/
sudo chmod 755 /usr/share/munin/plugins/rrdcached

cd /etc/munin/plugins
sudo ln -s /usr/share/munin/plugins/chrony* .
sudo ln -s /usr/share/munin/plugins/bme280_non2 .
sudo ln -s /usr/share/munin/plugins/dnsmasq .
sudo ln -s /usr/share/munin/plugins/healthcheck_ping .
sudo ln -s /usr/share/munin/plugins/healthcheck_url .
sudo ln -s /usr/share/munin/plugins/rrdcached .

cat << 'EOS'| sudo tee -a /etc/munin/plugin-conf.d/munin-node
[rrdcached]
    group apache
    env.PEER    /var/rrdtool/rrdcached/rrdcached.sock

[healthcheck_url]
env.url_1  http://www.google.co.jp/
env.slowspeed_1 5                    #limit time(sec)
#env.htmlgrep_1 google               #check egrep string

[healthcheck_ping]
env.ping_1  192.168.xxx.y1
env.ping_2  192.168.xxx.y2
env.ping_3  192.168.xxx.y3

[bme280_*]
user root

[dnsmasq]
user root
EOS
sudo systemctl restart munin-node

 次にサーバ機の設定、CGIによりアクセスが有ったときだけグラフ画像を生成する。Raspberry Pi Zeroの処理能力でサーバ稼働は無理があり、最低でもRaspberry Pi 3、できればRaspberry Pi4 (4GB)が必要と思います。

sudo apt-get install -y apache2 munin rrdcached
sudo vi /etc/munin/apache24.conf
pi@rp1:/etc/munin $ diff -u apache24.conf-orig apache24.conf
--- apache24.conf-orig  2019-09-07 22:50:01.819999958 +0900
+++ apache24.conf       2019-09-07 22:51:44.129999919 +0900
@@ -14,12 +14,14 @@
 Alias /munin/static/ /var/cache/munin/www/static/

 
-    Require local
+#    Require local
+    Require all granted
     Options None
 

-    Require local
+#    Require local
+    Require all granted
     
         SetHandler fcgid-script
     


sudo ln -s /etc/munin/apache24.conf /etc/apache2/sites-enabled/munin.conf
sudo vi /etc/default/rrdcached
pi@raspberrypi:/etc/default $ diff -u ~/rrdcached.orig rrdcached
--- /home/pi/rrdcached.orig     2020-04-29 15:34:52.931161830 +0900
+++ rrdcached   2020-04-29 15:36:06.140876081 +0900
@@ -4,10 +4,10 @@
 DAEMON=/usr/bin/rrdcached

 # Optional override flush interval, in seconds.
-#WRITE_TIMEOUT=300
+WRITE_TIMEOUT=1800

 # Optional override maximum write delay, in seconds.
-#WRITE_JITTER=0
+WRITE_JITTER=1800

 # Optional override number of write_threads
 #WRITE_THREADS=4
@@ -29,7 +29,7 @@

 # Optional override group that should own/access the local control
 # socket
-#SOCKGROUP=root
+SOCKGROUP=www-data

 # Optional override access mode of local control socket.
 #SOCKMODE=0660
@@ -54,4 +54,5 @@

 # Any other options not specifically supported by the script (-P, -f,
 # -F, -B).
-BASE_OPTIONS="-B"
+#BASE_OPTIONS="-B"
+BASE_OPTIONS="-F -f 3600"

sudo vi /etc/munin/munin.conf

sudo su - munin --shell=/usr/bin/munin-cron
ls -alF /var/lib/rrdcached/journal/

sudo gpasswd -a munin www-data
sudo gpasswd -a www-data munin
sudo chown -R www-data.www-data /var/lib/munin/cgi-tmp
sudo a2enmod cgi

以下、特に参考になったサイトです(順不同)。
muninでヘルスチェック(死活監視/生存監視/サイト監視とか)(https://rti7743.hatenadiary.org/entry/20110604/1307219520)
Raspberry Piで温度記録Webサーバを作る(https://qiita.com/kitashu/items/31a078fd9184a2734792)
復旧最終回:bme280で気圧・温度・湿度!(http://non2nrp.blogspot.com/2015/10/bme280.html)
【Munin】rrdcachedでIOを取り戻せ!(http://pocketstudio.jp/log3/2013/07/31/bring_back_io_with_munin_and_rrdcached/)

エレクトロニクス

 Luxeritas 3.7.11.2から一気にLuxeritas 3.8.1.2までアップデートしました。カレンダーウィジェットを使っていますのでアップデートの必要がありました。詳細は開発元のWP 5.4 対応その2(カレンダーウィジェットの CSS 修正)Luxeritas 3.8.1.1(https://thk.kanzae.net/dev/wp-themes/luxeritas/t12947/)を御覧ください。

 ちなみに、PHPのバージョンは4/8から7.4.3に切り替えています。PHP 7.4 導入のお知らせ(https://www.xserver.ne.jp/news_detail.php?view_id=6517)に書いてあります通り、7.3よりも高速かつ安定したウェブサイト運用が可能となるらしいからです。