summaryrefslogtreecommitdiffstats
path: root/ksysguard/ksysguardd/Irix/Memory.c
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /ksysguard/ksysguardd/Irix/Memory.c
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksysguard/ksysguardd/Irix/Memory.c')
-rw-r--r--ksysguard/ksysguardd/Irix/Memory.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/ksysguard/ksysguardd/Irix/Memory.c b/ksysguard/ksysguardd/Irix/Memory.c
new file mode 100644
index 000000000..e88123ddd
--- /dev/null
+++ b/ksysguard/ksysguardd/Irix/Memory.c
@@ -0,0 +1,128 @@
+/*
+ KSysGuard, the KDE System Guard
+
+ Copyright (c) 1999, 2000 Chris Schlaeger <[email protected]>
+
+ Irix support by Carsten Kroll <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of version 2 of the GNU General Public
+ License as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/statfs.h>
+#include <sys/swap.h>
+#include <sys/sysmp.h>
+
+#include "config.h"
+
+#include "ksysguardd.h"
+#include "Command.h"
+#include "Memory.h"
+
+static int Dirty = 1;
+static t_memsize totalmem = (t_memsize) 0;
+static t_memsize freemem = (t_memsize) 0;
+static unsigned long totalswap = 0L,vswap = 0L;
+static unsigned long freeswap = 0L,bufmem = 0L ;
+
+void initMemory( struct SensorModul* sm ) {
+
+ registerMonitor( "mem/physical/free", "integer",
+ printMemFree, printMemFreeInfo, sm );
+ registerMonitor( "mem/physical/used", "integer",
+ printMemUsed, printMemUsedInfo, sm );
+ registerMonitor( "mem/swap/free", "integer",
+ printSwapFree, printSwapFreeInfo, sm );
+ registerMonitor( "mem/swap/used", "integer",
+ printSwapUsed, printSwapUsedInfo, sm );
+}
+
+void exitMemory( void ) {
+}
+
+int updateMemory( void ) {
+ struct statfs sf;
+ off_t val;
+ int pagesize = getpagesize();
+ struct rminfo rmi;
+ if( sysmp(MP_SAGET, MPSA_RMINFO, &rmi, sizeof(rmi)) == -1 )
+ return( -1 );
+ totalmem = rmi.physmem*pagesize/1024; // total physical memory (without swaps)
+ freemem = rmi.freemem*pagesize/1024; // total free physical memory (without swaps)
+ bufmem = rmi.bufmem *pagesize/1024;
+
+ statfs ("/proc", &sf,sizeof(sf),0);
+
+ swapctl(SC_GETSWAPVIRT,&val);
+ vswap = val >> 1;
+ swapctl(SC_GETSWAPTOT,&val);
+ totalswap = val >> 1;
+ swapctl(SC_GETFREESWAP,&val);
+ freeswap = val >> 1;
+
+ Dirty = 1;
+
+ return( 0 );
+}
+
+void printMemFreeInfo( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "Free Memory\t0\t%ld\tKB\n", freemem );
+}
+
+void printMemFree( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "%ld\n", freemem );
+}
+
+void printMemUsedInfo( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "Used Memory\t0\t%ld\tKB\n", totalmem - freemem );
+}
+
+void printMemUsed( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "%ld\n", totalmem - freemem );
+}
+
+void printSwapFreeInfo( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "Free Swap\t0\t%ld\tKB\n", freeswap );
+}
+
+void printSwapFree( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "%ld\n", freeswap );
+}
+void printSwapUsedInfo( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "Used Swap\t0\t%ld\tKB\n", totalswap - freeswap );
+}
+
+void printSwapUsed( const char *cmd ) {
+ if( Dirty )
+ updateMemory();
+ fprintf(CurrentClient, "%ld\n", totalswap - freeswap );
+}