ホーム » コンピュータ » Linux (ページ 19)

Linux」カテゴリーアーカイブ

システム

最近の投稿

アーカイブ

カテゴリー

暑さの測定

以前購入した、Raspberry-Pi 内蔵の MZ-80C のミニチュアは、温度・湿度・気圧のセンサーを付けて、2Fのトイレに設置していたけど、WiFiが若干不安定だったので、常時サーバで記録はしていなかった。しかし、この暑さなので、エアコンの無い部屋の温度を測定したかったので、改めて設定してみた。

Raspberry-Pi の inetd の echo サーバの所に温度測定スクリプトを記載して、”/usr/bin/nc raspberry-pi 7″ で測定できるように設定し、munin 用のデータ取得スクリプトを書いて設定。このクソ暑い温度を測ってみた。

家の西側の2会のトイレに設置しているので、夕方が最高温度で、家の中でも34℃越え。湿度は、トイレのドアを開放すると、大きく変化するようだ。

icingaからgoogle-home-notifierで警告

あまりにも暑い日が続くなか、夜は涼しくなるかとエアコンを控えめにすると、暑さで目が覚めることもある。部屋の温度は、温度・湿度センサーで測っているし、google-home-notifier を使って暑さの警告をしゃべらせてみる。単純に温度が設定温度を越えたら…なんてプログラムだと、頻繁に喋られてもうるさいし、icinga から呼び出させてみた。

警告時にプログラムを起動

## /etc/icinga/commands.cfg 追記 ##
# 'notify-host-by-program' command definition
define command{
   command_name  notify-host-by-program
   command_line  /etc/icinga/commands-host.sh \
      "$HOSTNAME$" "$NOTIFICATIONTYPE$" \
      "$HOSTSTATE$" "$HOSTOUTPUT$"
   }

# 'notify-service-by-program' command definition
define command{
   command_name  notify-service-by-program
   command_line  /etc/icinga/commands-service.sh \
      "$HOSTNAME$" "$SERVICESESC$" "$NOTIFICATIONTYPE$" \
      "$SERVICESTATE$" "$SERVICEOUTPUT$"
   }
## /etc/icinga/objects/contacts_icinga.cfg 追記 ##
define contact{
   contact_name                    notifyProgram
   alias                           NotifyProgram
   service_notification_period     24x7
   host_notification_period        24x7
   service_notification_options    w,u,c,r
   host_notification_options       d,r
   service_notification_commands   notify-service-by-program
   host_notification_commands      notify-host-by-program
   email                           foobar@example.com
   }
define contactgroup{
   contactgroup_name       adminsProgram
   alias                   Administrators and Notify Program
   members                 root,notifyProgram
   }

温度センサーの設定

## /etc/icinga/objects/localhost_icinga.cfg ##
# USBRH
define service{
   use                    generic-service
   host_name              localhost
   service_description    USBRH
      check_command       check_usbrh2!32!35!81!85
      contact_groups      adminsProgram
   }
## /etc/icinga/commands-service.sh ##
#!/bin/bash
# icinga からプログラムにより警告
#    ((commands.cfg を参照))
#    /etc/icinga/commands-service.sh
#       "$HOSTNAME$" "$SERVICESESC$" "$NOTIFICATIONTYPE$"
#       "$SERVICESTATE$" "$SERVICEOUTPUT$"
case "$2-$3" in
  USBRH-PROBLEM )
    case "$4" in
      WARNING | CRITICAL )
        if [ "$4" == "CRITICAL" ]; then
          MESS="部屋の温度が危険です。"
        else
          MESS="部屋の温度に注意してください。"
        fi
        /usr/bin/printf "%s %.1f 度 %.1f %%" "$MESS" \
           `温度と湿度を取得するスクリプト` \
           | 標準入力をgoogle-home-notifierに送るスクリプト
        ;;
    esac
    ;;
esac

dovecot 2.3 更新

dovecot を更新したら、2.2 → 2.3 で SSL 関連の設定が変更になったみたい。

以下の設定を追記

(( /etc/dovecot/conf.d/10-ssl.conf ))
ssl_dh = </usr/share/dovecot/dh.pem
ssl_min_protocol = TLSv1.2

XcXsrv の最新版を入れる

Bash on Windows やら、Linux 環境を Windows と絡めて使っていると、Windows 環境用の X Server が使いたくなる。以前は、Xming とか cygwin などを使っていたけど、設定などが大変なので、XcXsrv を使っていた。しかし、アプリによってはうまく動かず、tgif などはフォントが見つからないというエラーが出る。

調べると、gsfonts-x11 を入れるとか出てくるけど、ローカルサーバのお話。XcXsrv に gsfonts-x11 を入れるといいのだろうけど、これまた設定がややこしそう。

しかし、最新の XcXsrv-1.20 を入れたら、特にフォント入れなくても、問題なく動くじゃん。

DISPLAY環境変数の設定

そんなに X Server を使うわけじゃないけど、WSL環境と、Linuxサーバで DISPLAY 環境変数を設定する処理を .profile に書いとくか。

(( WSL環境の $HOME/.profile に追加 ))
if [ -z "$DISPLAY" -a -n "$HOSTNAME" ]; then
    export DISPLAY=$HOSTNAME:0.0
fi

(( Linuxの $HOME/.profile に追加 ))
if [ -z "$DISPLAY" -a -n "$SSH_CLIENT" ]; then
    case $SSH_CLIENT in
        192.168.*)
            export DISPLAY=`echo $SSH_CLIENT | cut -d' ' -f 1 `:0.0
            ;; 
        *)  ;;
    esac
fi

Windowsのwslコマンド

紹介記事で、最新のWindows での Windows Subsystem for Linux の使い方の説明があった。普通に bash.exe を起動する以外にも、wsl コマンドがあり、コマンド1つでも Linux の呼び出しができるんだ。

C:\User\foo> wsl ls -al                  Windows で ls -al を実行
-rwxr--r-- 1 foo  foo  20  5月  1 06:05 ntuser.ini
lrwxrwxrwx 1 foo  foo   0  5月  1 05:40 スタート メニュー
C:\User\foo> wsl vi test.c               普通にコーディングと実行もできる。
C:\User\foo> wsl gcc test.c
C:\User\foo> wsl ./a.out
C:\User\foo> type test.c | wsl grep "#"  Windows と Linux 間でパイプをつなげることも可能

icinga の check_mailq が動かない

自宅サーバは、icinga で状態検知をしているけど、アップデートをしていたら、check_mailq が正常に動かなくなった。
動作確認のために、手作業で以下の命令を実行したけど、問題ない。

(( 手作業で確認 ))
$ /usr/lib/nagios/plugins/check_mailq -w 2 -c 5 -M postfix
OK: postfix mailq reports queue is empty|unsent=0;2;5;0

(( /var/log/icinga/icinga.log を確認 ))
... Warning: Check of service 'Postfix mailque' on host 'localhost' did not exit properly

icingaの組み込みPerl呼び出しが原因

icinga.log のメッセージをヒントに調べてみたら、icinga がプラグインの Perl Script を呼び出す時に、組み込み perl を使うことによって発生する。icinga は、定時処理の負荷低減のために、Perl で書かれたプログラムは、icinga に組み込まれた軽いPerl インタプリタを呼び出すが、これは簡易版Perlなので動かないプログラムもある。この場合、Perl Script の先頭に “# nagios: -epn” を入れることで、組み込みPerl呼び出しを抑止できる。

nagios-plugin の更新の中で、”-epn” が消されたのかな。

php5からphp7に変更

この2日間、朝になると自宅のWebサーバが落ちている。決まって同じ時間から症状が発生しているので、状況を調査。

apachectl reloadで発症

すると、logrotated が、ログの切替処理の中で “/etc/init.d/apache2 reload”を実行すると、その後から動かないことが見えてきた。
/var/log/apache2/error.log を観察すると、以下のようなエラーが多発。

[Fri May 11 ...AH00052: child pid 1475 exit signal Segmentation fault (11)
[Fri May 11 ...AH00167: long lost child came home! (pid 1475)
[Fri May 11 ...AH00052: child pid 1476 exit signal Segmentation fault (11)
[Fri May 11 ...AH00546: no record of generation 0 of exiting child 1476

これをネタにググったら、php が原因のような話があったので、現状の php5 を php7 に変更してみた。

php7.0に変更

$ sudo aptitude remove php5-common
$ sudo aptitude install php7.0 php7.0-common php7.0-mysql libapache2-mod-php7.0 php7.0-mbstring
$ sudo a2enmod php7.0
$ sudo /etc/init.d/apache2 restart

そうしたら、無事に reload ができるようになってきた。

php7.2 に変更しようとしてみたが、WordPress の中で使っている PHP Code widget が非対応ということで、ひとまず見送り。

anthy から mozc に移行

今まで、emacs での日本語入力には、anthy を使っていたけど、 emacs25 + anthy(1:0.3-6) になったあたりから、記号をタイプすると、 \xxx\xxx\xxx といった、UTF-8 のゴミが表示されるようになってきた。

色々と設定を触っているけど、うまく治らない。

mozc を使う

原因をこれ以上調べていても面倒なので、mozc(google-ime) に切り替えてみた。

(( install ))
$ sudo aptitude install emacs-mozc mozc-server mozc-data

(( .emacs/init.el ))
+ (load-library "mozc")
+ (set-input-method "japanese-mozc")

さほど、問題はないんだけど、canna – anthy と使ってきた慣れで、 変換範囲の変更が \C-i \C-o で変更できないのが気持ち悪いな。

Windows の WSL じゃ mozc-server で動かない

環境を揃えるという意味で、Windows 上の Linux 環境でも mozc にするか…と思ったけど、mozc は ローカルホストで、mozc-server を動かすサーバ・クライアント型。ダメだろうとは思ってたけど、試してみると、インストール直後は サーバを起動してくれたから、変換できたけど、WSL のウィンドウを全部消してから、改めて使うと mozc-server が落ちてるので、漢字変換ができない。 WSL のデーモンいつになったら、使いやすくなるのかな。

WSLでdebianを入れる

WSL(Windows Subsystem for Linux?) で Debian が簡単にインストールできるようなので、インストールしてみる。

Bash on Windows で Ubuntu は使わないので消す

Debian 派生の Ubuntu といっても、デスクトップ環境が使えないなら、Ubuntu の必要性はない。Windows で LaTeX 環境として使っていた程度で、執着はないので、あっさり消す。

> cmd.exe 管理者モードで起動
> lxrun /uninstall /full

WSL で Debian を入れる

サーバ管理という点では、Debian に慣れているし、ほぼ Ubuntu でいいじゃんと思いつつも、信者なので。

Enter new UNIX username:

xxxxxxxx

Enter new UNIX password: yyyyyyyy
Retype new UNIX password: yyyyyyyy
$ sudo bash
# apt-get update ; apt-get dist-upgrade
# apt-get install aptitude
# aptitude install lv w3m git \
      emacs25 anthy anthy-el \
      cjk-latex latex-cjk-all tgif man \
      gcc g++ flex bison make cmake
# aptitude purge nano
# vi /etc/locale.gen
ja_JP.UTF-8 UTF-8  # コメントを外す
# locale-gen
# update-locale LANG=ja_JP.UTF-8

wsl.conf

(( /etc/wsl.conf ))
# Enable extra metadata options by default
[automount]
enabled = true
mountFsTab = true
root = /mnt/
options = "metadata,umask=22,fmask=11"

# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true

味真野小学校/万葉中学校/鯖江高校のTwitterBotを停止

今まで、味真野小学校(@AjimanoES),万葉中学校(@ManyoJHS),鯖江高校(@SabaeHS) のホームページの更新情報をつぶやく勝手BOTを運営していた。しかし、子供も進学&卒業と共にメンテナンスが疎かになってしまって、変な動作をしても迷惑をかけてしまうので、Tweetするためのdlvr.itの各アカウントと、Twitterアカウントを停止した。どのアカウントも多少は利用者がいたけど、大量ユーザというほどでもないので、あっさり削除。

 

Google 検索

My Google   Yahoo

Microsoft

ファンサイト