ubuntu

Ubuntu 14.04上安装smokeping

Smokeping是网络服务器监控的利器。在运维中,如果利用smokeping给出统计数据,那么结果将令人信服。无奈smokeping上手并不十分容易,网络上的知识库都是只言片语。下面是我的安装记录,仅供参考。

安装smokeping及其依赖包
$ sudo apt-get install smokeping curl libauthen-radius-perl libnet-ldap-perl libnet-dns-perl libio-socket-ssl-perl libnet-telnet-perl libsocket6-perl libio-socket-inet6-perl apache2

  •  MASTER模式

配置apache

cd /etc/apache2/conf-available
sudo ln -s ../../smokeping/apache2.conf smokeping.conf

请注意apache配置

$ cd /etc/smokeping
$ cat apache2.conf

ScriptAlias /smokeping/smokeping.cgi /usr/lib/cgi-bin/smokeping.cgi
Alias /smokeping /usr/share/smokeping/www
Directory "/usr/share/smokeping/www">
Options FollowSymLinks

sudo a2enconf smokeping
sudo a2enmod cgid

编辑/etc/smokeping/slavesecrets.conf 和 /etc/smokeping/slave-secrets。其中key是密码,slave-server是”被监控者”的名字。

$ cd /etc/smokeping/
$ echo key > slavesecrets.conf
$ echo slave-server:key >> smokeping_secrets

编辑/etc/smokeping/config.d/Slaves

+slave-server
display_names=slave-server
color=ff0000

编辑/etc/smokeping/config.d/Targets

++ Site
menu = Corp
title = CORP – slave server
host = slave-server.com # slave server的地址
slaves = slave-server

编辑/etc/default/smokeping

$ cat /etc/default/smokeping
MODE=master

编辑权限(此步骤特别注意,否则会出现莫名的提示)

$ ls -la /etc/smokeping
total 48
drwxr-xr-x 3 root root 4096 Jul 6 23:57 .
drwxr-xr-x 128 root root 12288 Jul 6 15:45 ..
-rw-r–r– 1 root root 191 Jul 6 17:21 apache2.conf
-rw-r–r– 1 root root 2031 Jan 29 2014 basepage.html
-rw-r–r– 1 root root 290 Jan 29 2014 config
drwxr-xr-x 2 root root 4096 Jul 7 00:16 config.d
-rw——- 1 smokeping root 21 Jul 6 23:56 slavesecrets.conf
-rw-r–r– 1 root root 1564 Jan 29 2014 smokemail
-rw——- 1 www-data www-data 87 Jul 6 22:21 smokeping_secrets
-rw-r–r– 1 root root 3815 Jan 29 2014 tmail
以上文件中smokeping_secrets是给web server用的(所有者应该是:www-data),因为slave端是通过web server取得密匙。

  • SLAVE模式

编辑/etc/default/smokeping

$ cat /etc/default/smokeping
#

select master or slave mode

MODE=slave

in master mode, the rest of the configuration is in

/etc/smokeping/config

#

in slave mode, uncomment and set the following variables too

see smokeping(1)

#

Mandatory configuration

MASTER_URL=http://slave-server.com/smokeping/smokeping.cgi ## 该url对照master的apache conf档配置
SHARED_SECRET=/etc/smokeping/slavesecrets.conf
#

Optional configuration

SLAVE_NAME=slave-server

同样的,修改slavesecrets.conf

$ echo key > slavesecrets.conf

同样的,编辑权限(此步骤也要特别注意,否则会出现莫名的提示)

$ ls -la /etc/smokeping
yiwang@localhost:/etc/smokeping$ ls -la
total 48
drwxr-xr-x 3 root root 4096 Jul 6 23:40 .
drwxr-xr-x 140 root root 12288 Jul 6 17:05 ..
-rw-r–r– 1 root root 191 Jan 29 2014 apache2.conf
-rw-r–r– 1 root root 2031 Jan 29 2014 basepage.html
-rw-r–r– 1 root root 290 Jan 29 2014 config
drwxr-xr-x 2 root root 4096 Jul 6 22:31 config.d
-rw——- 1 smokeping smokeping 21 Jul 6 23:40 slavesecrets.conf
-rw-r–r– 1 root root 1564 Jan 29 2014 smokemail
-rw-rw-rw- 1 smokeping smokeping 21 Jul 6 23:40 smokeping_secrets
-rw-r–r– 1 root root 3815 Jan 29 2014 tmail