smokeping-2.6.8 主从部署

除了上文说的 SP 在报警方面比较强大之外,M/S 也是 SP 一个比较强大的地方,这样,从各地收集的数据更能客观的说明情况。

slave
# hostname
slave1.jaseywang.me
# cd /etc/smokeping
# echo "helloworld" > slavesecrets.conf
# chmod 600 !$
# chown smokeping !$
# cat /etc/default/smokeping

MODE=slave
MASTER_URL=http://master_ip/smokeping/smokeping.cgi
SHARED_SECRET=/etc/smokeping/slavesecrets.conf
SLAVE_NAME=slave1.jaseywang.me

master:
# cd /etc/smokeping
# echo "helloworld" > slavesecrets.conf
# chmod 600 !$
# chown smokeping !$
# echo "slave1.jaseywang.me:helloworld" > smokeping_secrets
# chown www-data !$
# chmod 600 !$
# cat /etc/default/smokeping

MODE=master
# cat config.d/Slaves
*** Slaves ***
secrets=/etc/smokeping/smokeping_secrets
+test.jaseywang.me
display_name=test.jaseywang.me
color=00ff00
# head config.d/Targets
*** Targets ***

slaves = test.jaseywang.me

在启动过程中,会出现类似如下的一些 error:
WARNING: Opening secrets file /etc/smokeping/smokeping_secrets: Permission denied
WARNING: No targets found for slave 'slave1.jaseywang.me'
ERROR: we did not get config from the master. Maybe we are not configured as a slave for any of the targets on the master ?
ERROR: the shared secret file (/etc/smokeping/slavesecrets.conf) is world-readable or writable at /usr/share/perl5/Smokeping.pm line 4117.

原因无非是上面哪个步骤做的有问题。正确的启动 log 如下:
 * Starting latency logger daemon smokeping                                                                                                                    Sent data to Server and got new config in response.
                                                                     [ OK ]
# ps axu | grep sm
root        83  0.0  0.0      0     0 ?        SN   Dec06   0:00 [ksmd]
109      31537  0.3  0.1 143980 27100 ?        Ss   00:38   0:00 /usr/bin/perl /usr/sbin/smokeping –config=/etc/smokeping/config –master-url http://master_ip/smokeping/smokeping.cgi –shared-secret /etc/smokeping/slavesecrets.conf –slave-name slave1.jaseywang.me –cache-dir /var/lib/smokeping –pid-dir /var/run/smokeping
109      31538  0.0  0.1 143980 27000 ?        S    00:38   0:00 /usr/sbin/smokeping [Curl]
109      31540  0.0  0.1 143980 27000 ?        S    00:38   0:00 /usr/sbin/smokeping [DNS]
109      31541  0.0  0.1 143980 27000 ?        S    00:38   0:00 /usr/sbin/smokeping [FPing]
root     31561  0.0  0.0   7624   928 pts/0    R+   00:38   0:00 grep –color=auto sm

以上是在 ubuntu 上,有 /etc/default/smokeping 文件,比较省心,如果是 CentOS 等,则需要像下面这样手动启动:
# /usr/local/smokeping/bin/smokeping --config=/usr/local/smokeping/etc/config --master-url http://master_ip/smokeping/smokeping.cgi --shared-secret /usr/local/smokeping/etc/slavesecrets.conf --slave-name test.jaseywang.me --cache-dir /usr/local/smokeping/cache/ --pid-dir /usr/local/smokeping/var/
Sent data to Server and got new config in response.
### parsing dig output…OK
### assuming you are using an fping copy reporting in milliseconds
Note: logging to syslog as local0/info.
Daemonizing /usr/local/smokeping/bin/smokeping …

ref:
https://nsrc.org/workshops/2012/menog-dns-dnssec/attachment/wiki/References/sample-smokeping-master-slave.txt