Hello All,

We have made some changes in ganglia-php-rrd-client-1.0.4.

Add:
       -You can selection range on host.php
       -Network graph on host.php and index.php
       -Network general load (in + out) in the "Cluster Overview"
       -moved $rrd_dir and $rrdtool from graph.php to ganglia.php

network.sh must be run in a while on every node.

If you use a Mandrake8.2 you can install the rpm from cooker:
ganglia-monitor-core-2.4.1-3mdk.i586.rpm
ganglia-monitor-script-2.4.1-3mdk.i586.rpm
libganglia-monitor1-devel-2.4.1-3mdk.i586.rpm

The patch will be add in our ganglia-php-rrd-client-1.0.4 rpm.


Gonéri Le Bouder <[EMAIL PROTECTED]>
                 <[EMAIL PROTECTED]>
#Add:
#	-You can selection range on host.php
#	-Network graph on host.php and index.php
#	-Network general load (in + out) in the "Cluster Overview"
#	-moved $rrd_dir and $rrdtool from graph.php to ganglia.php
#Gonéri Le Bouder <[EMAIL PROTECTED]>

diff -r -u -u web/ganglia.php web.new/ganglia.php
--- web/ganglia.php	Tue Jun  4 16:27:57 2002
+++ web.new/ganglia.php	Tue Jun  4 16:23:59 2002
@@ -28,6 +28,16 @@
  *
  * args: none
  */
+
+
+# you ganglia-rrd.pl script
+$rrd_dir = "/var/www/html/ganglia/rrds";
+
+# The location of your rrdtool binary
+$rrdtool = "/usr/bin/rrdtool";
+
+
+
 function ganglia_error_string()
    {
       global $__ganglia_error_stack; 
diff -r -u -u web/graph.php web.new/graph.php
--- web/graph.php	Tue Jun  4 16:27:57 2002
+++ web.new/graph.php	Tue Jun  4 16:25:32 2002
@@ -1,11 +1,15 @@
 <?
 
 # This must be set to the same value as the $rrd_dir in 
+
+# I put that in ganglia.php
 # you ganglia-rrd.pl script
-$rrd_dir = "/var/log/ganglia/rrds";
+# $rrd_dir = "/var/www/html/ganglia/rrds";
 
 # The location of your rrdtool binary
-$rrdtool = "/usr/local/rrdtool-1.0.33/bin/rrdtool";
+# $rrdtool = "/usr/bin/rrdtool";
+include "ganglia.php";
+
 
 # End configuration options 
 #
@@ -192,8 +196,42 @@
                ."LINE2:'num_nodes'#FF0000:'Total Number of Hosts' "
                ."LINE2:'cpu_num'#0000FF:'Total Number of Processors' ";
          }    
-      else
+	else if ($graph == "netload")
+         {
+	   $command = "$rrdtool graph - --start $start --end N "
+               ."--width $width --height $height "
+               ."--lower-limit 0 "
+               ."--title 'Network Interface ($interface) load $range' "
+	       #."--upper-limit 1500000 --lower-limit 0 --rigid "
+	       ."--lower-limit 0 --rigid "
+               ."--vertical-label b/s "
+               ."DEF:'num_nodes'='${rrd_dir}/${host}-$interface in.rrd':'ganglia':AVERAGE "
+               ."DEF:'cpu_num'='${rrd_dir}/${host}-$interface out.rrd':'ganglia':AVERAGE "
+               ."LINE2:'num_nodes'#FF0000:'in' "
+               ."LINE2:'cpu_num'#0000FF:'out' ";
+         }    
+	else if ($graph == "generalnetload")
          {
+	   $command = "$rrdtool graph - --start $start --end N "
+            
+               ."--width $width --height $height "
+               ."--title '$host network load last $range' "
+               ."--vertical-label 'b/s' "
+               ."DEF:'proc_total'='${rrd_dir}/${host}-network_load.rrd':'ganglia':AVERAGE "
+               ."AREA:'proc_total'#FF0000:'network load' ";
+           
+	  /* ."--width $width --height $height "
+               ."--lower-limit 0 "
+               ."--title 'Network General load $range' "
+	       ."--lower-limit 0 --rigid "
+               ."--vertical-label b/s "
+               ."DEF:'num_nodes'='${rrd_dir}/network_load.rrd':'ganglia':AVERAGE "
+               ."DEF:'cpu_num'='${rrd_dir}/network.rrd':'ganglia':AVERAGE "
+               ."LINE2:'num_nodes'#FF0000:'in' "
+               ."LINE2:'cpu_num'#0000FF:'out' "; */
+         }  
+	else	 
+	 {
             /* Got a strange value for $graph */
             exit();
          }   
diff -r -u -u web/host.php web.new/host.php
--- web/host.php	Tue Jun  4 16:27:57 2002
+++ web.new/host.php	Tue Jun  4 16:26:56 2002
@@ -26,6 +26,24 @@
 header ("Pragma: no-cache");                          // HTTP/1.0
 include "ganglia.php";
 
+
+
+$blueish = "#D0D0FF";
+
+/* Set the defaults */
+/*if (! isset($metric) )
+   {
+      $metric = "load_one";
+   }*/
+if (! isset($refresh) )
+   {
+      $refresh = 0;
+   }
+if (! isset($range) )
+   {
+      $range = "hour";
+   }
+
 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
 print "<HTML>\n";
 print "<HEAD>\n";
@@ -33,12 +51,15 @@
 print "<META http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">\n";
 if ($refresh > 0 )
    {
-      print "<META http-equiv=\"refresh\" content=\"$refresh URL=\"$PHP_SELF?$QUERY_STRING\">\n";
-   } 
+      print "<META http-equiv=\"refresh\" content=\"$refresh URL=\"$PHP_SELF?refresh=$refresh\">\n";
+   }
 print "</HEAD>\n";
 print "<BODY BGCOLOR=\"#FFFFFF\">\n";
 
-print "<TABLE WIDTH=\"100%\"><TR><TD VALIGN=\"TOP\" ALIGN=\"LEFT\" COLSPAN=\"2\">\n";
+print "<TABLE BORDER=\"0\" CELLPADDING=\"5\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
+print "<TR>\n";
+print "<TD VALIGN=\"TOP\" ALIGN=\"CENTER\" WIDTH=\"100%\">\n";
+
 ?>
 
 <TABLE WIDTH="100%" BORDER="3">
@@ -46,12 +67,78 @@
 <TD VALIGN="MIDDLE" ALIGN="CENTER">
 <A HREF="http://ganglia.sourceforge.net/";>
 <IMG SRC="logo.jpg" ALT="http://ganglia.sourceforge.net/";
-     HEIGHT="79" WIDTH="140" BORDER="0"></A>
+     HEIGHT="79" WIDTH="140" BORDER="0"><BR></A>
 </TD>
-<TD VALIGN="MIDDLE" ALIGN="CENTER">
-<FONT SIZE="+3"><?print "<B>$host</B><BR> ($__ganglia_hosts[$host])" ;?><BR>
+<TD VALIGN="MIDDLE" ALIGN="CENTER" BGCOLOR="#CCCCCC">
+
+<FORM ACTION="<?echo "$PHP_SELF?host=$host&amp;";?>" METHOD="POST" NAME="ganglia_form">
+<TABLE WIDTH="100%">
+<TR>
+<TD COLSPAN="4" ALIGN="CENTER">
+<B><FONT SIZE="+1">
+Ganglia Control Panel (<?print "v$__ganglia_version";?>)
+
 </FONT>
+</B>
+<HR SIZE="1" NOSHADE>
 </TD>
+</TR>
+<TR>
+<TD ALIGN="RIGHT"><B>Range:</B></TD>
+<TD>
+<SELECT NAME="range" OnChange="ganglia_form.submit();">
+<?
+   $ranges = array("hour","day","week","month","year");
+   foreach ( $ranges as $v )
+      {
+         print "<OPTION VALUE=\"$v\" ";
+         if ($v == $range )
+            {
+               print "SELECTED";
+            }
+         print ">last $v\n";
+      }
+?>
+</SELECT>
+</TD>
+<TD COLSPAN="2" ALIGN="CENTER">
+<INPUT TYPE="SUBMIT" VALUE="Reload Page with Fresh Data"><BR>
+<FONT SIZE="-1">Last update: <B><?echo date("D h:i:s a")?></B></FONT>
+<?
+/* We'll add this later 
+<B>Auto Refresh:</B></TD>
+<TD>
+<SELECT NAME="refresh" OnChange="ganglia_form.submit();">
+   $refresh_rates = array("0","15","30","45","60","300");
+   foreach ( $refresh_rates as $v )
+      {
+         print "<OPTION VALUE=\"$v\" ";
+         if ($v == $refresh)
+            {
+               print "SELECTED";
+            }
+         if ($v == "0")
+            {
+               print ">Off\n";
+            }
+         else
+            {
+               print ">every $v secs\n";      
+            }
+      }
+</SELECT> */
+?>
+
+</TD>
+</TR>
+</TABLE>
+</FORM>
+
+</TD>
+<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="20%">
+
+<TABLE WIDTH="100%">
+
 <TD WIDTH="15%" ALIGN="LEFT" VALIGN="TOP">
 <FONT SIZE="+1">Host Status:</FONT> 
 <?
@@ -66,9 +153,71 @@
 ?>
 <BR>
 Last Reported <?echo date("F j, Y, g:i a", $__ganglia_last_reported[$host]);?>
+<BR>
+<?
+print "<B>$host</B>";
+print "<BR>";
+print $__ganglia_hosts_up[$host];
+
+?>
 </TD>
 </TR>
-</TABLE>
+
+<TR>
+<TD>
+<?/*
+if ( is_array($a) && sizeof($a) )
+   {
+      print "<FONT COLOR=\"#FF0000\">\n";
+      print "<B>There are ".sizeof($a)." hosts down</B><BR>";
+      print "</FONT>\n";
+      print "<FONT SIZE=\"-1\">(Most recent crashes at the top)</FONT>\n";
+      ksort($a);
+      reset($a);
+      while( list($k, $v) = each($a) )
+         {
+            $lr[$k] = $__ganglia_last_reported[$k];
+         }
+      arsort($lr);
+      print "<FORM ACTION=\"host.php\" METHOD=\"GET\" NAME=\"host_down\">\n";
+      print "<SELECT NAME=\"host\" OnChange=\"host_down.submit();\">\n";
+      print "<OPTION VALUE=\"none\">--Click here for list of hosts--\n";
+      while( list($k, $v) = each($lr) )
+         {
+            $v = strftime("%A %r %D", $v);
+            print "<OPTION VALUE=\"$k\">$k\n";
+            #print "<A HREF=\"host.php?host=$k\">$k</A> ($v)\n";
+         } 
+      print "</SELECT>\n";
+      print "<BR>\n";
+      print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Go to the host detail page\">\n";
+      print "</FORM>\n";
+   }       
+else
+   {
+      print "All nodes are reporting on the ganglia cluster multicast channel\n";
+   }
+
+*/
+?>
+</TD></TR></TABLE>
+
+</TD>
+</TR></TABLE>
+<HR SIZE="1" NOSHADE>
+<TABLE WIDTH="100%">
+<TR>
+<TD COLSPAN="2" ALIGN="CENTER" BGCOLOR="<?echo $blueish;?>">
+<B><FONT SIZE="+2">Cluster Overview</FONT></B>
+</TD>
+</TR>
+
+
+
+
+
+
+
 <CENTER>
 <B>
 <FONT SIZE="+1">
@@ -121,14 +270,24 @@
    }
 print "</TABLE>\n";
 print "</TD><TD ALIGN=\"CENTER\" VALIGN=\"TOP\">\n";
-print "<IMG SRC=\"graph.php?graph=load&amp;host=$host\" ALT=\"$host LOAD\" ";
+print "<IMG SRC=\"graph.php?graph=load&amp;host=$host&amp;range=$range&amp\" ALT=\"$host LOAD\" ";
 print "HEIGHT=\"172\" WIDTH=\"495\"><BR>";
-print "<IMG SRC=\"graph.php?graph=cpu&amp;host=$host\" ALT=\"$host CPU\" ";
+print "<IMG SRC=\"graph.php?graph=cpu&amp;host=$host&amp;range=$range&amp\" ALT=\"$host CPU\" ";
 print "HEIGHT=\"172\" WIDTH=\"495\"><BR>";
-print "<IMG SRC=\"graph.php?graph=mem&amp;host=$host\" ALT=\"$host MEM\" ";
+print "<IMG SRC=\"graph.php?graph=mem&amp;host=$host&amp;range=$range&amp\" ALT=\"$host MEM\" ";
 print "HEIGHT=\"185\" WIDTH=\"495\"><BR>";
-print "<IMG SRC=\"graph.php?graph=procs&amp;host=$host\" ALT=\"$host PROCESSES\" ";
+print "<IMG SRC=\"graph.php?graph=procs&amp;host=$host&amp;range=$range&amp\" ALT=\"$host PROCESSES\" ";
 print "HEIGHT=\"172\" WIDTH=\"495\"><BR>";
+
+$if=0;
+while(file_exists("$rrd_dir/$host-eth$if out.rrd"))
+	{
+	print "<IMG SRC=\"graph.php?graph=netload&amp;host=$host&amp;range=$range&amp;interface=eth$if&amp\" ALT=\"$host NETLOAD\" ";
+
+	print "HEIGHT=\"172\" WIDTH=\"495\"><BR>";
+$if++;
+}
+
 print "</TD></TR></TABLE>\n";
 
 ?>
diff -r -u -u web/index.php web.new/index.php
--- web/index.php	Tue Jun  4 16:27:57 2002
+++ web.new/index.php	Tue Jun  4 16:16:43 2002
@@ -335,8 +335,31 @@
 </B>
 </TD>
 </TR>
-</TABLE>
 
+<TR>
+<TD ALIGN="CENTER" VALIGN="MIDDLE">
+
+<IMG SRC="graph.php?graph=generalnetload&amp;size=medium&amp;range=<?echo $range;?>"
+     HEIGHT="160" WIDTH="395" ALT="General netload"><BR>
+<?
+$network_sum = ganglia_cluster_reduce("network_load", ganglia_sum) + ganglia_cluster_reduce("network_load", ganglia_sum);
+
+$mem_free = sprintf("%.2f", $mem_free / 1048576);
+
+?>
+<B>
+general network load: <FONT COLOR="#FF0000"><?echo $network_sum;?></FONT>b/s
+</B>
+
+
+</TD>
+
+<TD ALIGN="CENTER" VALIGN="MIDDLE">
+<?
+#You can put another graph here
+?>
+</TR>
+</TABLE>
 
 </TD></TR><TR><TD>
 
#!/bin/bash
#contributed by Andrei Chevel 
#contributed by Fredrik Steen
#contributed by Gonéri Le Bouder <[EMAIL PROTECTED]>


TOP=/usr/bin/top
AWK=/bin/awk
GMETRIC=/usr/bin/gmetric
RM=/bin/rm

$TOP -ibn 1 | $AWK /COMMAND/,/++++++++++/ | head -2 | tail -1 > /tmp/t$$

$GMETRIC --name UserTime  --value `$AWK '{print($11)}' /tmp/t$$`  --type string  --units 'min:sec'
$GMETRIC --name UserProg  --value `$AWK '{print($12)}' /tmp/t$$`  --type string  --units 'name'
$GMETRIC --name UserCPU   --value `$AWK '{print($9)}'  /tmp/t$$`  --type float   --units '%'
$GMETRIC --name UserTime  --value `$AWK '{print($11)}' /tmp/t$$`  --type string  --units 'min:sec'

$RM -f /tmp/t$$

NBRE=1
# For each network interface
for i in `cat /proc/net/dev | grep eth | wc -l`
do
        NBRE=`expr $NBRE - 1`
INTERFACE=eth$NBRE

OUT=`grep $INTERFACE /proc/net/dev | awk -F\: '{print($2)}' | awk '{print($9)}'`
IN=`grep $INTERFACE /proc/net/dev | awk -F\: '{print($2)}' | awk '{print($1)}'`

sleep 1

let OUT=(`grep $INTERFACE /proc/net/dev | awk -F\: '{print($2)}' | awk '{print($9)}'`-$OUT)
let IN=(`grep $INTERFACE /proc/net/dev | awk -F\: '{print($2)}' | awk '{print($1)}'`-$IN)

$GMETRIC --name "$INTERFACE out"  --value $OUT --type uint32 --units 'b/s'

$GMETRIC --name "$INTERFACE in"  --value $IN --type uint32 --units 'b/s'


$GMETRIC -t uint16 -n TCP_ESTABLISHED -v `/bin/netstat -t -n|egrep "ESTABLISHED"|wc -l`

done

Attachment: signature.asc
Description: PGP signature

Reply via email to