centos7.2 安裝smokeping

來源:互聯網
上載者:User

centos7.2 安裝smokeping
第1章基本概念

第2章安裝2.0時間同步yum-yinstallntpdatentpdatetimes.aliyun.com2.1安裝依賴包yumgroupinstall"Compatibilitylibraries""Base""Developmenttools"-yyum-yinstallcpanperlperl-FCGIperl-CGIperl-Digest-HMACperl-Net-Telnetperl-Net-OpenSSHperl-Net-SNMPperl-LDAPperl-Net-DNSperl-IO-Pty-Easyperl-Test-Simpleperl-Sys-Syslogperl-libwww-perlperl-IO-Socket-SSLperl-Socket6perl-CGI-SpeedyCGIperl-FCGIperl-Time-HiResperl-ExtUtils-MakeMakerrrdtoolrrdtool-perlcurlfpinghttpdhttpd-develgccmakewgetlibxml2-devellibpng-develglibpangopango-develfreetypefreetype-develfontconfigcairocairo-devellibart_lgpllibart_lgpl-develmod_fcgidscreen2.2安裝echopingtarxvfechoping-6.0.2.tar.gzcdechoping-6.0.2./configure--prefix=/usr/local/echopingmake&&makeinstall2.3安裝smokeping

cd/usr/local/srcxfsmokeping-2.6.11.tar.gzcdsmokeping-2.6.11#exportPERL5LIB=/usr/local/smokeping/thirdparty/lib/perl5/./setup/build-perl-modules.sh/usr/local/smokeping/thirdparty./configure--prefix=/usr/local/smokepinggmakeinstall

如果./configure過程中提示找不到某些perl擴充,如下所示

checkingcheckingforperlmodule'Config::Grammar'...Can'tlocateConfig/Grammar.pmin@INC(@INCcontains:/usr/local/smokeping/thirdparty/lib/perl5/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.)at-eline1.BEGINfailed--compilationabortedat-eline1.

請使用以下命令安裝對應模組:

perl-MCPAN-e'installConfig::Grammar'

注意:有時候需要重複安裝幾次才能裝上模組。

注意要選擇國內的的模組源,不然速度很慢。

2.4建立相關目錄和記錄檔cd/usr/local/smokepingmkdircachedatavartouch/var/log/smokeping.logchownapache.apachecache/data/var//var/log

因為這裡的web服務使用的是httpd,所以相關檔案的屬主屬組均為apache

2.5建立相關設定檔

#fcgi檔案cp/usr/local/smokeping/htdocs/smokeping.fcgi.dist/usr/local/smokeping/htdocs/smokeping.fcgi#主設定檔cp/usr/local/smokeping/etc/config.dist/usr/local/smokeping/etc/config

2.6修改設定檔#指定cgi的url地址為本機sed-i‘s#cgiurl=http://some.url/smokeping.cgi#cgiurl=http://10.0.56.12/smokeping.cgi#g’/usr/local/smokeping/etc/config#指定檢測的時間為60秒sed-i‘s#step=300#step=60#g’/usr/local/smokeping/etc/config#指定ping的次數為60sed-i‘s#pings=20#pings=60#g’/usr/local/smokeping/etc/config將step和pings都設定為60表示每60秒ping60次。

2.7修改字元集和字型支援中文vim/usr/local/smokeping/etc/config***Presentation***charset=utf-8

yum -y install wqy-zenhei-fonts

vim/usr/local/smokeping/lib/Smokeping/Graphs.pm

my$val = 0;

formy $host (@hosts){

my ($graphret,$xs,$ys) = RRDs::graph

("dummy",

'--start', $tasks[0][1],

'--end', $tasks[0][2],

'--font TITLE:20"WenQuanYiZen Hei Mono"',

"DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",

'PRINT:maxping:MAX:%le' );

my $ERROR = RRDs::error();

2.8修改apache設定檔增加登入驗證htpasswd-c/usr/local/smokeping/htdocs/htpasswdsmokepingchmod600/usr/local/smokeping/etc/smokeping_secrets.dist

2.9修改httpd.conf增加smokeping的web介面

在httpd.conf末尾添加如下內容

vim/etc/httpd/conf/httpd.conf#########changedbyggvylf2016/06/13##############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">AllowOverrideNoneOptionsAllAddHandlercgi-script.fcgi.cgiAllowOverrideAuthConfigOrderallow,denyAllowfromallAuthName"Smokeping"AuthTypeBasicAuthUserFile/usr/local/smokeping/htdocs/htpasswdRequirevalid-userDirectoryIndexsmokeping.fcgi</Directory>

2.10添加監控對象vim/usr/local/smokeping/etc/config***Targets***++Localhostmenu=Localhosttitle=Localhostalerts=someloss#slaves=boomerslave2host=10.0.56.12

2.11添加監控節點

注意:每次修改設定檔後需要重啟smokeping進程

/usr/local/smokeping/bin/smokeping--restart或/usr/local/smokeping/bin/smokeping--reload或pkillsmokeping/usr/local/smokeping/bin/smokeping

監控節點範例如下,注意+是第一層,++是第二層,+++是第三層:

vim/usr/local/smokeping/etc/config+Othermenu=三大網路監控title=監控統計++dianxinmenu=電信網路監控title=電信網路監控列表host=/Other/dianxin/dianxin-bj/Other/dianxin/dianxin-hlj/Other/dianxin/dianxin-tj/Other/dianxin/dianxin-sc/Other/dianxin/dianxin-sh/Other/dianxin/dianxin-gz+++dianxin-bjmenu=北京電信title=北京電信alerts=somelosshost=202.96.199.133+++dianxin-hljmenu=黑龍江電信title=黑龍江電信alerts=somelosshost=219.147.198.242+++dianxin-tjmenu=天津電信title=天津電信alerts=somelosshost=219.150.32.132+++dianxin-scmenu=四川電信title=四川電信alerts=somelosshost=61.139.2.69+++dianxin-shmenu=上海電信title=上海電信alerts=somelosshost=116.228.111.118+++dianxin-gzmenu=廣東電信title=廣東電信alerts=somelosshost=113.111.211.22++liantongmenu=聯通網路監控title=聯通網路監控列表host=/Other/liantong/liantong-bj/Other/liantong/liantong-hlj/Other/liantong/liantong-tj/Other/liantong/liantong-sc/Other/liantong/liantong-sh/Other/liantong/liantong-gz+++liantong-bjmenu=北京聯通title=北京聯通alerts=somelosshost=61.135.169.121+++liantong-hljmenu=黑龍江聯通title=黑龍江聯通alerts=somelosshost=202.97.224.69+++liantong-tjmenu=天津聯通title=天津聯通alerts=somelosshost=202.99.96.68+++liantong-scmenu=四川聯通title=四川聯通alerts=somelosshost=119.6.6.6+++liantong-shmenu=上海聯通title=上海聯通alerts=somelosshost=210.22.84.3+++liantong-gzmenu=廣東聯通title=廣東聯通alerts=somelosshost=221.5.88.88++yidongmenu=移動網路監控title=移動網路監控列表host=/Other/yidong/yidong-bj/Other/yidong/yidong-hlj/Other/yidong/yidong-tj/Other/yidong/yidong-sc/Other/yidong/yidong-sh/Other/yidong/yidong-gz+++yidong-bjmenu=北京移動title=北京移動alerts=somelosshost=221.130.33.52+++yidong-hljmenu=黑龍江移動title=黑龍江移動alerts=somelosshost=211.137.241.35+++yidong-tjmenu=天津移動title=天津移動alerts=somelosshost=211.137.160.5+++yidong-scmenu=四川移動title=四川移動alerts=somelosshost=218.201.4.3+++yidong-shmenu=上海移動title=上海移動alerts=somelosshost=117.131.19.23+++yidong-gzmenu=廣東移動title=廣東移動alerts=somelosshost=211.136.192.6

smokeping會根據設定檔中配置監控節點的內容,在/usr/local/smokeping/data目錄下產生對應的moniter檔案夾,其下包含website子檔案夾。

[root@linux-node2smokeping]#tree/usr/local/smokeping/data//usr/local/smokeping/data/├──Other│├──dianxin││├──dianxin-bj.rrd││├──dianxin-gd.rrd││├──dianxin-gs.rrd││├──dianxin-gz.rrd││├──dianxin-hlj.rrd││├──dianxin-sc.rrd││├──dianxin-sh.rrd││└──dianxin-tj.rrd│├──liantong││├──liantong-bj.rrd││├──liantong-gz.rrd││├──liantong-hlj.rrd││├──liantong-sc.rrd││├──liantong-sh.rrd││└──liantong-tj.rrd│└──yidong│├──yidong-bj.rrd│├──yidong-gz.rrd│├──yidong-hlj.rrd│├──yidong-sc.rrd│├──yidong-sh.rrd│└──yidong-tj.rrd├──__sortercache│└──data.FPing.storable└──Test├──James~boomer.rrd├──James.rrd├──James~slave2.rrd└──Localhost.rrd

2.12啟動服務並測試systemctlstarthttpd/usr/local/smokeping/bin/smokeping

在瀏覽器中訪問

http://10.0.56.12/smokeping

使用者名稱和密碼為htpasswd命令中設定使用者名稱和密碼

出現以下介面表示成功。

可以看到添加的節點的相關資訊。

可以看到添加的監控點的ping狀態

附錄:

更改CPAN源的方法:

[root@linux-node2smokeping-2.6.11]#cpanSorry,wehavetoreruntheconfigurationdialogforCPAN.pmduetosomemissingparameters.Configurationwillbewrittento<</root/.cpan/CPAN/MyConfig.pm>>CPAN.pmrequiresconfiguration,butmostofitcanbedoneautomatically.Ifyouanswer'no'below,youwillenteraninteractivedialogforeachconfigurationoptioninstead.Wouldyouliketoconfigureasmuchaspossibleautomatically?[yes]yes<install_help>Warning:YoudonothavewritepermissionforPerllibrarydirectories.Toinstallmodules,youneedtoconfigurealocalPerllibrarydirectoryorescalateyourprivileges.CPANcanhelpyoubybootstrappingthelocal::libmoduleorbyconfiguringitselftouse'sudo'(ifavailable).Youmayalsoresolvethisproblemmanuallyifyouneedtocustomizeyoursetup.Whatapproachdoyouwant?(Choose'local::lib','sudo'or'manual')[local::lib]Autoconfiguredeverythingbut'urllist'.NowyouneedtochooseyourCPANmirrorsites.Youcanletmepickmirrorsforyou,youcanselectthemfromalistoryoucanenterthembyhand.WouldyoulikemetoautomaticallychoosesomeCPANmirrorsitesforyou?(ThismeansconnectingtotheInternet)[yes]noWouldyouliketopickfromtheCPANmirrorlist?[yes]yesFoundacachedmirrorlistasofMonJun1307:01:482016Ifyou'dliketojustusethecachedcopy,answer'yes',below.Ifyou'dlikeanupdatedcopyofthemirrorlist,answer'no'andI'llgetafreshonefromtheInternet.ShallIusethecachedmirrorlist?[yes]yesFirst,pickanearbycontinentandcountrybytypinginthenumber(s)infrontoftheitem(s)youwanttoselect.Youcanpickseveralofeach,separatedbyspaces.Then,youwillbepresentedwithalistofURLsofCPANmirrorsinthecountriesyouselected,alongwithpreviouslyselectedURLs.SelectsomeofthoseURLs,orjustkeeptheoldlist.Finally,youwillbepromptedforanyextraURLs--file:,ftp:,orhttp:--thathostaCPANmirror.Youshouldselectmorethanone(justincasethefirstisn'tavailable).(1)Africa(2)Asia(3)Europe(4)NorthAmerica(5)Oceania(6)SouthAmericaSelectyourcontinent(orseveralnearbycontinents)[]2(1)Bangladesh(2)China(3)India(4)Indonesia(5)Iran(6)Israel(7)Japan(8)Kazakhstan(9)Philippines(10)Qatar(11)RepublicofKorea(12)Singapore(13)Taiwan(14)Turkey(15)VietNamSelectyourcountry(orseveralnearbycountries)[]2(1)ftp://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/(2)ftp://mirrors.ustc.edu.cn/CPAN/(3)ftp://mirrors.xmu.edu.cn/CPAN/(4)http://cpan.communilink.net/(5)http://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/(6)http://mirror.lzu.edu.cn/CPAN/(7)http://mirrors.163.com/cpan/(8)http://mirrors.hust.edu.cn/CPAN/(9)http://mirrors.neusoft.edu.cn/cpan/(10)http://mirrors.sohu.com/CPAN/(11)http://mirrors.ustc.edu.cn/CPAN/(12)http://mirrors.xmu.edu.cn/CPAN/(13)http://mirrors.zju.edu.cn/CPAN/SelectasmanyURLsasyoulike(bynumber),putthemononeline,separatedbyblanks,hyphenatedrangesallowede.g.'145'or'71-48'[]7NowyoucanenteryourownCPANURLsbyhand.AlocalCPANmirrorcanbelistedusinga'file:'URLlike'file:///path/to/cpan/'EnteranotherURLorENTERtoquit:[]Newurllisthttp://mirrors.163.com/cpan/Autoconfigurationcomplete.Attemptingtobootstraplocal::lib...Writing/root/.cpan/CPAN/MyConfig.pmforbootstrap...commit:wrote'/root/.cpan/CPAN/MyConfig.pm'FetchingwithLWP:http://mirrors.163.com/cpan/authors/01mailrc.txt.gzReading'/root/.cpan/sources/authors/01mailrc.txt.gz'............................................................................DONEFetchingwithLWP:http://mirrors.163.com/cpan/modules/02packages.details.txt.gzReading'/root/.cpan/sources/modules/02packages.details.txt.gz'DatabasewasgeneratedonThu,09Jun201622:53:42GMT.............NewCPAN.pmversion(v2.10)available.[Currentlyrunningversionisv1.9800]YoumightwanttotryinstallCPANreloadcpantobothupgradeCPAN.pmandrunthenewversionwithoutleavingthecurrentsession................................................................DONEFetchingwithLWP:http://mirrors.163.com/cpan/modules/03modlist.data.gzReading'/root/.cpan/sources/modules/03modlist.data.gz'DONEWriting/root/.cpan/MetadataRunningmakeforH/HA/HAARG/local-lib-2.000019.tar.gzFetchingwithLWP:http://mirrors.163.com/cpan/authors/id/H/HA/HAARG/local-lib-2.000019.tar.gzFetchingwithLWP:http://mirrors.163.com/cpan/authors/id/H/HA/HAARG/CHECKSUMSChecksumfor/root/.cpan/sources/authors/id/H/HA/HAARG/local-lib-2.000019.tar.gzokCPAN.pm:BuildingH/HA/HAARG/local-lib-2.000019.tar.gzCheckingifyourkitiscomplete...LooksgoodWarning:prerequisiteTest::More0notfound.GeneratingaUnix-styleMakefileWritingMakefileforlocal::libWritingMYMETA.ymlandMYMETA.json----Unsatisfieddependenciesdetectedduring--------HAARG/local-lib-2.000019.tar.gz----Test::More[build_requires]RunningmaketestDelayeduntilafterprerequisitesRunningmakeinstallDelayeduntilafterprerequisitesTriedtodeactivateinactivelocal::lib'/root/perl5'local::libisinstalled.Youmustnowaddthefollowingenvironmentvariablestoyourshellconfigurationfiles(orregistry,ifyouareonWindows)andthenrestartyourcommandlineshellandCPANbeforeinstallingmodules:Useofuninitializedvalue$deactivatinginnumericeq(==)at/usr/share/perl5/vendor_perl/local/lib.pmline381.Useofuninitializedvalue$deactivatinginnumericeq(==)at/usr/share/perl5/vendor_perl/local/lib.pmline383.Useofuninitializedvalue$options{"interpolate"}innumericeq(==)at/usr/share/perl5/vendor_perl/local/lib.pmline424.Useofuninitializedvalue$options{"interpolate"}innumericeq(==)at/usr/share/perl5/vendor_perl/local/lib.pmline424.Useofuninitializedvalue$options{"interpolate"}innumericeq(==)at/usr/share/perl5/vendor_perl/local/lib.pmline424.exportPERL_LOCAL_LIB_ROOT="$PERL_LOCAL_LIB_ROOT:/root/perl5";exportPERL_MB_OPT="--install_base/root/perl5";exportPERL_MM_OPT="INSTALL_BASE=/root/perl5";exportPERL5LIB="/root/perl5/lib/perl5:$PERL5LIB";exportPATH="/root/perl5/bin:$PATH";Wouldyoulikemetoappendthatto/root/.bashrcnow?[yes]commit:wrote'/root/.cpan/CPAN/MyConfig.pm'Youcanre-runconfigurationanytimewith'oconfinit'intheCPANshellTerminaldoesnotsupportAddHistory.cpanshell--CPANexplorationandmodulesinstallation(v1.9800)Enter'h'forhelp.cpan[1]>exitTerminaldoesnotsupportGetHistory.Lockfileremoved.***Remembertorestartyourshellbeforerunningcpanagain***

#perl-MCPAN-eshellcpan>oconfurllistunshifthttp://mirrors.aliyun.com/CPAN/cpan>oconfcommit

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.