Re: Page stats in multiload applet



Den 11 Jul 2001 16:49:49 +0200, skrev Kjartan Maraas:
> Hi.
> 
> I recently found a patch in bugzilla to add page stats to the multiload
> applet. The only problem was that it was for an ancient version of
> gnome-applets(1.0.55). I tried updating it to the current release but it
> fails on load. Can someone please help finding the bugs in it?
> 
> multiload-page-new.diff (my updated version)
> multiload-page-orig.diff (the one from bugzilla)
> 
> I don't remember the name of the author of the original piece but I'll
> try to find it before making a release.
> 


This time with patches.

Cheers
Kjartan

Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/Makefile.am,v
retrieving revision 1.18
diff -u -r1.18 Makefile.am
--- Makefile.am	2001/02/04 09:52:05	1.18
+++ Makefile.am	2001/07/11 14:53:37
@@ -7,6 +7,7 @@
 bin_PROGRAMS = multiload_applet
 
 multiload_applet_SOURCES = cpuload.c		\
+			   pageload.c		\
 			   memload.c		\
 			   swapload.c		\
 			   netload.c		\
@@ -35,7 +36,9 @@
 
 Monitors_predata	= cpuload_applet.desktop.in	\
 		memload_applet.desktop.in swapload_applet.desktop.in	\
-		netload_applet.desktop.in loadavg_applet.desktop.in
+		netload_applet.desktop.in loadavg_applet.desktop.in	\
+		pageload_applet.desktop.in
+		
 Monitors_DATA = $(Monitors_predata:.desktop.in=.desktop)
 @XML_I18N_MERGE_DESKTOP_RULE@
 
Index: global.h
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/global.h,v
retrieving revision 1.7
diff -u -r1.7 global.h
--- global.h	2000/03/18 11:09:08	1.7
+++ global.h	2001/07/11 14:53:37
@@ -16,6 +16,10 @@
 GtkWidget *
 make_cpuload_applet (const gchar *goad_id);
 
+/* start a new instance of the pageload applet */
+GtkWidget *
+make_pageload_applet (const gchar *goad_id);
+
 /* start a new instance of the memload applet */
 GtkWidget *
 make_memload_applet (const gchar *goad_id);
Index: linux-proc.c
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/linux-proc.c,v
retrieving revision 1.13
diff -u -r1.13 linux-proc.c
--- linux-proc.c	2000/05/21 22:47:26	1.13
+++ linux-proc.c	2001/07/11 14:53:37
@@ -18,11 +18,17 @@
 (1 << GLIBTOP_CPU_USER) +
 (1 << GLIBTOP_CPU_IDLE);
 
+static unsigned needed_page_flags = 
+(1 << GLIBTOP_SWAP_PAGEIN) +
+(1 << GLIBTOP_SWAP_PAGEOUT);
+
 static unsigned needed_mem_flags =
 (1 << GLIBTOP_MEM_USED) +
 (1 << GLIBTOP_MEM_FREE);
 
-static unsigned needed_swap_flags = 0;
+static unsigned needed_swap_flags =
+(1 << GLIBTOP_SWAP_USED) +
+(1 << GLIBTOP_SWAP_FREE);
 
 static unsigned needed_loadavg_flags =
 (1 << GLIBTOP_LOADAVG_LOADAVG);
@@ -72,6 +78,52 @@
     data [1] = sys;
     data [2] = nice;
     data [3] = free;
+}
+
+void
+GetPage (int Maximum, int data [3], LoadGraph *g)
+{
+    static int max = 100; /* guess at maximum page rate (= in + out) */
+    static u_int64_t lastin = 0;
+    static u_int64_t lastout = 0;
+    int in, out, idle;
+
+    glibtop_swap swap;
+	
+    glibtop_get_swap (&swap);
+	
+    assert ((swap.flags & needed_page_flags) == needed_page_flags);
+
+    if ((lastin > 0) && (lastin < swap.pagein)) {
+	in = swap.pagein - lastin;
+    }
+    else {
+	in = 0;
+    }
+    lastin = swap.pagein;
+
+    if ((lastout > 0) && (lastout < swap.pageout)) {
+	out = swap.pageout - lastout;
+    }
+    else {
+	out = 0;
+    }
+    lastout = swap.pageout;
+
+    if ((in + out) > max) {
+	/* Maximum page rate has increased. Change the scale without
+	   any indication whatsoever to the user (not a nice thing to
+	   do). */
+	max = in + out;
+    }
+
+    in   = rint (Maximum * ((float)in / max));
+    out  = rint (Maximum * ((float)out / max));
+    idle = Maximum - in - out;
+
+    data [0] = in;
+    data [1] = out;
+    data [2] = idle;
 }
 
 void
Index: linux-proc.h
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/linux-proc.h,v
retrieving revision 1.4
diff -u -r1.4 linux-proc.h
--- linux-proc.h	2000/02/20 17:38:03	1.4
+++ linux-proc.h	2001/07/11 14:53:37
@@ -4,6 +4,7 @@
 #include <load-graph.h>
 
 void GetLoad (int Maximum, int data [4], LoadGraph *g);
+void GetPage (int Maximum, int data [3], LoadGraph *g);
 void GetMemory (int Maximum, int data [4], LoadGraph *g);
 void GetSwap (int Maximum, int data [2], LoadGraph *g);
 void GetLoadAvg (int Maximum, int data [2], LoadGraph *g);
Index: main.c
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/main.c,v
retrieving revision 1.22
diff -u -r1.22 main.c
--- main.c	2001/07/02 10:52:44	1.22
+++ main.c	2001/07/11 14:53:37
@@ -28,6 +28,10 @@
     N_("User"),  N_("System"),   N_("Nice"),  N_("Idle")
 };
 
+static const gchar *page_texts [3] = {
+    N_("In"),  N_("Out"), N_("Idle")
+};
+
 static const gchar *mem_texts [4] =  {
     N_("Other"), N_("Shared"), N_("Buffers"), N_("Free")
 };
@@ -49,6 +53,11 @@
     "#afffafffafff", "#000000000000"
 };
 
+static const gchar *page_color_defs [3] = {
+    "#ffffffff4fff", "#afffafffafff",
+    "#000000000000"
+};
+
 static const gchar *mem_color_defs [4] = {
     "#bfffbfff4fff", "#efffefff4fff",
     "#afffafffafff", "#00008fff0000"
@@ -80,6 +89,8 @@
 	return make_netload_applet (goad_id);
     else if (strstr (goad_id, "multiload_loadavg_applet"))
 	return make_loadavg_applet (goad_id);
+    else if (strstr (goad_id, "multiload_pageload_applet"))
+	return make_pageload_applet (goad_id);
     else
 	return make_cpuload_applet (goad_id);
 }
@@ -145,6 +156,20 @@
     multiload_properties.cpuload.adj_data [0] = 500;
     multiload_properties.cpuload.adj_data [1] = 40;
 
+    multiload_properties.pageload.n = 3;
+    multiload_properties.pageload.name = "pageload";
+#ifdef ENABLE_NLS
+    {
+	int i;
+	for (i=0;i<4;i++) page_texts[i]=_(page_texts[i]);
+    }
+#endif
+    multiload_properties.pageload.texts = page_texts;
+    multiload_properties.pageload.color_defs = page_color_defs;
+    multiload_properties.pageload.adj_data [0] = 500;
+    multiload_properties.pageload.adj_data [1] = 40;
+    multiload_properties.pageload.adj_data [2] = 40;
+
     multiload_properties.memload.n = 4;
     multiload_properties.memload.name = "memload";
 #ifdef ENABLE_NLS
@@ -208,6 +233,7 @@
     /* Add property objects. */
 
     ADD_PROPERTIES (LoadGraph, cpuload);
+    ADD_PROPERTIES (LoadGraph, pageload);
     ADD_PROPERTIES (LoadGraph, memload);
     ADD_PROPERTIES (LoadGraph, swapload);
     ADD_PROPERTIES (LoadGraph, netload);
@@ -221,18 +247,22 @@
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
     c = g_list_nth (multiload_property_object_list, 1);
-    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Memory Load"));
+    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Page Load"));
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
     c = g_list_nth (multiload_property_object_list, 2);
-    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Swap Load"));
+    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Memory Load"));
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
     c = g_list_nth (multiload_property_object_list, 3);
-    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Net Load"));
+    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Swap Load"));
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
     c = g_list_nth (multiload_property_object_list, 4);
+    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Net Load"));
+    gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
+
+    c = g_list_nth (multiload_property_object_list, 5);
     ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Load Average"));
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
Index: multiload_applet.gnorba
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/multiload_applet.gnorba,v
retrieving revision 1.7
diff -u -r1.7 multiload_applet.gnorba
--- multiload_applet.gnorba	2000/02/20 17:38:03	1.7
+++ multiload_applet.gnorba	2001/07/11 14:53:37
@@ -10,6 +10,12 @@
 description=CPU Load applet/multi
 location_info=multiload_applet
 
+[multiload_pageload_applet]
+type=factory
+repo_id=IDL:GNOME/Applet:1.0
+description=Page Load applet/multi
+location_info=multiload_applet
+
 [multiload_memload_applet]
 type=factory
 repo_id=IDL:GNOME/Applet:1.0
Index: properties.c
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/properties.c,v
retrieving revision 1.13
diff -u -r1.13 properties.c
--- properties.c	2000/05/04 12:24:03	1.13
+++ properties.c	2001/07/11 14:53:38
@@ -16,6 +16,8 @@
 
     if (g->global_prop_data == &multiload_properties.cpuload)
 	multiload_show_properties (PROP_CPULOAD);
+    else if (g->global_prop_data == &multiload_properties.pageload)
+	multiload_show_properties (PROP_PAGELOAD);
     else if (g->global_prop_data == &multiload_properties.memload)
 	multiload_show_properties (PROP_MEMLOAD);
     else if (g->global_prop_data == &multiload_properties.swapload)
Index: properties.h
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/properties.h,v
retrieving revision 1.8
diff -u -r1.8 properties.h
--- properties.h	2000/02/20 18:08:47	1.8
+++ properties.h	2001/07/11 14:53:38
@@ -7,6 +7,7 @@
 
 typedef enum {
     PROP_CPULOAD,
+    PROP_PAGELOAD,
     PROP_MEMLOAD,
     PROP_SWAPLOAD,
     PROP_NETLOAD,
@@ -35,7 +36,7 @@
 };
 
 struct _MultiLoadProperties {
-    LoadGraphProperties cpuload, memload, swapload, netload, loadavg;
+    LoadGraphProperties cpuload, pageload, memload, swapload, netload, loadavg;
 };
 
 extern GList *multiload_property_object_list;
Index: docs/C/cpuload/cpuload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/C/cpuload/cpuload_applet.sgml,v
retrieving revision 1.3
diff -u -r1.3 cpuload_applet.sgml
--- docs/C/cpuload/cpuload_applet.sgml	2000/12/11 22:18:22	1.3
+++ docs/C/cpuload/cpuload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
   <!ENTITY cpuload.sgml SYSTEM "cpuload.sgml">
 ]>
 
Index: docs/C/loadavg/loadavg_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/C/loadavg/loadavg_applet.sgml,v
retrieving revision 1.2
diff -u -r1.2 loadavg_applet.sgml
--- docs/C/loadavg/loadavg_applet.sgml	2000/12/11 22:18:34	1.2
+++ docs/C/loadavg/loadavg_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
  <!ENTITY loadavg.sgml SYSTEM "loadavg.sgml">
 
 ]>
Index: docs/C/memload/memload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/C/memload/memload_applet.sgml,v
retrieving revision 1.3
diff -u -r1.3 memload_applet.sgml
--- docs/C/memload/memload_applet.sgml	2001/03/21 02:47:43	1.3
+++ docs/C/memload/memload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
  <!ENTITY memload.sgml SYSTEM "memload.sgml">
 
 ]>
Index: docs/C/netload/netload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/C/netload/netload_applet.sgml,v
retrieving revision 1.2
diff -u -r1.2 netload_applet.sgml
--- docs/C/netload/netload_applet.sgml	2000/12/11 22:18:57	1.2
+++ docs/C/netload/netload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
   <!ENTITY netload.sgml SYSTEM "netload.sgml">
 ]>
 
Index: docs/C/swapload/swapload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/C/swapload/swapload_applet.sgml,v
retrieving revision 1.2
diff -u -r1.2 swapload_applet.sgml
--- docs/C/swapload/swapload_applet.sgml	2000/12/11 22:19:08	1.2
+++ docs/C/swapload/swapload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
   <!ENTITY swapload.sgml SYSTEM "swapload.sgml">
 ]>
 
Index: docs/de/cpuload.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/de/cpuload.sgml,v
retrieving revision 1.2
diff -u -r1.2 cpuload.sgml
--- docs/de/cpuload.sgml	2000/04/01 21:51:25	1.2
+++ docs/de/cpuload.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE sect1 PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE sect1 PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
 ]>
 
 <!-- Permission is granted to make and distribute verbatim copies of -->
Index: docs/it/cpuload/cpuload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/it/cpuload/cpuload_applet.sgml,v
retrieving revision 1.3
diff -u -r1.3 cpuload_applet.sgml
--- docs/it/cpuload/cpuload_applet.sgml	2000/12/11 22:19:34	1.3
+++ docs/it/cpuload/cpuload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
   <!ENTITY cpuload.sgml SYSTEM "cpuload.sgml">
 ]>
 
Index: docs/it/loadavg/loadavg_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/it/loadavg/loadavg_applet.sgml,v
retrieving revision 1.4
diff -u -r1.4 loadavg_applet.sgml
--- docs/it/loadavg/loadavg_applet.sgml	2000/12/11 22:19:44	1.4
+++ docs/it/loadavg/loadavg_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
  <!ENTITY loadavg.sgml SYSTEM "loadavg.sgml">
 
 ]>
Index: docs/it/memload/memload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/it/memload/memload_applet.sgml,v
retrieving revision 1.3
diff -u -r1.3 memload_applet.sgml
--- docs/it/memload/memload_applet.sgml	2000/12/11 22:19:56	1.3
+++ docs/it/memload/memload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
  <!ENTITY memload.sgml SYSTEM "memload.sgml">
 
 ]>
Index: docs/it/netload/netload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/it/netload/netload_applet.sgml,v
retrieving revision 1.3
diff -u -r1.3 netload_applet.sgml
--- docs/it/netload/netload_applet.sgml	2000/12/11 22:20:10	1.3
+++ docs/it/netload/netload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
   <!ENTITY netload.sgml SYSTEM "netload.sgml">
 ]>
 
Index: docs/it/swapload/swapload_applet.sgml
===================================================================
RCS file: /cvs/gnome/gnome-applets/multiload/docs/it/swapload/swapload_applet.sgml,v
retrieving revision 1.3
diff -u -r1.3 swapload_applet.sgml
--- docs/it/swapload/swapload_applet.sgml	2000/12/11 22:28:38	1.3
+++ docs/it/swapload/swapload_applet.sgml	2001/07/11 14:53:38
@@ -1,4 +1,4 @@
-<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.0//EN"[
+<!DOCTYPE Article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
   <!entity swapload.sgml SYSTEM "swapload.sgml">
 ]>
 
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/Makefile.am gnome-core-1.0.55/applets/multiload/Makefile.am
--- gnome-core-1.0.55.old/applets/multiload/Makefile.am	Mon Dec 28 09:58:28 1998
+++ gnome-core-1.0.55/applets/multiload/Makefile.am	Thu Apr 13 17:19:36 2000
@@ -6,6 +6,7 @@
 bin_PROGRAMS = multiload_applet
 
 multiload_applet_SOURCES = cpuload.c		\
+			   pageload.c		\
 			   memload.c		\
 			   swapload.c		\
 			   main.c		\
@@ -29,7 +30,7 @@
 Monitorsdir	= $(appletdir)/Monitors
 
 Monitors_DATA	= cpuload_applet.desktop memload_applet.desktop \
-		  swapload_applet.desktop
+		  swapload_applet.desktop pageload_applet.desktop
 
 EXTRA_DIST	= $(Monitors_DATA) multiload_applet.gnorba
 
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/Makefile.in gnome-core-1.0.55/applets/multiload/Makefile.in
--- gnome-core-1.0.55.old/applets/multiload/Makefile.in	Fri Dec 17 17:33:16 1999
+++ gnome-core-1.0.55/applets/multiload/Makefile.in	Thu Apr 13 17:20:13 2000
@@ -159,7 +159,7 @@
 
 bin_PROGRAMS = multiload_applet
 
-multiload_applet_SOURCES = cpuload.c					   memload.c					   swapload.c					   main.c					   global.h					   properties.c					   properties.h					   property-entries.c				   property-entries.h				   linux-proc.h 				   linux-proc.c 				   load-graph.c					   load-graph.h
+multiload_applet_SOURCES = cpuload.c		pageload.c			   memload.c					   swapload.c					   main.c					   global.h					   properties.c					   properties.h					   property-entries.c				   property-entries.h				   linux-proc.h 				   linux-proc.c 				   load-graph.c					   load-graph.h
 
 
 multiload_applet_LDADD = ../../panel/libpanel_applet.la 		     $(GNOME_LIBDIR) 		     $(GNOMEGNORBA_LIBS) $(INTLLIBS)			     $(LIBGTOP_LIBS) $(LIBGTOP_EXTRA_LIBS)
@@ -169,7 +169,7 @@
 
 Monitorsdir = $(appletdir)/Monitors
 
-Monitors_DATA = cpuload_applet.desktop memload_applet.desktop 		  swapload_applet.desktop
+Monitors_DATA = cpuload_applet.desktop pageload_applet.desktop memload_applet.desktop 		  swapload_applet.desktop
 
 
 EXTRA_DIST = $(Monitors_DATA) multiload_applet.gnorba
@@ -184,7 +184,7 @@
 
 DEFS = @DEFS@ -I. -I$(srcdir) -I../..
 LIBS = @LIBS@
-multiload_applet_OBJECTS =  cpuload.o memload.o swapload.o main.o \
+multiload_applet_OBJECTS =  cpuload.o pageload.o memload.o swapload.o main.o \
 properties.o property-entries.o linux-proc.o load-graph.o
 multiload_applet_DEPENDENCIES =  ../../panel/libpanel_applet.la
 multiload_applet_LDFLAGS = 
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/global.h gnome-core-1.0.55/applets/multiload/global.h
--- gnome-core-1.0.55.old/applets/multiload/global.h	Fri Apr 16 18:41:09 1999
+++ gnome-core-1.0.55/applets/multiload/global.h	Thu Apr 13 16:34:36 2000
@@ -15,6 +15,10 @@
 GtkWidget *
 make_cpuload_applet (const gchar *goad_id);
 
+/* start a new instance of the pageload applet */
+GtkWidget *
+make_pageload_applet (const gchar *goad_id);
+
 /* start a new instance of the memload applet */
 GtkWidget *
 make_memload_applet (const gchar *goad_id);
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/linux-proc.c gnome-core-1.0.55/applets/multiload/linux-proc.c
--- gnome-core-1.0.55.old/applets/multiload/linux-proc.c	Mon Oct 18 08:08:27 1999
+++ gnome-core-1.0.55/applets/multiload/linux-proc.c	Fri Apr 14 12:49:22 2000
@@ -12,6 +12,7 @@
 #include <glibtop/cpu.h>
 #include <glibtop/mem.h>
 #include <glibtop/swap.h>
+/* paging is in glibtop/swap.h */
 
 #include "linux-proc.h"
 
@@ -24,11 +25,17 @@
 (1 << GLIBTOP_CPU_USER) +
 (1 << GLIBTOP_CPU_IDLE);
 
+static unsigned needed_page_flags = 
+(1 << GLIBTOP_SWAP_PAGEIN) +
+(1 << GLIBTOP_SWAP_PAGEOUT);
+
 static unsigned needed_mem_flags =
 (1 << GLIBTOP_MEM_USED) +
 (1 << GLIBTOP_MEM_FREE);
 
-static unsigned needed_swap_flags = 0;
+static unsigned needed_swap_flags =
+(1 << GLIBTOP_SWAP_USED) +
+(1 << GLIBTOP_SWAP_FREE);
 
 void
 GetLoad (int Maximum, int data [4])
@@ -76,6 +83,52 @@
     data [1] = sys;
     data [2] = nice;
     data [3] = free;
+}
+
+void
+GetPage (int Maximum, int data [3])
+{
+    static int max = 100; /* guess at maximum page rate (= in + out) */
+    static u_int64_t lastin = 0;
+    static u_int64_t lastout = 0;
+    int in, out, idle;
+
+    glibtop_swap swap;
+	
+    glibtop_get_swap (&swap);
+	
+    assert ((swap.flags & needed_page_flags) == needed_page_flags);
+
+    if ((lastin > 0) && (lastin < swap.pagein)) {
+	in = swap.pagein - lastin;
+    }
+    else {
+	in = 0;
+    }
+    lastin = swap.pagein;
+
+    if ((lastout > 0) && (lastout < swap.pageout)) {
+	out = swap.pageout - lastout;
+    }
+    else {
+	out = 0;
+    }
+    lastout = swap.pageout;
+
+    if ((in + out) > max) {
+	/* Maximum page rate has increased. Change the scale without
+	   any indication whatsoever to the user (not a nice thing to
+	   do). */
+	max = in + out;
+    }
+
+    in   = rint (Maximum * ((float)in / max));
+    out  = rint (Maximum * ((float)out / max));
+    idle = Maximum - in - out;
+
+    data [0] = in;
+    data [1] = out;
+    data [2] = idle;
 }
 
 void
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/linux-proc.h gnome-core-1.0.55/applets/multiload/linux-proc.h
--- gnome-core-1.0.55.old/applets/multiload/linux-proc.h	Mon Dec 28 09:58:32 1998
+++ gnome-core-1.0.55/applets/multiload/linux-proc.h	Thu Apr 13 16:44:48 2000
@@ -2,6 +2,7 @@
 #define LINUX_PROC_H__
 
 void GetLoad (int Maximum, int data [4]);
+void GetPage (int Maximum, int data [3]);
 void GetMemory (int Maximum, int data [4]);
 void GetSwap (int Maximum, int data [2]);
 
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/main.c gnome-core-1.0.55/applets/multiload/main.c
--- gnome-core-1.0.55.old/applets/multiload/main.c	Wed Dec  1 15:41:01 1999
+++ gnome-core-1.0.55/applets/multiload/main.c	Fri Apr 14 10:03:11 2000
@@ -27,6 +27,10 @@
     N_("User"),  N_("System"),   N_("Nice"),  N_("Idle")
 };
 
+static const gchar *page_texts [3] = {
+    N_("In"),  N_("Out"), N_("Idle")
+};
+
 static const gchar *mem_texts [4] =  {
     N_("Other"), N_("Shared"), N_("Buffers"), N_("Free")
 };
@@ -40,6 +44,11 @@
     "#afffafffafff", "#000000000000"
 };
 
+static const gchar *page_color_defs [3] = {
+    "#ffffffff4fff", "#afffafffafff",
+    "#000000000000"
+};
+
 static const gchar *mem_color_defs [4] = {
     "#bfffbfff4fff", "#efffefff4fff",
     "#afffafffafff", "#00008fff0000"
@@ -59,6 +68,8 @@
 	return make_memload_applet (goad_id);
     else if (strstr (goad_id, "multiload_swapload_applet"))
 	return make_swapload_applet (goad_id);
+    else if (strstr (goad_id, "multiload_pageload_applet"))
+	return make_pageload_applet (goad_id);
     else
 	return make_cpuload_applet (goad_id);
 }
@@ -110,6 +121,20 @@
     multiload_properties.cpuload.adj_data [1] = 40;
     multiload_properties.cpuload.adj_data [2] = 40;
 
+    multiload_properties.pageload.n = 3;
+    multiload_properties.pageload.name = "pageload";
+#ifdef ENABLE_NLS
+    {
+	int i;
+	for (i=0;i<4;i++) page_texts[i]=_(page_texts[i]);
+    }
+#endif
+    multiload_properties.pageload.texts = page_texts;
+    multiload_properties.pageload.color_defs = page_color_defs;
+    multiload_properties.pageload.adj_data [0] = 500;
+    multiload_properties.pageload.adj_data [1] = 40;
+    multiload_properties.pageload.adj_data [2] = 40;
+
     multiload_properties.memload.n = 4;
     multiload_properties.memload.name = "memload";
 #ifdef ENABLE_NLS
@@ -141,6 +166,7 @@
     /* Add property objects. */
 
     ADD_PROPERTIES (LoadGraph, cpuload);
+    ADD_PROPERTIES (LoadGraph, pageload);
     ADD_PROPERTIES (LoadGraph, memload);
     ADD_PROPERTIES (LoadGraph, swapload);
 
@@ -152,10 +178,14 @@
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
     c = g_list_nth (multiload_property_object_list, 1);
-    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Memory Load"));
+    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Page Load"));
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
     c = g_list_nth (multiload_property_object_list, 2);
+    ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Memory Load"));
+    gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
+
+    c = g_list_nth (multiload_property_object_list, 3);
     ((GnomePropertyObject *) c->data)->label = gtk_label_new (_("Swap Load"));
     gtk_widget_ref (((GnomePropertyObject *) c->data)->label);
 
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/multiload_applet.gnorba gnome-core-1.0.55/applets/multiload/multiload_applet.gnorba
--- gnome-core-1.0.55.old/applets/multiload/multiload_applet.gnorba	Thu Dec 31 21:24:16 1998
+++ gnome-core-1.0.55/applets/multiload/multiload_applet.gnorba	Fri Apr 14 12:59:32 2000
@@ -10,6 +10,12 @@
 description=CPU Load applet/multi
 location_info=multiload_applet
 
+[multiload_pageload_applet]
+type=factory
+repo_id=IDL:GNOME/Applet:1.0
+description=Page Load applet/multi
+location_info=multiload_applet
+
 [multiload_memload_applet]
 type=factory
 repo_id=IDL:GNOME/Applet:1.0
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/pageload.c gnome-core-1.0.55/applets/multiload/pageload.c
--- gnome-core-1.0.55.old/applets/multiload/pageload.c	Wed Dec 31 19:00:00 1969
+++ gnome-core-1.0.55/applets/multiload/pageload.c	Thu Apr 13 16:57:16 2000
@@ -0,0 +1,75 @@
+/* GNOME cpuload/memload panel applet
+ * (C) 1997 The Free Software Foundation
+ *
+ * Authors: Tim P. Gerla
+ *          Martin Baulig
+ *
+ * With code from wmload.c, v0.9.2, apparently by Ryan Land, rland bc1 com 
+ *
+ */
+
+#include <stdio.h>
+#include <config.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+#include <config.h>
+#include <gnome.h>
+#include <gdk/gdkx.h>
+#include <applet-widget.h>
+
+#include "global.h"
+
+static gint
+applet_save_session (GtkWidget *widget, char *privcfgpath,
+		     char *globcfgpath, gpointer data)
+{
+	return FALSE;
+}
+
+/* start a new instance of the pageload applet */
+GtkWidget *
+make_pageload_applet (const gchar *goad_id)
+{
+    GtkWidget *applet;
+    LoadGraph *g;
+
+    /* create a new applet_widget */
+    applet = applet_widget_new(goad_id);
+    /* in the rare case that the communication with the panel
+       failed, error out */
+    if (!applet)
+	g_error ("Can't create applet!\n");
+
+    g = load_graph_new (3, N_("PAGE Load"), &multiload_properties.pageload,
+			multiload_properties.pageload.adj_data[0],
+			multiload_properties.pageload.adj_data[1],
+			multiload_properties.pageload.adj_data[2], GetPage);
+
+    applet_widget_add (APPLET_WIDGET(applet), g->frame);
+    gtk_widget_show (applet);
+
+    load_graph_start (g);
+
+    gtk_signal_connect (GTK_OBJECT(applet),"save_session",
+			GTK_SIGNAL_FUNC(applet_save_session),
+			NULL);
+
+    applet_widget_register_stock_callback (APPLET_WIDGET(applet),
+					   "properties",
+					   GNOME_STOCK_MENU_PROP,
+					   _("Properties..."),
+					   multiload_properties_cb,
+					   g);
+
+    applet_widget_register_callback (APPLET_WIDGET(applet),
+				     "run_gtop",
+				     _("Run gtop..."),
+				     start_gtop_cb,
+				     NULL);
+
+    return applet;
+}
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/pageload_applet.desktop gnome-core-1.0.55/applets/multiload/pageload_applet.desktop
--- gnome-core-1.0.55.old/applets/multiload/pageload_applet.desktop	Wed Dec 31 19:00:00 1969
+++ gnome-core-1.0.55/applets/multiload/pageload_applet.desktop	Thu Apr 13 17:21:11 2000
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=PageLoad
+Comment=Page Load Meter
+Exec=multiload_applet --activate-goad-server=multiload_pageload_applet
+Icon=gnome-page.png
+Terminal=0
+Type=Application
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/properties.c gnome-core-1.0.55/applets/multiload/properties.c
--- gnome-core-1.0.55.old/applets/multiload/properties.c	Sun Feb  7 17:30:45 1999
+++ gnome-core-1.0.55/applets/multiload/properties.c	Thu Apr 13 16:36:33 2000
@@ -15,6 +15,8 @@
 
     if (g->prop_data == &multiload_properties.cpuload)
 	multiload_show_properties (PROP_CPULOAD);
+    else if (g->prop_data == &multiload_properties.pageload)
+	multiload_show_properties (PROP_PAGELOAD);
     else if (g->prop_data == &multiload_properties.memload)
 	multiload_show_properties (PROP_MEMLOAD);
     else if (g->prop_data == &multiload_properties.swapload)
diff -u -r -N gnome-core-1.0.55.old/applets/multiload/properties.h gnome-core-1.0.55/applets/multiload/properties.h
--- gnome-core-1.0.55.old/applets/multiload/properties.h	Sun Feb  7 17:30:47 1999
+++ gnome-core-1.0.55/applets/multiload/properties.h	Thu Apr 13 16:35:28 2000
@@ -7,6 +7,7 @@
 
 typedef enum {
     PROP_CPULOAD,
+    PROP_PAGELOAD,
     PROP_MEMLOAD,
     PROP_SWAPLOAD
 } PropertyClass;
@@ -25,7 +26,7 @@
 };
 
 struct _MultiLoadProperties {
-    LoadGraphProperties cpuload, memload, swapload;
+    LoadGraphProperties cpuload, pageload, memload, swapload;
 };
 
 extern GList *multiload_property_object_list;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]