照著這裡做的話不會遇到太大問題。
首先看哪個好心人有做對應版本的 package ,這裡找到 jtaylor。
然後就裝吧:
apt-get install python-software-properties add-apt-repository ppa:jtaylor/jtaylor apt-get update apt-get install valgrind
打完收工。
cd /usr/ports/www/p5-FCGI && make install clean cd /usr/ports/www/p5-FCGI-ProcManager && make install clean cd /usr/ports/www/spawn-fcgi && make install clean或是用 pkg :
pkg install p5-FCGI p5-FCGI-ProcManager spawn-fcgi2) 編輯 smokeping 的 fastcgi wrapper,vim /usr/local/smokeping/htdocs/smokeping.fcgi 檔案如下:
# -*-perl-*- use FCGI; use FCGI::ProcManager; use lib qw(/usr/local/smokeping/lib); use Smokeping 2.004002 ; use CGI::Fast; my $cfg = "/usr/local/etc/smokeping/config"; my $proc_manager = FCGI::ProcManager->new( {n_processes => 5} ); my $request = FCGI::Request(); $proc_manager->pm_manage(); while (my $q = new CGI::Fast) { Smokeping::cgi($cfg,$q); } while($request->Accept() >= 0) { my $q = new CGI::Fast; $proc_manager->pm_pre_dispatch(); Smokeping::cgi($cfg,$q); $proc_manager->pm_post_dispatch(); exit(0); }
#!/bin/sh /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 你要的PORT\ -P /var/run/smokeping-fastcgi.pid -u www \ -f /usr/local/smokeping/htdocs/smokeping.fcgi
location /smokeping/smokeping.cgi { error_log /PATH_TO/smoke-error.log info; access_log /PATH_TO/smoke-access.log combined; fastcgi_pass 127.0.0.1:你要的PORT; fastcgi_param SCRIPT_FILENAME /usr/local/smokeping/htdocs$fastcgi_script_name; include fastcgi_params; } location /smokeping/ { error_log /PATH_TO/smoke-error.log info; access_log /PATH_TO/smoke-access.log combined; alias /usr/local/smokeping/htdocs/; }然後記得跑
/usr/local/smokeping/htdocs/spawn-smoke之後再把 nginx 跑起來就沒問題了。
spawn_fcgi_enable="YES" spawn_fcgi_app="/usr/local/smokeping/htdocs/smokeping.fcgi" spawn_fcgi_bindaddr="127.0.0.1" spawn_fcgi_bindport="PORT"Update: slave 設定
smokeping_enable="YES" smokeping_flags="--master-url=http://MASTER.cgi --slave-name=SLAVENAME --cache-dir=/var/run/smokeping --shared-secret=SECRET"
# Define these smokeping_* variables in one of these files: # /etc/rc.conf # /etc/rc.conf.local # /etc/rc.conf.d/smokeping # # DO NOT CHANGE THESE DEFAULT VALUES HERE # # smokeping_flags="" smokeping_enable=${smokeping_enable-"NO"} smokeping_pidfile=${smokeping_pidfile-"/usr/local/var/smokeping/smokeping.pid"} smokeping_fcgi_pidfile=${smokeping_fcgi_pidfile-"/var/run/smokeping-fastcgi.pid"} smokeping_logfile=${smokeping_logfile-"/var/log/smokeping.log"} smokeping_user=${smokeping_user-"smokeping"} smokeping_group=${smokeping_group-"smokeping"} . /etc/rc.subr name="smokeping" rcvar="smokeping_enable" load_rc_config $name command="/usr/local/bin/smokeping" command_args="--logfile=${smokeping_logfile}" pidfile="${smokeping_pidfile}" fcgi_pidfile="${smokeping_fcgi_pidfile}" extra_commands="reload" reload_cmd="smokeping_reloadcmd" start_precmd="smokeping_startprecmd" stop_cmd="smokeping_stopcmd" status_cmd="smokeping_statuscmd" spawn_smokeping_fcgi="/usr/local/smokeping/htdocs/spawn-smoke" smokeping_reloadcmd() { $command --reload } smokeping_statuscmd() { if [ ! -e $pidfile ]; then echo "pidfile does not exist. $name is not running?"; exit 1; fi if pgrep -F $pidfile >/dev/null; then echo "$name is running."; else echo "$name is not running."; exit 1; fi } smokeping_stopcmd() { if pgrep -F $pidfile >/dev/null; then kill $sig_stop `cat $pidfile`; wait_for_pids `cat $pidfile`; kill $sig_stop `cat $fcgi_pidfile`; wait_for_pids `cat $fcgi_pidfile`; rm -rf $fcgi_pidfile; else echo "$name is not running."; exit 1; fi } smokeping_startprecmd() { if [ ! -e $smokeping_logfile ]; then install -o smokeping -g smokeping /dev/null $smokeping_logfile || echo "ERROR: Could not initialize logfile at $smokeping_logfile."; fi if [ ! -e $fcgi_pidfile ]; then $spawn_smokeping_fcgi; echo "starting smokeping fastcgi"; fi }