If you're using ganglia to monitor web servers, you might find this
script useful.  It runs netstat, counts connections on port 80, and
breaks them down by TCP state (ESTABLISHED, TIME_WAIT, etc.) and feeds
each of those to ganglia as a separate metric.

  http://thwip.sysadmin.org/netconncnt

You may need to slightly modify the list of states at the beginning to
match your OS - for example, your version of netstat may report
connections in SYN_RCVD rather than SYN_RECV.

It can also be easily modified for any other sort of server where you
want to keep track of the number of network connections.  Just change
$filter at the beginning from ":80" to some other substring that picks
out the connections you want to count, and change my $metric near the
end to change the basename from "net_port80_" to something more
suitable (like "net_mysql_").

I use it in conjuction with this graph definition I added to graph.php:

      else if ($graph == "net_port80")
        {
          $style = "Port 80 Connections";
          $lower_limit = "--lower-limit 0 --rigid";
          # $upper_limit = "--upper-limit 20";
          $extras = "--base 1024";
          $vertical_label = "--vertical-label 'Connections'";

          $series =
          
"DEF:'established'='${rrd_dir}/net_port80_established.rrd':'sum':AVERAGE
          "
            
."DEF:'closewait'='${rrd_dir}/net_port80_close_wait.rrd':'sum':AVERAGE "
            ."DEF:'closing'='${rrd_dir}/net_port80_closing.rrd':'sum':AVERAGE "
            
."DEF:'finwait1'='${rrd_dir}/net_port80_fin_wait1.rrd':'sum':AVERAGE "
            
."DEF:'finwait2'='${rrd_dir}/net_port80_fin_wait2.rrd':'sum':AVERAGE "
            ."DEF:'synsent'='${rrd_dir}/net_port80_syn_sent.rrd':'sum':AVERAGE "
            ."DEF:'synrecv'='${rrd_dir}/net_port80_syn_recv.rrd':'sum':AVERAGE "
            ."DEF:'lastack'='${rrd_dir}/net_port80_last_ack.rrd':'sum':AVERAGE "
            
."DEF:'timewait'='${rrd_dir}/net_port80_time_wait.rrd':'sum':AVERAGE "
            ."CDEF:'tw10'=timewait,10,/ "
            ."AREA:'tw10'#d0d0d0:'time_wait/10' "
            ."LINE1:'lastack'#303030:'last_ack' "
            ."LINE1:'closing'#e82828:'closing' "
            ."LINE1:'closewait'#600000:'close_wait' "
            ."LINE1:'synsent'#b00000:'syn_sent' "
            ."LINE1:'finwait1'#00a020:'fin_wait1' "
            ."LINE1:'synrecv'#662288:'SYN_RECV' "
            ."LINE2:'finwait2'#00c060:'FIN_WAIT2' "
            ."LINE2:'established'#0000c0:'ESTABLISHED' ";
        }


  --  Cos (Ofer Inbar)  --  [EMAIL PROTECTED]
   "A distributed system is one in which I cannot get any work done
    because a machine I've never heard of is down" -- Leslie Lamport

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Ganglia-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-general

Reply via email to