|
刚接触Linux中的smokeping监控时,什么也不懂,百度安装资料都不得心应手。根据多次尝试,总结得出的成功安装方法,很实用。相关的命令我也写出来了,供新手学习,大神就请跳过。在此就不多做解释什么是smokeping了,下面来开始安装吧。
此方法安装的smokeping默认位置是/usr/share/nginx/html/smokeping下,nginx使用80端口,网页登入网址:IP/smokeping.fcgi,无需验证用户名和密码。
1.操作系统的安装
操作系统安装centos6.0以上版本 64位
2.基本环境的设置
网卡的设置 /etc/sysconfig/network-scripts/ifcfg-eth0
DNS的设置 /etc/resolv.conf
设置时区 tzselect
依次选择5-9-1-1所在大洲—所在国家—所使用的时区—确定所选时区。
检验 输入date 查看是否为CST时区
同步时间
ntpdate time.nist.gov
安装epel源 rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
3.web服务器的基本设置
安装PHP、nginx、spawn-fcgi等基础支持软件
yum install -y openssh-clients telnet wget nginx php-cgi php-cli spawn-fcgi mysql-server mysql rrdtool net-snmp net-snmp-utils net-snmp-devel php-mysql php-snmp
配置PHP管理器 vi /etc/sysconfig/spawn-fcgi
在文件改位置添加如下命令
#SOCKET=/var/run/php-fcgi.sock
#OPTIONS="-u apache -g apache -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"
SOCKET=/var/run/php-fcgi.sock
OPTIONS="-u nginx -g nginx -s $SOCKET -S -M 0600 -C 32 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi"
重启php管理器及设置开机启动服务
/etc/init.d/spawn-fcgi restart
chkconfig spawn-fcgi on
创建/var/lib/php下session 目录
mkdir -p /var/lib/php/session
chown -R nginx.nginx /var/lib/php/session
修改PHP文件配置 vi /etc/php.ini
(1)修改PHP时区为Asia/ShangHai,在文件如下位置添加该句命令
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
date.timezone = Asia/ShangHai
(2)修改PHP调用内存限制,在文件如下位置修改如下
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
max_execution_time = 30
; Maximum amount of memory a script may consume (128MB)
; http://www.php.net/manual/en/ini.core.php#ini.memory-limit
#memory_limit = 128M
memory_limit = 512M
为nginx添加fcgi[不安装无法开启smokeping],支持fcgi支持需要一些组件支持,所有组件均下载到tmp目录下
安装组件FCGI
cd /tmp
yum -y install gcc wget perl-devel perl-CPAN
wget http://search.cpan.org/CPAN/authors/id/F/FL/FLORA/FCGI-0.74.tar.gz
tar zxvf FCGI-0.74.tar.gz
cd FCGI-0.74
perl Makefile.PL
make && make install
安装组件FCGI-ProcManager
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/B/BO/BOBTFISH/FCGI-ProcManager-0.24.tar.gz
tar zxvf FCGI-ProcManager-0.24.tar.gz
cd FCGI-ProcManager-0.24
perl Makefile.PL
make && make install
安装组件Getopt-Long
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/J/JV/JV/Getopt-Long-2.42.tar.gz
tar zxvf Getopt-Long-2.42.tar.gz
cd Getopt-Long-2.42
perl Makefile.PL
make && make install
安装组件IO-String
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/IO-String-1.08.tar.gz
tar zxvf IO-String-1.08.tar.gz
cd IO-String-1.08
perl Makefile.PL
make && make install
安装组件IO
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz
tar zxvf IO-1.25.tar.gz
cd IO-1.25
perl Makefile.PL
make && make install
安装组件IO-All
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.66.tar.gz
tar zxvf IO-All-0.66.tar.gz
cd IO-All-0.66
perl Makefile.PL
make && make install
安装组件ExtUtils-Constant
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/ExtUtils-Constant-0.23.tar.gz
tar zxvf ExtUtils-Constant-0.23.tar.gz
cd ExtUtils-Constant-0.23
perl Makefile.PL
make && make install
安装组件Socket
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/P/PE/PEVANS/Socket-2.014.tar.gz
tar zxvf Socket-2.014.tar.gz
cd Socket-2.014
perl Makefile.PL
make && make install
安装nginx-fcgi
cd /tmp
wget http://122.228.213.147/nginx-fcgi
cp nginx-fcgi /etc/
chmod +x /etc/nginx-fcgi
cd /etc/nginx
mkdir log
cd log/
touch nginx-fcgi.log
chown nginx:nginx nginx-fcgi.log
注册fcgi
cd /tmp
wget http://122.228.213.147/fcgi
cp ./fcgi /etc/init.d/
chmod +x /etc/init.d/fcgi
chkconfig --add fcgi
设置fcgi开机启动及重启fcgi服务
chkconfig fcgi on
service fcgi restart
4.smokeping安装
安装smokeping的依赖包
yum install -y rrdtool fping curl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-CGI-SpeedyCGI perl-libwww-perl perl-IO-Socket-SSL rrdtool-perl gcc gcc-c++ zlib-devel pcre-devel perl-devel rrdtool-devel ntp perl-Perl-OSType perl-IPC-Cmd
安装smokeping
cd /tmp
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
tar -zxvf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9
mkdir /usr/share/nginx/html/smokeping
./configure --prefix=/usr/share/nginx/html/smokeping
#出现提示缺少部分组件
安装FCGI、CGI、CGI::Fast、Config::Grammar、Digest::HMAC_MD5、Net::Telnet、Net::OpenSSH、Net::SNMP、Net::LDAP、Net::DNS、IO::Pty、LWP
根据提示执行相关语句
./setup/build-perl-modules.sh /usr/share/nginx/html/smokeping/thirdparty
./configure --prefix=/usr/share/nginx/html/smokeping
/usr/bin/gmake install
初始化环境
mkdir /usr/share/nginx/html/smokeping/{cache,data,var}
chmod 400 /usr/share/nginx/html/smokeping/etc/smokeping_secrets.dist
cp /usr/share/nginx/html/smokeping/htdocs/smokeping.fcgi.dist /usr/share/nginx/html/smokeping/htdocs/smokeping.fcgi
(出现报错后把smokeping重新安装一遍,最后执行根据提示执行相关语句/usr/bin/gmake install)
cp /usr/share/nginx/html/smokeping/etc/config.dist /usr/share/nginx/html/smokeping/etc/config
chown -R nginx:nginx /usr/share/nginx/html/smokeping
添加smokeping为系统服务,在/etc/init.d建立smokeping文件
wget http://122.228.213.147/smokeping.sh
mv smokeping.sh smokeping
cp ./smokeping /etc/init.d/
chmod +x /etc/init.d/smokeping
chkconfig --add smokeping
chkconfig smokeping on
service smokeping restart
有警告正常情况。
编辑ngingx配置文件 vi /etc/nginx/conf.d/default.conf
在文件中添加对于smokeping的支持(红色部分为添加、修改内容)
location / {
root /usr/share/nginx/html/smokeping;
index index.html index.htm;
}
location ~\.(pl|fcgi)$
{
root /usr/share/nginx/html/smokeping/htdocs/;
include fastcgi_params;
fastcgi_pass unix:/tmp/nginx-fcgi.sock;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
设置nginx开机启动及重启nginx服务
chkconfig nginx on
service nginx restart
添加smokeping中文支持
页面支持中文 vi /usr/share/nginx/html/smokeping/etc/config
cd /usr/share/nginx/html/smokeping/etc
vi config
在配置文件的*** Presentation ***下添加(红色部分为添加内容)
*** Presentation ***
charset = utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
vi basepage.html.dist
如页面左侧层里文字依然是乱码 vi /usr/share/nginx/html/smokeping/etc/basepage.html.dist
可在basepage.html.dist文件头部位置中添加一句。
<HEAD>
<META charset="utf-8" />
<META HTTP-EQUIV="Cache-Control" content="no-cache">
添加rrd图片支持中文
安装中文字库 yum -y install wqy-zenhei-fonts.noarch
修改配置文件 vi /usr/share/nginx/html/smokeping/lib/Smokeping/Graphs.pm
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[0][1],
'--end', $tasks[0][2],
'--font TITLE:20:"WenQuanYi Zen Hei Mono"',
"DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
'PRINT:maxping:MAX:%le' );
安装完成后,重启smokeping服务 /etc/init.d/smokeping restart
浏览器输入:IP/smokeping.fcgi 即可。 |
|
|