文書の過去の版を表示しています。
Pandora FMS と SMS ゲートウェイのインストールと設定
GSM デバイスについて
A special GSM device is used to send SMS via a serial port (USB). You can use either another similar GSM model, or a cell phone with USB or serial connection. The device used here is a MTX 65 v3. It is a very small and GNU/Linux compatible device, which has different optional components such as an external GSM antenna for greater signal coverage.
シリアル ポート (USB) 経由で SMS を送信するには、特別な GSM デバイスを使用します。同様の別の GSM モデル、または USB またはシリアル接続を備えた携帯電話を使用できます。ここで使用するデバイスは MTX 65 v3 です。これは非常に小型で GNU/Linux と互換性のあるデバイスで、信号範囲を広げるための外部 GSM アンテナなどのさまざまなオプション コンポーネントを備えています。
デバイスのインストール
The first step is to install the hardware device. This device consists of the following parts:
最初にハードウエアの設定を行います。このデバイスにはいくつかのパーツがあります。
- Standard USB cable, with a small connector and a lock.
- Power supply. In this example it is the European 220 volts, if you live in America (except Chile) make sure that the power supply is for 110 or 120 volts.
- SIM card.
- Pandora FMS SMS gateway device.
- 小さいコネクタの通常の USB ケーブル
- 電源アダプタ (この例ではヨーロッパの 220v のものです。あまりかであれば 110v のものが必要です。)
- SIM カード
- Pandora FMS の SMS ゲートウェイデバイス
Procedure:
手順:
- Open the Pandora FMS SMS gateway device.
- Place the SIM card inside.
- Connect to the network at the socket labeled power, insert the USB cable into the SMS gateway device.
- Connect the other end to the Pandora FMS server using a standard USB port.
- When you connect the device to the server, wait a few seconds and launch the dmesg command from the command line. You should see something similar to this screen:
- Pandora FMS の SMS ゲートウェイデバイスを開きます。
- SIM カードを挿します。
- 電源を接続し、SMS ゲートウェイデバイスに USB ケーブルを接続します。
- それを Pandora FMS サーバの USB ポートに接続します。
- サーバへデバイスを接続して数秒したら、コマンドラインから dmesg を実行します。次のような画面が表示されます。
- This means that the device has been recognized by the kernel and is ready to accept commands on a device such as
/dev/ttyACM0
.
これは、デバイスを kernel が /dev/ttyACM0
として認識し、利用できるようになったことを示します。
If there is a problem, check all the steps and make sure:
うまくいってない場合は、次の手順を確認してください。
- The device is connected and the cable is flashing green.
- The device is connected to the USB port, on both sides of the cable, one side with the SMS device and the other with the Pandora FMS host server.
- The device has a SIM card inside, and the SIM card is properly inserted.
- デバイスが接続され、LED が緑で点滅しているかどうか。
- デバイスが USB ポートに接続されているか。一方が SMS デバイス、他方が Pandora FMS サーバになっているか。
- デバイスに SIM カードが正しく挿入されているかどうか。
新たなデバイスを利用するための SMSTools の設定
This device is managed by a software package called SMSTools. You can install SMSTools using the package provided by your chosen GNU/Linux distribution or use the RPM package (Red Hat Package Manager or RPM Package Manager ) provided by PFMS.
このデバイスは、SMSTools というソフトウェアパッケージによって管理されます。選択した GNU/Linux ディストリビューションによって提供されるパッケージを使用して SMSTools をインストールするか、PFMS によって提供される RPM パッケージ (Red Hat Package Manager または RPM Package Manager ) を使用できます。
RPM を利用しているシステム
To use the RPM provided by PFMS you only have to install it with the following command:
PFMS が提供する RPM を使用するには、次のコマンドでインストールするだけです。
rpm -i smstools*.rpm
SMStools の設定
基本設定ファイルを編集します。
# vi /etc/smsd.conf
次の設定を書きます。dmesg の出力が ttyACM0 でない場合は、システムが検出した tty デバイスに応じて変更してください。
# Example smsd.conf. Read the manual for a description devices = GSM1 logfile = /var/log/smsd.log loglevel = 10 [GSM1] device = /dev/ttyACM0 incoming = no pin = 2920
SIM に設定された暗証番号を定義します。この例では、“2920” です。
そして、smstools を手動で起動します。
# /usr/bin/smstools start
SMS の送信テストをします。電話番号はプリフィックスを含めて指定することに注意してください。この例では、+34 がスペインで、電話番号が 627934648 です。
$ sendsms 34627934648 "Pandora FMS rocks"
数分待って、すべて正常化どうかログを確認します。数秒で SMS を受信します。ネットワークによっては、最初の SMS は 10-20秒遅れるので、それ以上待ってください。次の SMS からすぐに届きます。SMSTools は、メッセージ送信にキューを利用します。たくさん送信したい場合、携帯のネットワークの処理に依存した速さになります。
ログの確認は次の通りです。
# cat /var/log/smsd.log 2009-11-12 11:30:12,2, smsd: Smsd v2.2.20 started. 2009-11-12 11:30:12,6, smsd: outgoing file checker has started. 2009-11-12 11:30:12,6, GSM1: Modem handler 0 has started. 2009-11-12 11:30:13,6, smsd: Moved file /var/spool/sms/outgoing/send_mNZxHa to /var/spool/sms/checked 2009-11-12 11:30:13,6, smsd: I have to send 1 short message for /var/spool/sms/checked/send_iUegPD 2009-11-12 11:30:13,6, GSM1: Sending SMS from to 627934648 2009-11-12 11:30:13,6, GSM1: Checking if modem is ready 2009-11-12 11:30:13,7, GSM1: -> AT 2009-11-12 11:30:13,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:14,7, GSM1: <- AT OK 2009-11-12 11:30:14,6, GSM1: Checking if modem needs PIN 2009-11-12 11:30:14,7, GSM1: -> AT+CPIN? 2009-11-12 11:30:14,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:14,7, GSM1: <- AT+CPIN? +CPIN: SIM PIN OK 2009-11-12 11:30:14,5, GSM1: Modem needs PIN, entering PIN... 2009-11-12 11:30:14,7, GSM1: -> AT+CPIN="2920" 2009-11-12 11:30:14,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:15,7, GSM1: <- AT+CPIN="2920" OK 2009-11-12 11:30:15,7, GSM1: -> AT+CPIN? 2009-11-12 11:30:15,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:15,7, GSM1: <- AT+CPIN? +CPIN: READY OK 2009-11-12 11:30:15,6, GSM1: PIN Ready 2009-11-12 11:30:15,6, GSM1: Checking if Modem is registered to the network 2009-11-12 11:30:15,7, GSM1: -> AT+CREG? 2009-11-12 11:30:15,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:16,7, GSM1: <- AT+CREG? +CREG: 0,2 OK 2009-11-12 11:30:16,5, GSM1: Modem is not registered, waiting 10 sec. before retrying 2009-11-12 11:30:26,7, GSM1: -> AT+CREG? 2009-11-12 11:30:26,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:26,7, GSM1: <- AT+CREG? +CREG: 0,5 OK 2009-11-12 11:30:26,6, GSM1: Modem is registered to a roaming partner network 2009-11-12 11:30:26,6, GSM1: Selecting PDU mode 2009-11-12 11:30:26,7, GSM1: -> AT+CMGF=0 2009-11-12 11:30:26,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:26,7, GSM1: <- AT+CMGF=0 OK 2009-11-12 11:30:26,7, GSM1: -> AT+CMGS=94 2009-11-12 11:30:26,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:27,7, GSM1: <- AT+CMGS=94 > 2009-11-12 11:30:27,7, GSM1: -> 001100099126974346F900F1FF5CC8373BCC0295E7F437A83C07D5DDA076D93D0FABCBA069730A2297417079BD2C0EBB406779789C0ECF41F0B71C44AF83C66FB7391D76EBC32C503B3C46BFE96516081E7693DFF230C8D89C82E4EFF17A0E 2009-11-12 11:30:27,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:31,7, GSM1: <- 001100099126974346F900F1FF5CC8373BCC0295E7F437A83C07D5DDA076D93D0FABCBA069730A2297417079BD2C0EBB406779789C0ECF41F0B71C44AF83C66FB7391D76EBC32C503B3C46BFE96516081E7693DFF230C8D89C82E4EFF17A0E +CMGS: 0 OK 2009-11-12 11:30:31,5, GSM1: SMS sent, To: 627934648 2009-11-12 11:30:31,6, smsd: Deleted file /var/spool/sms/checked/send_iUegPD 2009-11-12 11:30:32,6, smsd: I have to send 1 short message for /var/spool/sms/checked/send_mNZxHa 2009-11-12 11:30:32,6, GSM1: Sending SMS from to 34627934648 2009-11-12 11:30:32,7, GSM1: -> AT+CMGS=29 2009-11-12 11:30:32,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:33,7, GSM1: <- AT+CMGS=29 > 2009-11-12 11:30:33,7, GSM1: -> 0011000B914326974346F900F1FF11D0B09BFC968741C6E614247F8FD773 2009-11-12 11:30:33,7, GSM1: Command is sent, waiting for the answer 2009-11-12 11:30:36,7, GSM1: <- 0011000B914326974346F900F1FF11D0B09BFC968741C6E614247F8FD773 +CMGS: 1 OK 2009-11-12 11:30:36,5, GSM1: SMS sent, To: 34627934648 2009-11-12 11:30:36,6, smsd: Deleted file /var/spool/sms/checked/send_mNZxHa
最後に、今後のために次の対応をしておきます。
1. 不必要にログファイルが巨大にならないように、/etc/smsd.conf のログレベルを 1 にします。
2. システムが再起動したときに smsd が自動起動するように設定(/etc/init.d/sms を /etc/rc2.d/S90sms または、/etc/rc.d/rc2.d/S90sms へリンク)しておきます。パッケージからインストールした場合は、おそらくすでに設定されていますので、確認してください。
Pandora FMS アラートの設定
This steps reproduce the basic steps to create SMS alerts in Pandora FMS 3.x. For more information see “Pandora FMS Alert System”.
Pandora FMS で SMS アラーとを作成する基本的な手順を示します。より詳細は、“Pandora FMS アラートシステム” を参照してください。
コマンドを作成します。
アクションを作成します。
アクションをアラートテンプレートを使ってモジュールに割り当てます。この場合、モジュールが障害状態になったときに送信するアラートテンプレートです。
(OBSOLETE) GSM デバイスについて
シリアルポート(USB) を通して SMS を送信するためには、特別なデバイスを利用します。USB ケーブルで接続することができる GSM モジュールまたは、携帯電話と一般的な USB ケーブルの組み合わせが利用できます。どれであるかはそれほど重要ではなく、ここで利用しているものは、MTX 65 v3 です。以下のウェブサイトでだいたい 100$ くらいで入手できます。
Yutube のものでは、GSM アンテナ(例えばデータセンターが地下にある場合に便利)のようないくつかのオプションとともに小さくて互換性のあるものです。
GSM 携帯を利用することも良いオプションです。現在ほとんどの(GSM)携帯は linux でサポートされています。
(OBSOLETE) 一般的なハードウエアおよび Gnokii を使って SMS を送信するためのゲートウェイ
It is recommended to keep your systems updated with the latest version of Pandora FMS. This information is kept for historical purposes.
Pandora FMS の最新バージョン にシステムをアップデートすることをお勧めします。ここに記載の内容は、過去の情報を保持するためものです。
This method for sending SMS was the one proposed in Pandora FMS versions 1.x and 2.x. in version 3.x smstools is used. The method based on smstools is better and it is not recommended to use Gnokii due to ist complexity and possibilities of failure. However it is referenced here to provide alternative methods to smtools.
SMS を送信するためのこの方法は、Pandora FMS バージョン 1.x および 2.x での方法です。バージョン 3.x では smstools が使用されます。 smstools 利用する方法の方が優れており、複雑で失敗する可能性がある、Gnokii の使用はお勧めしません。 ただし、ここでは smtools の代替手法として示しています。
この項では、送信キューにもとづいた、SMS 送信ゲートウェイを構築する方法を説明しています。この方法では、携帯を接続し、Gnokii プロジェクトのソフトウエアを通して SMS を送信する SMS 送信サーバを実装します。また、SMS 送信には、別のリモートサーバを利用できます。これにより、異なる Pandora FMS サーバから、それぞれに携帯を接続することなく、メッセージを送信することができます。
最初に、SMS 送信ゲートウェイをインストールしたいマシンに sms ユーザを作成する必要があります。その後、home/sms および /home/sms/incoming ディレクトリを作成します。他のマシンから SMS 送信ゲートウェイを利用したい場合は、(NFS, SMB, SSH(scp), TCP や Tentacle 等の)何らかのファイル送信の仕組みで /home/sms/incoming ディレクトリにアクセスできる必要があります。
SMS 送信ゲートウェイの仕組みはとても簡単です。送信ファイルを /home/sms/incoming ディレクトリに置くだけで、SMS が処理されます。送信したファイルは削除されます。このファイルは特別なフォーマットになっており、以下の通りです。
Phonenumber|SMSText
Gnokii でのゲートウェイの実装
It is recommended to keep your systems updated with the latest version of Pandora FMS. This information is kept for historical purposes.
Pandora FMS の最新バージョン にシステムをアップデートすることをお勧めします。ここに記載の内容は、過去の情報を保持するためものです。
4つのスクリプトを作成する必要があります。
SMS: USBケーブルを通して Gnokii を使って SMS を送信するスクリプトです。スクリプトはゲートウェイとして送信するシステム(GSM携帯に接続したシステム)にのみ置きます。
SMS_GATEWAY: 送信待ちのファイルが置かれる入力ディレクトリ(/home/sms/incoming)内のファイルを定期的に処理するスクリプトです。このスクリプトは、ゲートウェイとして送信するシステムにのみ設置します。
SMS_GATEWAY_LAUNCHER: SMS_GATEWAY スクリプトを起動するための(デーモンとして起動・停止する)スクリプトです。このスクリプトは、ゲートウェイとして送信するシステムにのみ設置します。
COPY_SMS: SMS を scp コマンドを使って、クライアントシステムからゲートウェイにコピーします。最初のパラメータとして、TELEPHONE を指定し、2番目に送信するテキストを指定します(各パラメータは、“” でくくります)。スクリプトは、転送のために sms ユーザでの ssh 無認証ログインを利用します。ローカルのシステムでは、scp を cp に置き換えたり、Tentacle などの転送プログラムを利用することもできます。
sms
It is recommended to keep your systems updated with the latest version of Pandora FMS. This information is kept for historical purposes.
Pandora FMS の最新バージョン にシステムをアップデートすることをお勧めします。ここに記載の内容は、過去の情報を保持するためものです。
これは、Gnokii を使って SMS を送信するスクリプトです。(/etc/gnokii.conf にて)設定済みの Gnokii が必要です。スクリプトは、root 権限で起動する必要がまります。または、gnokii バイナリで SETUID します。
#!/bin/bash texto=$1 number=$2 if [ $# != 2 ]; then echo "I need more parameters" exit 1; fi /bin/echo $1 | /usr/local/bin/gnokii --sendsms $2
sms_gateway
It is recommended to keep your systems updated with the latest version of Pandora FMS. This information is kept for historical purposes.
Pandora FMS の最新バージョン にシステムをアップデートすることをお勧めします。ここに記載の内容は、過去の情報を保持するためものです。
これはゲートウェイデーモンのスクリプトです。
#!/bin/bash INCOMING_DIR=/home/sms/incoming HOME_DIR=/home/sms while [ 1 ] do for a in `ls $INCOMING_DIR` do if [ ! -z "$a" ] then NUMBER=`cat $INCOMING_DIR/$a | cut -d "|" -f 1` MESSAGE=`cat $INCOMING_DIR/$a | cut -d "|" -f 2` TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` echo "$TIMESTAMP Sending to $NUMBER the message $MESSAGE" >> $HOME_DIR/sms_gateway.log $HOME_DIR/sms "$MESSAGE" "$NUMBER" echo "$TIMESTAMP Deleting $a" >> $HOME_DIR/sms_gateway.log rm -Rf $INCOMING_DIR/$a sleep 1 fi done sleep 5 done
sms_gateway_launcher
It is recommended to keep your systems updated with the latest version of Pandora FMS. This information is kept for historical purposes.
Pandora FMS の最新バージョン にシステムをアップデートすることをお勧めします。ここに記載の内容は、過去の情報を保持するためものです。
This is the launching script form the sms_gateway
:
これは、sms_gateway
を起動するスクリプトです。
#!/bin/bash # SMS Gateway, startup script # Sancho Lerena, <slerena@gmail.com> # Linux Version (generic) # Configurable path and filenames SMS_GATEWAY_HOME=/home/sms SMS_PID_DIR=/var/run SMS_PID=/var/run/sms.pid # Main script if [ ! -d "$SMS_PID_DIR" ] then echo "SMS Gateway cannot write it's PID file in $SMS_PID_DIR. Please create directory or assign appropiate perms" exit fi if [ ! -f $SMS_GATEWAY_HOME/sms_gateway ] then echo "SMS Gateway not found, please check setup and read manual" exit fi case "$1" in start) OLD_PATH="`pwd`" if [ -f $SMS_PID ] then CHECK_PID=`cat $SMS_PID` CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "sms_gateway" | wc -l` if [ $CHECK_PID_RESULT == 1 ] then echo "SMS Gateway is currently running on this machine with PID ($CHECK_PID). Aborting now..." exit fi fi nohup $SMS_GATEWAY_HOME/sms_gateway > /dev/null 2> /dev/null & 2> /dev/null > /dev/null sleep 1 MYPID=`ps aux | grep "$SMS_GATEWAY_HOME/sms_gateway" | grep -v grep | tail -1 | awk '{ print $2 }'` if [ ! -z "$MYPID" ] then echo $MYPID > $SMS_PID echo "SMS Gateway is now running with PID $MYPID" else echo "Cannot start SMS Gateway. Aborted." fi cd "$OLD_PATH" ;; stop) if [ -f $SMS_PID ] then echo "Stopping SMS Gateway" PID_2=`cat $SMS_PID` if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'sms_gateway' `" ] then kill `cat $SMS_PID` 2> /dev/null > /dev/null else echo "SMS Gateway is not executing with PID $PID_2, skip Killing step" fi rm -f $SMS_PID else echo "SMS Gateway is not running, cannot stop it." fi ;; force-reload|restart) $0 stop $0 start ;; *) echo "Usage: sms_gateway {start|stop|restart}" exit 1 esac
copy_sms
Pandora FMS の最新バージョン にシステムをアップデートすることをお勧めします。ここに記載の内容は、過去の情報を保持するためものです。
これは、クライアントマシンで送信する SMS を作成し、SMS ゲートウェイへ scp を用いてコピーするスクリプトです。
#!/bin/bash SERIAL=`date +"%j%M%s"` SERIAL=`hostname`_$SERIAL TEL=$1 TEXT=$2 echo $TEL\|$TEXT >> /tmp/$SERIAL scp /tmp/$SERIAL sms@192.168.1.1:/home/sms/incoming rm -Rf /tmp/$SERIAL1
OBSOLETE
Debian / Ubuntu
Debian/Ubuntu では、Pandora FMS が利用する sendsms スクリプトをカスタマイズする必要があります。
最初に APT リポジトリからパッケージをインストールします。
$ sudo apt-get install smstools
次に、コマンドラインから sms を送信するためのサンプルスクリプトをカスタマイズします。
cp /usr/share/doc/smstools/examples/scripts/sendsms /usr/bin chmod 750 /usr/bin/sendsms
/usr/bin/sendsms を編集し、次の行をスクリプトの最後に追加します。
chmod 666 $FILE