{"id":3843,"date":"2019-09-07T11:34:25","date_gmt":"2019-09-07T16:34:25","guid":{"rendered":"https:\/\/dev.iachieved.it\/iachievedit\/?p=3843"},"modified":"2019-09-07T11:37:06","modified_gmt":"2019-09-07T16:37:06","slug":"recognizing-openwrt-as-an-os-in-observium","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/recognizing-openwrt-as-an-os-in-observium\/","title":{"rendered":"Recognizing OpenWrt as an OS in Observium"},"content":{"rendered":"<p><a href=\"https:\/\/www.observium.org\">Observium<\/a> is a great application for monitoring network equipment, regardless of type (e.g., routers, switches, firewalls, etc.)  What makes it so powerful is due in large part to the amount of information exposed by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Simple_Network_Management_Protocol\">SNMP<\/a> for network gear and its ability to intelligently parse the returned data and display it.<\/p>\n<p>This intelligence can only go so far, however, when a given piece of gear has either an incomplete implementation of SNMP or the values returned aren&#8217;t indicative of the equipment.  Take, for example, <a href=\"https:\/\/openwrt.org\">OpenWrt<\/a>.  It is, in a word, an awesome piece of software, capable of turning a $250 <a href=\"https:\/\/www.linksys.com\/us\/p\/P-WRT1900ACS\/\">Linksys home router<\/a> into a participant in an <a href=\"https:\/\/bird.network.cz\/?index\">OSPF area<\/a>.  Pretty nift.<\/p>\n<p>Due to its open nature there are a number of SNMP options for OpenWrt:<\/p>\n<ul>\n<li><a href=\"https:\/\/openwrt.org\/docs\/guide-user\/services\/snmp\/server\">snmpd<\/a><\/li>\n<li><a href=\"https:\/\/openwrt.org\/docs\/guide-user\/services\/snmp\/mini_snmpd\">mini_snmpd<\/a><\/li>\n<li><a href=\"https:\/\/openwrt.org\/packages\/pkgdata\/smartsnmpd\">smartsnmpd<\/a><\/li>\n<\/ul>\n<p>Only one of these will give you a suitable view in Observium, and that is the <code>snmpd<\/code> package.  Let&#8217;s install it (note that I&#8217;m using the OpenWrt shell vs. <a href=\"https:\/\/openwrt.org\/docs\/guide-user\/luci\/start\">LUCI<\/a>):<\/p>\n<p>[code lang=text]<br \/>\n# opkg update<br \/>\n# opkg install snmpd<br \/>\n[\/code]<\/p>\n<p>Unfortunately if you add your device now Observium will recognize it as a generic Linux machine.  That&#8217;s due to the fact that, by default, the OpenWrt <code>snmpd<\/code> package will not return suitable information in the <code>sysDescr<\/code> OID for Observium&#8217;s <a href=\"https:\/\/docs.observium.org\/developing\/add_os\/\">OS detection<\/a> routines.<\/p>\n<p>For reference, here is what you can expect Observium to display with <code>snmpd<\/code> not configured properly:<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2019\/09\/dllstx01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2019\/09\/dllstx01.png\" alt=\"\" width=\"616\" height=\"409\" class=\"aligncenter size-full wp-image-3847\" \/><\/a><\/p>\n<p>Let&#8217;s take a look directly at the <code>sysDescr<\/code> OID with <code>snmpget<\/code>, which is available by installing <code>snmp<\/code> on your Observium host (if you&#8217;re using a Debian variant).  There is a little dance to be done to get <code>snmpget<\/code> to work properly:<\/p>\n<p>[code lang=text]<br \/>\n# apt-get install snmp snmp-mibs-downloader<br \/>\n# printf &quot;[snmp]\\\\nmibs +ALL\\\\n&quot; &gt; \/etc\/snmp\/snmp.conf<br \/>\n# download-mibs<br \/>\n# snmpget -v2c -c public &lt;HOSTNAME&gt; sysDescr.0<br \/>\n[\/code]<\/p>\n<p>For our router:<\/p>\n<p>[code lang=text]<br \/>\nsnmpget -v2c -c public gw.gw01.chcgil01.iachieved.it sysDescr.0<br \/>\n.1.3.6.1.2.1.1.1.0 = STRING: Linux chcgil 4.14.131 #0 SMP Thu Jun 27 12:18:52 2019 armv7l<br \/>\n[\/code]<\/p>\n<p><code>sysDescr<\/code> as is will cause Observium to detect the router as a basic Linux OS.  We want more.  Here&#8217;s how to do it!  Go to the <code>\/etc\/config\/snmpd<\/code> file in OpenWrt and find this block:<\/p>\n<p>[code lang=text]<br \/>\nconfig system<br \/>\n        option sysLocation      &#039;office&#039;<br \/>\n        option sysContact       &#039;bofh@example.com&#039;<br \/>\n        option sysName          &#039;HeartOfGold&#039;<br \/>\n#       option sysServices      72<br \/>\n#       option sysDescr         &#039;adult playground&#039;<br \/>\n#       option sysObjectID      &#039;1.2.3.4&#039;<br \/>\n[\/code]<\/p>\n<p><code>sysLocation<\/code> can be set to a locale name and Observium will automatically map it properly.  Since this router is in Chicago we&#8217;ll put Chicago there.  Likewise, <code>sysName<\/code> will be changed to <code>gw01.chcgil01<\/code> as this router is <i>Gateway #1<\/i> in <i>Chicago Site #1<\/i>.  What we&#8217;re particularly interested in changing here is <code>sysDescr<\/code>.  Uncomment the line and change it to <code>OpenWrt<\/code>.  Here&#8217;s what our final <code>config system<\/code> block looks like:<\/p>\n<p>[code lang=text]<br \/>\nconfig system<br \/>\n        option sysLocation      &#039;Chicago&#039;<br \/>\n        option sysContact       &#039;admin@iachieved.it&#039;<br \/>\n        option sysName          &#039;gw01.chcgil01&#039;<br \/>\n        option sysDescr         &#039;OpenWrt&#039;<br \/>\n[\/code]<\/p>\n<p>Restart <code>snmpd<\/code>:<\/p>\n<p>[code lang=text]<br \/>\n# \/etc\/init.d\/snmpd restart<br \/>\n[\/code]<\/p>\n<p>And check <code>snmpget<\/code> again:<\/p>\n<p>[code lang=text]<br \/>\n# snmpget -v2c -c public gw.gw01.chcgil01.iachieved.it sysDescr.0<br \/>\nSNMPv2-MIB::sysDescr.0 = STRING: OpenWrt<br \/>\n[\/code]<\/p>\n<p>Perfect.  Add the device to Observium and watch it fill in the rest.<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2019\/09\/chcgil.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2019\/09\/chcgil.png\" alt=\"\" width=\"619\" height=\"380\" class=\"aligncenter size-full wp-image-3849\" \/><\/a><\/p>\n<p>Notice that the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tux_(mascot)\">Tux<\/a> logo has been replaced with the OpenWrt logo as Observium correctly identifies this device as running OpenWrt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Observium is a great application for monitoring network equipment, regardless of type (e.g., routers, switches, firewalls, etc.) What makes it so powerful is due in large part to the amount of information exposed by SNMP for network gear and its ability to intelligently parse the returned data and display it. This intelligence can only go [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3856,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[93,94],"class_list":["post-3843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-networking","tag-observium-openwrt","tag-observium-openwrt-snmp"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3843"}],"collection":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/comments?post=3843"}],"version-history":[{"count":8,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3843\/revisions"}],"predecessor-version":[{"id":3858,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3843\/revisions\/3858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media\/3856"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=3843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=3843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=3843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}