forked from daily-scripts/shell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_smokeping.sh
1233 lines (797 loc) · 18.3 KB
/
install_smokeping.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#############
#Date 2016/11/11
#mail [email protected]
#############
echo "##########################################"
echo "Auto Install smokeping-2.6.11 ##"
echo "Press Ctrl + C to cancel ##"
echo "Any key to continue ##"
echo "##########################################"
read -n 1
/etc/init.d/iptables status >/dev/null 2>&1
if [ $? -eq 0 ]
then
iptables -I INPUT -p tcp --dport 80 -j ACCEPT &&
iptables-save >/dev/null 2>&1
else
echo -e "\033[32m iptables is stopd\033[0m"
fi
IP=`/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/1p'|sed -n '1p'`
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 1>/dev/null
yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl gcc libart_lgpl-devel mod_fastcgi wget wqy-*
if [ -d /opt ];then
cd /opt
else
mkdir -p /opt && cd /opt
fi
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
tar -xvf smokeping-2.6.11.tar.gz 1>/dev/null
cd /opt/smokeping-2.6.11
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure -prefix=/usr/local/smokeping
/usr/bin/gmake install 1>/dev/null
cd /usr/local/smokeping
mkdir cache data var 1>/dev/null
touch /var/log/smokeping.log
chown -R apache:apache cache data var
chown -R apache:apache /var/log/smokeping.log
mv /usr/local/smokeping/htdocs/smokeping.fcgi.dist /usr/local/smokeping/htdocs/smokeping.fcgi
mv /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config
cp -f /usr/local/smokeping/etc/config /usr/local/smokeping/etc/config.back
sed -i "s/some.url/IP/g" /usr/local/smokeping/etc/config
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
if [ -d /opt ];then
cd /opt
else
mkdir -p /opt && cd /opt
fi
wget -c -O /opt/fping-3.13.tar.gz http://fping.org/dist/fping-3.13.tar.gz
tar zxvf fping-3.13.tar.gz
cd fping-3.13
./configure --prefix=/usr/local/fping
make && make install
sed -i "s#`grep fping /usr/local/smokeping/etc/config`#binary = /usr/local/fping/sbin/fping#g" /usr/local/smokeping/etc/config
sed -i "148i'--font TITLE:20:"WenQuanYi\ Zen\ Hei\ Mono"'\," /usr/local/smokeping/lib/Smokeping/Graphs.pm
cp -rf /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.back
cat >> /etc/httpd/conf/httpd.conf <<'EOF'
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
</Directory>
EOF
if [ -f /etc/init.d/smokeping ];then
echo "/etc/init.d/smokeping is exist"
else
touch /etc/init.d/smokeping
cat > /etc/init.d/smokeping <<'EOF'
#!/bin/bash
#chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Create by : Mox
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
smokeping=/usr/local/smokeping/bin/smokeping
prog=smokeping
pidfile=${PIDFILE-/usr/local/smokeping/var/smokeping.pid}
lockfile=${LOCKFILE-/var/lock/subsys/smokeping}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
LOG=/var/log/smokeping.log
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $smokeping $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# Restart the service Smokeping
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $smokeping
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
STOP_TIMEOUT=${STOP_TIMEOUT-10}
LOG=/var/log/smokeping.log
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $smokeping $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# Restart the service Smokeping
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $smokeping
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
RETVAL=2
esac
EOF
fi
cat > /usr/local/smokeping/etc/config <<'EOF'
*** General ***
owner = Peter Random
contact = [email protected]
#mailhost = smtp.51idc.com:25
#mailusr = xuel@51idc
#mailpwd = [email protected]
#sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /usr/local/smokeping/cache
imgurl = cache
datadir = /usr/local/smokeping/data
piddir = /usr/local/smokeping/var
cgiurl = http://$IP/smokeping.cgi
smokemail = /usr/local/smokeping/etc/smokemail.dist
tmail = /usr/local/smokeping/etc/tmail.dist
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no
*** Alerts ***
to = [email protected]
from = [email protected]
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row
+rttdetect
type = rtt
#in milli seconds
pattern = <10,<10,<10,<10,<10,<100,>100,>100,>100
edgetrigger = yes
comment = routing messed up again ?
+lossdetect
type = loss
# in percent
pattern = ==0%,==0%,==0%,==0%,>20%,>20%,>20%
edgetrigger = yes
comment = suddenly there is packet loss
+miniloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
edgetrigger = yes
#pattern = >0%,*12*
comment = detected loss 1 times over the last two hours
#+rttdetect
#type = rtt
# in milliseconds
#pattern = <1,<1,<1,<1,<1,<2,>2,>2,>2
#comment = routing messed up again ?
+rttbad
type = rtt
# in milliseconds
edgetrigger = yes
pattern = ==S,>20
comment = route
+rttbadstart
type = rtt
# in milliseconds
edgetrigger = yes
pattern = ==S,==U
comment = offline at startup
*** Database ***
step = 60
pings = 20
# consfn mrhb steps total
AVERAGE 0.5 1 1008
AVERAGE 0.5 12 4320
MIN 0.5 12 4320
MAX 0.5 12 4320
AVERAGE 0.5 144 720
MAX 0.5 144 720
MIN 0.5 144 720
*** Presentation ***
charset = utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
+ charts
menu = 排行榜
title = 排行榜
++ stddev
sorter = StdDev(entries=>4)
title = 综合指数排行
menu = 综合指数排行
format = 综合指数 %f
++ max
sorter = Max(entries=>5)
title = 最大延迟排行
menu = 最大延迟排行
format = 最大延迟时间 %f 秒
++ loss
sorter = Loss(entries=>5)
title = 丢包率排行
menu = 丢包率排行
format = 丢包 %f
++ median
sorter = Median(entries=>5)
title = 平均延迟排行
menu = 平均延迟排行
format = 平均延迟 %f 秒
+ overview
width = 860
height = 150
range = 10h
+ detail
width = 860
height = 200
unison_tolerance = 2
"Last 3 Hours" 3h
"Last 30 Hours" 30h
"Last 10 Days" 10d
"Last 30 Days" 30d
"Last 90 Days" 90d
#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location
*** Probes ***
+ FPing
binary = /usr/local/fping/sbin/fping
*** Slaves ***
secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
+boomer
display_name=boomer
color=0000ff
+slave2
display_name=another
color=00ff00
*** Targets ***
probe = FPing
menu = Top
#title = Network Latency Grapher
title = IDC网络节点质量监控
#remark = Welcome to the SmokePing website of xxx Company. \
# Here you will learn all about the latency of our network.
remark = Smokeping 网络质量监控系统
+ TELCOM
menu = 电信
title = 电信
++ north
menu = 华北区
title = 华北区
+++ beijing
menu = 北京
title = 北京:218.30.25.45
host = 218.30.25.45
+++ tianjin
menu = 天津
title = 天津:219.150.32.132
host = 219.150.32.132
+++ shijiazhuang
menu = 石家庄
title = 石家庄:123.180.0.1
host = 123.180.0.1
+++ huhehaote
menu = 呼和浩特
title = 呼和浩特:219.148.168.218
host = 219.148.168.218
++ northeast
menu = 东北区
title = 东北区
+++ qiqihaer
menu = 齐齐哈尔
title = 齐齐哈尔:222.170.0.61
host = 222.170.0.61
+++ changchun
menu = 长春
title = 长春:222.168.78.1
host = 222.168.78.1
+++ jilin
menu = 吉林
title = 吉林:123.173.127.2
host = 123.173.127.2
++ east
menu = 华东区
title = 华东区
+++ jinan
menu = 济南
title = 济南:58.56.25.4
host = 58.56.25.4
+++ shanghai
menu = 上海
title = 上海:116.228.111.118
host = 116.228.111.118
+++ nanjing
menu = 南京
title = 南京:221.231.191.214
host = 221.231.191.214
+++ hefei
menu = 合肥
title = 合肥:61.190.246.5
host = 61.190.246.5
+++ nanchang
menu = 南昌
title = 南昌:202.101.224.68
host = 202.101.224.68
+++ hangzhou
menu = 杭州
title = 杭州:60.191.62.31
host = 60.191.62.31
+++ fuzhou
menu = 福州
title = 福州:202.101.98.55
host = 202.101.98.55
++ south
menu = 中南区
title = 中南区
+++ luoyang
menu = 洛阳
title = 洛阳:123.52.130.12
host = 123.52.130.12
+++ wuhan
menu = 武汉
title = 武汉:111.175.233.30
host = 111.175.233.30
+++ changsha
menu = 长沙
title = 长沙:124.232.134.54
host = 124.232.134.54
+++ guangzhou
menu = 广州
title = 广州:58.61.200.1
host = 58.61.200.1
+++ shenzhen
menu = 深圳
title = 深圳:58.60.3.102
host = 58.60.3.102
+++ nanning
menu = 南宁
title = 南宁:222.217.164.38
host = 222.217.164.38
+++ haikou
menu = 海口
title = 海口:218.77.149.238
host = 218.77.149.238
++ southwest
menu = 西南区
title = 西南区
+++ chengdu
menu = 成都
title = 成都:61.157.77.1
host = 61.157.77.1
+++ chongqing
menu = 重庆
title = 重庆:218.70.65.254
host = 218.70.65.254
+++ guiyang
menu = 贵阳
title = 贵阳:59.51.128.31
host = 59.51.128.31
+++ kunming
menu = 昆明
title = 昆明:222.172.200.5
host = 222.172.200.5
+++ lasa
menu = 拉萨
title = 拉萨:124.31.0.1
host = 124.31.0.1
++ northwest
menu = 西北区
title = 西北区
+++ xian
menu = 西安
title = 西安:125.76.191.163
alerts = someloss
host = 125.76.191.163
+++ ningxia
menu = 宁夏
title = 宁夏:124.224.255.54
host = 124.224.255.54
+++ lanzhou
menu = 兰州
title = 兰州:61.178.252.218
host = 61.178.252.218
+++ xining
menu = 西宁
title = 西宁:223.220.241.26
host = 223.220.241.26
+++ wulumuqi
menu = 乌鲁木齐
title = 乌鲁木齐:61.128.96.1
host = 61.128.96.1
+ UNICOM
menu = 联通
title = 联通
++ north
menu = 华北区
title = 华北区
+++ beijing
menu = 北京
title = 北京:61.135.150.3
host = 61.135.150.3
+++ tianjin
menu = 天津
title = 天津:202.99.96.38
host = 202.99.96.38
+++ shijiazhuang
menu= 石家庄
title = 石家庄:221.192.1.221
host = 221.192.1.221
+++ taiyuan
menu = 太原
title = 太原:218.26.171.2
host = 218.26.171.2
++ northeast
menu = 东北区
title = 东北区
+++ changchun
menu = 长春
title = 长春:125.32.127.2
host = 125.32.127.2
+++ shenyang
menu = 沈阳
title = 沈阳:218.60.54.164
host = 218.60.54.164
+++ jilin
menu = 吉林
title = 吉林:218.62.77.121
host = 218.62.77.121
++ east
menu = 华东区
title = 华东区
+++jinan
menu = 济南
title = 济南:221.0.2.41
host = 221.0.2.41
+++ shanghai
menu = 上海
title = 上海:210.22.67.1
host = 210.22.67.1
+++ hangzhou
menu = 杭州
title = 杭州:101.68.92.11
host = 101.68.92.11
+++ nanchang
menu = 南昌
title = 南昌:118.212.189.129
host = 118.212.189.129
++ south
menu = 中南区
title = 中南区
+++ zhengzhou
menu = 郑州
title = 郑州:61.168.254.211
host = 61.168.254.211
+++ wuhan
menu = 武汉
title = 武汉:218.106.115.1
host = 218.106.115.1
+++ guangzhou
menu = 广州
title = 广州:211.95.193.69
host = 211.95.193.69
+++ shenzhen
menu = 深圳
title = 深圳:58.250.0.1
host = 58.250.0.1
+++ nanning
menu = 南宁
title = 南宁:211.97.71.202
host = 211.97.71.202
++ southwest
menu = 西南区
title = 西南区
+++ chongqing
menu = 重庆
title = 重庆:221.5.255.1
host = 221.5.255.1
++ northwest
menu = 西北区
title = 西北区
+++ xining
menu = 西宁
title = 西宁:221.207.27.1
host = 221.207.27.1
++ ceshiqu
menu = 测试区1
title = 测试区1
+++ test1
menu = 长春联通
title = 长春联通:119.48.221.29
host = 119.48.221.29
+++ test2
menu = 广东网通
title = 广东网通:120.84.0.1
host = 120.84.0.1
+++ test3
menu = 上海网通
title = 上海网通:210.22.67.1
host = 210.22.67.1
+++ test4
menu = 海南网通
title = 海南网通:221.11.132.2
host = 221.11.132.2
+++ test5
menu = 贵州联通
title = 贵州联通:221.13.21.194
host = 221.13.21.194
+++ test6
menu = 广西联通
title = 广西联通:221.7.136.68
host = 221.7.136.68
+++ test7
menu = 北京联通
title = 北京联通:60.30.128.1
host = 60.30.128.1
+++ test8
menu = 北京移动
title = 北京移动:218.205.128.1
host = 218.205.128.1
+++ test9
menu = 海口移动
title = 海口移动:221.182.227.1
host = 221.182.227.1
+++ test10
menu = 武汉铁通
title = 武汉铁通:61.232.206.1
host = 61.232.206.1
+ CMCC
menu = 移动
title = 移动
++ north
menu = 华北区
title = 华北区
+++ beijing
menu = 北京
title = 北京:221.130.33.1
host = 221.130.33.1
+++ tianjin
menu = 天津
title = 天津:211.137.160.1
host = 211.137.160.1
+++ qinhuangdao
menu = 秦皇岛
title = 秦皇岛:211.143.111.14
host = 211.143.111.14
+++ shijiazhuang
menu = 石家庄
title = 石家庄:111.11.64.142
host = 111.11.64.142
++ northeast
menu = 东北区
title = 东北区
+++ dalian
menu = 大连
title = 大连:211.140.192.4
host = 211.140.192.4
++ east
menu = 华东区
title = 华东区
+++ hefei
menu = 合肥
title = 合肥:211.138.191.65
host = 211.138.191.65
+++ nanjing
menu = 南京
title = 南京:120.195.118.1
host = 120.195.118.1
+++ jinan
menu = 济南
title = 济南:120.192.97.186
host = 120.192.97.186
+++ hangzhou
menu = 杭州
title = 杭州:111.1.33.222
host = 111.1.33.222
+++ nanchang
menu = 南昌
title = 南昌:218.204.68.41
host = 218.204.68.41
+++ jiangsu
menu = 江苏
title = 江苏:112.22.15.226
host = 112.22.15.226
++ south
menu = 中南区
title = 中南区
+++ zhengzhou
menu = 郑州