Gk's Blog
Wednesday, November 11, 2009
  Cài đặt Smokeping ( Master / Slave ) trên Centos 5 (note)
I, Cài đặt SMOKEPING
Copy, paste từ trang http://slog.carlheaton.co.uk/index.php/2009/06/centos-5-3-smokeping-2-4-2-install-quick/ có sửa đổi.

Cài đặt CentOS5 minimal. Tắt SELinux.
Smokeping có 2 thành phần chính:
file cgi : chạy qua web. Tương tác với người dùng, tương tác với slave
file binary: chạy daemon để lấy thông tin và lưu trữ vào RRD

Install all of the smokeping prerequisites:

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uv rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rm rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
yum update
yum install rrdtool perl-CGI-SpeedyCGI fping httpd perl-libwww-perl.noarch fontconfig freetype dejavu-lgc-fonts.noarch perl-rrdtool

Install and configure smokeping 2.4.2:

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
tar xvzf smokeping-2.4.2.tar.gz
mv smokeping-2.4.2 /usr/local/smokeping
chown -R root:root /usr/local/smokeping
cd /usr/local/smokeping/bin
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd /usr/local/smokeping/etc/
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd /usr/local/smokeping/htdocs
for foo in *.dist; do cp $foo `basename $foo .dist`; done

vi /usr/local/smokeping/bin/smokeping


#Thay đổi đường dẫn của các lib cần thiết, chú ý nếu bạn dùng bản 32bit thì phải thay đổi đường dẫn tương ứng

· change > use lib qw(/usr/pack/rrdtool-1.3.0-rp/lib/perl);
to > use lib qw(/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs);
# với bản 32 bit> use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs);
· change > use lib qw(lib);
to > use lib qw(/usr/local/smokeping/lib);
· change > Smokeping::main(”etc/config.dist”);
to > Smokeping::main(”/usr/local/smokeping/etc/config”);
vi /usr/local/smokeping/htdocs/smokeping.cgi
· change > use lib qw(/usr/pack/rrdtool-1.3.0-rp/lib/perl);
to > use lib qw(/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs);
#với bản 32bit> use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs);
· change > use lib qw(/home/oetiker/checkouts/smokeping/trunk/software/lib);
to > use lib qw(/usr/local/smokeping/lib);
· change > Smokeping::cgi(”/home/oetiker/checkouts/smokeping/trunk/software/etc/config.dist”);
to > Smokeping::cgi(”/usr/local/smokeping/etc/config”);
cp /usr/local/smokeping/htdocs/smokeping.cgi /var/www/cgi-bin
cp -R /usr/local/smokeping/htdocs/* /var/www/html/smokeping

vi /usr/local/smokeping/etc/config

· change > owner | contact | mailhost
to > what they should be
· change > imgcache = /home/oetiker/public_html/smokeping-ms/cache
to > imgcache = /var/www/html/smokeping/img
· change > imgurl = cache
to > imgurl = http://yoursite.url/smokeping/img
#quan trọng nếu không sẽ không thấy graph
· change > datadir = /tmp/smokeping-ms/data
to > datadir = /usr/local/smokeping/var
· change > piddir = /tmp/smokeping-ms/var
to > piddir = /usr/local/smokeping/var
· change > cgiurl = http://some.url/smokeping.cgi
to > cgiurl = http://yoursite.url/cgi-bin/smokeping.cgi
· change > smokemail = /home/oetiker/checkouts/smokeping/trunk/software/etc/smokemail.dist
to > smokemail = /usr/local/smokeping/etc/smokemail
· change > tmail = /home/oetiker/checkouts/smokeping/trunk/software/etc/tmail.dist
to > tmail = /usr/local/smokeping/etc/tmail
· change > template = /home/oetiker/checkouts/smokeping/trunk/software/etc/basepage.html.dist
to > template = /usr/local/smokeping/etc/basepage.html
#có thể phải sửa đổi file này cho phù hợp với đường dẫn của các file js, img trong thư mục smokeping/cropper và smokeping/img
· change > binary = /usr/sbin/fping
to > binary = /usr/sbin/fping
#tìm đường dẫn của fping bằng lệnh “which fping”
· comment out (#) the “*** Slaves ***” section
· comment out or remove everything below “*** Targets ***” > remark (don’t remove probe, menu, title)
· You’ll need to add your targets before you can do anything useful with smokeping.
Tạo thư mục lưu img và thông tin cho smokeping

mkdir -p /var/www/html/smokeping/img
chown -R apache:apache /var/www/html/smokeping/img
mkdir /usr/local/smokeping/var
Chạy:

/usr/local/smokeping/bin/smokeping &

Visit http://some.url/cgi-bin/smokeping.cgi in a web browser and check that you’re not getting an error 500 (check your SELinux config).



Config and start apache
vi /etc/httpd/conf/httpd.conf
/etc/init.d/httpd start


II, Cài đặt Slaves
HD chính thức ở trang chủ: http://oss.oetiker.ch/smokeping/doc/smokeping_master_slave.en.html
Ở master:

vi /usr/local/smokeping/etc/config
edit mục Slaves


*** Slaves ***
secrets=/usr/local/smokeping/etc/smokeping_secrets
#File secrets ở trên phải được chmod 600, chown apache:apache
#Nếu ko sẽ ko start đc smokeping hoặc gây lỗi:
# WARNING: Opening secrets file /usr/local/smokeping/etc/smokeping_secrets: Permission denied
#File secrets chứa các dòng, mỗi dòng gồm có hostname của slave và pass
#(secrets string) cho slave đó theo định dạng:
#slave1:abc123
#slave2:abc123


+slave1
#bắt buộc phải trùng với hostname của slave
display_name=erul22
location=India
color=ff0000


++override
Probes.FPing.binary = /usr/bin/fping
#phần override để áp dụng các cấu hình cho từng slave nếu nó khác với master. Ví dụ như trên là chỉ ra đường dẫn của fping trên slave

Edit mục Targets

*** Targets ***
slaves = slave1 slave2
#Chứa tên tất cả các slave.
#Nếu thiếu sẽ gây lỗi: "WARNING: No targets found for slave 'tên slave'"
...
+dest1
slaves =
...
+dest2
slaves = slave1
host = IPcuaHost
title = TenHost
#Đặt menu cho đẹp, chứa các host và title ở đây.


...
+dest3

Ở slave:
Copy file binary của smokeping, cài đặt fping…

./smokeping --master-url=http://master.url/smokeping.cgi \
--cache-dir=/var/smokeping/ \
--shared-secret=/var/smokeping/secret.txt

File /var/smokeping/secret.txt chỉ chứa password của slave, ví dụ với cấu hình trên của master thì:

$ cat /var/smokeping/secret.txt
abc123


*Nếu không thấy graph của slave(mặc dù không có lỗi, debug + logfile đều ghi dữ liệu đã gửi đến master tuy nhiên RRD của slave không được update) thì xem lại permission trên master, đảm bảo user đang chạy smokeping.cgi (cụ thể ở đây là apache) có quyền ghi vào thư mục chứa file RRD (cụ thể ở đây là /usr/local/smokeping/var/)

Labels: ,

 
Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

My Photo
Name:
Location: Hanoi, Vietnam
Archives
July 2009 / November 2009 / January 2010 / August 2010 / September 2010 / June 2011 / September 2013 /


Powered by Blogger

Subscribe to
Posts [Atom]