{"id":1923,"date":"2023-06-11T23:00:00","date_gmt":"2023-06-11T22:00:00","guid":{"rendered":"https:\/\/www.balajibandi.com\/?p=1923"},"modified":"2023-07-12T09:40:33","modified_gmt":"2023-07-12T08:40:33","slug":"setup-snmp-using-net-snmp-extend-mib","status":"publish","type":"post","link":"https:\/\/www.balajibandi.com\/?p=1923","title":{"rendered":"Setup SNMP using NET-SNMP-EXTEND-MIB"},"content":{"rendered":"\n<p>I have challenge to Monitor some of the process running or not on Linux<\/p>\n\n\n\n<p>There are many ways you can perform this Monitoring, But if you have centralize NMS and people do not have enough experience on Linux this steps help to Monitor extended MIB to poll and get outcome of Process running or not.<\/p>\n\n\n\n<p>by default you can only Monitor certain system inputs using SNMP Like :<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>CPU<\/li>\n\n\n\n<li>RAM<\/li>\n\n\n\n<li>HDD space<\/li>\n\n\n\n<li>Interface<\/li>\n<\/ol>\n\n\n\n<p>But if you like to Monitor NTP Process or Squid process working or not ( you need to Login got Linux and check with status of service or using ps -ef command. (its not easy  task  if you looking to Monitor 100 of Servers to login and check ps -ef or status  every 5min or 10min &#8230;.so on.)<\/p>\n\n\n\n<p>So i found good documentation online let me put them order what i have done so people can easily refer.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install SNMP package on Linux (i am referring Ubuntu here &#8211; its same other distro&#8217;s)<\/li>\n<\/ul>\n\n\n\n<p>Login to Ubuntu Server using SSH<\/p>\n\n\n\n<p>Update packages :<\/p>\n\n\n\n<p><strong>#apt-get update<\/strong><\/p>\n\n\n\n<p><strong>#apt-get -y install snmp snmpd snmp-mibs-downloader libnet-snmp-perl snmptrapd<\/strong><\/p>\n\n\n\n<p>Note : I am installing SNMP trapd , so from Linux you can also send SNMP trap to NMS server, based on that you can make any action.<\/p>\n\n\n\n<p>If you do not need SNMPtrap package. use below packages only.<\/p>\n\n\n\n<p><strong>#apt-get -y install snmp snmpd snmp-mibs-downloader<\/strong><\/p>\n\n\n\n<p>by default after installation snmp start automatically (and open for the people to use public community)<\/p>\n\n\n\n<p>we need to tweak as per the security best practice.<\/p>\n\n\n\n<p>Stop the SNMP Service and make changes.<\/p>\n\n\n\n<p><strong>#\/etc\/init.d\/snmpd stop<\/strong><\/p>\n\n\n\n<p>backup the old config &#8211; so in case required we can move the config to default if we like to roleback.<\/p>\n\n\n\n<p><strong>#cd  \/etc\/snmp<\/strong><\/p>\n\n\n\n<p><strong>#cp snmpd.conf snmpd.back<\/strong><\/p>\n\n\n\n<p>editing snmpd config and make basic config.<\/p>\n\n\n\n<p>#<strong>vi snmpd.conf<\/strong>   ( add below basic config to work &#8211; more information refer Manuals)<\/p>\n\n\n\n<p>sysLocation  &#8211; Where this Server Located (so in NMS it will automatically placed in that Location)<br>sysContact  &#8211; Team who manages this Server<br>sysServices 72<br>master agentx<br>agentaddress 127.0.0.1,[::1]<br>agentAddress udp:x.x.x.x:161 (x.x.x.x &#8211; replace with Server IP address, so SNMP can listen on that IP address).<br>view systemonly included .1.3.6.1.2.1.1<br>view systemonly included .1.3.6.1.2.1.25.1<br>extend squid-status \/usr\/bin\/sudo \/bin\/sh \/etc\/snmp\/squid-status.sh   <strong>&#8211; this is the example i used for Squid process to check up or down)  &#8211; you will the File content Later in this steps<\/strong><br>extend squid-clients \/usr\/bin\/sudo \/etc\/snmp\/squid-tcp-connections.sh  <strong> &#8211; this will show you how many TCP connection Squid using.<\/strong><br>rouser authPrivUser authpriv -V systemonly<br>includeDir \/etc\/snmp\/snmpd.conf.d<\/p>\n\n\n\n<p>Saving the config<\/p>\n\n\n\n<p><strong>:wq!<\/strong><\/p>\n\n\n\n<p>Creating the SNMPv3 user (this is more secure to use v3)<\/p>\n\n\n\n<p><strong>#net-snmp-create-v3-user -ro -A xxxxxxxxxxxxxxxxxxxxx -a SHA -X yyyyyyyyyyyyyyyyy -x AES BB-snmpv3-User<\/strong><\/p>\n\n\n\n<p>Create below files using vi editor with the content posted<\/p>\n\n\n\n<p><strong>Create a File squid-status.sh<\/strong><\/p>\n\n\n\n<p>!\/bin\/sh<\/p>\n\n\n\n<p>NUMPIDS=<code>sudo \/bin\/netstat -lnptu | grep -i squid | grep -c :3128<\/code><\/p>\n\n\n\n<p>exit $NUMPIDS<\/p>\n\n\n\n<p><strong>Create a File squid-tcp-connections.sh<\/strong><\/p>\n\n\n\n<p>!\/bin\/sh<\/p>\n\n\n\n<p>NUMPIDS=<code>sudo \/usr\/bin\/ss -s | head -1 | awk '{ print $2 }'<\/code><\/p>\n\n\n\n<p>exit $NUMPIDS<\/p>\n\n\n\n<p>change the file to executable.<\/p>\n\n\n\n<p><strong>#chmod +x squid-status.sh<br>#chmod +x squid-tcp-connections.sh<\/strong><\/p>\n\n\n\n<p>Start the SNMP Service<\/p>\n\n\n\n<p><strong>#\/etc\/init.d\/snmpd start<\/strong><\/p>\n\n\n\n<p>check the status <\/p>\n\n\n\n<p><strong>#\/etc\/init.d\/snmpd status<\/strong><\/p>\n\n\n\n<p>Testing :<\/p>\n\n\n\n<p>From NMS Server try polling using snmpwalk.<\/p>\n\n\n\n<p><strong>#snmpwalk -v3 -l authPriv -u BB-snmpv3-User -a SHA -A &#8220;xxxxxxxxxxxxx&#8221; -x AES -X &#8220;yyyyyyyyyy&#8221; x.x.x.x NET-SNMP-EXTEND-MIB::nsExtendObjects<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Good Luck&#8230;.Happy Learninggggggggggggggggg!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have challenge to Monitor some of the process running or not on Linux There are many ways you can perform this Monitoring, But if you have centralize NMS and people do not have enough experience on Linux this steps help to Monitor extended MIB to poll and get outcome of Process running or not. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1923","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/1923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1923"}],"version-history":[{"count":1,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/1923\/revisions"}],"predecessor-version":[{"id":1924,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/1923\/revisions\/1924"}],"wp:attachment":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}