├── 1.jpg ├── 2.jpg ├── CentOS-Base.repo ├── Graphs.pm ├── README.md ├── config ├── epel-7.repo ├── nginx.conf ├── smokeping-2.6.11.tar.gz ├── smokeping-master.conf ├── smokeping.conf ├── smokeping.sh ├── spawnfcgi.ini └── tcpping /1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ILLKX/smokeping-onekey/8bfee6102c23bfd0726309650f7be98612854606/1.jpg -------------------------------------------------------------------------------- /2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ILLKX/smokeping-onekey/8bfee6102c23bfd0726309650f7be98612854606/2.jpg -------------------------------------------------------------------------------- /CentOS-Base.repo: -------------------------------------------------------------------------------- 1 | # CentOS-Base.repo 2 | # 3 | # The mirror system uses the connecting IP address of the client and the 4 | # update status of each mirror to pick mirrors that are updated to and 5 | # geographically close to the client. You should use this for CentOS updates 6 | # unless you are manually picking other mirrors. 7 | # 8 | # If the mirrorlist= does not work for you, as a fall back you can try the 9 | # remarked out baseurl= line instead. 10 | # 11 | # 12 | 13 | [base] 14 | name=CentOS-$releasever - Base - mirrors.aliyun.com 15 | failovermethod=priority 16 | baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ 17 | gpgcheck=1 18 | gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 19 | 20 | #released updates 21 | [updates] 22 | name=CentOS-$releasever - Updates - mirrors.aliyun.com 23 | failovermethod=priority 24 | baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ 25 | gpgcheck=1 26 | gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 27 | 28 | #additional packages that may be useful 29 | [extras] 30 | name=CentOS-$releasever - Extras - mirrors.aliyun.com 31 | failovermethod=priority 32 | baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ 33 | gpgcheck=1 34 | gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 35 | 36 | #additional packages that extend functionality of existing packages 37 | [centosplus] 38 | name=CentOS-$releasever - Plus - mirrors.aliyun.com 39 | failovermethod=priority 40 | baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ 41 | gpgcheck=1 42 | enabled=0 43 | gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 44 | 45 | #contrib - packages by Centos Users 46 | [contrib] 47 | name=CentOS-$releasever - Contrib - mirrors.aliyun.com 48 | failovermethod=priority 49 | baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ 50 | gpgcheck=1 51 | enabled=0 52 | gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 53 | -------------------------------------------------------------------------------- /Graphs.pm: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | package Smokeping::Graphs; 3 | use strict; 4 | use Smokeping; 5 | 6 | =head1 NAME 7 | 8 | Smokeping::Graphs - Functions used in Smokeping for creating graphs 9 | 10 | =head1 OVERVIEW 11 | 12 | This module currently only contains the code for generating the 'multi target' graphs. 13 | Code for the other graphs will be moved here too in time. 14 | 15 | =head2 IMPLEMENTATION 16 | 17 | =head3 get_multi_detail 18 | 19 | A version of get_detail for multi host graphs where there is data from 20 | multiple targets shown in one graph. The look of the graph is modeld after 21 | the graphs shown in the overview page, except for the size. 22 | 23 | =cut 24 | 25 | sub get_colors ($){ 26 | my $cfg = shift; 27 | 28 | if ($cfg->{Presentation}{graphborders} eq 'no') { 29 | return '--border', '0', 30 | '--color', 'BACK#ffffff00', 31 | '--color', 'CANVAS#ffffff00'; 32 | } 33 | 34 | # Use rrdtool defaults 35 | return; 36 | } 37 | 38 | sub get_multi_detail ($$$$;$){ 39 | # a) 's' classic with several static graphs on the page 40 | # b) 'n' navigator mode with one graph. below the graph one can specify the end time 41 | # and the length of the graph. 42 | # c) 'a' ajax mode, generate image based on given url and dump in on stdout 43 | # 44 | my $cfg = shift; 45 | my $q = shift; 46 | my $tree = shift; 47 | my $open = shift; 48 | my $mode = shift || $q->param('displaymode') || 's'; 49 | my $phys_open = $open; 50 | if ($tree->{__tree_link}){ 51 | $tree=$tree->{__tree_link}; 52 | $phys_open = $tree->{__real_path}; 53 | } 54 | 55 | my @dirs = @{$phys_open}; 56 | 57 | return "
ERROR: ".(join ".", @dirs)." has no probe defined
" 58 | unless $tree->{probe}; 59 | 60 | return "
ERROR: ".(join ".", @dirs)." $tree->{probe} is not known
" 61 | unless $cfg->{__probes}{$tree->{probe}}; 62 | 63 | return "
ERROR: ".(join ".", @dirs)." ist no multi host
" 64 | unless $tree->{host} =~ m|^/|; 65 | 66 | return "
ERROR: unknown displaymode $mode
" 67 | unless $mode =~ /^[snca]$/; 68 | 69 | my $dir = ""; 70 | 71 | for (@dirs) { 72 | $dir .= "/$_"; 73 | mkdir $cfg->{General}{imgcache}.$dir, 0755 74 | unless -d $cfg->{General}{imgcache}.$dir; 75 | die "ERROR: creating $cfg->{General}{imgcache}$dir: $!\n" 76 | unless -d $cfg->{General}{imgcache}.$dir; 77 | 78 | } 79 | 80 | my $page; 81 | my $file = pop @dirs; 82 | 83 | my @hosts = split /\s+/, $tree->{host}; 84 | 85 | 86 | 87 | my $ProbeDesc; 88 | my $ProbeUnit; 89 | 90 | 91 | my $imgbase; 92 | my $imghref; 93 | my @tasks; 94 | my %lastheight; 95 | my $max = {}; 96 | 97 | if ($mode eq 's'){ 98 | # in nav mode there is only one graph, so the height calculation 99 | # is not necessary. 100 | $imgbase = $cfg->{General}{imgcache}."/".(join "/", @dirs)."/${file}"; 101 | $imghref = $cfg->{General}{imgurl}."/".(join "/", @dirs)."/${file}"; 102 | @tasks = @{$cfg->{Presentation}{detail}{_table}}; 103 | if (open (HG,"<${imgbase}.maxheight")){ 104 | while (){ 105 | chomp; 106 | my @l = split / /; 107 | $lastheight{$l[0]} = $l[1]; 108 | } 109 | close HG; 110 | } 111 | for my $rrd (@hosts){ 112 | my $newmax = Smokeping::findmax($cfg, $cfg->{General}{datadir}.$rrd.".rrd"); 113 | map {$max->{$_} = $newmax->{$_} if not $max->{$_} or $newmax->{$_} > $max->{$_} } keys %{$newmax}; 114 | } 115 | if (open (HG,">${imgbase}.maxheight")){ 116 | foreach my $size (keys %{$max}){ 117 | print HG "$size $max->{$size}\n"; 118 | } 119 | close HG; 120 | } 121 | } 122 | elsif ($mode eq 'n' or $mode eq 'a') { 123 | 124 | if ($mode eq 'n') { 125 | $imgbase =$cfg->{General}{imgcache}."/__navcache/".time()."$$"; 126 | $imghref =$cfg->{General}{imgurl}."/__navcache/".time()."$$"; 127 | } else { 128 | my $serial = int(rand(2000)); 129 | $imgbase =$cfg->{General}{imgcache}."/__navcache/".$serial; 130 | $imghref =$cfg->{General}{imgurl}."/__navcache/".$serial; 131 | } 132 | mkdir $cfg->{General}{imgcache}."/__navcache",0755 unless -d $cfg->{General}{imgcache}."/__navcache"; 133 | # remove old images after one hour 134 | my $pattern = $cfg->{General}{imgcache}."/__navcache/*.png"; 135 | for (glob $pattern){ 136 | unlink $_ if time - (stat $_)[9] > 3600; 137 | } 138 | 139 | @tasks = (["Navigator Graph", Smokeping::parse_datetime($q->param('start')),Smokeping::parse_datetime($q->param('end'))]); 140 | } else { 141 | # chart mode 142 | mkdir $cfg->{General}{imgcache}."/__chartscache",0755 unless -d $cfg->{General}{imgcache}."/__chartscache"; 143 | # remove old images after one hour 144 | my $pattern = $cfg->{General}{imgcache}."/__chartscache/*.png"; 145 | for (glob $pattern){ 146 | unlink $_ if time - (stat $_)[9] > 3600; 147 | } 148 | my $desc = join "/",@{$open}; 149 | @tasks = ([$desc , time()-3600, time()]); 150 | $imgbase = $cfg->{General}{imgcache}."/__chartscache/".(join ".", @dirs).".${file}"; 151 | $imghref = $cfg->{General}{imgurl}."/__chartscache/".(join ".", @dirs).".${file}"; 152 | } 153 | if ($mode =~ /[anc]/){ 154 | my $val = 0; 155 | for my $host (@hosts){ 156 | my ($graphret,$xs,$ys) = RRDs::graph 157 | ("dummy", 158 | '--start', $tasks[0][1], 159 | '--end', $tasks[0][2], 160 | '--font', "TITLE:20:WenQuanYi Zen Hei Mono", 161 | "DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE", 162 | 'PRINT:maxping:MAX:%le' ); 163 | my $ERROR = RRDs::error(); 164 | return "
RRDtool did not understand your input: $ERROR.
" if $ERROR; 165 | $val = $graphret->[0] if $val < $graphret->[0]; 166 | } 167 | $val = 1e-6 if $val =~ /nan/i; 168 | $max = { $tasks[0][1] => $val * 1.5 }; 169 | } 170 | 171 | for (@tasks) { 172 | my ($desc,$start,$end) = @{$_}; 173 | my $xs; 174 | my $ys; 175 | my $sigtime = ($end and $end =~ /^\d+$/) ? $end : time; 176 | my $date = $cfg->{Presentation}{detail}{strftime} ? 177 | POSIX::strftime($cfg->{Presentation}{detail}{strftime}, localtime($sigtime)) : scalar localtime($sigtime); 178 | if ( $RRDs::VERSION >= 1.199908 ){ 179 | $date =~ s|:|\\:|g; 180 | } 181 | $end ||= 'last'; 182 | $start = Smokeping::exp2seconds($start) if $mode =~ /[s]/; 183 | 184 | my $startstr = $start =~ /^\d+$/ ? POSIX::strftime("%Y-%m-%d %H:%M",localtime($mode eq 'n' ? $start : time-$start)) : $start; 185 | my $endstr = $end =~ /^\d+$/ ? POSIX::strftime("%Y-%m-%d %H:%M",localtime($mode eq 'n' ? $end : time)) : $end; 186 | 187 | my $realstart = ( $mode =~ /[sc]/ ? '-'.$start : $start); 188 | 189 | my @G; 190 | my @colors = split /\s+/, $cfg->{Presentation}{multihost}{colors}; 191 | my $i = 0; 192 | for my $host (@hosts){ 193 | $i++; 194 | my $swidth = $max->{$start} / $cfg->{Presentation}{detail}{height}; 195 | my $rrd = $cfg->{General}{datadir}.$host.".rrd"; 196 | next unless -r $rrd; # skip things that do not exist; 197 | my $medc = shift @colors; 198 | my @tree_path = split /\//,$host; 199 | shift @tree_path; 200 | my ($host,$real_slave) = split /~/, $tree_path[-1]; #/ 201 | $tree_path[-1] = $host; 202 | my $tree = Smokeping::get_tree($cfg,\@tree_path); 203 | my $label = $tree->{menu}; 204 | if ($real_slave){ 205 | $label .= "<". $cfg->{Slaves}{$real_slave}{display_name}; 206 | } 207 | 208 | my $probe = $cfg->{__probes}{$tree->{probe}}; 209 | my $XProbeDesc = $probe->ProbeDesc(); 210 | if (not $ProbeDesc or $ProbeDesc eq $XProbeDesc){ 211 | $ProbeDesc = $XProbeDesc; 212 | } 213 | else { 214 | $ProbeDesc = "various probes"; 215 | } 216 | my $XProbeUnit = $probe->ProbeUnit(); 217 | if (not $ProbeUnit or $ProbeUnit eq $XProbeUnit){ 218 | $ProbeUnit = $XProbeUnit; 219 | } 220 | else { 221 | $ProbeUnit = "various units"; 222 | } 223 | 224 | my $pings = $probe->_pings($tree); 225 | 226 | $label = sprintf("%-20s",$label); 227 | $label =~ s/:/\\:/g; 228 | 229 | push @colors, $medc; 230 | my $sdc = $medc; 231 | my $stddev = Smokeping::RRDhelpers::get_stddev($rrd,'median','AVERAGE',$realstart,$sigtime) || 0; 232 | $sdc =~ s/^(......).*/${1}30/; 233 | push @G, 234 | "DEF:median$i=${rrd}:median:AVERAGE", 235 | "DEF:loss$i=${rrd}:loss:AVERAGE", 236 | "CDEF:ploss$i=loss$i,$pings,/,100,*", 237 | "CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT", 238 | Smokeping::calc_stddev($rrd,$i,$pings), 239 | "CDEF:dmlow$i=dm$i,sdev$i,2,/,-", 240 | "CDEF:s2d$i=sdev$i", 241 | # "CDEF:dm2=median,1.5,*,0,$max,LIMIT", 242 | # "LINE1:dm2", # this is for kicking things down a bit 243 | "AREA:dmlow$i", 244 | "AREA:s2d${i}#${sdc}::STACK", 245 | "LINE1:dm$i#${medc}:${label}", 246 | "VDEF:avmed$i=median$i,AVERAGE", 247 | "VDEF:avsd$i=sdev$i,AVERAGE", 248 | "CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/", 249 | "VDEF:avmsr$i=msr$i,AVERAGE", 250 | "GPRINT:avmed$i:%5.1lf %ss av md ", 251 | "GPRINT:ploss$i:AVERAGE:%5.1lf %% av ls", 252 | sprintf('COMMENT:%5.1lf ms sd',$stddev*1000.0), 253 | "GPRINT:avmsr$i:%5.1lf %s am/as\\l"; 254 | 255 | }; 256 | my @task; 257 | push @task, "--logarithmic" if $cfg->{Presentation}{detail}{logarithmic} and 258 | $cfg->{Presentation}{detail}{logarithmic} eq 'yes'; 259 | push @task, '--lazy' if $mode eq 's' and $lastheight{$start} == $max->{$start}; 260 | 261 | push @task, 262 | "${imgbase}_${end}_${start}.png", 263 | '--start',$realstart, 264 | ($end ne 'last' ? ('--end',$end) : ()), 265 | '--height',$cfg->{Presentation}{detail}{height}, 266 | '--width',$cfg->{Presentation}{detail}{width}, 267 | '--title',$cfg->{Presentation}{htmltitle} ne 'yes' ? $desc : '', 268 | '--rigid','--upper-limit', $max->{$start}, 269 | '--lower-limit',($cfg->{Presentation}{detail}{logarithmic} ? ($max->{$start} > 0.01) ? '0.001' : '0.0001' : '0'), 270 | '--vertical-label',$ProbeUnit, 271 | '--imgformat','PNG', 272 | Smokeping::Graphs::get_colors($cfg), 273 | @G, 274 | "COMMENT:$ProbeDesc", 275 | 'COMMENT:end\: '.$date.'\j'; 276 | 277 | my $graphret; 278 | ($graphret,$xs,$ys) = RRDs::graph @task; 279 | # print "
INFO:".join("
",@task)."
"; 280 | my $ERROR = RRDs::error(); 281 | if ($ERROR) { 282 | return "
ERROR: $ERROR
".join("
",@task)."
"; 283 | }; 284 | 285 | 286 | if ($mode eq 'a'){ # ajax mode 287 | open my $img, "${imgbase}_${end}_${start}.png"; 288 | binmode $img; 289 | print "Content-Type: image/png\n"; 290 | my $data; 291 | read($img,$data,(stat($img))[7]); 292 | close $img; 293 | print "Content-Length: ".length($data)."\n\n"; 294 | print $data; 295 | unlink "${imgbase}_${end}_${start}.png"; 296 | return undef; 297 | } 298 | 299 | elsif ($mode eq 'n'){ # navigator mode 300 | $page .= "
"; 301 | $page .= "

$desc

" 302 | if $cfg->{Presentation}{htmltitle} eq 'yes'; 303 | $page .= "
"; 304 | 305 | $page .= qq|| ; 306 | 307 | $page .= $q->start_form(-method=>'GET', -id=>'range_form') 308 | . "

Time range: " 309 | . $q->textfield(-name=>'start',-default=>$startstr) 310 | . "  to  ".$q->textfield(-name=>'end',-default=>$endstr) 311 | . $q->hidden(-name=>'epoch_start',-id=>'epoch_start',-default=>$start) 312 | . $q->hidden(-name=>'epoch_end',-id=>'epoch_end',-default=>time()) 313 | . $q->hidden(-name=>'target',-id=>'target' ) 314 | . $q->hidden(-name=>'hierarchy',-id=>'hierarchy' ) 315 | . $q->hidden(-name=>'displaymode',-default=>$mode ) 316 | . " " 317 | . $q->submit(-name=>'Generate!') 318 | . "

" 319 | . $q->end_form(); 320 | 321 | $page .= "
\n"; 322 | } elsif ($mode eq 's') { # classic mode 323 | $startstr =~ s/\s/%20/g; 324 | $endstr =~ s/\s/%20/g; 325 | $page .= "
"; 326 | # $page .= (time-$timer_start)."
"; 327 | # $page .= join " ",map {"'$_'"} @task; 328 | $page .= "

$desc

" 329 | if $cfg->{Presentation}{htmltitle} eq 'yes'; 330 | $page .= "
"; 331 | $page .= ( qq{' 332 | . qq{}."" ); #" 333 | $page .= "
\n"; 334 | } else { # chart mode 335 | $page .= "
"; 336 | $page .= "

$desc

" 337 | if $cfg->{Presentation}{htmltitle} eq 'yes'; 338 | $page .= "
"; 339 | $page .= ( qq{} 340 | . qq{}."" ); #" 341 | $page .= "
\n"; 342 | } 343 | 344 | } 345 | return $page; 346 | } 347 | 348 | 349 | 1; 350 | 351 | __END__ 352 | 353 | =head1 COPYRIGHT 354 | 355 | Copyright 2007 by Tobias Oetiker 356 | 357 | =head1 LICENSE 358 | 359 | This program is free software; you can redistribute it 360 | and/or modify it under the terms of the GNU General Public 361 | License as published by the Free Software Foundation; either 362 | version 2 of the License, or (at your option) any later 363 | version. 364 | 365 | This program is distributed in the hope that it will be 366 | useful, but WITHOUT ANY WARRANTY; without even the implied 367 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 368 | PURPOSE. See the GNU General Public License for more 369 | details. 370 | 371 | You should have received a copy of the GNU General Public 372 | License along with this program; if not, write to the Free 373 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 374 | 02139, USA. 375 | 376 | =head1 AUTHOR 377 | 378 | Tobias Oetiker Etobi@oetiker.chE 379 | 380 | =cut 381 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SmokePing一键管理脚本 # 2 | 3 | **此脚本会污染建站环境,请在Docker或干净的机器内使用** 4 | 5 | ## 介绍 ## 6 | 一个Shell脚本,集成SmokePing三种版本(Master/Slaves/单机版)安装、启动、停止、重启等基本操作,方便用户操作。 7 | 8 | [https://www.sabia.cc/smokeping-onekey.html](https://www.sabia.cc/smokeping-onekey.html) 9 | 10 | ## 系统支持 ## 11 | * CentOS 7 12 | 13 | ## 功能 ## 14 | - 一键启动、停止、重启SmokePing服务 15 | - 一键安装、卸载SmokePing三种版本 16 | - 一键安装Tcpping (Smokeping专用版本) 17 | - 安装supervisor以守护fcgi进程 18 | - 自动更换至GMT+8时区并对时 19 | - 自动更换阿里云源(可选) 20 | - 支持中文显示 21 | - 覆盖安装提醒 22 | 23 | ## 缺点 ## 24 | - 仅适配CentOS7系统 25 | - 未设置开机启动 26 | - Master端/单机版会自动安装Nginx并修改Nginx默认配置 27 | 28 | ## 注意事项 ## 29 | - 请尽量确保服务器环境干净,最好重新安装系统后使用此脚本 30 | - 本脚本只为方便用户安装/管理SmokePing,请用户自行配置SmokePing 31 | - 每次修改SmokePing配置文件后请重启SmokePing 32 | - 此脚本安装的Tcppinng仅适用于SmokePing 33 | 34 | ## 安装/卸载 ## 35 | wget -N --no-check-certificate https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/smokeping.sh && bash smokeping.sh 36 | 37 | ## 截图 ## 38 | ![https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/1.jpg](1.jpg) 39 | 40 | ![https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/2.jpg](2.jpg) 41 | 42 | ## 程序安装目录 ## 43 | - Nginx配置:/etc/nginx/ /etc/nginx/conf/ 44 | - smokeping安装目录:/opt/smokeping/ 45 | - smokeping配置文件:/opt/smokeping/etc/config 46 | - fcgi文件:/opt/smokeping/htdocs/smokeping.fcgi 47 | 48 | spawn-fcgi、Nginx、supervisor采用yum安装 49 | 50 | ## 参考资料 ## 51 | [CentOS7详细安装配置SmokePing教程-来自lala.im](https://lala.im/2821.html) 52 | 53 | [SmokePing主从服务器详细配置教程-来自lala.im](https://lala.im/2867.html) 54 | 55 | [参考逗比的mt-proxy安装脚本部分代码](https://github.com/ToyoDAdoubi/doubi) 56 | 57 | [Tcpping-SmokePing](https://github.com/tobbez/tcpping-smokeping) 58 | -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | *** General *** 2 | 3 | owner = Peter Random 4 | contact = some@address.nowhere 5 | mailhost = my.mail.host 6 | sendmail = /usr/sbin/sendmail 7 | # NOTE: do not put the Image Cache below cgi-bin 8 | # since all files under cgi-bin will be executed ... this is not 9 | # good for images. 10 | imgcache = /opt/smokeping/htdocs/cache 11 | imgurl = cache 12 | datadir = /opt/smokeping/htdocs/data 13 | piddir = /opt/smokeping/htdocs/var 14 | cgiurl = http://some.url/smokeping.cgi 15 | smokemail = /opt/smokeping/etc/smokemail.dist 16 | tmail = /opt/smokeping/etc/tmail.dist 17 | # specify this to get syslog logging 18 | syslogfacility = local0 19 | # each probe is now run in its own process 20 | # disable this to revert to the old behaviour 21 | # concurrentprobes = no 22 | 23 | *** Alerts *** 24 | to = alertee@address.somewhere 25 | from = smokealert@company.xy 26 | 27 | +someloss 28 | type = loss 29 | # in percent 30 | pattern = >0%,*12*,>0%,*12*,>0% 31 | comment = loss 3 times in a row 32 | 33 | *** Database *** 34 | 35 | step = 300 36 | pings = 20 37 | 38 | # consfn mrhb steps total 39 | 40 | AVERAGE 0.5 1 1008 41 | AVERAGE 0.5 12 4320 42 | MIN 0.5 12 4320 43 | MAX 0.5 12 4320 44 | AVERAGE 0.5 144 720 45 | MAX 0.5 144 720 46 | MIN 0.5 144 720 47 | 48 | *** Presentation *** 49 | 50 | charset = utf-8 51 | 52 | template = /opt/smokeping/etc/basepage.html.dist 53 | 54 | + charts 55 | 56 | menu = Charts 57 | title = The most interesting destinations 58 | 59 | ++ stddev 60 | sorter = StdDev(entries=>4) 61 | title = Top Standard Deviation 62 | menu = Std Deviation 63 | format = Standard Deviation %f 64 | 65 | ++ max 66 | sorter = Max(entries=>5) 67 | title = Top Max Roundtrip Time 68 | menu = by Max 69 | format = Max Roundtrip Time %f seconds 70 | 71 | ++ loss 72 | sorter = Loss(entries=>5) 73 | title = Top Packet Loss 74 | menu = Loss 75 | format = Packets Lost %f 76 | 77 | ++ median 78 | sorter = Median(entries=>5) 79 | title = Top Median Roundtrip Time 80 | menu = by Median 81 | format = Median RTT %f seconds 82 | 83 | + overview 84 | 85 | width = 600 86 | height = 50 87 | range = 10h 88 | 89 | + detail 90 | 91 | width = 600 92 | height = 200 93 | unison_tolerance = 2 94 | 95 | "Last 3 Hours" 3h 96 | "Last 30 Hours" 30h 97 | "Last 10 Days" 10d 98 | "Last 400 Days" 400d 99 | 100 | #+ hierarchies 101 | #++ owner 102 | #title = Host Owner 103 | #++ location 104 | #title = Location 105 | 106 | *** Probes *** 107 | 108 | + FPing 109 | 110 | binary = /usr/sbin/fping 111 | 112 | *** Slaves *** 113 | secrets=/opt/smokeping/etc/smokeping_secrets.dist 114 | +boomer 115 | display_name=boomer 116 | color=0000ff 117 | 118 | +slave2 119 | display_name=another 120 | color=00ff00 121 | 122 | *** Targets *** 123 | 124 | probe = FPing 125 | 126 | menu = Top 127 | title = Network Latency Grapher 128 | remark = Welcome to the SmokePing website of xxx Company. \ 129 | Here you will learn all about the latency of our network. 130 | 131 | + Test 132 | menu= Targets 133 | #parents = owner:/Test/James location:/ 134 | 135 | ++ James 136 | 137 | menu = James 138 | title = James 139 | alerts = someloss 140 | slaves = boomer slave2 141 | host = james.address 142 | 143 | ++ MultiHost 144 | 145 | menu = Multihost 146 | title = James and James as seen from Boomer 147 | host = /Test/James /Test/James~boomer 148 | -------------------------------------------------------------------------------- /epel-7.repo: -------------------------------------------------------------------------------- 1 | [epel] 2 | name=Extra Packages for Enterprise Linux 7 - $basearch 3 | baseurl=http://mirrors.aliyun.com/epel/7/$basearch 4 | failovermethod=priority 5 | enabled=1 6 | gpgcheck=0 7 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 8 | 9 | [epel-debuginfo] 10 | name=Extra Packages for Enterprise Linux 7 - $basearch - Debug 11 | baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug 12 | failovermethod=priority 13 | enabled=0 14 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 15 | gpgcheck=0 16 | 17 | [epel-source] 18 | name=Extra Packages for Enterprise Linux 7 - $basearch - Source 19 | baseurl=http://mirrors.aliyun.com/epel/7/SRPMS 20 | failovermethod=priority 21 | enabled=0 22 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 23 | gpgcheck=0 24 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | error_log /var/log/nginx/error.log warn; 5 | pid /var/run/nginx.pid; 6 | 7 | 8 | events { 9 | worker_connections 1024; 10 | } 11 | 12 | 13 | http { 14 | include /etc/nginx/mime.types; 15 | default_type application/octet-stream; 16 | 17 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 18 | '$status $body_bytes_sent "$http_referer" ' 19 | '"$http_user_agent" "$http_x_forwarded_for"'; 20 | 21 | access_log /var/log/nginx/access.log main; 22 | 23 | sendfile on; 24 | #tcp_nopush on; 25 | 26 | keepalive_timeout 65; 27 | 28 | #gzip on; 29 | 30 | include /etc/nginx/conf.d/*.conf; 31 | } 32 | -------------------------------------------------------------------------------- /smokeping-2.6.11.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ILLKX/smokeping-onekey/8bfee6102c23bfd0726309650f7be98612854606/smokeping-2.6.11.tar.gz -------------------------------------------------------------------------------- /smokeping-master.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | location / { 5 | root /opt/smokeping/htdocs/; 6 | index index.html index.htm smokeping.fcgi; 7 | } 8 | location ~ .*\.fcgi$ { 9 | root /opt/smokeping/htdocs/; 10 | fastcgi_pass 127.0.0.1:9007; 11 | fastcgi_intercept_errors on; 12 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 13 | include /etc/nginx/fastcgi_params; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /smokeping.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | location / { 5 | root /opt/smokeping/htdocs/; 6 | index index.html index.htm smokeping.fcgi; 7 | } 8 | location ~ .*\.fcgi$ { 9 | root /opt/smokeping/htdocs/; 10 | fastcgi_pass 127.0.0.1:9007; 11 | fastcgi_intercept_errors on; 12 | include /etc/nginx/fastcgi_params; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /smokeping.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | #定义终端输出颜色 6 | Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m" 7 | Info="${Green_font_prefix}[信息]${Font_color_suffix}" 8 | Error="${Red_font_prefix}[错误]${Font_color_suffix}" 9 | Tip="${Green_font_prefix}[注意]${Font_color_suffix}" 10 | 11 | #定义文件路径 12 | smokeping_ver="/opt/smokeping/onekeymanage/ver" 13 | smokeping_key="/opt/smokeping/onekeymanage/key" 14 | smokeping_name="/opt/smokeping/onekeymanage/name" 15 | smokeping_host="/opt/smokeping/onekeymanage/host" 16 | tcpping="/usr/bin/tcpping" 17 | 18 | #Check Root 19 | [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } 20 | 21 | #获取进程PID 22 | Get_PID(){ 23 | PID=(`ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|awk '{print $2}'|xargs`) 24 | } 25 | 26 | #更换安装包源 27 | Change_Source(){ 28 | yum clean all 29 | wget -O /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/CentOS-Base.repo 30 | wget -O /etc/yum.repos.d/epel.repo https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/epel-7.repo 31 | } 32 | 33 | #安装elep 34 | Install_Epel(){ 35 | yum install epel-release -y 36 | } 37 | 38 | #安装依赖 39 | Install_Dependency(){ 40 | yum install rrdtool perl-rrdtool perl-core openssl-devel fping curl gcc-c++ make wqy-zenhei-fonts.noarch supervisor curl -y 41 | } 42 | 43 | #下载smokeping 44 | Download_Source(){ 45 | cd 46 | wget https://github.com/ILLKX/smokeping-onekey/raw/master/smokeping-2.6.11.tar.gz 47 | tar -xzvf smokeping-2.6.11.tar.gz 48 | cd smokeping-2.6.11 49 | } 50 | 51 | #安装smokeping 52 | Install_SomkePing(){ 53 | ./setup/build-perl-modules.sh /opt/smokeping/thirdparty 54 | ./configure --prefix=/opt/smokeping 55 | make install 56 | } 57 | 58 | #清除文件 59 | Delete_Files(){ 60 | rm -rf /root/smokeping-2.6.* 61 | } 62 | 63 | #配置smokeping 64 | Configure_SomkePing(){ 65 | cd /opt/smokeping/htdocs 66 | mkdir var cache data 67 | mv smokeping.fcgi.dist smokeping.fcgi 68 | cd /opt/smokeping/etc 69 | rm -rf config* 70 | wget -O config https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/config 71 | wget -O /opt/smokeping/lib/Smokeping/Graphs.pm https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/Graphs.pm 72 | chmod 600 /opt/smokeping/etc/smokeping_secrets.dist 73 | } 74 | 75 | #配置config Master 76 | Master_Configure_SomkePing(){ 77 | cd /opt/smokeping/etc 78 | sed -i "s/some.url/$server_name/g" config 79 | } 80 | 81 | #安装Nginx及其他软件 82 | Install_Nginx(){ 83 | yum install nginx spawn-fcgi -y 84 | } 85 | 86 | #修改Nginx配置文件 87 | Configure_Nginx(){ 88 | wget -O /etc/nginx/conf.d/smokeping.conf https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/smokeping.conf 89 | rm -rf /etc/nginx/nginx.conf 90 | wget -O /etc/nginx/nginx.conf https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/nginx.conf 91 | } 92 | 93 | #修改Nginx配置文件 Master 94 | Master_Configure_Nginx(){ 95 | wget -O /etc/nginx/conf.d/smokeping.conf https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/smokeping-master.conf 96 | sed -i "s/local/$server_name/g" /etc/nginx/conf.d/smokeping.conf 97 | rm -rf /etc/nginx/nginx.conf 98 | wget -O /etc/nginx/nginx.conf https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/nginx.conf 99 | } 100 | 101 | #启动Nginx并禁用防火墙 102 | Start_Nginx_Disable_Firewall(){ 103 | systemctl start nginx 104 | systemctl stop firewalld 105 | systemctl disable firewalld 106 | } 107 | 108 | #禁用SELinux 109 | Disable_SELinux(){ 110 | setenforce 0 111 | sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config 112 | sed -i "s/SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/config 113 | } 114 | 115 | #修改smokeping权限 116 | Change_Access(){ 117 | chown -R nginx:nginx /opt/smokeping/htdocs 118 | chown -R nginx:nginx /opt/smokeping/etc/smokeping_secrets.dist 119 | } 120 | 121 | #设置Slaves密钥 122 | Slaves_Set_Secret(){ 123 | rm -rf /opt/smokeping/etc/smokeping_secrets.dist 124 | echo -e "${slaves_secret}" > /opt/smokeping/etc/smokeping_secrets.dist 125 | } 126 | 127 | #配置supervisor 128 | Configure_Supervisor(){ 129 | wget -O /etc/supervisord.d/spawnfcgi.ini https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/spawnfcgi.ini 130 | supervisord -c /etc/supervisord.conf 131 | systemctl enable supervisord.service 132 | supervisorctl stop spawnfcgi 133 | } 134 | 135 | #同步时间 136 | Time_Synchronization(){ 137 | \cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 2>/dev/null 138 | date -s "$(curl -sk --head https://dash.cloudflare.com | grep ^Date: | sed 's/Date: //g')" 139 | } 140 | 141 | #启动Single服务 142 | Single_Run_SmokePing(){ 143 | cd /opt/smokeping/bin 144 | ./smokeping --config=/opt/smokeping/etc/config --logfile=smoke.log 145 | supervisorctl reload 146 | Change_Access 147 | } 148 | 149 | #启动Master服务 150 | Master_Run_SmokePing(){ 151 | cd /opt/smokeping/bin 152 | ./smokeping --config=/opt/smokeping/etc/config --logfile=smoke.log 153 | supervisorctl reload 154 | Change_Access 155 | } 156 | 157 | #启动Slaves服务 158 | Slaves_Run_SmokePing(){ 159 | cd /opt/smokeping/bin 160 | ./smokeping --master-url=http://$server_name/smokeping.fcgi --cache-dir=/opt/smokeping/htdocs/cache --shared-secret=/opt/smokeping/etc/smokeping_secrets.dist --slave-name=$slaves_name --logfile=/opt/smokeping/slave.log 161 | } 162 | 163 | Single_Install(){ 164 | echo 165 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 166 | rm -rf /opt/smokeping 167 | Ask_Change_Source 168 | Install_Dependency 169 | Download_Source 170 | Install_SomkePing 171 | Configure_SomkePing 172 | Install_Nginx 173 | Configure_Nginx 174 | Start_Nginx_Disable_Firewall 175 | Change_Access 176 | Disable_SELinux 177 | Configure_Supervisor 178 | Time_Synchronization 179 | Delete_Files 180 | mkdir /opt/smokeping/onekeymanage 181 | echo "Single" > ${smokeping_ver} 182 | echo -e "${Info} 安装 SmokePing 单机版完成" 183 | } 184 | 185 | Slaves_Install(){ 186 | echo 187 | read -p "请输入Master地址 : " server_name 188 | read -p "请输入Slaves名称 : " slaves_name 189 | read -p "请输入Slaves密钥 : " slaves_secret 190 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 191 | rm -rf /opt/smokeping 192 | Ask_Change_Source 193 | Install_Dependency 194 | Download_Source 195 | Install_SomkePing 196 | Slaves_Set_Secret 197 | Configure_SomkePing 198 | Disable_SELinux 199 | Time_Synchronization 200 | Delete_Files 201 | mkdir /opt/smokeping/onekeymanage 202 | echo "Slaves" > ${smokeping_ver} 203 | echo -e "${slaves_secret}" > ${smokeping_key} 204 | echo -e "${slaves_name}" > ${smokeping_name} 205 | echo -e "${server_name}" > ${smokeping_host} 206 | echo -e "${Info} 安装 SmokePing Slaves端完成" 207 | } 208 | 209 | Master_Install(){ 210 | echo 211 | read -p "请输入Master地址 : " server_name 212 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 213 | rm -rf /opt/smokeping 214 | Ask_Change_Source 215 | Install_Dependency 216 | Download_Source 217 | Install_SomkePing 218 | Configure_SomkePing 219 | Master_Configure_SomkePing 220 | Install_Nginx 221 | Master_Configure_Nginx 222 | Start_Nginx_Disable_Firewall 223 | Change_Access 224 | Disable_SELinux 225 | Configure_Supervisor 226 | Time_Synchronization 227 | Delete_Files 228 | mkdir /opt/smokeping/onekeymanage 229 | echo "Master" > ${smokeping_ver} 230 | echo -e "${Info} 安装 SmokePing Master端完成" 231 | } 232 | 233 | #询问是否换源 234 | Ask_Change_Source(){ 235 | while :; do echo 236 | echo -e "${Tip} 是否将系统源更换成阿里云源 (国内外均可用) [y/n]: " 237 | read ifchangesource 238 | if [[ ! $ifchangesource =~ ^[y,n]$ ]]; then 239 | echo "输入错误! 请输入y或者n!" 240 | else 241 | break 242 | fi 243 | done 244 | if [[ $ifchangesource == y ]]; then 245 | Change_Source 246 | else 247 | Install_Epel 248 | fi 249 | yum install wget -y 250 | } 251 | 252 | Install_Tcpping(){ 253 | cd 254 | yum install tcptraceroute -y 255 | rm -rf /usr/bin/tcpping 256 | wget https://raw.githubusercontent.com/ILLKX/smokeping-onekey/master/tcpping 257 | chmod 777 tcpping 258 | mv tcpping /usr/bin/ 259 | echo -e "${Info} 安装 tcpping 完成" 260 | } 261 | 262 | #卸载SmokePing 263 | Uninstall(){ 264 | while :; do echo 265 | echo -e "${Tip} 已经安装${Green_font_prefix} $mode2 ${Font_color_suffix},是否卸载 [y/n]: " 266 | read um 267 | if [[ ! $um =~ ^[y,n]$ ]]; then 268 | echo "输入错误! 请输入y或者n!" 269 | else 270 | break 271 | fi 272 | done 273 | if [[ $um == "y" ]]; then 274 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 275 | rm -rf /opt/smokeping 276 | rm -rf /usr/bin/tcpping 277 | rm -rf /etc/supervisord.d/spawnfcgi.ini 278 | supervisorctl reload 279 | echo 280 | echo -e "${Info} SmokePing 卸载完成!" 281 | echo 282 | else 283 | echo 284 | echo -e "${Info} 卸载已取消!" 285 | echo 286 | exit 287 | fi 288 | } 289 | 290 | clear 291 | 292 | echo && echo -e " SmokePing 一键管理脚本 293 | 294 | ${Green_font_prefix} 1.${Font_color_suffix} 安装 SmokePing Master端 295 | ${Green_font_prefix} 2.${Font_color_suffix} 安装 SmokePing Slaves端 296 | ${Green_font_prefix} 3.${Font_color_suffix} 安装 SmokePing 单机版 297 | ${Green_font_prefix} 4.${Font_color_suffix} 卸载 SmokePing 298 | ———————————— 299 | ${Green_font_prefix} 5.${Font_color_suffix} 启动 SmokePing 300 | ${Green_font_prefix} 6.${Font_color_suffix} 停止 SmokePing 301 | ${Green_font_prefix} 7.${Font_color_suffix} 重启 SmokePing 302 | ———————————— 303 | ${Green_font_prefix} 8.${Font_color_suffix} 安装 Tcpping 304 | ———————————— 305 | ${Green_font_prefix} 9.${Font_color_suffix} 退出 306 | ————————————" && echo 307 | if [[ -e ${smokeping_ver} ]]; then 308 | Get_PID 309 | if [[ `grep "Slaves" ${smokeping_ver}` ]]; then 310 | mode="Slaves" 311 | mode2="Slaves端" 312 | slaves_secret=(`cat ${smokeping_key}`) 313 | slaves_name=(`cat ${smokeping_name}`) 314 | server_name=(`cat ${smokeping_host}`) 315 | fi 316 | if [[ `grep "Master" ${smokeping_ver}` ]]; then 317 | mode="Master" 318 | mode2="Master端" 319 | fi 320 | if [[ `grep "Single" ${smokeping_ver}` ]]; then 321 | mode="Single" 322 | mode2="单机版" 323 | fi 324 | if [[ ! -z "${PID}" ]]; then 325 | echo -e "当前状态: ${Green_font_prefix}已安装 $mode2 ${Font_color_suffix}并 ${Green_font_prefix}已启动${Font_color_suffix}" 326 | else 327 | echo -e "当前状态: ${Green_font_prefix}已安装 $mode2 ${Font_color_suffix}但 ${Red_font_prefix}未启动${Font_color_suffix}" 328 | fi 329 | else 330 | echo -e "当前状态: ${Red_font_prefix}未安装${Font_color_suffix}" 331 | fi 332 | echo 333 | if [[ ! -e ${tcpping} ]]; then 334 | echo -e "Tcpping状态: ${Red_font_prefix}未安装${Font_color_suffix}" 335 | else 336 | echo -e "Tcpping状态: ${Green_font_prefix}已安装${Font_color_suffix}" 337 | fi 338 | echo 339 | read -p "请输入数字 [1-9]:" num 340 | 341 | case "$num" in 342 | 343 | 1) 344 | if [[ -e ${smokeping_ver} ]]; then 345 | while :; do echo 346 | echo -e "${Tip} 已经安装${Green_font_prefix} $mode2 ${Font_color_suffix},是否重新安装 [y/n]: " 347 | read um 348 | if [[ ! $um =~ ^[y,n]$ ]]; then 349 | echo "输入错误! 请输入y或者n!" 350 | else 351 | break 352 | fi 353 | done 354 | if [[ $um == "y" ]]; then 355 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 356 | rm -rf /opt/smokeping 357 | rm -rf /usr/bin/tcpping 358 | supervisorctl stop spawnfcgi 359 | echo 360 | echo -e "${Info} Smokeping ${mode2} 卸载完成! 开始安装 Master端!" 361 | echo 362 | sleep 5 363 | Master_Install 364 | exit 365 | else 366 | exit 367 | fi 368 | fi 369 | Master_Install 370 | ;; 371 | 2) 372 | if [[ -e ${smokeping_ver} ]]; then 373 | while :; do echo 374 | echo -e "${Tip} 已经安装${Green_font_prefix} $mode2 ${Font_color_suffix},是否重新安装 [y/n]: " 375 | read um 376 | if [[ ! $um =~ ^[y,n]$ ]]; then 377 | echo "输入错误! 请输入y或者n!" 378 | else 379 | break 380 | fi 381 | done 382 | if [[ $um == "y" ]]; then 383 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 384 | rm -rf /opt/smokeping 385 | rm -rf /usr/bin/tcpping 386 | supervisorctl stop spawnfcgi 387 | echo 388 | echo -e "${Info} Smokeping ${mode2} 卸载完成! 开始安装 Slaves端!" 389 | echo 390 | sleep 5 391 | Slaves_Install 392 | exit 393 | else 394 | exit 395 | fi 396 | fi 397 | Slaves_Install 398 | ;; 399 | 3) 400 | if [[ -e ${smokeping_ver} ]]; then 401 | while :; do echo 402 | echo -e "${Tip} 已经安装${Green_font_prefix} $mode2 ${Font_color_suffix},是否重新安装 [y/n]: " 403 | read um 404 | if [[ ! $um =~ ^[y,n]$ ]]; then 405 | echo "输入错误! 请输入y或者n!" 406 | else 407 | break 408 | fi 409 | done 410 | if [[ $um == "y" ]]; then 411 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 412 | rm -rf /opt/smokeping 413 | rm -rf /usr/bin/tcpping 414 | supervisorctl stop spawnfcgi 415 | echo 416 | echo -e "${Info} Smokeping ${mode2} 卸载完成! 开始安装 单机版!" 417 | echo 418 | sleep 5 419 | Single_Install 420 | exit 421 | else 422 | exit 423 | fi 424 | fi 425 | Single_Install 426 | ;; 427 | 428 | 4) 429 | [[ ! -e ${smokeping_ver} ]] && echo -e "${Error} Smokeping 没有安装,请检查!" && exit 1 430 | Uninstall 431 | ;; 432 | 433 | 5) 434 | [[ ! -e ${smokeping_ver} ]] && echo -e "${Error} Smokeping 没有安装,请检查!" && exit 1 435 | ${mode}_Run_SmokePing 436 | ;; 437 | 438 | 6) 439 | [[ ! -e ${smokeping_ver} ]] && echo -e "${Error} Smokeping 没有安装,请检查!" && exit 1 440 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 441 | supervisorctl stop spawnfcgi 442 | ;; 443 | 444 | 7) 445 | [[ ! -e ${smokeping_ver} ]] && echo -e "${Error} Smokeping 没有安装,请检查!" && exit 1 446 | kill -9 `ps -ef |grep "smokeping"|grep -v "grep"|grep -v "smokeping.sh"|grep -v "perl"|awk '{print $2}'|xargs` 2>/dev/null 447 | ${mode}_Run_SmokePing 448 | ;; 449 | 450 | 8) 451 | if [[ -e ${tcpping} ]]; then 452 | while :; do echo 453 | echo -e "${Tip} 已经安装${Green_font_prefix} tcpping ${Font_color_suffix},是否重新安装 [y/n]: " 454 | read um 455 | if [[ ! $um =~ ^[y,n]$ ]]; then 456 | echo "输入错误! 请输入y或者n!" 457 | else 458 | break 459 | fi 460 | done 461 | if [[ $um == "y" ]]; then 462 | rm -rf /usr/bin/tcpping 463 | echo 464 | echo -e "${Info} tcpping 卸载完成! 开始安装 Tcpping!" 465 | echo 466 | sleep 5 467 | Install_Tcpping 468 | exit 469 | else 470 | exit 471 | fi 472 | fi 473 | Install_Tcpping 474 | ;; 475 | 476 | 9) 477 | exit 478 | ;; 479 | 480 | *) 481 | echo "输入错误! 请输入正确的数字! [1-9]" 482 | ;; 483 | 484 | esac 485 | -------------------------------------------------------------------------------- /spawnfcgi.ini: -------------------------------------------------------------------------------- 1 | [program:spawnfcgi] 2 | command = spawn-fcgi -a 127.0.0.1 -p 9007 -P /var/run/smokeping-fastcgi.pid -n -u nginx -g nginx -f /opt/smokeping/htdocs/smokeping.fcgi 3 | autostart = true 4 | autorestart = true 5 | user = root 6 | -------------------------------------------------------------------------------- /tcpping: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # Copyright (c) 2016, Torbjörn Lönnemark 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software for any 6 | # purpose with or without fee is hereby granted, provided that the above 7 | # copyright notice and this permission notice appear in all copies. 8 | # 9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | 17 | if [ $# != 5 -a $# != 4 ] 18 | then 19 | echo "Wrong number of arguments" 20 | exit 21 | fi 22 | 23 | output="$4 :" 24 | for i in $(seq $3) 25 | do 26 | portflag="" 27 | if [ $# = 5 ] 28 | then 29 | portflag="-p $5" 30 | fi 31 | tr=$(traceroute -n -T -f 255 -m 255 -q 1 -w 3 $portflag $4 2>&1| tail -n1 | sed 's/ / /g') 32 | if ! echo "$tr" | grep 'ms$' > /dev/null 33 | then 34 | output="$output -" 35 | else 36 | ms=$(echo "$tr" | cut -d" " -f3) 37 | output="$output $ms" 38 | fi 39 | done 40 | echo $output 41 | --------------------------------------------------------------------------------