系统centos6.X

1、配置固定IP地址

2、关闭iptables

3、关闭selinux

4、安装其他yum源

rpm -Uvh http://ftp.pbone.net/mirror/apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

5、安装依赖包

yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping  httpd httpd-devel gcc make  wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi screen httpd


注:perl-CGI-SpeedyCGI,perl-CGI-SpeedCGI这两个包在安装过程中会提示找不到,但没关系

注:用yum安装大量的依赖包还是很方便的,而百度上有些关于安装smokeping的文档要求使用wget下载后再用make,make install方式安装,虽然make方式不复杂,但通过make编译再安装几十个包就显得有点繁锁了。


6、下载安装smokeping

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz

tar zxvf smokeping-2.6.8.tar.gz

cd smokeping-2.6.8

./configure --prefix=/usr/local/smokeping

出现问题是因为需要安装perl的模块,所以运行下面内容即可

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty

./configure --prefix=/usr/local/smokeping

/usr/bin/gmake install


7、配置smokeping

cd /usr/local/smokeping

mkdir cache data var

touch /var/log/smokeping.log

chown apache:apache cache data var

chown apache:apache /var/log/smokeping.log

cd /usr/local/smokeping/htdocs/

mv smokeping.fcgi.dist smokeping.fcgi

cd /usr/local/smokeping/etc

mv config.dist config

vim config

cgiurl   = http://some.url/smokeping.cgi

主要是修改这行,把some.url修改为你的ip或者域名

*** Database ***

step  = 300

pings  = 60

然后修改step,从300改为60,这是检测的时间, pings 从20 改为60, 即60秒ping 60次


8、修改密码权限

chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist


9、安装网站服务

yum -y install httpd*

已经做过了·······



10、修改网站服务配置文件


vim /etc/httpd/conf/httpd.conf


在DocumentRoot "/var/www/html" 这一行之下添加如下内容:

Alias /cache "/usr/local/smokeping/cache/"

Alias /cropper "/usr/local/smokeping/htdocs/cropper/"

Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"

AllowOverride None

Options All

AddHandler cgi-script .fcgi .cgi

Order allow,deny

Allow from all

DirectoryIndex smokeping.fcgi


11、设置开启启动httpd、smokeping、关闭iptables

echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local

chkconfig httpd on      #开机启动httpd进程

chkconfig iptables off  #开机不启动iptables服务


12、启动服务


/etc/init.d/httpd start

/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &


13、打开web验证

在Web浏览器里输入 http://您的监控主机IP/smokeping



注:

如果遇到500错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

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

Apache/2.2.15 (CentOS) Server at 192.168.2.101 Port 80


说明没有关闭SElinux 选项,关闭就正常了

vi /etc/sysconfig/selinux

SELINUX=permissive


临时关闭selinux

setenforce 0

[root@localhost ~]# getenforce     #查看SElinux 的命令

Permissive                      #返回的结果是Permissive, 表示已经关闭SElinux了




特别注意如果web界面出现软件错误那么需要执行一条命令即可

mv /usr/local/smokeping/thirdparty/lib/perl5/Carp/Heavy.pm /usr/local/smokeping/thirdparty/lib/perl5/Carp/Heavy.pm.bak



13、添加密码验证



修改httpd.conf里的内容


AllowOverride None

Options All

AddHandler cgi-script .fcgi .cgi

AllowOverride AuthConfig

Order allow,deny

Allow from all

AuthName "Smokeping"

AuthType Basic

AuthUserFile /usr/local/smokeping/htdocs/htpasswd

Require valid-user

DirectoryIndex smokeping.fcgi


进入cd /usr/local/smokeping/htdocs目录, 执行命令:htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin

这个是设置登录账户为admin,密码在后面输入,然后重启httpd就可以实现密码验证登录