====== Pandora FMS と SMS ゲートウェイのインストールと設定 ======
{{indexmenu_n>2}}
[[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]]
===== GSM デバイスについて =====
A special GSM device is used to send SMS through a serial port (USB). You may 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 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 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** を実行します。次のような画面が表示されます。
[[:wiki:smsstep1.png?id=ja%3Adocumentation%3Apandorafms%3Atechnical_annexes%3A02_pandorafms_sms_gateway&media=wiki:smsstep1.png|{{ :wiki:smsstep1.png }}]]
* 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 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 may 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 just install it with the following command:
PFMS が提供する RPM を使用するには、次のコマンドでインストールするだけです。
rpm -i smstools*.rpm
==== SMStools の設定 ====
Edit with the user **root**, or equivalent, the base configuration file with a text editor (**Vi** is used here):
ユーザ **root** または同等の権限で、テキストエディタ (ここでは **Vi** ) を使用して基本設定ファイルを編集します。
vi /etc/smsd.conf
The following contents have to be added (if the output or result of the **dmesg** command differs from ''ttyACMO'', //use the device// ''tty'' //detected by your system//):
以下の内容を追加する必要があります (**dmesg** コマンドの出力または結果が ''ttyACMO'' と異なる場合は、システムによって検出された // デバイス ''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 =
On the last line, enter the PIN assigned to the SIM used.
最後の行に、使用する SIM に割り当てられた PIN を入力します。
Then **smstools** must be started manually:
そして、**smstools** を手動で起動します。
/usr/bin/smstools start
You may now send a test SMS with a user other than **root** (''34'' is the international code for Spain, fill in the asterisks with the test phone number):
これで、**root** 以外のユーザでテスト SMS を送信できます (''34'' はスペインの国際コードです。アスタリスクにテスト電話番号を入力してください)。
sendsms 34******** "Pandora FMS rocks"
After a minute of waiting, monitor the logs to make sure that everything is correct. The SMS should be received within a few seconds. Depending on the network, the first SMS may be checked every 10 to 20 seconds, the next SMS should be almost immediate. **SMSTools** uses a queue to send messages, so you may send as many messages as needed, //and they will be broadcasted when the cell phone network can handle them//.
1 分ほど待った後、ログを監視してすべてが正しいことを確認します。SMS は数秒以内に受信されるはずです。ネットワークによっては、最初の SMS は 10 ~ 20 秒ごとにチェックされ、次の SMS はほぼ即時に受信されるはずです。**SMSTools** はキューを使用してメッセージを送信するため、必要な数のメッセージを送信できます。//そして、携帯電話ネットワークが処理できるときにメッセージがブロードキャストされます// 。
To see logs:
ログの確認:
cat /var/log/smsd.log
Finally, some tasks to secure this operation for the future:
最後に、今後のために次の対応をしておきます。
- Set ''1'' for **loglevel** in ''/etc/smsd.conf'' to avoid an excessively large and unnecessary //log// file.
- Make sure **smsd** is configured to start automatically when the system reboots (this implies a link from ''/etc/init.d/sms'' to ''/etc/rc2.d/S90sms'' or ''/etc/rc.d/rc2.d/S90sms''). If you installed it from a package, it probably already exists on the system, it will be a matter of checking it.
- 過度に大きくて不要な //ログ// ファイルを回避するには、''/etc/smsd.conf'' の **loglevel** に ''1'' を設定します。
- システムの再起動時に **smsd** が自動的に起動するように設定されていることを確認してください (これは、''/etc/init.d/sms'' から ''/etc/rc2.d/S90sms'' または ''/etc/rc.d/rc2.d/S90sms'' へのリンクを意味します)。パッケージからインストールした場合は、おそらく既にシステム上に存在しているので、確認するだけです。
===== Pandora FMS アラートの設定 =====
For more information see "[[:en:documentation:pandorafms:management_and_operation:01_alerts|Alert system in Pandora FMS]]".
より詳細は、"[[:ja:documentation:pandorafms:management_and_operation:01_alerts|Pandora FMS アラートシステム]]" を参照してください。
* First the alert command must be created:
* 最初にアラートコマンドを作成します。
[[:wiki:smsalerts1.png?media=wiki:smsalerts1.png|{{ :wiki:smsalerts1.png?direct& }}]]
* And then create the alert action:
* そして、アラートアクションを作成します。
[[:wiki:smsalerts2.png?media=wiki:smsalerts2.png|{{ :wiki:smsalerts2.png?direct& }}]]
The action is associated to a module using a previous alert template. In this case, the alert template will be triggered when the module status is CRITICAL.
アクションをアラートテンプレートを使ってモジュールに割り当てます。この場合、モジュールが障害状態になったときに実行されるアラートテンプレートです。
[[:ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]]
===== (OBSOLETE) GSM デバイスについて =====
シリアルポート(USB) を通して SMS を送信するためには、特別なデバイスを利用します。USB ケーブルで接続することができる GSM モジュールまたは、携帯電話と一般的な USB ケーブルの組み合わせが利用できます。どれであるかはそれほど重要ではなく、ここで利用しているものは、MTX 65 v3 です。以下のウェブサイトでだいたい 100$ くらいで入手できます。
* http://matrix.es
* http://www.youtube.com/watch?v=OxcKAarS2M0
Yutube のものでは、GSM アンテナ(例えばデータセンターが地下にある場合に便利)のようないくつかのオプションとともに小さくて互換性のあるものです。
GSM 携帯を利用することも良いオプションです。現在ほとんどの(GSM)携帯は linux でサポートされています。
===== (OBSOLETE) 一般的なハードウエアおよび Gnokii を使って SMS を送信するためのゲートウェイ =====
\\
It is recommended to keep your systems updated with the [[:en:documentation:08_technical_reference:10_versions|latest version of Pandora FMS]]. **This information is kept for historical purposes**.\\
\\
[[:ja:documentation:08_technical_reference:10_versions|Pandora FMS の最新バージョン]] にシステムをアップデートすることをお勧めします。**ここに記載の内容は、過去の情報を保持するためものです。**
This method for sending SMS was the one proposed in Pandora FMS versions 1.x and 2.x. in version 3.x [[:en:documentation:07_technical_annexes:02_pandorafms_sms_gateway#configure_smstools_to_use_the_new_device|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 では [[:ja:documentation:07_technical_annexes:02_pandorafms_sms_gateway#新たなデバイスを利用するための_smstools_の設定|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 [[:en:documentation:08_technical_reference:10_versions|latest version of Pandora FMS]]. **This information is kept for historical purposes**.\\
\\
[[:ja:documentation:08_technical_reference:10_versions|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 [[:en:documentation:08_technical_reference:10_versions|latest version of Pandora FMS]]. **This information is kept for historical purposes**.\\
\\
[[:ja:documentation:08_technical_reference:10_versions|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 [[:en:documentation:08_technical_reference:10_versions|latest version of Pandora FMS]]. **This information is kept for historical purposes**.\\
\\
[[:ja:documentation:08_technical_reference:10_versions|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 [[:en:documentation:08_technical_reference:10_versions|latest version of Pandora FMS]]. **This information is kept for historical purposes**.\\
\\
[[:ja:documentation:08_technical_reference:10_versions|Pandora FMS の最新バージョン]] にシステムをアップデートすることをお勧めします。**ここに記載の内容は、過去の情報を保持するためものです。**
This is the launching script form the ''sms_gateway'':
これは、''sms_gateway'' を起動するスクリプトです。
#!/bin/bash
# SMS Gateway, startup script
# Sancho Lerena,
# 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 ===
\\
[[:ja:documentation:08_technical_reference:10_versions|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