はーどでぃすく
とあるサーバのハードディスクの容量が7.999ZBに到達した。
ディスク周りの故障があってパーツ交換待ちなんだけど、今日はファイルシステムがread-onlyになって色々おかしくなった。
OS再起動で復旧したけど不安でしかたないな('A`)
Adapter #0 Enclosure Device ID: 32 Slot Number: 0 Device Id: 0 Sequence Number: 2 Media Error Count: 0 Other Error Count: 0 Predictive Failure Count: 0 Last Predictive Failure Event Seq Number: 0 PD Type: SAS Raw Size: 0 KB [0x0 Sectors] Non Coerced Size: 7.999 ZB [0xfffffffffff00000 Sectors] Coerced Size: 0 KB [0x0 Sectors] Firmware state: Unconfigured(bad) SAS Address(0): 0x5000c5000d2df3b9 SAS Address(1): 0x0 Connected Port Number: 0(path0) Inquiry Data: SEAGATE ST3500620SS XXXXXXXXXXXXXXX FDE Capable: Not Capable FDE Enable: Disable Secured: Unsecured Locked: Unlocked Foreign State: None Device Speed: Unknown Link Speed: Unknown
Matchディレクティブを使って制御する
仕事で使う機会があったので書いておく。
OpenSSH 4.4以降ではMatchディレクティブを使ってユーザ、グループ、ホスト名、IPアドレスに応じて設定を再定義することが可能。
Matchディレクティブはグローバルの設定よりも優先され、利用できるオプションは下記の通り。
- AllowAgentForwarding
- AllowTcpForwarding
- AuthorizedKeysFile
- AuthorizedPrincipalsFile
- BannerChrootDirectory
- ForceCommand
- GatewayPorts
- GSSAPIAuthentication
- HostbasedAuthentication
- HostbasedUsesNameFromPacketOnly
- KbdInteractiveAuthentication
- KerberosAuthentication
- MaxAuthTries
- MaxSessions
- PasswordAuthentication
- PermitEmptyPasswords
- PermitOpen
- PermitRootLogin
- PermitTunnel
- PubkeyAuthentication
- RhostsRSAAuthentication
- RSAAuthentication
- X11DisplayOffset
- X11Forwarding
- X11UseLocalHost
設定例
PasswordAuthentication no X11Forwarding no Match User hoge PasswordAuthentication yes Match Address 192.168.1.0/24 X11Forwarding yes
詳しくはマニュアルで。
http://www.openbsd.org/cgi-bin/man.cgi?query=sshd_config&sektion=5
nginx + Nagios のインストール(前編)
Fedora16にnginxとNagiosを使った監視サーバを構築してみます。
nginx固有の部分を覗いて基本的に公式のマニュアル通り *1 です。
パッケージのインストール
まずコンパイル、Web UI表示のために色々いれます。
$ sudo yum install gcc glibc glibc-common gd gd-devel nginx php fcgi-devel spawn-fcgi php-fpm
ユーザ、グループ作成
Nagios用のユーザを作成します。
$ sudo useradd -m nagios $ sudo passwd nagios
次にグループを作成し、nagiosユーザとnginxユーザを所属させます。
これはWebインタフェースからのコマンド実行のため用います。
$ sudo useradd -m nagios $ sudo groupadd nagios $ sudo usermod -a -G nagios nagios $ sudo usermod -a -G nagios nginx
Nagiosのコンパイル・インストール
Nagiosの公式サイトからNagios Coreのソースファイルをダウンロード、展開します。
sedの箇所を実施しないとmake installの途中でエラーになりますので気をつけてください。
$ cd /tmp $ curl http://jaist.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz | tar zxv $ cd nagios $ ./configure $ sed -i 's:for file in includes/rss/\*;:for file in includes/rss/\*.\*;:g' ./html/Makefile $ sed -i 's:for file in includes/rss/extlib/\*;:for file in includes/rss/extlib/\*.\*;:g' ./html/Makefile $ make all
なお、configureのオプションを指定しない場合こんな感じになります。
General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagios Embedded Perl: no Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /bin/traceroute Review the options above for accuracy. If they look okay, type 'make all' to compile the main program and CGIs.
次にインストールします。
$ sudo make install install-init install-commandmode $ sudo make install-config
ちなみにApacheの場合はfullinstallとするとApache向けのコンフィグもインストールしてくれます。
install-configについてはサンプルのコンフィグをインストールしてくれます。
あとはお好みで自動起動設定でもすればOKです。
nagios-pluginsのコンパイル・インストール
nagios pluginsはNagiosが監視をするためのコマンドたちです。
先ほどインストールしたコンフィグで監視するためにはnagios pluginsが必要になります。
現時点での最新版は1.4.15ですが、しばらくリリースされていないのでGit版にします。
autoconf, automake, gitが必要になるのでインストールしておいてください。
こちらは特に難しいことはなく、レポジトリをクローンしてconfigureスクリプトを作成、実行、make、make installして完了です。
$ cd /tmp $ git clone git://nagiosplug.git.sourceforge.net/gitroot/nagiosplug/nagiosplug $ cd nagiosplug $ ./tools/setup $ ./configure $ make && sudo make install
なお、ライブラリ等の有無によって作成されるプラグインに違いが出てきますので詳しくはドキュメントを確認してください。
例えばMySQLの接続性を監視したい場合はmysql-develなどが必要になります。