3流プログラマのメモ書き

元開発職→社内SE→派遣で営業支援の三流プログラマのIT技術メモ書き。 このメモが忘れっぽい自分とググってきた技術者の役に立ってくれれば幸いです。(jehupc.exblog.jpから移転中)

(Linux)CentOS6.0にSmokePingを入れようとしてハマッた

(ツール)ネットワーク遅延グラフツールSmokePingを入れてみたで、CentOS5.6にSmokePingを入れました。

今回、CentOS6.0にSmokePing2.4.2を入れようとしたんですが、結構ハマりました。

以前の記事で書いたように、rpmパッケージで入れたんですが、起動しようとすると以下のようなエラーになります。

# service smokeping start

smokeping を起動中: Can't locate RRDs.pm in @INC (@INC contains: /usr/share/smokeping/lib /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at /usr/share/smokeping/lib/Smokeping.pm line 13.

BEGIN failed--compilation aborted at /usr/share/smokeping/lib/Smokeping.pm line 13.

Compilation failed in require at /usr/sbin/smokeping line 7.

BEGIN failed--compilation aborted at /usr/sbin/smokeping line 7.

どうやら、rrdtoolへのパスが通っていないようだったので /usr/share/smokeping/lib/Smokeping.pm に use lib '/usr/lib/perl5/vendor_perl/5.8.8'; とパスを追加してみましたが、今度はシンボルが読めないとかでやはり動きません。

CentOS6.0が Perl5.10 がインストールされており、rrdtoolやsmokepingが Perl5.8 ベースというのが原因かもしれません。

それで、RRDTool と SmokePing はソースからインストールすることにしました。

RRDTool と SmokePing 以外の依存パッケージは yum でインストールします。

RRDToolコンパイルするには下記のライブラリが必要です。

zlib

libpng

freetype-2

gd-2

libart_lgpl-2

ライブラリをCentOSRPMからインストールする際は必ず各-develパッケージも入れておきましょう。

yum install zlib libpng freetype gd libart_lgpl

yum install zlib-devel libpng-devel freetype-devel gd-devel libart_lgpl-devel

次にRRDToolをダウンロードし、ビルドします。

ダウンロードは、http://oss.oetiker.ch/rrdtool/pub/から可能です。

# tar xzvf rrdtool-1.4.5.tar.gz

# cd rrdtool-1.4.5

# ./configure --enable-perl-site-install --disable-python --disable-tcl

configure: WARNING:

----------------------------------------------------------------------------

* I found a copy of pkgconfig, but there is no cairo-png.pc file around.

You may want to set the PKG_CONFIG_PATH variable to point to its

location.

----------------------------------------------------------------------------

configure: WARNING:

----------------------------------------------------------------------------

* I could not find a working copy of cairo-png. Check config.log for hints on why

this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately

so that compiler and the linker can find libcairo and its header files. If

you have not installed cairo-png, you can get it either from its original home on

http://cairographics.org/releases/

You can find also find an archive copy on

http://oss.oetiker.ch/rrdtool/pub/libs

The last tested version of cairo-png is 1.4.6.

LIBS=-lm

LDFLAGS=

CPPFLAGS=

......(省略).......

configure: error: Please fix the library issues listed above and try again.

何やら、エラーが出まくりです。

依存パッケージが足りないようなので、以下パッケージをインストールします。

# yum install pango-devel cairo-devel glibc-devel libxslt-devel

configure がうまくいくと、こうなります。

config.status: creating bindings/Makefile

config.status: creating bindings/tcl/Makefile

config.status: creating bindings/tcl/ifOctets.tcl

config.status: creating Makefile

config.status: creating bindings/lua/Makefile

config.status: creating rrd_config.h

config.status: executing depfiles commands

config.status: executing libtool commands

config.status: executing po-directories commands

config.status: creating po/POTFILES

config.status: creating po/Makefile

config.status: executing default commands

checking in... and out again

ordering CD from http://tobi.oetiker.ch/wish .... just kidding ;-)

----------------------------------------------------------------

Config is DONE!

With MMAP IO: yes

Build rrd_getopt: no

Static programs: no

Perl Modules: perl_piped perl_shared

Perl Binary: /usr/bin/perl

Perl Version: 5.10.1

Perl Options:

Ruby Modules:

Ruby Binary: /usr/bin/ruby

Ruby Options: sitedir=/opt/rrdtool-1.4.5/lib/ruby

Build Lua Bindings: no

Build Tcl Bindings: no

Build Python Bindings: no

Build rrdcgi: yes

Build librrd MT: yes

Use gettext: yes

With libDBI: no

With libwrap: no

Libraries: -lxml2 -lcairo -lcairo -lcairo -lm -lcairo -lpng12 -lglib-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

Type 'make' to compile the software and use 'make install' to

install everything to: /opt/rrdtool-1.4.5.

... that wishlist is NO JOKE. If you find RRDtool useful

make me happy. Go to http://tobi.oetiker.ch/wish and

place an order.

-- Tobi Oetiker

----------------------------------------------------------------

makeします。

# make

# make install

デフォルトでは、/opt/rrdtool-1.4.5/ 配下にインストールされるようです。

次に、RRDToolの、perlモジュールを作成します。

解凍したフォルダに移動し、以下コマンドを実行します。

# cd rrdtool-1.4.5/bindings/perl-shared/

# perl Makefile.PL

# make

# make install

Files found in blib/arch: installing files in blib/lib into architecture dependent library tree

Installing /usr/local/lib/perl5/auto/RRDs/RRDs.so

Appending installation info to /usr/lib/perl5/perllocal.pod

どうやら、/usr/local/lib/perl5/auto/RRDs/RRDs.so にインストールされたようです。

さて、よーやくSmokePingのダウンロードと配置です。

SmokePingを、http://oss.oetiker.ch/smokeping/pub/からダウンロードします。

/usr/local/src/ に移動して、解凍します。

# cd /usr/local/src/

# tar zxvf smokeping-2.4.2.tar.gz

# ln -s smokeping-2.4.2/ smokeping

スクリプトのファイル名を変更、スクリプトの設定も変更します。

# cd /usr/local/src/smokeping/bin

# cp smokeping.dist smokeping

# cp tSmoke.dist tSmoke

# vi smokeping

先頭を以下のように変更。

--------------

#!/usr/bin/perl -w

# -*-perl-*-

#use lib qw(/usr/pack/rrdtool-1.3.0-rp/lib/perl); ←コメントアウト

use lib qw(lib);

use lib qw(/usr/local/src/smokeping/lib); ←追加

use strict;

use warnings;

use Smokeping 2.004002;

#Smokeping::main("etc/config.dist");

Smokeping::main("/usr/local/src/smokeping/etc/config"); ←コンフィグファイルの場所変更

--------------

CGI用のスクリプトもコピーし、変更します。

# cd /usr/local/src/smokeping/htdocs/

# cp smokemail.cgi.dist smokemail.cgi

vi /usr/local/src/smokeping/htdocs/smokeping.cgi

-------------------------------

#!/usr/bin/perl ←speedy を perl 変更

# -*-perl-*-

use strict;

use warnings;

#use lib qw(/usr/pack/rrdtool-1.3.0-rp/lib/perl); ←コメントアウト

#use lib qw(/home/oetiker/checkouts/smokeping/trunk/software/lib); ←コメントアウト

use lib qw(/usr/lib);

use lib qw(/usr/local/src/smokeping/lib);

use CGI::Carp qw(fatalsToBrowser);

use Smokeping 2.004002;

#Smokeping::cgi("/home/oetiker/checkouts/smokeping/trunk/software/etc/config.dist");

Smokeping::cgi("/usr/local/src/smokeping/etc/config"); ←コンフィグファイルの場所変更

-------------------------------

先頭の speedy を perl に変更しないと、ブラウザからアクセスしたときに下記エラーになりました。(Apacheのerrorログ)

[Tue Sep 06 17:03:55 2011] [error] [client 192.168.1.8] (2)No such file or directory: exec of '/usr/local/src/smokeping/htdocs/smokeping.cgi' failed

[Tue Sep 06 17:03:55 2011] [error] [client 192.168.1.8] Premature end of script headers: smokeping.cgi

また、各ファイルもコピーしておきます。

# cd /usr/local/src/smokeping/etc

# cp tmail.dist tmail

# cp basepage.html.dist basepage.html

# cp smokeping_secrets.dist smokeping_secrets

# chmod 777 smokeping_secrets

# cp config.dist config

データ置き場ディレクトリ作成します。ここがRRDToolのデータ(pingの結果)が置かれます。

# mkdir /var/lib/smokeping

# mkdir /var/lib/smokeping/images

# mkdir /var/lib/smokeping/rrd

# mkdir /var/run/smokeping

# chown -R apache:apache /var/lib/smokeping/images

# mkdir /var/run/smokeping

configファイルを修正します。

# vi /usr/local/src/smokeping/etc/config

configファイルは以下のように設定しました。

---------------------

*** General ***

owner = Super User

contact = root@localhost

mailhost = smtp.hoge.jp

sendmail = /usr/sbin/sendmail

# NOTE: do not put the Image Cache below cgi-bin

# since all files under cgi-bin will be executed ... this is not

# good for images.

imgcache = /var/lib/smokeping/images

imgurl = /smokeping/images

datadir = /var/lib/smokeping/rrd

piddir = /var/run/smokeping

cgiurl = http://smokeping/smokeping/sm.cgi

smokemail = /usr/local/src/smokeping/etc/smokemail

tmail = /usr/local/src/smokeping/etc/tmail

# specify this to get syslog logging

syslogfacility = local0

# each probe is now run in its own process

# disable this to revert to the old behaviour

# concurrentprobes = no

....(省略)....

*** Presentation ***

charset = UTF-8

template = /usr/local/src/smokeping/etc/basepage.html

....(省略)....

*** Slaves ***

secrets=/usr/local/src/smokeping/etc/smokeping_secrets

---------------------

起動スクリプトを作成します。

# vi /etc/init.d/smokeping

---------------------

#!/bin/sh

case "$1" in

'start')

/usr/local/src/smokeping/bin/smokeping

;;

'stop')

kill -9 `cat /var/run/smokeping/smokeping.pid`

;;

*)

/usr/local/src/smokeping/bin/smokeping

;;

esac

---------------------

# chmod 755 /etc/rc.d/init.d/smokeping

# cd /etc/rc.d/rc3.d/

# ln -s ../init.d/smokeping S99smokeping

# cd /etc/rc.d/rc0.d/

# ln -s ../init.d/smokeping K01smokeping

# cd /etc/rc.d/rc6.d/

# ln -s ../init.d/smokeping K01smokeping

Apache側の設定を行います。

# vi /etc/httpd/conf/httpd.conf

---------------------

AddHandler cgi-script .cgiコメントアウトを外す)

最下行に以下追加

Order allow,deny

# Deny from all

Allow from all

Order allow,deny

#Deny from all

Allow from all

ScriptAlias /smokeping/sm.cgi /usr/local/src/smokeping/htdocs/smokeping.cgi

Alias /smokeping/images /var/lib/smokeping/images

Alias /smokeping /usr/local/src/smokeping/htdocs

Options +ExecCGI

---------------------

# /etc/init.d/smokeping start

Can't load '/usr/local/lib/perl5/auto/RRDs/RRDs.so' for module RRDs: librrd.so.4: 共有オブジェクトファイルを開けません: そのようなファイルやディレクトリはありません at /usr/lib/perl5/DynaLoader.pm line 200.

at /usr/local/src/smokeping/lib/Smokeping.pm line 13

Compilation failed in require at /usr/local/src/smokeping/lib/Smokeping.pm line 13.

BEGIN failed--compilation aborted at /usr/local/src/smokeping/lib/Smokeping.pm line 13.

Compilation failed in require at /usr/local/src/smokeping/bin/smokeping line 9.

BEGIN failed--compilation aborted at /usr/local/src/smokeping/bin/smokeping line 9.

ん? rrttoolのモジュールが読めいないようです。

以下のようにパスを通してやったら解決しました。

# ln -s /opt/rrdtool-1.4.5/lib/librrd.so.4.1.4 /usr/lib/librrd.so.4

# /etc/init.d/smokeping start

Note: logging to syslog as local0/info.

Daemonizing /usr/local/src/smokeping/bin/smokeping ...

上記のようにでれば起動完了です。

ブラウザから、http://ホスト名/smokeping/sm.cgi でアクセスができれば、CGI,Apache側の設定もOKです。

RRDToolのインストール - satospo

smokeping(その1):はいはい、備忘録ですよ。:So-netブログ

smokeping(その2):はいはい、備忘録ですよ。:So-netブログ

smokeping(その3):はいはい、備忘録ですよ。:So-netブログ

smokeping(その4):はいはい、備忘録ですよ。:So-netブログ

smokeping(その5):はいはい、備忘録ですよ。:So-netブログ

CloudForecastを入れてみた - メメメモモ RRDToolPerlモジュールのインストール方法。

へっぽこエンジニア@日記 Muninのインストールと設定・その3

cgi界にはびこる民間療法 Premature end of script headers - それはそれ。これはこれ。 ブラウザでアクセスしたときにエラーになった時の解決策。先頭のパス違い。

【防備録】■Linuxネットワーク監視ツール構築 | NANDEMO徒然日記