RHEL / CentOS 安装配置 SmokePing


SmokePing 是一套相当实用的网络监督工具, 画出的图片也很漂亮。虽然要安装 SmokePing 比较麻烦, 但只要透过 yum 安装 SmokePing 所需的套件就方便很多了, 以下是 RHEL 及 CentOS 安装及配置 SmokePing 的方法。

首先启用 EPEL Repo:

# yum install epel-release

接着安装 SmokePing 所需的套件:

# yum install perl httpd httpd-devel mod_fcgid rrdtool perl-CGI-SpeedyCGI fping rrdtool-perl perl-Sys-Syslog

然后安装以下 CPAN 模组:

# yum install perl-CPAN perl-local-lib perl-Time-HiRes

安装编译器, 用作编译 SmokePing 原始码:

# yum groupinstall “Development tools”

—————————————————————————————————————–

安装好所需的套件后, 现在到官网下载 SmokePing 原始码安装, 目前最新的版本是 2.6.11:

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

解压缩原始码:

# tar -zxvf smokeping-2.6.11.tar.gz

安装 SmokePing 所需的 Perl 模组, 以及编译 SmokePing:

# cd smokeping-2.6.11/
# ./setup/build-perl-modules.sh
# mkdir /opt/smokeping
# cp -R thirdparty /opt/smokeping/
# ./configure –prefix=/opt/smokeping
# make install

安装好 SmokePing 后, 现在是配置 SmokePing 的设定档, 输入以下指令:

然后开启 Apache 的设定档 httpd.conf:

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

找到设定 DirectoryIndex 的一行, 加入 smokeping.fcgi 及AddHandler 部份, 例如:

DirectoryIndex index.html index.html.var smokeping.fcgi
AddHandler cgi-script .cgi

开启 /etc/httpd/conf.d/smokeping.conf 档案, 改成这样:

执行以下指令, 建立 SmokePing 储存资料目录及设定权限:

# mkdir /opt/smokeping/img
# mkdir /opt/smokeping/data
# mkdir /opt/smokeping/var
# mkdir /opt/smokeping/cache
# chown -R apache:apache /opt/smokeping/img
# chown -R apache:apache /opt/smokeping/cache
# ln -s /opt/smokeping/htdocs /var/www/html/smokeping
# ln -s /opt/smokeping/img /var/www/html/smokeping
# ln -s /opt/smokeping/cache /var/www/html/smokeping
# chmod 600 /opt/smokeping/etc/smokeping_secrets
# chmod 600 /opt/smokeping/etc/smokeping_secrets.dist
# chown -R apache:apache /var/www/html/smokeping

现在建立 SmokePing 的设定档, 要根据自己的需要修改某些设定:

# vi /opt/smokeping/etc/config

范例档案:

然后启动 httpd:

# systemctl start httpd

设定 SmokePing 开机自动启动, 需要下载 SmokePing 的开机 script 到 /etc/init.d/ 目录, 及设定可执行权限:

# cd /etc/init.d/
# wget http://oss.oetiker.ch/smokeping/pub/contrib/smokeping-start-script
# chmod 755 smokeping-start-script

将 smokeping-start-script 第 10 行的 SMOKEPING binary 档位置, 改成这样:

SMOKEPING=/usr/local/smokeping/bin/smokeping

最后启动 SmokePing 便完成了:

# /etc/init.d/smokeping start

2 Comments

  1. Adrian 06 April 2017
  2. Adrian 06 April 2017

Leave a Reply