{"id":2900,"date":"2016-05-05T22:56:00","date_gmt":"2016-05-05T13:56:00","guid":{"rendered":"http:\/\/tsaitoh.net\/wp\/2016\/05\/05\/g-240w-b-munin\/"},"modified":"2025-11-02T08:43:43","modified_gmt":"2025-11-01T23:43:43","slug":"g-240w-b-munin","status":"publish","type":"post","link":"https:\/\/tsaitoh.net\/wp\/2016\/05\/05\/g-240w-b-munin\/","title":{"rendered":"G-240W-B \u306e Munin \u30d7\u30e9\u30b0\u30a4\u30f3"},"content":{"rendered":"<p>\u81ea\u5b85\u306e\u5149\u901a\u4fe1\u5316\u306b\u3088\u308a\u3001\u65b0\u3057\u3044\u30eb\u30fc\u30bf\u304c\u5165\u3063\u305f\u304c\u3001\u30d1\u30b1\u30c3\u30c8\u6d41\u91cf\u6e2c\u5b9a\u306e \u305f\u3081\u306e Munin \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u30eb\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u53d6\u5f97\u306e\u305f\u3081\u3001\u30eb\u30fc\u30bf\u306e\u300cLAN\u72b6\u614b\u300d\u306e\u30da\u30fc\u30b8\u306eHTML\u3092\u89b3\u5bdf\u3057\u306a\u304c\u3089\u3001 Cookie\u306b\u3088\u308b\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u6271\u3044\u306a\u304c\u3089\u30d1\u30b1\u30c3\u30c8\u6d41\u91cf\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u308bPerl\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a18\u8ff0\u3002 Perl \u3067\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u307e\u305f\u304c\u3063\u305f\u30c7\u30fc\u30bf\u53d6\u5f97\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3044\u3044\u7df4\u7fd2\u306b\u306a\u3063\u305f\u304b\u306a\u3002<\/p>\n<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" src=\"\/~t-saitoh\/etc\/2016\/1605060900-ftth-gpon.png\" width=\"420\" height=\"267\" \/><\/div>\n<p>\u30eb\u30fc\u30bf\u304b\u3089\u306f\u3001Packets* \u3068 Bytes* \u304c\u53d6\u5f97\u3067\u304d\u308b\u3051\u3069\u3001 Bytes \u3060\u3068\u3001Munin\u306e\u6e2c\u5b9a\u5468\u671f5\u5206\u3067\u3001\u7c21\u5358\u306b 2^32 \u3092\u8d85\u3048\u3061\u3083\u3046\u3088\u3046\u3067\u3001 \u4f7f\u3044\u7269\u306b\u306a\u3089\u306a\u3044\u307f\u305f\u3044\u3002BPS \u304c\u76f4\u611f\u7684\u3060\u304b\u3089\u3001Bytes&#8230;\u306b\u5909\u66f4\u3057\u305f\u3051\u3069\u3001 \u3059\u3050\u306b\u5143\u306b\u623b\u3059\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">#!\/usr\/bin\/perl\r\n#%# family=auto\r\n#%# capabilities=autoconf\r\nuse LWP::UserAgent ;\r\nuse HTTP::Cookies ;\r\n# \u30eb\u30fc\u30bf\u60c5\u5831\r\nmy $router = \"http:\/\/192.168.1.254\" ;\r\nmy $auth = [ 'name' =&gt; \"userAdmin\" ,\r\n             'pswd' =&gt; \"xxxxxxxxxxxx\"\r\n           ] ;\r\n# Munin \u306e\u30b0\u30e9\u30d5\u60c5\u5831\u306e\u8a2d\u5b9a\u7528\u51e6\u7406\r\nif ( defined($ARGV[0]) and $ARGV[0] eq \"config\" ) {\r\n   # \u30b0\u30e9\u30d5\u306e\u57fa\u672c\u60c5\u5831\r\n   print \"graph_title FTTH GPON network statics\\n\" ;\r\n   print \"graph_category network\\n\" ;\r\n   print \"graph_vlabel packet\/sec (-)send \/ (+)recv\\n\" ;\r\n   print \"graph_args --base 1024\\n\" ;\r\n   print \"graph_printf %4.1lf\\n\" ;\r\n   # LAN1..LAN4\r\n   for( my $i = 1 ; $i &lt;= 4 ; $i++ ) {\r\n      foreach my $sr ( \"Sent\" , \"Received\" ) {\r\n         print \"LAN$i$sr.label LAN$i pkt\\n\" ;\r\n         print \"LAN$i$sr.type COUNTER\\n\" ;\r\n         if ( $sr eq \"Sent\" ) {\r\n            print \"LAN$i$sr.graph no\\n\" ;\r\n         } else {\r\n            print \"LAN$i$sr.draw LINE2\\n\" ;\r\n            print \"LAN$i$sr.negative LAN${i}Sent\\n\" ;\r\n         }\r\n         print \"LAN$i$sr.max 1000000\\n\" ;\r\n      }\r\n   }\r\n   exit 0 ;\r\n}\r\n# \u30eb\u30fc\u30bf\u306b login\r\nmy $ua = LWP::UserAgent-&gt;new ;\r\nmy $cookie = new HTTP::Cookies() ;\r\n$ua-&gt;cookie_jar( $cookie ) ;\r\nmy $res = $ua-&gt;post( \"$router\/login.cgi\" , $auth ) ;\r\nif ( $res-&gt;is_redirect ) {\r\n   # LAN\u60c5\u5831\u3092\u53d6\u5f97\r\n   $res = $ua-&gt;get( \"$router\/lan_status.cgi?lan\" ) ;\r\n   my $flag = 0 ;\r\n   my $lan_id = 0 ;\r\n   foreach my $line( split( \/\\n\/ , $res-&gt;content ) ) {\r\n      if ( $line =~ \/^\\s+var\\s+lan_ether=\/ ) {\r\n         # \"var lan_ether=\"\u3092\u63a2\u3059\r\n         $flag = 1 ;\r\n      } elsif ( $flag &amp;&amp; $line =~ \/^(|,)(\\d+):\\{\/ ) {\r\n         # LAN\u756a\u53f7\u3092\u53d6\u5f97\r\n         $lan_id = $2 ;\r\n      } elsif ( $flag &amp;&amp; $line =~ \/^Packets(Sent|Received):(\\d+),$\/ ) {\r\n         # PacketsSent \/ PacketsReceived\r\n         print \"LAN$lan_id$1.value $2\\n\" ;\r\n      } elsif ( $flag &amp;&amp; $line =~ \/^;$\/ ) {\r\n         last ;\r\n      }\r\n   }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5b85\u306e\u5149\u901a\u4fe1\u5316\u306b\u3088\u308a\u3001\u65b0\u3057\u3044\u30eb\u30fc\u30bf\u304c\u5165\u3063\u305f\u304c\u3001\u30d1\u30b1\u30c3\u30c8\u6d41\u91cf\u6e2c\u5b9a\u306e \u305f\u3081\u306e Munin \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3002 \u30eb\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u53d6\u5f97\u306e\u305f\u3081\u3001\u30eb\u30fc\u30bf\u306e\u300cLAN\u72b6\u614b\u300d\u306e\u30da\u30fc\u30b8\u306eHTML\u3092\u89b3\u5bdf\u3057\u306a\u304c\u3089\u3001 Cookie\u306b\u3088\u308b\u30bb\u30c3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-2900","post","type-post","status-publish","format-standard","hentry","category-network"],"_links":{"self":[{"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/posts\/2900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/comments?post=2900"}],"version-history":[{"count":0,"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/posts\/2900\/revisions"}],"wp:attachment":[{"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/media?parent=2900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/categories?post=2900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tsaitoh.net\/wp\/wp-json\/wp\/v2\/tags?post=2900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}