{"id":289,"date":"2009-04-10T16:14:11","date_gmt":"2009-04-10T14:14:11","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=289"},"modified":"2021-09-05T22:39:03","modified_gmt":"2021-09-05T20:39:03","slug":"monitor-as400-resources-mrtg","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html","title":{"rendered":"Monitoring AS400 Resources with SNMP"},"content":{"rendered":"\n<p>AS400 CPU and memory resources monitoring can be handled with the <a href=\"\/en\/tag\/snmp\">SNMP<\/a> protocol if SNMP service has been enabled. Values are not directly exploitable and need to be worked on before being displayed. All of these commands were executed on a Linux server. Check your Linux distribution to install snmpwalk, there&#8217;s a package for it most likely.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>CPU Monitoring with SNMP<\/h3>\n\n\n\n<p>It is recommended to monitor <a href=\"\/en\/tag\/ibm-i\">IBM i<\/a> CPU load with SNMP OID .1.3.6.1.4.1.2.6.4.5.1.0 that returns a value based on 10,000 units. It needs then to be divided by 100 to get a percentage.<br>The 2nd disadvantage is that the result is slightly wrong, the integer part only is being returned.<br>However, OID HOST-RESOURCES-MIB::hrProcessorLoad.2 from an IBM i gives the correct value in percentage.<\/p>\n\n\n\n<p>For instance:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">monitoring@server:~&gt; snmpwalk -c $COMMUNITY -v1 $AS400_IP .1.3.6.1.4.1.2.6.4.5.1.0;\nSNMPv2-SMI::enterprises.2.6.4.5.1.0 = Gauge32: 2380\nmonitoring@server:~&gt; snmpwalk -c $COMMUNITY -v1 $AS400_IP .1.3.6.1.2.1.25.3.3.1.2.2\nHOST-RESOURCES-MIB::hrProcessorLoad.2 = INTEGER: 24<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Memory Monitoring with SNMP<\/h3>\n\n\n\n<p>First, MaxBytes and max amount of memory can be retrieved with snmpwalk (in KB) with a bit of processing:<br>expr `snmpwalk -v1 -c $COMMUNITY $AS400_IP hrMemorySize.0 | awk &#8216;{ print $(NF-1) }&#8217;` \\* 1024<br>&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/images\/as400.mem-day.png\" alt=\"AS400 memory usage monitoring\"\/><\/figure>\n\n\n\n<p><br>Here is a shell script that computes memory usage from SNMP values (from Cacti forum). It is not a straightforward value as you can see.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">#!\/bin\/sh\nIP=$1\nCOMMUNITY=$2\nSNMP_VERSION=$3\n# RAM used\nNB_ELEMENTS=`snmpwalk -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageIndex \\\n| awk '{ print $NF }' | tail -n 1`\n\nRAM_USED=0\n\nfor i in `seq 1 $NB_ELEMENTS`; do\n  TYPE_ELEMENT=`snmpget -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageDescr.$i \\\n  | awk '{ print $NF }'`\n  if [ \"$TYPE_ELEMENT\" != \"RAM\" ]; then\n    continue\n  fi\n\n  BLOCK_SIZE=`snmpget -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageAllocationUnits.$i \\\n  | awk '{ print $(NF-1) }'`\n  NB_BLOCKS_USED=`snmpget -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageUsed.$i \\\n  | awk '{ print $NF }'`\n  RAM_USED=`expr $NB_BLOCKS_USED \\* $BLOCK_SIZE`\n  TOTAL_RAM_USED=`expr $TOTAL_RAM_USED + $RAM_USED`\ndone\n\nTOTAL_RAM_USED=`expr $TOTAL_RAM_USED`\n\necho $TOTAL_RAM_USED\necho $TOTAL_RAM_USED<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br>MRTG Configuration<\/h3>\n\n\n\n<p>The resulting MRTG configuration looks like the following. It will generate usage graphs like above. These AS400 values can of course be handled by any other monitoring tool that support the SNMP protocol such as <a href=\"https:\/\/www.zabbix.com\" target=\"_blank\" rel=\"noreferrer noopener\">Zabbix<\/a> or <a href=\"https:\/\/www.cacti.net\" target=\"_blank\" rel=\"noreferrer noopener\">Cacti<\/a> for example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\"># Standard method displays twice the same value\n# Target[AS400.cpu]:.1.3.6.1.2.1.25.3.3.1.2.2&amp;.1.3.6.1.2.1.25.3.3.1.2.2:COMMUNITY@IP\n# Or via a script as described <a href=\"\/en\/monitoring\/mrtg-graph-only-one-value.html\">here<\/a>\nTarget[AS400.cpu]:`\/home\/mrtg\/get-as400-cpu.sh IP COMMUNITY 1`\nRouterUptime[AS400.cpu]: COMMUNITY@IP\nMaxBytes[AS400.cpu]: 100\nTitle[AS400.cpu]: AS400 CPU Load\nPageTop[AS400.cpu]: &lt;H1&gt;AS400 CPU Load&lt;\/H1&gt;\nUnscaled[AS400.cpu]: ymwd\nShortLegend[AS400.cpu]: %\nYLegend[AS400.cpu]: CPU Utilization\nLegend1[AS400.cpu]: Active CPU Load\nLegendI[AS400.cpu]: CPU\nOptions[AS400.cpu]: growright,nopercent,gauge\nColours[AS400.cpu]: RED#e13c13,RED#e13c13,RED#e13c13,RED#e13c13\n\n# Same for memory usage\nTarget[AS400.mem]:`\/home\/mrtg\/get-as400-memory.sh IP COMMUNITY 1`\nRouterUptime[AS400.mem]: COMMUNITY@IP\nMaxBytes[AS400.mem]: 12129927168\nTitle[AS400.mem]: AS400 Memory Usage\nPageTop[AS400.mem]: &lt;H1&gt;AS400 Memory Usage&lt;\/H1&gt;\nUnscaled[AS400.mem]: ymwd\nYLegend[AS400.mem]: Memory Usage\nLegend1[AS400.mem]: Memory Usage\nLegendI[AS400.mem]: Memory\nOptions[AS400.mem]: growright,nopercent,gauge\nColours[AS400.mem]: ORANGE#F88017,ORANGE#F88017,ORANGE#F88017,ORANGE#F88017<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>AS400 CPU and memory resources monitoring can be handled with the SNMP protocol if SNMP service has been enabled. Values are not directly exploitable and need to be worked on before being displayed. All of these commands were executed on a Linux server. Check your Linux distribution to install snmpwalk, there&#8217;s a package for it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[210,202],"tags":[396,405,230,205,207],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Monitoring AS400 Resources with SNMP<\/title>\n<meta name=\"description\" content=\"Retrieve AS400 CPU and memory usage with the SNMP protocol for monitoring. Graph IBM i resources with tools like MRTG or Zabbix\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Monitoring AS400 Resources with SNMP\" \/>\n<meta property=\"og:description\" content=\"Retrieve AS400 CPU and memory usage with the SNMP protocol for monitoring. Graph IBM i resources with tools like MRTG or Zabbix\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2009-04-10T14:14:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-05T20:39:03+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html\",\"name\":\"Netexpertise - Monitoring AS400 Resources with SNMP\",\"isPartOf\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2009-04-10T14:14:11+00:00\",\"dateModified\":\"2021-09-05T20:39:03+00:00\",\"author\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"Retrieve AS400 CPU and memory usage with the SNMP protocol for monitoring. Graph IBM i resources with tools like MRTG or Zabbix\",\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Monitoring AS400 Resources with SNMP\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Monitoring AS400 Resources with SNMP","description":"Retrieve AS400 CPU and memory usage with the SNMP protocol for monitoring. Graph IBM i resources with tools like MRTG or Zabbix","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Monitoring AS400 Resources with SNMP","og_description":"Retrieve AS400 CPU and memory usage with the SNMP protocol for monitoring. Graph IBM i resources with tools like MRTG or Zabbix","og_url":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html","og_site_name":"Netexpertise","article_published_time":"2009-04-10T14:14:11+00:00","article_modified_time":"2021-09-05T20:39:03+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html","url":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html","name":"Netexpertise - Monitoring AS400 Resources with SNMP","isPartOf":{"@id":"http:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2009-04-10T14:14:11+00:00","dateModified":"2021-09-05T20:39:03+00:00","author":{"@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"Retrieve AS400 CPU and memory usage with the SNMP protocol for monitoring. Graph IBM i resources with tools like MRTG or Zabbix","breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/monitor-as400-resources-mrtg.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Monitoring AS400 Resources with SNMP"}]},{"@type":"WebSite","@id":"http:\/\/www.netexpertise.eu\/en\/#website","url":"http:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/289"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=289"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/289\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}