Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

SettingUpSNMP

ThisHowTowillexplainhowtoinstallandconfiguretheNetSNMPagent.Attimeofwriting,thelatestversion availableis5.4(publishedon12/06/2006).

GettingNetSNMPbinaries
Dependingonyouroperatingsystem,you'llfindpackagesortarballstoinstallNetSNMP: Linux UsuallyeveryLinuxdistributioncomeswithNetSNMPpackages: RedHat/Fedora:installthenetsnmp,netsnmplibsandnetsnmputilspackages Debian/Ubuntu:installthelibsnmpbase,libsnmp5,snmpandsnmpdpackages SuSE:installthenetsnmppackage Gentoo:simplyemergethenetsnmpebuild Mandriva:installthelibnetsnmp5,netsnmpandnetsnmputilspackages. AIX PackageswereareavailableintheUniversityofCaliforniaRepository,butit'snolongeravailable. YoucanfindNetSNMP5.0.3forAIX5.1ontheBullAIXfreewaresite. Solaris Solaris10shipswithNetSNMP5.0.9ForolderSolarisreleases,packagesareavailableintheSunfreeware repository: release5.1.1forSolaris9Sparc release5.1.1forSolaris9Intel release5.1.1forSolaris8Sparc release5.1.1forSolaris8Intel release5.1.1forSolaris7Sparc release5.1.1forSolaris2.6Sparc release5.1.1forSolaris2.5SparcForthesepackagestowork,OpenSSLandGCClibrariesneedtobe installedalso.TarballsarealsoavailablefromtheNetSNMPmainsite: release5.2.2forSolaris9onsun4uhardware release5.2.2forSolaris8onsun4uhardware release5.2.2forSolaris7onsun4uhardwareThesetarballshavetobeextractedfrom/hastheycontain absolutepaths. Filesarecopiedto/usr/local/share/snmp,/usr/local/libs,/usr/local/include/netsnmp,/usr/local/man, /usr/local/binand/usr/local/sbin HPUX TarballsareavailablefromtheNetSNMPmainsite: release5.4forHPUX11.11PARISC release5.4forHPUX11.00PARISC release5.4forHPUX10.20PARISCThesetarballshavetobeextractedfrom/hastheycontainabsolute paths.Bewarethatthebinariesarenotstrippedinthesetarballs,thiswastealotspace. Filesarecopiedto/usr/local/share/snmp,/usr/local/libs,/usr/local/include/netsnmp,/usr/local/man, /usr/local/binand/usr/local/sbin FreeBSD NetSNMPisavailablethroughtheports

BuildingtheNetSNMPagentfromsource
Ifyoucan'tfindbinariesforyourarchitecture,youcanbuildtheNetSNMPagentfromsources. Here'showtogettheconfigureoptionsofanalreadyrunningNetSNMPagent:

$smwlv1ulclclot.......011060 npakcpbioahs13614122.0.. UDSMI:vrinofgrOtos0=SRN:"ialhrdwtioue=oth_ytm" CNPMB:esoCniuepin.TIG'dsbesae''ihmbmdlshs/rsse'

ConfiguringtheNetSNMPagent
Dependingonhowyou'veinstalledNetSNMP,themainconfigurationfile(snmpd.conf)islocatedin/etc/snmp (installationfrompackage)or/usr/local/share/snmp(installationfromtarball). Pleasenotethatyouneedtorestart(orsendtheHUPsignal)thesnmpddaemonwheneveryoumodifysnmpd.conf Theminimumconfigurationisthisone:
rcmuiypbi oomntulc

ThiswillenableSNMPversion1/2readonlyrequestsfromanyhost,withthecommunitynamepublic. Withthisminimalconfiguration,you'llbeabletographCPUusage,loadaverage,networkinterfaces,memory/swap usage,loggedinusersandnumberofprocesses. YoucanrestrictfromwhichhostsSNMPqueriesareallowed:


rcmuiypbi2... oomntulc17001 rcmuiyts76.32 oomntet8.54.1

BydefaultNetSNMPlistensonUDPport161onallIPv4interfaces. Withthefollowingexample,NetSNMPwilllistenonUDPport10000on10.20.30.40IPaddress:
aetdrs02.04:00 gnades1.03.0100

YoucanalsomakeitlistensonTCP,whichissupportedbyCacti
aetdrsc:6 gnadestp11

ThetcpkeywordcanthenbeusedinCacti:

Forthosewhowantsomemoresecurity,youcanusetheSNMPversion3protocol,withMD5orSHAhashing:
cetUerdrcM5mpsprsE raesrfeeiDyashaeDS gopgop3umrdrc ruruvsfeei vealicueio0 iwlnldd.s8 acsruv"nuhxcalall cesgop3"ayateatllal

Thiscreatesauserfredericwhosepasswordismypassphrase.Totestit:
#smgtlAtNPiufeeiAmpsprs05.04yNm. npev3uhorvrdrcyashae1.08.5ssae0 SMvI:ssae0=SRN:ccoe NP2MB:yNm.TIGylps

InCacti,addyourdevice,chooseSNMPversion3,andfilltheusernameandpasswordfields:

Nowthatyou'redonewithaccesscontrol,addthese2linesinsnmpd.conftoindicatethelocationandcontactnameof yourdevice:
ssoainBt2 ylctoa.C ssotcoen@oehr.r ycnatsmoesmweeog

TheywillthenappearinCactimanagementinterface:

SomeOIDsreturnaunit,eg153.1dBm. It'sasafeideatoturnthisoff,byaddingthistosnmpd.conf:
dnPitntre otrnUistu

NextstepistographfilesystemsinCactitheeasyestwayistoaddthislineinsnmpd.conf:
icuelDss nldAlik

Whenyou'llruntheucd/netGetMonitoredPartitionsDataQuery,allthemountedfilesystemswillshowup:

Ifyouwantafilesystemnottobelistedhere,addthislinetosnmpd.conf:
inrdsdvrs/020 goeik/e/dkctd

Unfortunatly,someolderversionsofNetSNMPdonotfullyworkwiththeincludeAllDiskskeyword You'llthenhavetolistexplicitlyallfilesystemsyouwanttograph:
ds ik/ dsur ik/s dsvr ik/a dsoal ik/rce

YoucanalsospecifyNFSmountpoints. PleasenotethattheNetSNMPagentcanonlyreportfilesystemswhichwheremountedbeforeitsstart. Ifyoumanuallymountfilesystemslater,you'llhavetoreloadtheNetSNMPagent(sendtheHUPsignal). Youcanalsographprocesses,byaddingthistosnmpd.conf:


potp rchtd

Theresultwillbeaccessibleundertheucdavis.prTable.prEntrytree: prCount,numberofcurrentprocessesrunningwiththenameinquestion prNames,theprocessnameyou'recounting. Inourexample,thenumberofApacheprocesseswillbeavailableunderthe.1.3.6.1.4.1.2021.2.1.5OIDSomeusefulmib modulesare: mibII/mta_sendmail,tographMTA(Sendmail,Postfix,etc.)statistics diskio,toenabletographI/Ostatistics ucdsnmp/lmSensors,forhardwaremonitoring(LinuxandSolarisonly) Mibmodulescanbeaddedlikethis:


$.cniuewtioue=mdl1mdl2 /ofgrihmbmdls"oueoue"

TocompileNetSNMPandbuildacompressedarchive,followthesesteps:
$.cniuewtorotos /ofgrihyupin $mk ae #mdr/s/oa/it kiurlclds #mkntlrfx/s/oa/iturlclee_rfx/s/oa/iturlcl aeisalpei=urlclds/s/oaxcpei=urlclds/s/oa #curlclds d/s/oa/it #trcf/m/enp531ds.as avtpntsm..ittrur #gitpntsm..ittr zp/m/enp531ds.a #rrurlclds mf/s/oa/it

Youcanthencopythe/tmp/netsnmp5.3.1dist.tar.gzfiletootherservers,anduncompressitfromtherootdirectory (everythingwillgetextractedto/usr/local).

Testyourconfiguration
OnceNetSNMPisconfiguredandstarted,here'showtotestit:
$smwlv1ulclclot......... npakcpbioahs136121110 SMvI:ssec.TIGiurns2422SPvnjn141:1CT2066 NP2MB:yDsr0=SRN:Lnxcoo..8#Mea41:20E05i8

ThisbasicqueryshowsthatyourNetSNMPagentisreachable. YoucanevenquerywhichNetSNMPversionisrunningonahost:
$smwlv1ulclclot.......011020 npakcpbioahs13614122.0.. UDSMI:vrina.TIG... CNPMB:esoTg0=SRN:5212

Ananswerlikethatone
$smwlv1ooahs136121110 npakcfolclot......... TmotoRsosrmlclot ieu:Nepnefooahs

indicatesthateithertheagentisnotstarted,orthatthecommunitystringisincorrect,orthatthisdeviceisunreachable. Checkyourcommunitystring,addfirewallrulesifnecessary,etc.

IfusingSNMPversion3,specifyinganunknownuserwillresultinthiserrormessage:
$smgtlAtNPiujhAmpsprs05.04yNm. npev3uhorvonyashae1.08.5ssae0 smgtnnwsrnm npe:Ukonueae

Anincorrectpassphrasewillresultinthiserrormessage:
$smgtlAtNPiufeeiAbdashae1.08.5ssae0 npev3uhorvrdrcapsprs05.04yNm. smgtuhniainfiue(norcasodomntrky npe:Atetctoalricretpswr,cmuiyoe)

Thisquerywillshowyouwhatfilesystemsaremounted:
$smwlv1ulclclot.......01912 npakcpbioahs13614122... UDSMI:dkah1=SRN:/ CNPMB:sPt.TIG UDSMI:dkah2=SRN:/B CNPMB:sPt.TIGB UDSMI:dkah3=SRN:/e/h CNPMB:sPt.TIGdvsm

Iftheanswerisempty,usuallyitmeanstheincludeAllDisksisnotsupportedbyyourNetSNMPagent(you'llhavetolist eachfilesystemyouwanttographasexplainedinpreviouschapter). Finally,thisquerywillyoudisplayyournetworkinterfaces:


$smwlv1ulclclot.......... npakcpbioahs1361212212 II:iDsr1=SRN:l FMB:fec.TIGo II:iDsr2=SRN:eh FMB:fec.TIGt0 II:iDsr3=SRN:eh FMB:fec.TIGt1

ExtendingtheSNMPAgent
AgreatfunctionnalityofNetSNMPisthatyoucanextendit. Let'srunthe/tmp/foo.shscript:
$/m/o.hr1 tpfosag 13 2

Nowputthisinsnmpd.conf:
eeobnstpfosag xcfo/i/h/m/o.hr1

Theresultofyourscriptwillbeaccessibleundertheucdavis.extTable.extEntrytree:*outputofthescript: ucdavis.extTable.extEntry.extOutput*exitstatus:ucdavis.extTable.extEntry.extResult*command: ucdavis.extTable.extEntry.extCommand YoucanchecktheresultwiththisSNMPquery:


$smwlv1ulclclot.......0181 npakcpbioahs13614122.. UDSMI:etne.NEE:1 CNPMB:xIdx1=ITGR UDSMI:etae.TIGo CNPMB:xNms1=SRN:fo UDSMI:etomn.TIGbnstpfosag CNPMB:xCmad1=SRN:/i/h/m/o.hr1 UDSMI:eteut1=ITGR CNPMB:xRsl.NEE:0 UDSMI:etupt1=SRN:13 CNPMB:xOtu.TIG2 UDSMI:etrFx1=ITGR CNPMB:xEri.NEE:0 UDSMI:etrFxm.TIG CNPMB:xEriCd1=SRN:

extOutputtranslatesto.1.3.6.1.4.1.2021.8.1.101Asfooisourfirstexecdirective,add.1attheendoftheOID. InCacti,usetheSNMPGenericOIDTemplatelikethis:

Voila!Resultofthe/tmp/foo.shscriptisnowgraphedinCacti. Nowlet'srunthissecondscript,whichreturnsmorethanoneresult:
$/m/a.h tpbrs 46 5 79 8

Itreturnstwovalues,oneperline(thisisimportant). Anotherwaytocallscriptsfromsnmpd.confisbyspecifyinganOID,likethis:
ee13614122.5bnstpbrs xc.......0155/i/h/m/a.h

Runthisquery:
$smwlv1ulclclot.......0155 npakcpbioahs13614122.5 UDSMI:udvs5511=ITGR CNPMB:cai.5..NEE:1 UDSMI:udvs5521=SRN:"bns" CNPMB:cai.5..TIG/i/h UDSMI:udvs5531=SRN:"tpbrs" CNPMB:cai.5..TIG/m/a.h UDSMI:udvs55101=ITGR CNPMB:cai.5.0.NEE:0 UDSMI:udvs55111=SRN:"5" CNPMB:cai.5.0.TIG46 UDSMI:udvs55112=SRN:"8" CNPMB:cai.5.0.TIG79 UDSMI:udvs55121=ITGR CNPMB:cai.5.0.NEE:0 UDSMI:udvs55131=" CNPMB:cai.5.0."

Firstlinereturnedbythescriptwillbeavailableat.1.3.6.1.4.1.2021.555.101.1,secondoneat.1.3.6.1.4.1.2021.555.101.2, andsoon. YoucanthenusetheSNMPGenericOIDTemplateinCacti(oneDataSourceperOID). Let'ssayyouwanttocountthenumberofentriesinalogfile.Addthistosnmpd.conf:


lgacatsas/oeccisrccilgccilg10SSETT omthccitthm/atue/at/o/at.o2YTMSAS

*theglobalcountofmatcheswillbeavailableunderthe.1.3.6.1.4.1.2021.16.2.1.5.1OID*theRegexmatchcounter (whichisresetwitheachfilerotation)willbeavailableunderthe.1.3.6.1.4.1.2021.16.2.1.7.1OID Tolistalltheavailablevariables,usethisquery:


$smwlv1ulclclotlgac npakcpbioahsoMth UDSMI:lgacMxnre.NEE:5 CNPMB:oMthaEtis0=ITGR0 UDSMI:lgacIdx1=ITGR CNPMB:oMthne.NEE:1 UDSMI:lgacNm.TIGatsas CNPMB:oMthae1=SRN:ccitt UDSMI:lgacFlnm.TIGhm/atue/at/o/at.o CNPMB:oMthieae1=SRN:/oeccisrccilgccilg UDSMI:lgacRgx1=SRN:SSETT CNPMB:oMtheE.TIGYTMSAS UDSMI:lgacGoaCutr1=Cutr2064 CNPMB:oMthlblone.one3:313 UDSMI:lgacGoaCut1=ITGR064 CNPMB:oMthlblon.NEE:313 UDSMI:lgacCretone.one3:69 CNPMB:oMthurnCutr1=Cutr262 UDSMI:lgacCreton.NEE:69 CNPMB:oMthurnCut1=ITGR62

UDSMI:lgacCutr1=Cutr2 CNPMB:oMthone.one3:1 UDSMI:lgacCut1=ITGR CNPMB:oMthon.NEE:0 UDSMI:lgacCce1=ITGR2 CNPMB:oMthyl.NEE:10 UDSMI:lgacErrlg1=ITGR CNPMB:oMthroFa.NEE:0 UDSMI:lgacRgxoplto.TIGucs CNPMB:oMtheECmiain1=SRN:Sces

We'llthenuseanotherinterestingdirective,theproxyone.Let'stakeforexampletheSquidproxy:whenenabled,its SNMPagentlistentoUDP3401port.IfyouwanttohavesystemgraphsandSquidgraphswithoutdeclaring2devicesin Cacti,addthisinsnmpd.conf:


poycpbioahs:41.......451 rxv1ulclclot3013614139.

TheSquidSNMPtreewillbeavailableunderthe.1.3.6.1.4.1.3495.1branch. Let'squerythishost:
$smwlv1ulc1.5.33ssec npakcpbi0113.ydsr SMvI:ssec.TIGiur1focm26811mk#rc25:1CS04i8 NP2MB:yDsr0=SRN:Lnxsv.o.o...2d1FiOt11:34ET2066

Andhere'stheSquidpart(thisspecificOIDreturnstheSquidversion):
$smwlv1ulc1.5.33.......451230 npakcpbi0113.13614139.... SMvM:etrrss39....TIG25SAL6 NP2SI:nepie.451230=SRN:"..TBE"

Here,you'llfindhowtoenabletheSquidSNMPagent. 1_installation.1_install_unix.5_install_and_configure_cacti

1_installation.1_install_unix.3_configure_mysql

manual

623617!
fair.lastresort.co.jp

You might also like