{"id":355,"date":"2010-12-27T23:05:00","date_gmt":"2010-12-27T23:05:00","guid":{"rendered":"http:\/\/zensonic.dk\/?p=355"},"modified":"2017-04-09T10:03:43","modified_gmt":"2017-04-09T10:03:43","slug":"graphing-data-obtained-from-the-zyxel-zynos-ras-interface-in-cacti","status":"publish","type":"post","link":"https:\/\/zensonic.dk\/?p=355","title":{"rendered":"Graphing data obtained from the zyxel zynos ras interface in cacti"},"content":{"rendered":"<p>After a brief IRC session on ADSL and noise levels with some former <a href=\"http:\/\/telia.dk\">colleagues<\/a>, I decided to graph the line quality of my ADSL connection using <a href=\"http:\/\/www.cacti.net\/\">cacti<\/a>. This blog post will briefly explain how to graph <strong>any<\/strong> data that can be obtained from the zyxel zynos ras interface. The data will be graphed using cacti and this blog assumes that a working cacti installation already is running.<\/p>\n<p>The task at hand can be split into two:<\/p>\n<ol>\n<li>Obtaining data from a zyxel device (a<a href=\"http:\/\/www.zyxel.com\/web\/product_family_detail.php?PC1indexflag=20040520161246&amp;CategoryGroupNo=35E87D65-4EB2-46BF-A25F-6DCA5D2DD5EA\"> P-2602R<\/a> in my case)<\/li>\n<li>Graphing the data in cacti<\/li>\n<\/ol>\n<h3>Obtaining data from a zyxel device<\/h3>\n<p>I attacked the first problem by doing an snmpwalk of the zyxel device. A normal consumer zyxel ADSL router like the P-2602R will export two MIB trees:<\/p>\n<ol>\n<li>The normal iso.3.6.1.2.1 tree<\/li>\n<li>The private iso.3.6.1.4.1.890 tree<\/li>\n<\/ol>\n<p>This can be seen by doing a normal SNMP walk of the device:<\/p>\n<div class=\"codesnip-container\" >\n<div class=\"text codesnip\" style=\"font-family:monospace;\">edison% &nbsp;snmpwalk -v1 -c public 192.168.1.1 | head -2<br \/>\niso.3.6.1.2.1.1.1.0 = STRING: &quot;P-2602R-D1A&quot;<br \/>\niso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.890<\/div>\n<\/div>\n<p>A quick browse of the two MIB trees made it clear that not all values and parameters inside zynos was exported through SNMP.\u00c2\u00a0 I had to find another way of obtaining the values that I needed.<\/p>\n<p>Besides utilizing SNMP one, can make a telnet session to the zyxel device, whereby you end up at a RAS prompt. From there you can interface and control a zyxel device in great detail. You will probably need a password for this to work. Living in denmark, having <a href=\"http:\/\/www.telenor.dk\/\">telenor<\/a> as my ISP,\u00c2\u00a0 it is actually fairly easy as I, as\u00c2\u00a0 a customer, has access to all the information needed, ie. ipaddress of the ADSL router, the password and port information. Using this information, I logged into the router<\/p>\n<div class=\"codesnip-container\" >\n<div class=\"text codesnip\" style=\"font-family:monospace;\">telnet 192.168.1.1 23023<br \/>\nTrying 192.168.1.1&#8230;<br \/>\nConnected to 192.168.1.1.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\nPassword: **********<\/p>\n<p>Copyright (c) 1994 &#8211; 2008 ZyXEL Communications Corp.<\/p>\n<p>ras&amp;gt;<\/p>\n<\/div>\n<\/div>\n<p>From there it was fairly easy to find the information that I was looking for<\/p>\n<div class=\"codesnip-container\" >\n<div class=\"text codesnip\" style=\"font-family:monospace;\">ras&amp;gt; wan adsl linedata near<br \/>\nnoise margin downstream: 22 db<br \/>\noutput power upstream: 15 db<br \/>\nattenuation downstream: 12 db<\/div>\n<\/div>\n<p>Now I just needed be able to do this automatically. I used the unix tool <a href=\"http:\/\/en.wikipedia.org\/wiki\/Expect\">expect<\/a> in the form of the nice and easy to use <a href=\"http:\/\/search.cpan.org\/~rgiersig\/Expect\/Expect.pod\">Expect.pm<\/a> perl module. After 15-20 minutes of coding, I ended up with a <a href=\"https:\/\/zensonic.dk\/wp-content\/uploads\/query_zynos_ras.pl\">little script<\/a> that will fetch whatever values from the zynos ras prompt your heart desires in one go. Example usage of the script (XXXXXXX denotes the secret password)<\/p>\n<div class=\"codesnip-container\" >\n<div class=\"text codesnip\" style=\"font-family:monospace;\">edison% .\/query_zynos_ras.pl 192.168.1.1 23023 XXXXXXXX &quot;wan adsl &nbsp;linedata near&quot; &quot;noise margin downstream:&quot; &quot;attenuation downstream:&quot;<\/p>\n<p>noise:22 attenuation:12<\/p>\n<\/div>\n<\/div>\n<h3>Graphing the data in cacti<\/h3>\n<p>Now that the data collection had been scripted the data had to be graphed in cacti. This involved defining<\/p>\n<ul>\n<li>a data input method<\/li>\n<li>a data template and<\/li>\n<li>a graph template.<\/li>\n<\/ul>\n<p>Quick and dirty screendumps on how to do it:<\/p>\n<p style=\"text-align: center;\">\n<div id=\"attachment_410\" class=\"wp-caption aligncenter\" style=\"width: 471px\"><a href=\"https:\/\/zensonic.dk\/wp-content\/uploads\/data_input_method2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-410  \" title=\"data_input_method\" src=\"https:\/\/zensonic.dk\/wp-content\/uploads\/data_input_method2.png\" alt=\"\" width=\"461\" height=\"288\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">data input method<\/p>\n<\/div>\n<p style=\"text-align: center;\">\n<div id=\"attachment_394\" class=\"wp-caption aligncenter\" style=\"width: 471px\"><a href=\"https:\/\/zensonic.dk\/wp-content\/uploads\/data_template.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-394  \" title=\"data_template\" src=\"https:\/\/zensonic.dk\/wp-content\/uploads\/data_template.png\" alt=\"\" width=\"461\" height=\"288\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">data template<\/p>\n<\/div>\n<div id=\"attachment_396\" class=\"wp-caption aligncenter\" style=\"width: 471px\"><a href=\"https:\/\/zensonic.dk\/wp-content\/uploads\/graph_template.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-396  \" title=\"graph_template\" src=\"https:\/\/zensonic.dk\/wp-content\/uploads\/graph_template.png\" alt=\"\" width=\"461\" height=\"288\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">graph template<\/p>\n<\/div>\n<p>After a day or so, you get a graph like the following<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/zensonic.dk\/wp-content\/uploads\/adsl1.png\"><\/a><a href=\"https:\/\/zensonic.dk\/wp-content\/uploads\/adsl2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-405\" title=\"adsl\" src=\"https:\/\/zensonic.dk\/wp-content\/uploads\/adsl2.png\" alt=\"\" width=\"384\" height=\"166\" \/><\/a><\/p>\n<p>From the graph I could see that my telephone line is very stable and that I should be able <a href=\"http:\/\/ar7.wikispaces.com\/ModemStatus\">to get far better speeds<\/a> if my current employer would pay telenor to provide it to me.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a brief IRC session on ADSL and noise levels with some former colleagues, I decided to graph the line quality of my ADSL connection using cacti. This blog post will briefly explain how to graph any data that can be obtained from the zyxel zynos ras interface. The data will be graphed using cacti [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,19,21,6],"tags":[],"class_list":["post-355","post","type-post","status-publish","format-standard","hentry","category-cacti","category-linux-lvm","category-monitoring","category-unix"],"_links":{"self":[{"href":"https:\/\/zensonic.dk\/index.php?rest_route=\/wp\/v2\/posts\/355"}],"collection":[{"href":"https:\/\/zensonic.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zensonic.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zensonic.dk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zensonic.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355"}],"version-history":[{"count":0,"href":"https:\/\/zensonic.dk\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions"}],"wp:attachment":[{"href":"https:\/\/zensonic.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zensonic.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zensonic.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}