<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>brettdargan.com &#187; Monitoring</title>
	<atom:link href="http://brettdargan.com/blog/tag/monitoring/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettdargan.com/blog</link>
	<description>&#955; Thoughts and rants</description>
	<lastBuildDate>Fri, 28 May 2010 01:35:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using snmp through the layers</title>
		<link>http://brettdargan.com/blog/2005/10/18/using-snmp-through-the-layers/</link>
		<comments>http://brettdargan.com/blog/2005/10/18/using-snmp-through-the-layers/#comments</comments>
		<pubDate>Mon, 17 Oct 2005 15:54:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Stability, Performance and Monitoring]]></category>
		<category><![CDATA[Monitoring]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=54</guid>
		<description><![CDATA[For some time I've been working on a project where we need to improve monitoring of our web application. Recently that opportunity has been realised and I've been working with a few people to implement some of the patterns i discussed in System Management Patters. SNMP is a natural fit for publishing application statistics. The [...]]]></description>
			<content:encoded><![CDATA[<p>For some time I've been working on a project where we need to improve monitoring of our web application. Recently that opportunity has been realised and I've been working with a few people to implement some of the patterns i discussed in <a href="http://www.brettdargan.com/blog/archives/2005/07/performance_pat.html">System Management Patters</a>.</p>
<p>SNMP is a natural fit for publishing application statistics. The thing I don't like about existing snmp agent implementations is that they are all pretty language dependent and they are built on the old style, define a mib, crank a wheel to generate a template, then you finally get to add code for you metrics.</p>
<p>So firstly work has been done to have an agent publish statistics based on results from an xml stream. This has been built on top of <a href="http://pysnmp.sf.net">pysnmp</a>.</p>
<p>This allows us to have an agent on each device/box that can publish stats, regardless of language as long as you instrument the device in question (and you have a python 2.4 environment).</p>
<p>Once your stats are published, you will need a manager to gather them.<br />
While any SNMP manager can be used, often like with jffnms, you will need to write your own poller anyway. We've created an easily configurable pollers so a manager, can poll and update rrdtool database.</p>
<p>While some of the leg work is alleviated, you will still need to do the following: instrument your app, define your rrd datasources and optionally design your mib.</p>
<p>I'm currently looking at opensourcing this very shortly.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Using+snmp+through+the+layers+http%3A%2F%2Ftinyurl.com%2F69bp3lh" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Using+snmp+through+the+layers+http%3A%2F%2Ftinyurl.com%2F69bp3lh" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2005/10/18/using-snmp-through-the-layers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JVM Monitoring with SNMP</title>
		<link>http://brettdargan.com/blog/2005/04/01/jvm-monitoring-with-snmp/</link>
		<comments>http://brettdargan.com/blog/2005/04/01/jvm-monitoring-with-snmp/#comments</comments>
		<pubDate>Thu, 31 Mar 2005 19:30:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Stability, Performance and Monitoring]]></category>
		<category><![CDATA[Monitoring]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=42</guid>
		<description><![CDATA[One aspect of my described System Management Patterns includes gathering correlated metrics through the various layers of your system. Since SNMP is the defacto standard in monitoring. I used the SNMP aspects of the JVM. I never really got into SNMP before and since Tiger directly supports it, the time had come. The aim was [...]]]></description>
			<content:encoded><![CDATA[<p>One aspect of my described <a href="http://brettdargan.com/blog/2005/07/01/system-management-patterns/">System Management Patterns</a> includes gathering correlated metrics through the various layers of your system. Since SNMP is the defacto standard in monitoring. I used the SNMP aspects of the JVM. </p>
<p>I never really got into SNMP before and since Tiger directly supports it, the time had come.</p>
<p>The aim was to add our JVM to an existing monitoring system, <a href="http://jffnms.sf.net" title="Just for Fun Network Management System">jffnms</a>. </p>
<p>Being a newbie to SNMP I had a few setbacks than anticipated.</p>
<p>While the <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html">jconsole </a> is cool and useful, I wanted application/JVM monitoring to fit in with our existing monitoring tools and also for collected data to be nicely correlated with os and network stats.</p>
<p>Sun&apos;s <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/SNMP.html">SNMP guide</a> to enabling a port for monitoring is straight forward, but I found learning about snmp from google painful, and the best bits were hard to find.</p>
<p>If you've got/done the following then it will be easy to get started:
<ol>
<li><a href="net-snmp.sf.net">net-snmp</a> installed and read some doco on SNMP and MIBS, the net-snmp doco is better than most but has alot of fluff.
<li><a href="http://java.sun.com/j2se/1.5.0">tiger</a>
<li> have added followed the <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/SNMP.html">snmp monitoring setup</a> so you have a listenter and configure acl.
<li>and some kind of server to run
</ol>
<p>If any of the acl settings are wrong or file permissions aren't set correctly, the jvm won't start. </p>
<p>Once it is going you could double check, using netstat.</p>
<p>Now to use the snmp tools you will need to load in Sun's <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/JVM-MANAGEMENT-MIB.mib">JVM-MANAGEMENT-MIB</a></p>
<p>It's good practice to use <em>snmptranslate</em> first to see if there are any problems with the MIB definition, in particular any missing dependencies.</p>
<p><small><code>snmptranslate -M .:/usr/share/snmp/mibs -m JVM-MANAGEMENT-MIB -IR -Tp jvmMgtMIB</code></small></p>
<p>Assuming you are running this from the current directory where the new MIB is that command should work. -M is giving a search path for mibs and -m is telling is specifying which mibs we want to load. The final parameter, <em>jvmMgtMIB</em> is the module identity, you can see that inside the mib file.</p>
<p>You should see a tree view of the mib starting like this:<br />
+--jvmMgtMIB(1)<br />
   |<br />
   +--jvmMgtMIBObjects(1)<br />
   |  |<br />
   |  +--jvmClassLoading(1)<br />
   |  |  |<br />
   |  |  +-- -R-- Gauge     jvmClassesLoadedCount(1)<br />
   |  |  +-- -R-- Counter64 jvmClassesTotalLoadedCount(2)<br />
   |  |  +-- -R-- Counter64 jvmClassesUnloadedCount(3)<br />
   |  |  +-- -RW- EnumVal   jvmClassesVerboseLevel(4)<br />
...</p>
<p>And finally we can peek at some jvm stats, just plugin your port:</p>
<p><small><code>snmpwalk -v 2c -M .:/usr/share/snmp/mibs -m JVM-MANAGEMENT-MIB -c public localhost:port jvmMgtMIB</code></small></p>
<p>So in this snippet we are using snmp version 2c and still loading the sun mib. </p>
<p>You should see some results like this:<br />
...<br />
JVM-MANAGEMENT-MIB::jvmMemoryHeapInitSize.0 = Counter64: 838860800 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryHeapUsed.0 = Counter64: 39430568 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryHeapCommitted.0 = Counter64: 832438272 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryHeapMaxSize.0 = Counter64: 1664876544 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryNonHeapInitSize.0 = Counter64: 8552448 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryNonHeapUsed.0 = Counter64: 9260472 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryNonHeapCommitted.0 = Counter64: 9863168 bytes<br />
JVM-MANAGEMENT-MIB::jvmMemoryNonHeapMaxSize.0 = Counter64: 100663296 bytes<br />
...</p>
<p>To make this more useful you should install the mib properly, put it in with the others and update your ~/.snmp/snmp.conf file to have "mibs +JVM-MANAGEMENT-MIB". </p>
<p>One of the things I hated about getting started with SNMP were the misleading errors.<br />
Such as
<ul>
<li>snmpwalk: Timeout - can be caused by a bunch of things, like not specifying the correct version of snmp that you are trying to query!
<li>SNMPv2-SMI::mib-2 = No Such Object available on this agent at this OID - can be caused when you don't specify the OID, eg. jvmMgtMIB
</ul>
<p>Well writing this out takes too long, I'll have to figure out the <a href="http://jffnms.sf.net" title="Just for Fun Network Management System">jffnms</a> integration later.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=JVM+Monitoring+with+SNMP+http%3A%2F%2Ftinyurl.com%2F6x4jry3" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=JVM+Monitoring+with+SNMP+http%3A%2F%2Ftinyurl.com%2F6x4jry3" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2005/04/01/jvm-monitoring-with-snmp/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>What&#8217;s my server talking too?</title>
		<link>http://brettdargan.com/blog/2004/08/15/whats-my-server-talking-too/</link>
		<comments>http://brettdargan.com/blog/2004/08/15/whats-my-server-talking-too/#comments</comments>
		<pubDate>Sun, 15 Aug 2004 10:00:16 +0000</pubDate>
		<dc:creator>bdargan</dc:creator>
				<category><![CDATA[Monitoring]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=10</guid>
		<description><![CDATA[Every now and again things go wrong with resources and you want to narrow your search down quickly. Usually extra logging is turned on or added, but if your running in production in the heat of the moment that may not be an option. Also you may not have convenient access to monitor other servers [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and again things go wrong with <strong>resources</strong> and you want to narrow your search down quickly.</p>
<p>Usually extra logging is turned on or added, but if your running in production in the heat of the moment that may not be an option.</p>
<p>Also you may not have <strong>convenient access</strong> to monitor other servers involved. </p>
<p>I think socketcounting your server process is an under estimated technique for quickly seeing what your server process is connected too, or what is connecting to it. </p>
<p>socketcount &lt;server.pid&gt;</p>
<p>to sum connections per server/ip address from/to your server process.</p>
<p><code><br />
file:/usr/local/bin/socketcount<br />
#!/bin/bash</p>
<p>if [ $# -lt 1 ]<br />
then<br />
  echo "Usage:socketcount &lt;regex&gt;"<br />
  echo "regex is used to filter netstat output, ie. use pid"<br />
  exit 1<br />
fi<br />
export REGEX=$1<br />
export SNAPSHOT=/tmp/.netstat_snapshot$$<br />
#ip or name, has to be consistent with netstat command however</p>
<p>echo server pid = $REGEX, using temp file $SNAPSHOT<br />
#check all tcp connections except listeners if using local box<br />
#export NETSTAT_CMD="netstat -tnpa | grep ' $REGEX' | egrep -v '(LISTEN||^Proto||^\(Not)'"<br />
#echo "executing $NETSTAT_CMD"<br />
netstat -tpa | grep $REGEX | egrep -v 'LISTEN' &gt; $SNAPSHOT<br />
echo "------------------------------------"<br />
echo "Connections - this counts connections both ways, so running locally may appear weird."<br />
#echo "ServerConnections can be identified, by host and port."<br />
cat $SNAPSHOT | awk '{print $5}' | sort | awk -f /usr/local/bin/count-dups.awk<br />
</code></p>
<p>The socketcount file relies on the following awk script that sums up by hostname, it would be nice to keep it in one file, I'm sure there is an easier way to do it, but atleast it's readable.</p>
<p><code><br />
file:/usr/local/bin/count-dups.awk<br />
# expect single field for aggregation<br />
BEGIN{<br />
name=0;<br />
      count=0;<br />
      total=0}<br />
{<br />
if (name != $1) {<br />
    if (name != 0) {<br />
        total += count;<br />
        printf("%s = %d\n", name, count);<br />
        count = 1<br />
    }<br />
    name = $1<br />
    count = 1<br />
  }<br />
  else {<br />
    count++<br />
  }<br />
}<br />
END {<br />
  printf("%s = %d\n",name,count)<br />
  total += count<br />
  printf("Total = %d\n",total)<br />
}<br />
</code></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=What%E2%80%99s+my+server+talking+too%3F+http%3A%2F%2Ftinyurl.com%2F666z3to" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=What%E2%80%99s+my+server+talking+too%3F+http%3A%2F%2Ftinyurl.com%2F666z3to" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2004/08/15/whats-my-server-talking-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

