diff options
author | Alberto Villa <avilla@FreeBSD.org> | 2011-03-25 10:33:51 +0000 |
---|---|---|
committer | Alberto Villa <avilla@FreeBSD.org> | 2011-03-25 10:33:51 +0000 |
commit | c1f3de0f55e58790d19f686e510418e212aee85c (patch) | |
tree | 9c83366b7e53439af8a08cb4d55853e9209564e1 /sysutils/ksysguardd | |
parent | ccbd618ebd63ebf72b64b3b6679b6ee11976f839 (diff) | |
download | ports-c1f3de0f55e58790d19f686e510418e212aee85c.tar.gz ports-c1f3de0f55e58790d19f686e510418e212aee85c.zip |
Notes
Diffstat (limited to 'sysutils/ksysguardd')
24 files changed, 3259 insertions, 0 deletions
diff --git a/sysutils/ksysguardd/Makefile b/sysutils/ksysguardd/Makefile new file mode 100644 index 000000000000..891134a3ce5b --- /dev/null +++ b/sysutils/ksysguardd/Makefile @@ -0,0 +1,44 @@ +# New ports collection makefile for: ksysguardd +# Date created: 5 March 2011 +# Whom: avilla@FreeBSD.org +# +# $FreeBSD$ +# + +PORTNAME= ksysguardd +PORTVERSION= ${KDE4_VERSION} +CATEGORIES= sysutils kde +MASTER_SITES= ${MASTER_SITE_KDE} +MASTER_SITE_SUBDIR= ${KDE4_BRANCH}/${PORTVERSION}/src/ +DISTNAME= kdebase-workspace-${PORTVERSION} +DIST_SUBDIR= KDE + +MAINTAINER= kde@FreeBSD.org +COMMENT= KDE System Guard Daemon + +USE_KDE4= kdeprefix kdehier +USE_BZIP2= yes +USE_CMAKE= yes +CMAKE_ARGS+= -DBIN_INSTALL_DIR:STRING="${PREFIX}/bin" \ + -DSYSCONF_INSTALL_DIR:STRING="${PREFIX}/etc" +MAKE_JOBS_SAFE= yes + +EXTRACT_AFTER_ARGS= | ${TAR} -xf - \ + '${DISTNAME}/ksysguard/${PORTNAME}' \ + '${DISTNAME}/ksysguard/example/${PORTNAME}rc' \ + '${DISTNAME}/ksysguard/gui/SignalIDs.h' + +WRKSRC= ${WRKDIR}/${DISTNAME}/ksysguard/${PORTNAME} + +PLIST_FILES= bin/${PORTNAME} \ + etc/${PORTNAME}rc + +pre-build: + ${REINPLACE_CMD} -e 's/<config-workspace.h>/"config-${PORTNAME}.h"/' \ + ${WRKSRC}/${PORTNAME}.c + +post-install: + ${CHGRP} kmem ${PREFIX}/bin/${PORTNAME} && \ + ${CHMOD} g+s ${PREFIX}/bin/${PORTNAME} + +.include <bsd.port.mk> diff --git a/sysutils/ksysguardd/distinfo b/sysutils/ksysguardd/distinfo new file mode 100644 index 000000000000..751fd5e671a6 --- /dev/null +++ b/sysutils/ksysguardd/distinfo @@ -0,0 +1,2 @@ +SHA256 (KDE/kdebase-workspace-4.6.1.tar.bz2) = b2c113aec1e5c79b31f2dcac718ba94d142fe39e8e9640d13d19c2dcbf5fae98 +SIZE (KDE/kdebase-workspace-4.6.1.tar.bz2) = 69489744 diff --git a/sysutils/ksysguardd/files/patch-CMakeLists.txt b/sysutils/ksysguardd/files/patch-CMakeLists.txt new file mode 100644 index 000000000000..422cd5c26298 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-CMakeLists.txt @@ -0,0 +1,42 @@ +--- ./CMakeLists.txt.orig 2011-02-25 22:54:48.000000000 +0100 ++++ ./CMakeLists.txt 2011-03-05 16:31:50.557158447 +0100 +@@ -9,12 +9,15 @@ + + add_definitions(-DOSTYPE_${CMAKE_SYSTEM_NAME}) + +-macro_optional_find_package(Sensors) +-macro_bool_to_01(SENSORS_FOUND HAVE_LMSENSORS) +- +-check_include_files(sys/inotify.h SYS_INOTIFY_H_FOUND) +-macro_bool_to_01(SYS_INOTIFY_H_FOUND HAVE_SYS_INOTIFY_H) ++# Commenting this allows us not to depend on kdelibs (we don't have ++# lm-sensors in ports, nor inotify in base system). ++#macro_optional_find_package(Sensors) ++#macro_bool_to_01(SENSORS_FOUND HAVE_LMSENSORS) ++set(SENSORS_FOUND 0) + ++#check_include_files(sys/inotify.h SYS_INOTIFY_H_FOUND) ++#macro_bool_to_01(SYS_INOTIFY_H_FOUND HAVE_SYS_INOTIFY_H) ++set(SYS_INOTIFY_H_FOUND 0) + + configure_file(config-ksysguardd.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksysguardd.h) + +@@ -51,9 +54,9 @@ + + target_link_libraries(ksysguardd libksysguardd) + +- if( NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) ++ if( NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR NOT ${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD" ) + target_link_libraries(ksysguardd ${KDE4_KDEFAKES_LIBS}) +- endif( NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) ++ endif( NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR NOT ${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD" ) + + if( ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" ) + message(STATUS "Adding kvm library on NetBSD") +@@ -67,4 +70,5 @@ + target_link_libraries(ksysguardd socket nsl) + endif( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" ) + +-install(TARGETS ksysguardd ${INSTALL_TARGETS_DEFAULT_ARGS}) ++install(TARGETS ksysguardd RUNTIME DESTINATION "${BIN_INSTALL_DIR}") ++install(FILES ../example/ksysguarddrc DESTINATION "${SYSCONF_INSTALL_DIR}") diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__CMakeLists.txt b/sysutils/ksysguardd/files/patch-FreeBSD__CMakeLists.txt new file mode 100644 index 000000000000..31e279c2c898 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__CMakeLists.txt @@ -0,0 +1,23 @@ +--- FreeBSD/CMakeLists.txt 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/CMakeLists.txt 2011-03-07 18:04:26.000000000 +0200 +@@ -1,14 +1,16 @@ + INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../CContLib ${CMAKE_CURRENT_SOURCE_DIR}/../ ) + +-ADD_LIBRARY(libksysguardd STATIC ++ADD_LIBRARY(libksysguardd STATIC ++ acpi.c + apm.c +- CPU.c ++ cpuinfo.c + diskstat.c + loadavg.c + logfile.c + Memory.c + netdev.c +- ProcessList.c) ++ ProcessList.c ++ stat.c ++ uptime.c) + + TARGET_LINK_LIBRARIES(libksysguardd kvm) +- diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__Memory.c b/sysutils/ksysguardd/files/patch-FreeBSD__Memory.c new file mode 100644 index 000000000000..00a09438f5b9 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__Memory.c @@ -0,0 +1,402 @@ +--- FreeBSD/Memory.c 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/Memory.c 2011-01-30 11:18:45.000000000 +0200 +@@ -3,6 +3,7 @@ + + Copyright (c) 1999-2000 Hans Petter Bieker <bieker@kde.org> + Copyright (c) 1999 Chris Schlaeger <cs@kde.org> ++ Copyright (c) 2010 David Naylor <naylor.b.david@gmail.com> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +@@ -21,33 +22,39 @@ + */ + + #include <sys/types.h> +-#include <sys/param.h> + #include <sys/sysctl.h> +-#include <sys/vmmeter.h> +- +-#include <vm/vm_param.h> + + #include <fcntl.h> + #include <kvm.h> + #include <limits.h> + #include <stdio.h> +-#include <stdlib.h> +-#include <string.h> + #include <unistd.h> + + #include "Command.h" + #include "Memory.h" + #include "ksysguardd.h" + +-static size_t Total = 0; +-static size_t MFree = 0; +-static size_t Used = 0; +-static size_t Buffers = 0; +-static size_t Cached = 0; +-static size_t Application = 0; +-static size_t STotal = 0; +-static size_t SFree = 0; +-static size_t SUsed = 0; ++#define MEM_ACTIVE 0 ++#define MEM_INACTIVE 1 ++#define MEM_WIRED 2 ++#define MEM_CACHED 3 ++#define MEM_BUFFERED 4 ++#define MEM_FREE 5 ++#define MEM_TOTAL 6 ++ ++static size_t memory_stats[7]; ++ ++#define SWAP_IN 0 ++#define SWAP_OUT 1 ++#define SWAP_USED 2 ++#define SWAP_FREE 3 ++#define SWAP_TOTAL 4 ++ ++static size_t swap_stats[5]; ++static size_t swap_old[2]; ++ ++static int pagesize; ++ + static kvm_t *kd; + + void +@@ -56,24 +63,57 @@ + char *nlistf = NULL; + char *memf = NULL; + char buf[_POSIX2_LINE_MAX]; +- ++ ++ pagesize = getpagesize(); ++ + if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == NULL) { + log_error("kvm_openfiles()"); + return; + } + +- registerMonitor("mem/physical/free", "integer", printMFree, printMFreeInfo, sm); +- registerMonitor("mem/physical/used", "integer", printUsed, printUsedInfo, sm); +- registerMonitor("mem/physical/buf", "integer", printBuffers, printBuffersInfo, sm); +- registerMonitor("mem/physical/cached", "integer", printCached, printCachedInfo, sm); +- registerMonitor("mem/physical/application", "integer", printApplication, printApplicationInfo, sm); ++ registerMonitor("mem/physical/active", "integer", printMActive, printMActiveInfo, sm); ++ registerMonitor("mem/physical/inactive", "integer", printMInactive, printMInactiveInfo, sm); ++ registerMonitor("mem/physical/application", "integer", printMApplication, printMApplicationInfo, sm); ++ registerMonitor("mem/physical/wired", "integer", printMWired, printMWiredInfo, sm); ++ registerMonitor("mem/physical/cached", "integer", printMCached, printMCachedInfo, sm); ++ registerMonitor("mem/physical/buf", "integer", printMBuffers, printMBuffersInfo, sm); ++ registerMonitor("mem/physical/free", "integer", printMFree, printMFreeInfo, sm); ++ registerMonitor("mem/physical/used", "integer", printMUsed, printMUsedInfo, sm); ++ + registerMonitor("mem/swap/free", "integer", printSwapFree, printSwapFreeInfo, sm); + registerMonitor("mem/swap/used", "integer", printSwapUsed, printSwapUsedInfo, sm); ++ registerMonitor("mem/swap/pageIn", "integer", printSwapIn, printSwapInInfo, sm); ++ registerMonitor("mem/swap/pageOut", "integer", printSwapOut, printSwapOutInfo, sm); ++ ++ registerLegacyMonitor("cpu/pageIn", "float", printSwapIn, printSwapInInfo, sm); ++ registerLegacyMonitor("cpu/pageOut", "float", printSwapOut, printSwapOutInfo, sm); ++ ++ swap_old[SWAP_IN] = -1; ++ swap_old[SWAP_OUT] = -1; ++ ++ updateMemory(); + } + + void + exitMemory(void) + { ++ removeMonitor("mem/physical/active"); ++ removeMonitor("mem/physical/inactive"); ++ removeMonitor("mem/physical/application"); ++ removeMonitor("mem/physical/wired"); ++ removeMonitor("mem/physical/cached"); ++ removeMonitor("mem/physical/buf"); ++ removeMonitor("mem/physical/free"); ++ removeMonitor("mem/physical/used"); ++ ++ removeMonitor("mem/swap/free"); ++ removeMonitor("mem/swap/used"); ++ removeMonitor("mem/swap/pageIn"); ++ removeMonitor("mem/swap/pageOut"); ++ ++ removeMonitor("cpu/pageIn"); ++ removeMonitor("cpu/pageOut"); ++ + kvm_close(kd); + } + +@@ -81,129 +121,212 @@ + updateMemory(void) + { + size_t len; +- FILE *file; +- char buf[256]; +- struct kvm_swap kswap[16]; +- int i, swap_count, hlen, pagesize = getpagesize(); +- long blocksize; +- +- len = sizeof (Total); +- sysctlbyname("hw.physmem", &Total, &len, NULL, 0); +- Total /= 1024; +- +- /* Borrowed from pstat */ +- swap_count = kvm_getswapinfo(kd, kswap, 16, SWIF_DEV_PREFIX); +- getbsize(&hlen, &blocksize); +- +-#define CONVERT(v) ((int)((quad_t)(v) * pagesize / blocksize)) +- +- if (swap_count > 0) { +- STotal = CONVERT(kswap[0].ksw_total); +- SUsed = CONVERT(kswap[0].ksw_used); +- SFree = CONVERT(kswap[0].ksw_total - kswap[0].ksw_used); ++ int swapin, swapout; ++ ++#define CONVERT(v) ((quad_t)(v) * pagesize / 1024) ++ ++#define GETSYSCTL(mib, var) \ ++ len = sizeof(var); \ ++ sysctlbyname(mib, &var, &len, NULL, 0); ++ ++#define GETPAGESYSCTL(mib, var) \ ++ GETSYSCTL(mib, var) \ ++ var = CONVERT(var); ++ ++#define GETMEMSYSCTL(mib, var) \ ++ GETSYSCTL(mib, var) \ ++ var /= 1024; ++ ++ /* ++ * Memory ++ */ ++ GETPAGESYSCTL("vm.stats.vm.v_active_count", memory_stats[MEM_ACTIVE]) ++ GETPAGESYSCTL("vm.stats.vm.v_inactive_count", memory_stats[MEM_INACTIVE]) ++ GETPAGESYSCTL("vm.stats.vm.v_wire_count", memory_stats[MEM_WIRED]) ++ GETPAGESYSCTL("vm.stats.vm.v_cache_count", memory_stats[MEM_CACHED]) ++ GETPAGESYSCTL("vm.stats.vm.v_free_count", memory_stats[MEM_FREE]) ++ GETMEMSYSCTL("vfs.bufspace", memory_stats[MEM_BUFFERED]) ++ GETMEMSYSCTL("hw.physmem", memory_stats[MEM_TOTAL]) ++ ++ /* ++ * Swap ++ */ ++ GETSYSCTL("vm.stats.vm.v_swappgsin", swapin); ++ GETSYSCTL("vm.stats.vm.v_swappgsout", swapout); ++ ++ if (swap_old[SWAP_IN] < 0) { ++ swap_stats[SWAP_IN] = 0; ++ swap_stats[SWAP_OUT] = 0; ++ } else { ++ swap_stats[SWAP_IN] = CONVERT(swapin - swap_old[SWAP_IN]); ++ swap_stats[SWAP_OUT] = CONVERT(swapout - swap_old[SWAP_OUT]); + } + +- len = sizeof (Buffers); +- if ((sysctlbyname("vfs.bufspace", &Buffers, &len, NULL, 0) == -1) || !len) +- Buffers = 0; /* Doesn't work under FreeBSD v2.2.x */ +- Buffers /= 1024; +- +- len = sizeof (Cached); +- if ((sysctlbyname("vm.stats.vm.v_cache_count", &Cached, &len, NULL, 0) == -1) || !len) +- Cached = 0; /* Doesn't work under FreeBSD v2.2.x */ +- Cached *= pagesize / 1024; +- +- len = sizeof (MFree); +- if ((sysctlbyname("vm.stats.vm.v_free_count", &MFree, &len, NULL, 0) == -1) || !len) +- MFree = 0; /* Doesn't work under FreeBSD v2.2.x */ +- MFree *= pagesize / 1024; ++ /* call CPU heavy swapmode() only for changes */ ++ if (swap_stats[SWAP_IN] > 0 || swap_stats[SWAP_OUT] > 0 || swap_old[SWAP_IN] < 0) { ++ struct kvm_swap swapary; ++ if (kvm_getswapinfo(kd, &swapary, 1, 0) < 0 || swapary.ksw_total == 0) { ++ int i; ++ for (i = 0; i < (sizeof(swap_stats) / sizeof(swap_stats[0])); ++i) ++ swap_stats[i] = 0; ++ } else { ++ swap_stats[SWAP_TOTAL] = CONVERT(swapary.ksw_total); ++ swap_stats[SWAP_USED] = CONVERT(swapary.ksw_used); ++ swap_stats[SWAP_FREE] = CONVERT(swapary.ksw_total - swapary.ksw_used); ++ } ++ } + +- Used = Total - MFree; +- Application = Used - Buffers - Cached; ++ swap_old[SWAP_IN] = swapin; ++ swap_old[SWAP_OUT] = swapout; + + return 0; ++ ++#undef CONVERT ++#undef GETSYSCTL ++#undef GETPAGESYSCTL ++#undef GETMEMSYSCTL + } + + void +-printMFree(const char* cmd) ++printMActive(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", MFree); ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_ACTIVE]); + } + + void +-printMFreeInfo(const char* cmd) ++printMActiveInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Active Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); ++} ++ ++void ++printMInactive(const char* cmd) ++{ ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_INACTIVE]); ++} ++ ++void ++printMInactiveInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Inactive Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); ++} ++ ++void ++printMApplication(const char* cmd) + { +- fprintf(CurrentClient, "Free Memory\t0\t%d\tKB\n", Total); ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_ACTIVE] + memory_stats[MEM_INACTIVE]); + } + + void +-printUsed(const char* cmd) ++printMApplicationInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Application (Active and Inactive) Memory\t0\t%ld\tKB\n", memory_stats[MEM_TOTAL]); ++} ++ ++void ++printMWired(const char* cmd) ++{ ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_WIRED]); ++} ++ ++void ++printMWiredInfo(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", Used); ++ fprintf(CurrentClient, "Wired Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); + } + + void +-printUsedInfo(const char* cmd) ++printMCached(const char* cmd) + { +- fprintf(CurrentClient, "Used Memory\t0\t%d\tKB\n", Total); ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_CACHED]); + } + + void +-printBuffers(const char* cmd) ++printMCachedInfo(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", Buffers); ++ fprintf(CurrentClient, "Cached Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); + } + + void +-printBuffersInfo(const char* cmd) ++printMBuffers(const char* cmd) + { +- fprintf(CurrentClient, "Buffer Memory\t0\t%d\tKB\n", Total); ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_BUFFERED]); + } + + void +-printCached(const char* cmd) ++printMBuffersInfo(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", Cached); ++ fprintf(CurrentClient, "Buffer Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); + } + + void +-printCachedInfo(const char* cmd) ++printMFree(const char* cmd) + { +- fprintf(CurrentClient, "Cached Memory\t0\t%d\tKB\n", Total); ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_FREE]); + } + + void +-printApplication(const char* cmd) ++printMFreeInfo(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", Application); ++ fprintf(CurrentClient, "Free Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); + } + + void +-printApplicationInfo(const char* cmd) ++printMUsed(const char* cmd) + { +- fprintf(CurrentClient, "Application Memory\t0\t%ld\tKB\n", Total); ++ fprintf(CurrentClient, "%lu\n", memory_stats[MEM_TOTAL] - memory_stats[MEM_FREE]); ++} ++ ++void ++printMUsedInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Used Memory\t0\t%lu\tKB\n", memory_stats[MEM_TOTAL]); + } + + void + printSwapUsed(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", SUsed); ++ fprintf(CurrentClient, "%lu\n", swap_stats[SWAP_USED]); + } + + void + printSwapUsedInfo(const char* cmd) + { +- fprintf(CurrentClient, "Used Swap Memory\t0\t%d\tKB\n", STotal); ++ fprintf(CurrentClient, "Used Swap Memory\t0\t%lu\tKB\n", swap_stats[SWAP_TOTAL]); + } + + void + printSwapFree(const char* cmd) + { +- fprintf(CurrentClient, "%d\n", SFree); ++ fprintf(CurrentClient, "%lu\n", swap_stats[SWAP_FREE]); + } + + void + printSwapFreeInfo(const char* cmd) + { +- fprintf(CurrentClient, "Free Swap Memory\t0\t%d\tKB\n", STotal); ++ fprintf(CurrentClient, "Free Swap Memory\t0\t%lu\tKB\n", swap_stats[SWAP_TOTAL]); ++} ++ ++void ++printSwapIn(const char* cmd) ++{ ++ fprintf(CurrentClient, "%lu\n", swap_stats[SWAP_IN]); ++} ++ ++void ++printSwapInInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Swapped In Memory\t0\t0\tKB/s\n"); ++} ++ ++void ++printSwapOut(const char* cmd) ++{ ++ fprintf(CurrentClient, "%lu\n", swap_stats[SWAP_OUT]); ++} ++ ++void ++printSwapOutInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Swapped Out Memory\t0\t0\tKB/s\n"); + } diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__Memory.h b/sysutils/ksysguardd/files/patch-FreeBSD__Memory.h new file mode 100644 index 000000000000..85306ead9889 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__Memory.h @@ -0,0 +1,41 @@ +--- FreeBSD/Memory.h 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/Memory.h 2010-11-09 11:06:08.000000000 +0200 +@@ -27,19 +27,30 @@ + + int updateMemory(void); + ++void printMActive(const char* cmd); ++void printMActiveInfo(const char* cmd); ++void printMInactive(const char* cmd); ++void printMInactiveInfo(const char* cmd); ++void printMApplication(const char* cmd); ++void printMApplicationInfo(const char* cmd); ++void printMWired(const char* cmd); ++void printMWiredInfo(const char* cmd); ++void printMCached(const char* cmd); ++void printMCachedInfo(const char* cmd); ++void printMBuffers(const char* cmd); ++void printMBuffersInfo(const char* cmd); + void printMFree(const char* cmd); + void printMFreeInfo(const char* cmd); +-void printUsed(const char* cmd); +-void printUsedInfo(const char* cmd); +-void printBuffers(const char* cmd); +-void printBuffersInfo(const char* cmd); +-void printCached(const char* cmd); +-void printCachedInfo(const char* cmd); +-void printApplication(const char* cmd); +-void printApplicationInfo(const char* cmd); ++void printMUsed(const char* cmd); ++void printMUsedInfo(const char* cmd); ++ + void printSwapUsed(const char* cmd); + void printSwapUsedInfo(const char* cmd); + void printSwapFree(const char* cmd); + void printSwapFreeInfo(const char* cmd); ++void printSwapIn(const char* cmd); ++void printSwapInInfo(const char* cmd); ++void printSwapOut(const char* cmd); ++void printSwapOutInfo(const char* cmd); + + #endif diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__ProcessList.c b/sysutils/ksysguardd/files/patch-FreeBSD__ProcessList.c new file mode 100644 index 000000000000..cb29ec40467e --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__ProcessList.c @@ -0,0 +1,707 @@ +--- FreeBSD/ProcessList.c 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/ProcessList.c 2011-02-10 16:06:59.000000000 +0200 +@@ -1,6 +1,7 @@ + /* + KSysGuard, the KDE System Guard + ++ Copyright (c) 2011 David Naylor <naylor.b.david@gmail.com> + Copyright (c) 1999-2000 Hans Petter Bieker<bieker@kde.org> + Copyright (c) 1999 Chris Schlaeger <cs@kde.org> + +@@ -20,423 +21,271 @@ + + */ + +-#include <ctype.h> +-#include <dirent.h> ++#include "ProcessList.h" ++ ++#include <fcntl.h> ++#include <paths.h> + #include <pwd.h> ++#include <signal.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <sys/param.h> +- +-#if defined(__DragonFly__) +-#include <sys/user.h> +-#include <sys/resourcevar.h> +-#endif +- +-#if (__FreeBSD_version > 500015) || (__FreeBSD_kernel_version > 500015) +-#include <sys/priority.h> +-#endif + #include <sys/sysctl.h> +-#include <sys/time.h> + #include <sys/types.h> + #include <sys/user.h> ++#include <time.h> + #include <unistd.h> +-#include <signal.h> + +-#include "../../gui/SignalIDs.h" + #include "Command.h" +-#include "ProcessList.h" +-#include "ccont.h" +-#include "ksysguardd.h" +- +-CONTAINER ProcessList = 0; ++#include "../../gui/SignalIDs.h" + +-int fscale; ++#define KILL_COMMAND "kill" ++#define SETPRIORITY_COMMAND "setpriority" ++#define PROC_MONITOR "ps" ++#define NPROC_MONITOR "pscount" ++#define PID_MONITOR "lastpid" ++#define PROCBUF 1024 ++#define STATEBUF 12 ++#define NAMEBUF 24 ++#define UNAMEBUF 12 ++#define ARGBUF 256 ++#define PWDBUF 16 ++#define NAMELEN 128 ++ ++static struct kinfo_proc proc_buf[PROCBUF], prev_list[PROCBUF]; ++static int nproc, prev_nproc, sorted_proc[PROCBUF], prev_sorted[PROCBUF]; + +-#define BUFSIZE 1024 ++static struct timespec last_update; ++static float scale; + +-typedef struct +-{ +- /* This flag is set for all found processes at the beginning of the +- * process list update. Processes that do not have this flag set will +- * be assumed dead and removed from the list. The flag is cleared after +- * each list update. */ +- int alive; ++static int pagesize, smpmode; + +- /* the process ID */ +- pid_t pid; ++static unsigned int lastpid; + +- /* the parent process ID */ +- pid_t ppid; +- +- /* the real user ID */ ++static struct { + uid_t uid; ++ char name[NAMELEN]; ++} pwd_cache[PWDBUF]; ++static int pwd_size = 0, pwd_hit = 0, pwd_last = 0; + +- /* the real group ID */ +- gid_t gid; ++static char *const statuses[] = { "", "IDLE", "RUN", "SLEEP", "STOP", "ZOMBIE", "WAIT", "LOCK" }; ++static char (*cpunames)[8] = NULL; + +- /* a character description of the process status */ +- char status[16]; ++static int cmp_pid(const void *, const void *); ++static char *getname(const uid_t); + +- /* the number of the tty the process owns */ +- int ttyNo; ++void initProcessList(struct SensorModul *sm) { ++ size_t len; ++ ++ if (!RunAsDaemon) { ++ registerCommand(KILL_COMMAND, killProcess); ++ registerCommand(SETPRIORITY_COMMAND, setPriority); ++ } + +- /* +- * The nice level. The range should be -20 to 20. I'm not sure +- * whether this is true for all platforms. +- */ +- int niceLevel; +- +- /* +- * The scheduling priority. +- */ +- int priority; +- +- /* +- * The total amount of memory the process uses. This includes shared and +- * swapped memory. +- */ +- unsigned int vmSize; +- +- /* +- * The amount of physical memory the process currently uses. +- */ +- unsigned int vmRss; +- +- /* +- * The amount of memory (shared/swapped/etc) the process shares with +- * other processes. +- */ +- unsigned int vmLib; +- +- /* +- * The number of 1/100 of a second the process has spend in user space. +- * If a machine has an uptime of 1 1/2 years or longer this is not a +- * good idea. I never thought that the stability of UNIX could get me +- * into trouble! ;) +- */ +-#if !defined(__DragonFly__) +- unsigned int userTime; +-#else +- long userTime; +-#endif +- +- /* +- * The number of 1/100 of a second the process has spend in system space. +- * If a machine has an uptime of 1 1/2 years or longer this is not a +- * good idea. I never thought that the stability of UNIX could get me +- * into trouble! ;) +- */ +- unsigned int sysTime; +- +- /* system time as multime of 100ms */ +- int centStamp; +- +- /* the current CPU load (in %) from user space */ +- double userLoad; +- +- /* the current CPU load (in %) from system space */ +- double sysLoad; +- +- /* the name of the process */ +- char name[64]; +- +- /* the command used to start the process */ +- char cmdline[256]; +- +- /* the login name of the user that owns this process */ +- char userName[32]; +-} ProcessInfo; ++ len = sizeof(int); ++ if (sysctlbyname("kern.smp.active", &smpmode, &len, NULL, 0)) ++ smpmode = 0; ++ else { ++ int cpus = 0; ++ len = sizeof(int); ++ sysctlbyname("kern.smp.cpus", &cpus, &len, NULL, 0); ++ cpunames = malloc(8 * sizeof(char) * cpus); ++ while (cpus--) ++ snprintf(cpunames[cpus], 8, "CPU%d", cpus); ++ } + +-static unsigned ProcessCount; ++ pagesize = getpagesize() / 1024; + +-static int +-processCmp(void* p1, void* p2) +-{ +- return (((ProcessInfo*) p1)->pid - ((ProcessInfo*) p2)->pid); ++ registerMonitor(PROC_MONITOR, "table", printProcessList, printProcessListInfo, sm); ++ registerMonitor(NPROC_MONITOR, "integer", printProcessCount, printProcessCountInfo, sm); ++ registerMonitor(PID_MONITOR, "integer", printLastPID, printLastPIDInfo, sm); ++ ++ nproc = 0; ++ updateProcessList(); + } + +-static ProcessInfo* +-findProcessInList(int pid) +-{ +- ProcessInfo key; +- long index; ++void exitProcessList(void) { ++ removeCommand(KILL_COMMAND); ++ removeCommand(SETPRIORITY_COMMAND); + +- key.pid = pid; +- if ((index = search_ctnr(ProcessList, processCmp, &key)) < 0) +- return (0); ++ removeMonitor(PROC_MONITOR); ++ removeMonitor(NPROC_MONITOR); ++ removeMonitor(PID_MONITOR); + +- return (get_ctnr(ProcessList, index)); ++ free(cpunames); ++ cpunames = NULL; + } + +-static int +-updateProcess(int pid) +-{ +- static const char * const statuses[] = { "idle","run","sleep","stop","zombie" }; +- +- ProcessInfo* ps; +- struct passwd* pwent; +- int mib[4]; +- struct kinfo_proc p; +- struct rusage pru; ++int updateProcessList(void) { ++ int proc; ++ int mib[3]; + size_t len; +- size_t buflen = 256; +- char buf[256]; +- +- if ((ps = findProcessInList(pid)) == 0) +- { +- ps = (ProcessInfo*) malloc(sizeof(ProcessInfo)); +- ps->pid = pid; +- ps->centStamp = 0; +- push_ctnr(ProcessList, ps); +- bsort_ctnr(ProcessList, processCmp); +- } ++ struct timespec update; + +- ps->alive = 1; ++ memcpy(prev_list, proc_buf, sizeof(struct kinfo_proc) * nproc); ++ memcpy(prev_sorted, sorted_proc, sizeof(int) * nproc); ++ prev_nproc = nproc; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; +- mib[2] = KERN_PROC_PID; +- mib[3] = pid; +- +- len = sizeof (p); +- if (sysctl(mib, 4, &p, &len, NULL, 0) == -1 || !len) +- return -1; ++ mib[2] = KERN_PROC_PROC; ++ len = PROCBUF * sizeof(struct kinfo_proc); ++ clock_gettime(CLOCK_MONOTONIC, &update); ++ sysctl(mib, 3, proc_buf, &len, NULL, 0); ++ nproc = len / sizeof(struct kinfo_proc); ++ ++ len = sizeof(unsigned int); ++ sysctlbyname("kern.lastpid", &lastpid, &len, NULL, 0); ++ ++ if (nproc > PROCBUF) ++ nproc = PROCBUF; ++ for (proc = 0; proc < nproc; ++proc) ++ sorted_proc[proc] = proc; ++ qsort(sorted_proc, nproc, sizeof(int), cmp_pid); + +-#if (__FreeBSD_version > 500015) || (__FreeBSD_kernel_version > 500015) +- ps->pid = p.ki_pid; +- ps->ppid = p.ki_ppid; +- ps->uid = p.ki_uid; +- ps->gid = p.ki_pgid; +- ps->priority = p.ki_pri.pri_user; +- ps->niceLevel = p.ki_nice; +-#elif defined(__DragonFly__) && __DragonFly_version >= 190000 +- ps->pid = p.kp_pid; +- ps->ppid = p.kp_ppid; +- ps->uid = p.kp_uid; +- ps->gid = p.kp_pgid; +- ps->priority = p.kp_lwp.kl_tdprio; +- ps->niceLevel = p.kp_nice; +-#else +- ps->pid = p.kp_proc.p_pid; +- ps->ppid = p.kp_eproc.e_ppid; +- ps->uid = p.kp_eproc.e_ucred.cr_uid; +- ps->gid = p.kp_eproc.e_pgid; +-#if defined(__DragonFly__) +- ps->priority = p.kp_thread.td_pri; +-#else +- ps->priority = p.kp_proc.p_priority; +-#endif +- ps->niceLevel = p.kp_proc.p_nice; +-#endif +- +- /* this isn't usertime -- it's total time (??) */ +-#if (__FreeBSD_version > 500015) || (__FreeBSD_kernel_version > 500015) +- ps->userTime = p.ki_runtime / 10000; +-#elif defined(__DragonFly__) +-#if __DragonFly_version >= 190000 +- if (!getrusage(p.kp_pid, &pru)) +-#else +- if (!getrusage(p.kp_proc.p_pid, &pru)) +-#endif +- { +- errx(1, "failed to get rusage info"); +- } +- ps->userTime = pru.ru_utime.tv_usec / 1000; /*p_runtime / 1000*/ +-#elif __FreeBSD_version >= 300000 +- ps->userTime = p.kp_proc.p_runtime / 10000; +-#else +- ps->userTime = p.kp_proc.p_rtime.tv_sec*100+p.kp_proc.p_rtime.tv_usec/100; +-#endif +- ps->sysTime = 0; +- ps->sysLoad = 0; +- +- /* memory, process name, process uid */ +- /* find out user name with process uid */ +- pwent = getpwuid(ps->uid); +- strncpy(ps->userName,pwent&&pwent->pw_name? pwent->pw_name:"????",sizeof(ps->userName)); +- ps->userName[sizeof(ps->userName)-1]='\0'; ++ scale = (update.tv_sec - last_update.tv_sec) + (update.tv_nsec - last_update.tv_nsec) / 1000000000.0; ++ last_update = update; + +- if (fscale == 0) +- ps->userLoad = 0; +- else +-#if (__FreeBSD_version > 500015) || (__FreeBSD_kernel_version > 500015) +- ps->userLoad = 100.0 * (double) p.ki_pctcpu / fscale; +- ps->vmSize = p.ki_size; +- ps->vmRss = p.ki_rssize * getpagesize(); +- strlcpy(ps->name,p.ki_comm? p.ki_comm:"????",sizeof(ps->name)); +- strcpy(ps->status,(p.ki_stat>=1)&&(p.ki_stat<=5)? statuses[p.ki_stat-1]:"????"); +-#elif defined (__DragonFly__) && __DragonFly_version >= 190000 +- ps->userLoad = 100.0 * (double) p.kp_lwp.kl_pctcpu / fscale; +- ps->vmSize = p.kp_vm_map_size; +- ps->vmRss = p.kp_vm_rssize * getpagesize(); +- strlcpy(ps->name,p.kp_comm ? p.kp_comm : "????", +- sizeof(ps->name)); +- strcpy(ps->status,(p.kp_stat>=1)&&(p.kp_stat<=5)? statuses[p.kp_stat-1]:"????"); +-#else +- ps->userLoad = 100.0 * (double) p.kp_proc.p_pctcpu / fscale; +- ps->vmSize = p.kp_eproc.e_vm.vm_map.size; +- ps->vmRss = p.kp_eproc.e_vm.vm_rssize * getpagesize(); +-#if defined (__DragonFly__) +- strlcpy(ps->name,p.kp_thread.td_comm ? p.kp_thread.td_comm : "????", +- sizeof(ps->name)); +-#else +- strlcpy(ps->name,p.kp_proc.p_comm ? p.kp_proc.p_comm : "????", sizeof(ps->name)); +-#endif +- strcpy(ps->status,(p.kp_proc.p_stat>=1)&&(p.kp_proc.p_stat<=5)? statuses[p.kp_proc.p_stat-1]:"????"); +-#endif ++ return (0); ++} + +- /* process command line */ +- /* do a sysctl to get the command line args. */ ++void printProcessList(const char* cmd) ++{ ++ int proc, prev_proc; ++ float load; ++ int mib[4]; ++ char *name, *uname, *state, *arg_fix; ++ char buf[STATEBUF + 1], buf2[UNAMEBUF], buf3[NAMEBUF], args[ARGBUF]; ++ struct kinfo_proc *ps, *last_ps; ++ size_t len; + ++ buf[STATEBUF] = '\0'; ++ buf3[0] = '['; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_ARGS; +- mib[3] = pid; +- +- if ((sysctl(mib, 4, buf, &buflen, 0, 0) == -1) || !buflen) +- strcpy(ps->cmdline, "????"); +- else +- strncpy(ps->cmdline, buf, buflen); + +- return (0); +-} ++ for (prev_proc = 0, proc = 0; proc < nproc; ++proc) { ++ ps = &proc_buf[sorted_proc[proc]]; + +-static void +-cleanupProcessList(void) +-{ +- ProcessInfo* ps; +- +- ProcessCount = 0; +- /* All processes that do not have the active flag set are assumed dead +- * and will be removed from the list. The alive flag is cleared. */ +- for (ps = first_ctnr(ProcessList); ps; ps = next_ctnr(ProcessList)) +- { +- if (ps->alive) +- { +- /* Process is still alive. Just clear flag. */ +- ps->alive = 0; +- ProcessCount++; ++ mib[3] = ps->ki_pid; ++ len = ARGBUF; ++ sysctl(mib, 4, args, &len, 0, 0); ++ if (!len) ++ args[0] = '\0'; ++ else { ++ arg_fix = args; ++ while ((arg_fix += strlen(arg_fix)) < args + len - 1) ++ *arg_fix = '*'; + } ++ ++ if (args[0] == '\0' && (ps->ki_flag & P_SYSTEM || ps->ki_args == NULL)) { ++ int cpy; ++ cpy = strlcpy(buf3 + 1, ps->ki_comm, NAMEBUF - 1); ++ if (cpy > NAMEBUF - 2) ++ cpy = NAMEBUF - 2; ++ buf3[cpy + 1] = ']'; ++ buf3[cpy + 2] = '\0'; ++ name = buf3; ++ // TODO: should kernel processes be displayed? ++ //continue; ++ } else if (ps->ki_comm != NULL) ++ name = ps->ki_comm; + else +- { +- /* Process has probably died. We remove it from the list and +- * destruct the data structure. */ +- free(remove_ctnr(ProcessList)); ++ name = "????"; ++ ++ switch (ps->ki_stat) { ++ case SRUN: ++ if (smpmode && ps->ki_oncpu != 0xff) ++ state = cpunames[ps->ki_oncpu]; ++ else ++ state = statuses[2]; ++ break; ++ case SSLEEP: ++ if (ps->ki_wmesg != NULL) { ++ state = ps->ki_wmesg; ++ break; ++ } ++ ++ case SLOCK: ++ if (ps->ki_kiflag & KI_LOCKBLOCK) { ++ snprintf(buf, STATEBUF, "*%s", ps->ki_lockname); ++ state = buf; ++ break; ++ } ++ ++ case SIDL: ++ case SSTOP: ++ case SZOMB: ++ case SWAIT: ++ state = statuses[(int)ps->ki_stat]; ++ break; ++ ++ default: ++ snprintf(buf, STATEBUF, "?%d", ps->ki_stat); ++ state = buf; + } +- } +-} + +-/* +-================================ public part ================================== +-*/ ++ uname = getname(ps->ki_ruid); ++ if (uname[0] == '\0') { ++ snprintf(buf2, UNAMEBUF, "%d", ps->ki_ruid); ++ uname = buf2; ++ } + +-void +-initProcessList(struct SensorModul* sm) +-{ +- size_t fscalelen; +- ProcessList = new_ctnr(); ++ for (;;) { ++ if (prev_proc >= prev_nproc) { ++ last_ps = NULL; ++ break; ++ } ++ last_ps = &prev_list[prev_sorted[prev_proc]]; ++ if (last_ps->ki_pid == ps->ki_pid && ++ last_ps->ki_start.tv_sec == ps->ki_start.tv_sec && ++ last_ps->ki_start.tv_usec == ps->ki_start.tv_usec) ++ break; ++ else if (last_ps->ki_pid > ps->ki_pid) { ++ last_ps = NULL; ++ break; ++ } ++ ++prev_proc; ++ } + +- registerMonitor("ps", "table", printProcessList, printProcessListInfo, sm); +- registerMonitor("pscount", "integer", printProcessCount, printProcessCountInfo, sm); ++ if (last_ps != NULL) ++ load = (ps->ki_runtime - last_ps->ki_runtime) / 1000000.0 / scale; ++ else ++ load = ps->ki_runtime / 1000000.0 / scale; + +- if (!RunAsDaemon) +- { +- registerCommand("kill", killProcess); +- registerCommand("setpriority", setPriority); ++ fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%ld\t%s\t%.2f\t%.2f\t%d\t%ld\t%ld\t%s\t%s\n", ++ name, (long)ps->ki_pid, (long)ps->ki_ppid, ++ (long)ps->ki_uid, (long)ps->ki_pgid, state, ++ ps->ki_runtime / 1000000.0, load, ps->ki_nice, ++ ps->ki_size / 1024, ps->ki_rssize * pagesize, uname, args); + } +- +- fscalelen = sizeof(fscale); +- if (sysctlbyname("kern.fscale", &fscale, &fscalelen, NULL, 0) == -1) +- fscale = 0; +- +- updateProcessList(); +-} +- +-void +-exitProcessList(void) +-{ +- removeMonitor("ps"); +- removeMonitor("pscount"); +- +- if (ProcessList) +- free (ProcessList); +-} +- +-int +-updateProcessList(void) +-{ +- int mib[3]; +- size_t len; +- size_t num; +- struct kinfo_proc *p; +- +- +- mib[0] = CTL_KERN; +- mib[1] = KERN_PROC; +- mib[2] = KERN_PROC_ALL; +- sysctl(mib, 3, NULL, &len, NULL, 0); +- p = malloc(len); +- sysctl(mib, 3, p, &len, NULL, 0); +- +- for (num = 0; num < len / sizeof(struct kinfo_proc); num++) +-#if (__FreeBSD_version > 500015) || (__FreeBSD_kernel_version > 500015) +- updateProcess(p[num].ki_pid); +-#elif __DragonFly_version >= 190000 +- /* Skip kernel threads with pid -1. Swapper with pid 0 also +- * causing problems is skipped in printProcessList() as 'kernel' +- * entry. */ +- if (p[num].kp_pid >= 0) +- updateProcess(p[num].kp_pid); +-#elif defined(__DragonFly__) +- if (p[num].kp_proc.p_pid >= 0) +- updateProcess(p[num].kp_proc.p_pid); +-#else +- updateProcess(p[num].kp_proc.p_pid); +-#endif +- free(p); +- cleanupProcessList(); +- +- return (0); + } + +-void +-printProcessListInfo(const char* cmd) ++void printProcessListInfo(const char* cmd) + { + fprintf(CurrentClient, "Name\tPID\tPPID\tUID\tGID\tStatus\tUser%%\tSystem%%\tNice\tVmSize\tVmRss\tLogin\tCommand\n"); + fprintf(CurrentClient, "s\td\td\td\td\tS\tf\tf\td\tD\tD\ts\ts\n"); + } + +-void +-printProcessList(const char* cmd) +-{ +- ProcessInfo* ps; ++void printProcessCount(const char *cmd) { ++ fprintf(CurrentClient, "%d\n", nproc); ++} + +- ps = first_ctnr(ProcessList); /* skip 'kernel' entry */ +- for (ps = next_ctnr(ProcessList); ps; ps = next_ctnr(ProcessList)) +- { +- fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%ld\t%s\t%.2f\t%.2f\t%d\t%d\t%d\t%s\t%s\n", +- ps->name, (long)ps->pid, (long)ps->ppid, +- (long)ps->uid, (long)ps->gid, ps->status, +- ps->userLoad, ps->sysLoad, ps->niceLevel, +- ps->vmSize / 1024, ps->vmRss / 1024, ps->userName, ps->cmdline); +- } ++void printProcessCountInfo(const char *cmd) { ++ fprintf(CurrentClient, "Number of Processes\t1\t65535\t\n"); + } + +-void +-printProcessCount(const char* cmd) +-{ +- fprintf(CurrentClient, "%d\n", ProcessCount); ++void printLastPID(const char *cmd) { ++ fprintf(CurrentClient, "%u\n", lastpid); + } + +-void +-printProcessCountInfo(const char* cmd) +-{ +- fprintf(CurrentClient, "Number of Processes\t1\t65535\t\n"); ++void printLastPIDInfo(const char *cmd) { ++ fprintf(CurrentClient, "Last used Process ID\t1\t65535\t\n"); + } + +-void +-killProcess(const char* cmd) ++void killProcess(const char *cmd) + { + int sig, pid; + +@@ -524,8 +373,7 @@ + fprintf(CurrentClient, "0\t%d\n", pid); + } + +-void +-setPriority(const char* cmd) ++void setPriority(const char *cmd) + { + int pid, prio; + +@@ -535,20 +383,58 @@ + switch(errno) + { + case EINVAL: +- fprintf(CurrentClient, "4\n"); ++ fprintf(CurrentClient, "4\t%d\t%d\n", pid, prio); + break; + case ESRCH: +- fprintf(CurrentClient, "3\n"); ++ fprintf(CurrentClient, "3\t%d\t%d\n", pid, prio); + break; + case EPERM: + case EACCES: +- fprintf(CurrentClient, "2\n"); ++ fprintf(CurrentClient, "2\t%d\t%d\n", pid, prio); + break; + default: +- fprintf(CurrentClient, "1\n"); /* unknown error */ ++ fprintf(CurrentClient, "1\t%d\t%d\n", pid, prio); /* unknown error */ + break; + } + } + else + fprintf(CurrentClient, "0\n"); + } ++ ++int cmp_pid(const void *first_idx, const void *last_idx) { ++ struct kinfo_proc *first = &proc_buf[*(int *)first_idx]; ++ struct kinfo_proc *last = &proc_buf[*(int *)last_idx]; ++ ++ if (first->ki_pid < last->ki_pid) ++ return -1; ++ else if (first->ki_pid > last->ki_pid) ++ return 1; ++ else ++ return 0; ++} ++ ++char *getname(const uid_t uid) { ++ int idx; ++ struct passwd *pw; ++ ++ for (idx = 0; idx < pwd_size; ++idx) { ++ if (pwd_cache[pwd_hit].uid == uid) ++ return pwd_cache[pwd_hit].name; ++ pwd_hit = (pwd_hit + 1) % pwd_size; ++ } ++ ++ if (pwd_size < PWDBUF) ++ pwd_last = pwd_size++; ++ else ++ pwd_last = (pwd_last + 1) % PWDBUF; ++ pwd_hit = pwd_last; ++ ++ pwd_cache[pwd_hit].uid = uid; ++ pw = getpwuid(uid); ++ if (pw == NULL) ++ pwd_cache[pwd_hit].name[0] = '\0'; ++ else ++ strlcpy(pwd_cache[pwd_hit].name, pw->pw_name, NAMELEN); ++ ++ return (pwd_cache[pwd_hit].name); ++} diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__ProcessList.h b/sysutils/ksysguardd/files/patch-FreeBSD__ProcessList.h new file mode 100644 index 000000000000..947899bc2df1 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__ProcessList.h @@ -0,0 +1,39 @@ +--- FreeBSD/ProcessList.h 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/ProcessList.h 2011-01-30 11:06:11.000000000 +0200 +@@ -1,6 +1,7 @@ + /* + KSysGuard, the KDE System Guard + ++ Copyright (c) 2011 David Naylor <naylor.b.david@gmail.com> + Copyright (c) 1999 Chris Schlaeger <cs@kde.org> + + This program is free software; you can redistribute it and/or modify +@@ -22,15 +23,23 @@ + #ifndef _process_list_h_ + #define _process_list_h_ + +-void initProcessList(struct SensorModul* sm); ++struct SensorModul; ++ ++void initProcessList(struct SensorModul *); + void exitProcessList(void); + + int updateProcessList(void); + +-void printProcessList(const char*); +-void printProcessListInfo(const char*); +-void printProcessCount(const char* cmd); +-void printProcessCountInfo(const char* cmd); ++void printProcessList(const char *); ++void printProcessListInfo(const char *); ++void printThreadList(const char *); ++void printThreadListInfo(const char *); ++ ++void printProcessCount(const char *); ++void printProcessCountInfo(const char *); ++ ++void printLastPID(const char *); ++void printLastPIDInfo(const char *); + + void killProcess(const char* cmd); + void setPriority(const char* cmd); diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__acpi.c b/sysutils/ksysguardd/files/patch-FreeBSD__acpi.c new file mode 100644 index 000000000000..7c2bbd46795c --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__acpi.c @@ -0,0 +1,244 @@ +--- FreeBSD/acpi.c 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/acpi.c 2011-01-30 10:28:18.000000000 +0200 +@@ -0,0 +1,241 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 2011 David Naylor <naylor.b.david@gmail.com> ++ ++ 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. ++*/ ++ ++/* ++ * TODO ++ * - battery ++ * - fan ++ */ ++ ++#include "acpi.h" ++ ++#include <fcntl.h> ++#include <stdio.h> ++#include <sys/ioctl.h> ++#include <sys/types.h> ++#include <sys/sysctl.h> ++#include <unistd.h> ++ ++#include <dev/acpica/acpiio.h> ++ ++#include "Command.h" ++ ++#define BUF_LEN 80 ++ ++#define MAXTZ 6 ++#define TZ_MIB "hw.acpi.thermal.tz%i.temperature" ++#define TZ_MIB_LEN 32 ++#define TZ_MONITOR "acpi/thermal_zone/temp%i" ++ ++#define MAXBAT 6 ++#define BAT_CHARGE_MONITOR "acpi/battery/batt%i/batterycharge" ++#define BAT_CAPACITY_MONITOR "acpi/battery/batt%i/batterycapacity" ++#define BAT_REMAINING_MONITOR "acpi/battery/batt%i/remainingtime" ++#define BAT_VOLTAGE_MONITOR "acpi/battery/batt%i/batteryvoltage" ++#define BAT_RATE_MONITOR "acpi/battery/batt%i/batteryrate" ++#define BAT_UNIT(bat) (bat_bif[bat].bif.units ? "mA" : "mW") ++ ++static int acpifd = -1; ++ ++static int tz_temp[MAXTZ]; ++static int tz_cnt; ++ ++static int bat_cnt; ++static union acpi_battery_ioctl_arg bat_bif[MAXBAT], bat_bst[MAXBAT], bat_battinfo[MAXBAT]; ++ ++void initACPI(struct SensorModul *sm) { ++ char name[BUF_LEN]; ++ size_t len; ++ ++ /* Assume thermal zones use hw.acpi.thermal.tz%i.temperature format */ ++ for (tz_cnt = 0; tz_cnt < MAXTZ; ++tz_cnt) { ++ len = sizeof(int); ++ snprintf(name, TZ_MIB_LEN, TZ_MIB, tz_cnt); ++ if (sysctlbyname(name, &tz_temp[tz_cnt], &len, NULL, 0)) ++ break; ++ else { ++ snprintf(name, BUF_LEN, TZ_MONITOR, tz_cnt + 1); ++ registerMonitor(name, "float", printThermal, printThermalInfo, sm); ++ } ++ } ++ ++ if ((acpifd = open("/dev/acpi", O_RDONLY)) == -1) { ++ log_error("unable to open /dev/acpi"); ++ return; ++ } ++ ++ for (bat_cnt = 0; bat_cnt < MAXBAT; ++bat_cnt) { ++ bat_bif[bat_cnt].unit = bat_cnt; ++ if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &bat_bif[bat_cnt])) ++ break; ++ else { ++ snprintf(name, BUF_LEN, BAT_CHARGE_MONITOR, bat_cnt + 1); ++ registerMonitor(name, "integer", printBatCharge, printBatChargeInfo, sm); ++ snprintf(name, BUF_LEN, BAT_CAPACITY_MONITOR, bat_cnt + 1); ++ registerMonitor(name, "integer", printBatCapacity, printBatCapacityInfo, sm); ++ snprintf(name, BUF_LEN, BAT_REMAINING_MONITOR, bat_cnt + 1); ++ registerMonitor(name, "integer", printBatRemaining, printBatRemainingInfo, sm); ++ snprintf(name, BUF_LEN, BAT_VOLTAGE_MONITOR, bat_cnt + 1); ++ registerMonitor(name, "integer", printBatVoltage, printBatVoltageInfo, sm); ++ snprintf(name, BUF_LEN, BAT_RATE_MONITOR, bat_cnt + 1); ++ registerMonitor(name, "integer", printBatRate, printBatRateInfo, sm); ++ } ++ } ++} ++ ++void exitACPI(void) { ++ int bat, tz; ++ char name[BUF_LEN]; ++ ++ for (tz = 0; tz < tz_cnt; ++tz) { ++ snprintf(name, BUF_LEN, TZ_MONITOR, tz + 1); ++ removeMonitor(name); ++ } ++ ++ if (acpifd != -1) { ++ for (bat = 0; bat < bat_cnt; ++bat) { ++ snprintf(name, TZ_MIB_LEN, BAT_CHARGE_MONITOR, bat + 1); ++ removeMonitor(name); ++ snprintf(name, BUF_LEN, BAT_CAPACITY_MONITOR, bat + 1); ++ removeMonitor(name); ++ snprintf(name, BUF_LEN, BAT_REMAINING_MONITOR, bat + 1); ++ removeMonitor(name); ++ snprintf(name, BUF_LEN, BAT_VOLTAGE_MONITOR, bat + 1); ++ removeMonitor(name); ++ ++ } ++ ++ close(acpifd); ++ acpifd = -1; ++ } ++} ++ ++int updateACPI(void) { ++ int bat, tz; ++ char name[TZ_MIB_LEN]; ++ size_t len; ++ ++ for (tz = 0; tz < tz_cnt; ++tz) { ++ len = sizeof(int); ++ snprintf(name, TZ_MIB_LEN, TZ_MIB, tz); ++ sysctlbyname(name, &tz_temp[tz], &len, NULL, 0); ++ } ++ ++ for (bat = 0; bat < bat_cnt; ++bat) { ++ bat_bst[bat].unit = bat; ++ ioctl(acpifd, ACPIIO_BATT_GET_BST, &bat_bst[bat]); ++ bat_battinfo[bat].unit = bat; ++ ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &bat_battinfo[bat]); ++ } ++ ++ return (0); ++} ++ ++void printThermal(const char *cmd) { ++ int tz; ++ ++ sscanf(cmd + 22, "%i", &tz); ++ fprintf(CurrentClient, "%f\n", (tz_temp[tz - 1] - 2732) / 10.0); ++} ++ ++void printThermalInfo(const char *cmd) { ++ int tz; ++ ++ sscanf(cmd + 22, "%i", &tz); ++ fprintf(CurrentClient, "ACPI Thermal Zone %i\t0\t0\tC\n", tz); ++} ++ ++/* ++void printBat(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, ""); ++} ++*/ ++ ++void printBatCharge(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "%i\n", bat_bst[bat - 1].bst.cap); ++} ++ ++void printBatChargeInfo(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "Battery %i charge\t0\t%i\t%sh\n", bat, bat_bif[bat - 1].bif.dcap, BAT_UNIT(bat - 1)); ++} ++ ++void printBatCapacity(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "%i\n", bat_battinfo[bat - 1].battinfo.cap); ++} ++ ++void printBatCapacityInfo(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "Battery %i capacity\t0\t100\t%%\n", bat); ++} ++ ++void printBatRemaining(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "%i\n", bat_battinfo[bat - 1].battinfo.min); ++} ++ ++void printBatRemainingInfo(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "Battery %i remaining time\t0\t0\tmin\n", bat); ++} ++ ++void printBatVoltage(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "%i\n", bat_bst[bat - 1].bst.volt); ++} ++ ++void printBatVoltageInfo(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "Battery %i voltage\t0\t%i\tmV\n", bat, bat_bif[bat - 1].bif.dvol); ++} ++ ++void printBatRate(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "%i\n", bat_bst[bat - 1].bst.rate); ++} ++ ++void printBatRateInfo(const char *cmd) { ++ int bat; ++ ++ sscanf(cmd + 17, "%i", &bat); ++ fprintf(CurrentClient, "Battery %i discharge rate\t0\t0\t%s\n", bat, BAT_UNIT(bat - 1)); ++} diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__acpi.h b/sysutils/ksysguardd/files/patch-FreeBSD__acpi.h new file mode 100644 index 000000000000..e68693581753 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__acpi.h @@ -0,0 +1,48 @@ +--- FreeBSD/acpi.h 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/acpi.h 2011-01-27 20:56:50.000000000 +0200 +@@ -0,0 +1,45 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 2011 David Naylor <naylor.b.david@gmail.com> ++ ++ 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. ++ ++*/ ++ ++#ifndef _acpi_h_ ++#define _acpi_h_ ++ ++struct SensorModul; ++ ++void initACPI(struct SensorModul*); ++void exitACPI(void); ++ ++int updateACPI(void); ++ ++void printBatCharge(const char*); ++void printBatChargeInfo(const char*); ++void printBatCapacity(const char*); ++void printBatCapacityInfo(const char*); ++void printBatRemaining(const char*); ++void printBatRemainingInfo(const char*); ++void printBatVoltage(const char*); ++void printBatVoltageInfo(const char*); ++void printBatRate(const char*); ++void printBatRateInfo(const char*); ++ ++void printThermal(const char *); ++void printThermalInfo(const char *); ++ ++#endif /* _acpi_h_ */ diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__cpuinfo.c b/sysutils/ksysguardd/files/patch-FreeBSD__cpuinfo.c new file mode 100644 index 000000000000..f75f00e31267 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__cpuinfo.c @@ -0,0 +1,658 @@ +--- FreeBSD/cpuinfo.c 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/cpuinfo.c 2011-02-19 10:12:35.000000000 +0200 +@@ -0,0 +1,655 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 1999 Chris Schlaeger <cs@kde.org> ++ Copyright (c) 2010 David Naylor <naylor.b.david@gmail.com> ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ 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 <sys/types.h> ++ ++#include <sys/resource.h> ++#include <sys/sysctl.h> ++ ++#include <devstat.h> ++#include <fcntl.h> ++#include <nlist.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <string.h> ++ ++#include "cpuinfo.h" ++#include "Command.h" ++#include "ksysguardd.h" ++ ++#define FREQ_LEVEL_BUFFER 256 ++#define SYSCTL_ID_LEN 35 ++ ++static void get_mmfreq(int, int*, int*); ++ ++static long percentages(int cnt, long *out, long *new, long *old, long *diffs); ++ ++static long (*cp_time)[CPUSTATES] = NULL; ++static long (*cp_old)[CPUSTATES] = NULL; ++static long (*cp_diff)[CPUSTATES] = NULL; ++ ++static int maxcpus = 1; ++static int cpus = 1; ++static int cores = 1; ++static int (*freq)[3] = NULL; ++static int *temp = NULL; ++ ++static long (*cpu_states)[CPUSTATES] = NULL; ++ ++void ++initCpuInfo(struct SensorModul* sm) ++{ ++ size_t len; ++ int id; ++ char name[SYSCTL_ID_LEN]; ++ int minfreq, maxfreq; ++ ++ len = sizeof(cpus); ++ // XXX: this is a guess ++ sysctlbyname("kern.smp.active", &cpus, &len, NULL, 0); ++ // NOTE: cpus may be 0, which implies 1 ++ cpus = cpus ? cpus : 1; ++ ++ len = sizeof(cores); ++ sysctlbyname("kern.smp.cpus", &cores, &len, NULL, 0); ++ ++ len = sizeof(maxcpus); ++ sysctlbyname("kern.smp.maxcpus", &maxcpus, &len, NULL, 0); ++ ++ /* Core/process count */ ++ registerMonitor("system/processors", "integer", printNumCpus, printNumCpusInfo, sm); ++ registerMonitor("system/cores", "integer", printNumCores, printNumCoresInfo, sm); ++ ++ /* ++ * CPU Loads ++ */ ++ if ((cp_time = malloc(sizeof(long) * CPUSTATES * (cores * 4 + 1))) == NULL) { ++ log_error("out of memory for cp_time"); ++ return; ++ } ++ cp_old = &cp_time[cores]; ++ cp_diff = &cp_old[cores]; ++ cpu_states = &cp_diff[cores]; ++ ++ /* Total CPU load */ ++ registerMonitor("cpu/system/user", "float", printCPUUser, printCPUUserInfo, sm); ++ registerMonitor("cpu/system/nice", "float", printCPUNice, printCPUNiceInfo, sm); ++ registerMonitor("cpu/system/sys", "float", printCPUSys, printCPUSysInfo, sm); ++ registerMonitor("cpu/system/TotalLoad", "float", printCPUTotalLoad, printCPUTotalLoadInfo, sm); ++ registerMonitor("cpu/system/intr", "float", printCPUIntr, printCPUIntrInfo, sm); ++ registerMonitor("cpu/system/idle", "float", printCPUIdle, printCPUIdleInfo, sm); ++ ++ /* Monitor names changed from kde3 => kde4. Remain compatible with legacy requests when possible. */ ++ registerLegacyMonitor("cpu/user", "float", printCPUUser, printCPUUserInfo, sm); ++ registerLegacyMonitor("cpu/nice", "float", printCPUNice, printCPUNiceInfo, sm); ++ registerLegacyMonitor("cpu/sys", "float", printCPUSys, printCPUSysInfo, sm); ++ registerLegacyMonitor("cpu/idle", "float", printCPUIdle, printCPUIdleInfo, sm); ++ ++ for (id = 0; id < cores; ++id) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/user", id); ++ registerMonitor(name, "float", printCPUxUser, printCPUxUserInfo, sm); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/nice", id); ++ registerMonitor(name, "float", printCPUxNice, printCPUxNiceInfo, sm); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/sys", id); ++ registerMonitor(name, "float", printCPUxSys, printCPUxSysInfo, sm); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/TotalLoad", id); ++ registerMonitor(name, "float", printCPUxTotalLoad, printCPUxTotalLoadInfo, sm); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/intr", id); ++ registerMonitor(name, "float", printCPUxIntr, printCPUxIntrInfo, sm); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/idle", id); ++ registerMonitor(name, "float", printCPUxIdle, printCPUxIdleInfo, sm); ++ } ++ ++ /* ++ * CPU frequencies ++ */ ++ if ((freq = malloc(sizeof(int) * 3 * (cores + 1))) == NULL) { ++ log_error("out of memory for freq"); ++ return; ++ } ++ ++ registerMonitor("cpu/system/AverageClock", "float", printCPUClock, printCPUClockInfo, sm); ++ for (id = 0; id < cores; ++id) { ++ len = sizeof(int); ++ snprintf(name, SYSCTL_ID_LEN, "dev.cpu.%d.freq", id); ++ if (!sysctlbyname(name, &freq[id][0], &len, NULL, 0)) { ++ get_mmfreq(id, &freq[id][1], &freq[id][2]); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/clock", id); ++ registerMonitor(name, "integer", printCPUxClock, printCPUxClockInfo, sm); ++ } else { ++ freq[id][0] = -1; ++ freq[id][1] = 0; ++ freq[id][2] = 0; ++ } ++ } ++ ++ minfreq = freq[0][1]; ++ maxfreq = freq[0][2]; ++ for (id = 1; id < cores; ++id) ++ if (freq[id][0] != -1) { ++ minfreq = minfreq > freq[id][1] ? freq[id][1] : minfreq; ++ maxfreq = maxfreq < freq[id][2] ? freq[id][2] : maxfreq; ++ } ++ freq[cores][1] = minfreq; ++ freq[cores][2] = maxfreq; ++ ++ /* ++ * CPU temperature ++ */ ++ if ((temp = malloc(sizeof(int) * (cores + 1))) == NULL) { ++ log_error("out of memory for temp"); ++ return; ++ } ++ registerMonitor("cpu/system/AverageTemperature", "float", printCPUTemperature, printCPUTemperatureInfo, sm); ++ for (id = 0; id < cores; ++id) { ++ len = sizeof(int); ++ snprintf(name, SYSCTL_ID_LEN, "dev.cpu.%d.temperature", id); ++ if (!sysctlbyname(name, &temp[id], &len, NULL, 0)) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/temperature", id); ++ registerMonitor(name, "float", printCPUxTemperature, printCPUxTemperatureInfo, sm); ++ } else ++ temp[id] = -1; ++ } ++ ++ updateCpuInfo(); ++} ++ ++void ++exitCpuInfo(void) ++{ ++ int id; ++ char name[SYSCTL_ID_LEN]; ++ ++ removeMonitor("system/processors"); ++ removeMonitor("system/cores"); ++ ++ if (cp_time != NULL) { ++ removeMonitor("cpu/system/user"); ++ removeMonitor("cpu/system/nice"); ++ removeMonitor("cpu/system/sys"); ++ removeMonitor("cpu/system/TotalLoad"); ++ removeMonitor("cpu/system/intr"); ++ removeMonitor("cpu/system/idle"); ++ ++ /* These were registered as legacy monitors */ ++ removeMonitor("cpu/user"); ++ removeMonitor("cpu/nice"); ++ removeMonitor("cpu/sys"); ++ removeMonitor("cpu/idle"); ++ ++ for (id = 0; id < cores; ++id) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/user", id); ++ removeMonitor(name); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/nice", id); ++ removeMonitor(name); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/sys", id); ++ removeMonitor(name); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/TotalLoad", id); ++ removeMonitor(name); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/intr", id); ++ removeMonitor(name); ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/idle", id); ++ removeMonitor(name); ++ ++ if (freq != NULL && freq[id][0] != -1) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/clock", id); ++ removeMonitor(name); ++ } ++ if (temp != NULL && temp[id] != -1) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/temperature", id); ++ removeMonitor(name); ++ } ++ } ++ ++ free(cp_time); ++ cp_time = NULL; ++ } ++ ++ if (freq != NULL) { ++ removeMonitor("cpu/system/AverageClock"); ++ for (id = 0; id < cores; ++id) ++ if (freq[id][0] != -1) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/clock", id); ++ removeMonitor(name); ++ } ++ free(freq); ++ freq = NULL; ++ } ++ ++ if (temp != NULL) { ++ removeMonitor("cpu/system/AverageTemperature"); ++ for (id = 0; id < cores; ++id) ++ if (temp[id] != -1) { ++ snprintf(name, SYSCTL_ID_LEN, "cpu/cpu%d/temperature", id); ++ removeMonitor(name); ++ } ++ free(temp); ++ temp = NULL; ++ } ++ ++} ++ ++int ++updateCpuInfo(void) ++{ ++ int sid, id, tot_freq = 0, tot_temp = 0, freq_count = 0, temp_count = 0; ++ char name[SYSCTL_ID_LEN]; ++ ++ if (cp_time == NULL || freq == NULL || temp == NULL) ++ return (0); ++ ++ size_t len = sizeof(long) * CPUSTATES * cores; ++ sysctlbyname("kern.cp_times", cp_time, &len, NULL, 0); ++ for (sid = 0; sid < CPUSTATES; ++sid) ++ cpu_states[cores][sid] = 0; ++ for (id = 0; id < cores; ++id) { ++ percentages(CPUSTATES, cpu_states[id], cp_time[id], cp_old[id], cp_diff[id]); ++ for (sid = 0; sid < CPUSTATES; ++sid) ++ cpu_states[cores][sid] += cpu_states[id][sid]; ++ } ++ for (id = 0; id < cores; ++id) { ++ if (freq[id][0] != -1) { ++ len = sizeof(int); ++ snprintf(name, SYSCTL_ID_LEN, "dev.cpu.%d.freq", id); ++ freq[id][0] = 0; ++ if (!sysctlbyname(name, &freq[id][0], &len, NULL, 0)) { ++ freq_count += 1; ++ tot_freq += freq[id][0]; ++ } ++ } ++ if (temp[id] != -1) { ++ len = sizeof(int); ++ snprintf(name, SYSCTL_ID_LEN, "dev.cpu.%d.temperature", id); ++ temp[id] = 0.0; ++ if (!sysctlbyname(name, &temp[id], &len, NULL, 0)) { ++ temp_count += 1; ++ tot_temp += temp[id]; ++ } ++ } ++ } ++ freq[cores][0] = freq_count == 0 ? 0 : tot_freq * 100 / freq_count; ++ temp[cores] = temp_count == 0 ? 0.0 : tot_temp * 100 / temp_count; ++ ++ return (0); ++} ++ ++void ++printCPUUser(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", cpu_states[cores][CP_USER] / 10.0 / cores); ++} ++ ++void ++printCPUUserInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU User Load\t0\t100\t%%\n"); ++} ++ ++void ++printCPUNice(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", cpu_states[cores][CP_NICE] / 10.0 / cores); ++} ++ ++void ++printCPUNiceInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU Nice Load\t0\t100\t%%\n"); ++} ++ ++void ++printCPUSys(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", cpu_states[cores][CP_SYS] / 10.0 / cores); ++} ++ ++void ++printCPUSysInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU System Load\t0\t100\t%%\n"); ++} ++ ++void ++printCPUTotalLoad(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", (cpu_states[cores][CP_SYS] + cpu_states[cores][CP_USER] + ++ cpu_states[cores][CP_NICE] + cpu_states[cores][CP_INTR]) / 10.0 / cores); ++} ++ ++void ++printCPUTotalLoadInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU Total Load\t0\t100\t%%\n"); ++} ++ ++void ++printCPUIntr(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", cpu_states[cores][CP_INTR] / 10.0 / cores); ++} ++ ++void ++printCPUIntrInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU Interrupt Load\t0\t100\t%%\n"); ++} ++ ++void ++printCPUIdle(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", cpu_states[cores][CP_IDLE] / 10.0 / cores); ++} ++ ++void ++printCPUIdleInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU Idle Load\t0\t100\t%%\n"); ++} ++ ++void ++printCPUxUser(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%0.1f\n", cpu_states[id][CP_USER] / 10.0); ++} ++ ++void ++printCPUxUserInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d User Load\t0\t100\t%%\n", id + 1); ++} ++ ++void ++printCPUxNice(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%0.1f\n", cpu_states[id][CP_NICE] / 10.0); ++} ++ ++void ++printCPUxNiceInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d Nice Load\t0\t100\t%%\n", id + 1); ++} ++ ++void ++printCPUxSys(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%0.1f\n", cpu_states[id][CP_SYS] / 10.0); ++} ++ ++void ++printCPUxSysInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d System Load\t0\t100\t%%\n", id + 1); ++} ++ ++void ++printCPUxTotalLoad(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%f\n", (cpu_states[id][CP_SYS] + cpu_states[id][CP_USER] + ++ cpu_states[id][CP_NICE] + cpu_states[id][CP_INTR]) / 10.0); ++} ++ ++void ++printCPUxTotalLoadInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d Total Load\t0\t100\t%%\n", id + 1); ++} ++ ++void ++printCPUxIntr(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%0.1f\n", cpu_states[id][CP_INTR] / 10.0); ++} ++ ++void ++printCPUxIntrInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d Interrupt Load\t0\t100\t%%\n", id + 1); ++} ++ ++void ++printCPUxIdle(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%0.1f\n", cpu_states[id][CP_IDLE] / 10.0); ++} ++ ++void ++printCPUxIdleInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d Idle Load\t0\t100\t%%\n", id + 1); ++} ++ ++void printCPUxClock(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%d\n", freq[id][0]); ++} ++ ++void printCPUxClockInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d Clock Frequency\t%d\t%d\tMHz\n", id + 1, ++ freq[id][1], freq[id][2]); ++} ++ ++void printCPUClock(const char* cmd) ++{ ++ fprintf(CurrentClient, "%f\n", freq[cores][0] / 100.0); ++} ++ ++void printCPUClockInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU Clock Frequency\t%d\t%d\tMHz\n", freq[cores][1], freq[cores][2]); ++} ++ ++void printCPUxTemperature(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "%0.1f\n", (temp[id] - 2732) / 10.0); ++} ++ ++void printCPUxTemperatureInfo(const char* cmd) ++{ ++ int id; ++ ++ sscanf(cmd + 7, "%d", &id); ++ fprintf(CurrentClient, "CPU%d Temperature\t0\t0\tC\n", id + 1); ++} ++ ++void printCPUTemperature(const char* cmd) ++{ ++ fprintf(CurrentClient, "%0.3f\n", (temp[cores] - 273200) / 1000.0); ++} ++ ++void printCPUTemperatureInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "CPU Temperature\t0\t0\tC\n"); ++} ++ ++void printNumCpus(const char* cmd) ++{ ++ fprintf(CurrentClient, "%d\n", cpus); ++} ++ ++void printNumCpusInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Number of physical CPUs\t0\t%d\t\n", maxcpus); ++} ++ ++void printNumCores(const char* cmd) ++{ ++ fprintf(CurrentClient, "%d\n", cores); ++} ++ ++void printNumCoresInfo(const char* cmd) ++{ ++ fprintf(CurrentClient, "Total number of processor cores\t0\t%d\t\n", maxcpus); ++} ++ ++void get_mmfreq(int id, int* minfreq, int* maxfreq) ++{ ++ char buf[FREQ_LEVEL_BUFFER]; ++ char mid[SYSCTL_ID_LEN]; ++ size_t len = FREQ_LEVEL_BUFFER; ++ ++ *minfreq = 0; ++ *maxfreq = 0; ++ ++ snprintf(mid, sizeof(mid), "dev.cpu.%d.freq_levels", id); ++ if (!sysctlbyname(mid, buf, &len, NULL, 0)) ++ { ++ char *start = buf; ++ char *end; ++ ++ /* ++ * The string is ([[freq]]/[[num]] )*([[freq]]/[[num]] ), so ++ * for each frequency we get we must also skip over another ++ * set of numbers ++ */ ++ while (1) ++ { ++ // Get the first number ++ int number = strtol(start, &end, 10); ++ if (start == end) ++ break; ++ if (!*maxfreq) ++ *maxfreq = number; ++ else ++ *minfreq = number; ++ if (!*end) ++ break; ++ start = end + 1; ++ ++ // Skip over the next number ++ strtol(start, &end, 10); ++ if (start == end || !*end) ++ break; ++ start = end + 1; ++ } ++ } ++} ++ ++/* The part ripped from top... */ ++/* ++ * Top users/processes display for Unix ++ * Version 3 ++ * ++ * This program may be freely redistributed, ++ * but this entire comment MUST remain intact. ++ * ++ * Copyright (c) 1984, 1989, William LeFebvre, Rice University ++ * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University ++ */ ++ ++/* ++ * percentages(cnt, out, new, old, diffs) - calculate percentage change ++ * between array "old" and "new", putting the percentages i "out". ++ * "cnt" is size of each array and "diffs" is used for scratch space. ++ * The array "old" is updated on each call. ++ * The routine assumes modulo arithmetic. This function is especially ++ * useful on BSD mchines for calculating cpu state percentages. ++ */ ++long percentages(int cnt, long *out, long *new, long *old, long *diffs) ++{ ++ int i; ++ long change; ++ long total_change; ++ long *dp; ++ long half_total; ++ ++ /* initialization */ ++ total_change = 0; ++ dp = diffs; ++ ++ /* calculate changes for each state and the overall change */ ++ for (i = 0; i < cnt; i++) ++ { ++ if ((change = *new - *old) < 0) ++ { ++ /* this only happens when the counter wraps */ ++ change = (int) ++ ((unsigned long)*new-(unsigned long)*old); ++ } ++ total_change += (*dp++ = change); ++ *old++ = *new++; ++ } ++ ++ /* avoid divide by zero potential */ ++ if (total_change == 0) ++ { ++ total_change = 1; ++ } ++ ++ /* calculate percentages based on overall change, rounding up */ ++ half_total = total_change / 2l; ++ ++ /* Do not divide by 0. Causes Floating point exception */ ++ for (i = 0; i < cnt; i++) ++ { ++ *out++ = (int)((*diffs++ * 1000 + half_total) / total_change); ++ } ++ ++ /* return the total in case the caller wants to use it */ ++ return(total_change); ++} diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__cpuinfo.h b/sysutils/ksysguardd/files/patch-FreeBSD__cpuinfo.h new file mode 100644 index 000000000000..c560d454da71 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__cpuinfo.h @@ -0,0 +1,77 @@ +--- FreeBSD/cpuinfo.h 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/cpuinfo.h 2011-01-03 22:13:03.000000000 +0200 +@@ -0,0 +1,74 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 1999 Chris Schlaeger <cs@kde.org> ++ Copyright (c) 2010 David Naylor <naylor.b.david@gmail.com> ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ 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. ++ ++*/ ++ ++#ifndef _cpuinfo_h_ ++#define _cpuinfo_h_ ++ ++struct SensorModul; ++ ++void initCpuInfo(struct SensorModul*); ++void exitCpuInfo(void); ++ ++int updateCpuInfo(void); ++ ++void printCPUUser(const char* cmd); ++void printCPUUserInfo(const char* cmd); ++void printCPUNice(const char* cmd); ++void printCPUNiceInfo(const char* cmd); ++void printCPUSys(const char* cmd); ++void printCPUSysInfo(const char* cmd); ++void printCPUTotalLoad(const char* cmd); ++void printCPUTotalLoadInfo(const char* cmd); ++void printCPUIntr(const char* cmd); ++void printCPUIntrInfo(const char* cmd); ++void printCPUIdle(const char* cmd); ++void printCPUIdleInfo(const char* cmd); ++void printCPUxUser(const char* cmd); ++void printCPUxUserInfo(const char* cmd); ++void printCPUxNice(const char* cmd); ++void printCPUxNiceInfo(const char* cmd); ++void printCPUxSys(const char* cmd); ++void printCPUxSysInfo(const char* cmd); ++void printCPUxTotalLoad(const char* cmd); ++void printCPUxTotalLoadInfo(const char* cmd); ++void printCPUxIntr(const char* cmd); ++void printCPUxIntrInfo(const char* cmd); ++void printCPUxIdle(const char* cmd); ++void printCPUxIdleInfo(const char* cmd); ++ ++void printCPUxClock(const char* cmd); ++void printCPUxClockInfo(const char* cmd); ++void printCPUClock(const char* cmd); ++void printCPUClockInfo(const char* cmd); ++ ++void printCPUxTemperature(const char* cmd); ++void printCPUxTemperatureInfo(const char* cmd); ++void printCPUTemperature(const char* cmd); ++void printCPUTemperatureInfo(const char* cmd); ++ ++void printNumCpus(const char* cmd); ++void printNumCpusInfo(const char* cmd); ++ ++void printNumCores(const char* cmd); ++void printNumCoresInfo(const char* cmd); ++ ++#endif /* _cpuinfo_h_ */ diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__diskstat.c b/sysutils/ksysguardd/files/patch-FreeBSD__diskstat.c new file mode 100644 index 000000000000..7f904b4ec4f3 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__diskstat.c @@ -0,0 +1,297 @@ +--- FreeBSD/diskstat.c 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/diskstat.c 2011-02-19 23:24:28.000000000 +0200 +@@ -19,8 +19,6 @@ + + */ + +-#include <config-workspace.h> +- + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +@@ -43,8 +41,19 @@ + long bfree; + long bused; + int bused_percent; ++ long bsize; ++ long files; ++ long ffree; ++ long fused; ++ int fused_percent; + } DiskInfo; + ++#define BLK2KB(disk_info, prop) \ ++ (disk_info->prop * (disk_info->bsize / 1024)) ++ ++#define MNTPNT_NAME(disk_info) \ ++ (strcmp(disk_info->mntpnt, "/root") ? disk_info->mntpnt : "/") ++ + static CONTAINER DiskStatList = 0; + static struct SensorModul* DiskStatSM; + +@@ -96,6 +105,12 @@ + registerMonitor(monitor, "integer", printDiskStatFree, printDiskStatFreeInfo, DiskStatSM); + snprintf(monitor, sizeof(monitor), "partitions%s/filllevel", disk_info->mntpnt); + registerMonitor(monitor, "integer", printDiskStatPercent, printDiskStatPercentInfo, DiskStatSM); ++ snprintf(monitor, sizeof(monitor), "partitions%s/usedinode", disk_info->mntpnt); ++ registerMonitor(monitor, "integer", printDiskStatIUsed, printDiskStatIUsedInfo, DiskStatSM); ++ snprintf(monitor, sizeof(monitor), "partitions%s/freeinode", disk_info->mntpnt); ++ registerMonitor(monitor, "integer", printDiskStatIFree, printDiskStatIFreeInfo, DiskStatSM); ++ snprintf(monitor, sizeof(monitor), "partitions%s/inodelevel", disk_info->mntpnt); ++ registerMonitor(monitor, "integer", printDiskStatIPercent, printDiskStatIPercentInfo, DiskStatSM); + } + } + +@@ -123,6 +138,12 @@ + removeMonitor(monitor); + snprintf(monitor, sizeof(monitor), "partitions%s/filllevel", disk_info->mntpnt); + removeMonitor(monitor); ++ snprintf(monitor, sizeof(monitor), "partitions%s/usedinode", disk_info->mntpnt); ++ removeMonitor(monitor); ++ snprintf(monitor, sizeof(monitor), "partitions%s/freeinode", disk_info->mntpnt); ++ removeMonitor(monitor); ++ snprintf(monitor, sizeof(monitor), "partitions%s/inodelevel", disk_info->mntpnt); ++ removeMonitor(monitor); + } + + destr_ctnr(DiskStatList, free); +@@ -132,7 +153,7 @@ + { + struct statfs *fs_info; + struct statfs fs; +- float percent; ++ float percent, fpercent; + int i, mntcount; + DiskInfo *disk_info; + +@@ -144,29 +165,33 @@ + + for (i = 0; i < mntcount; i++) { + fs = fs_info[i]; +- if (strcmp(fs.f_fstypename, "procfs") && strcmp(fs.f_fstypename, "devfs") && strcmp(fs.f_fstypename, "devfs")) { ++ if (strcmp(fs.f_fstypename, "procfs") && strcmp(fs.f_fstypename, "devfs") && strcmp(fs.f_fstypename, "linprocfs")) { + if ( fs.f_blocks != 0 ) +- { +- percent = (((float)fs.f_blocks - (float)fs.f_bfree)*100.0/(float)fs.f_blocks); +- } ++ percent = (((float)fs.f_blocks - (float)fs.f_bfree)*100.0/(float)fs.f_blocks); + else +- percent = 0; +- if ((disk_info = (DiskInfo *)malloc(sizeof(DiskInfo))) == NULL) { ++ percent = 0; ++ if (fs.f_files != 0) ++ fpercent = (((float)fs.f_files - (float)fs.f_ffree)*100.0/(float)fs.f_files); ++ else ++ fpercent = 0; ++ if ((disk_info = (DiskInfo *)malloc(sizeof(DiskInfo))) == NULL) + continue; +- } + memset(disk_info, 0, sizeof(DiskInfo)); + strlcpy(disk_info->device, fs.f_mntfromname, sizeof(disk_info->device)); +- if (!strcmp(fs.f_mntonname, "/")) { ++ if (!strcmp(fs.f_mntonname, "/")) + strncpy(disk_info->mntpnt, "/root", 6); +- } else { ++ else + strlcpy(disk_info->mntpnt, fs.f_mntonname, sizeof(disk_info->mntpnt)); +- } + disk_info->blocks = fs.f_blocks; + disk_info->bfree = fs.f_bfree; + disk_info->bused = (fs.f_blocks - fs.f_bfree); + disk_info->bused_percent = (int)percent; +- ++ disk_info->bsize = fs.f_bsize; + push_ctnr(DiskStatList, disk_info); ++ disk_info->files = fs.f_files; ++ disk_info->ffree = fs.f_ffree; ++ disk_info->fused = fs.f_files - fs.f_ffree; ++ disk_info->fused_percent = (int)fpercent; + } + } + +@@ -178,13 +203,17 @@ + DiskInfo* disk_info; + + for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { +- fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%d\t%s\n", ++ fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%d\t%ld\t%ld\t%ld\t%d\t%s\n", + disk_info->device, +- disk_info->blocks, +- disk_info->bused, +- disk_info->bfree, ++ BLK2KB(disk_info, blocks), ++ BLK2KB(disk_info, bused), ++ BLK2KB(disk_info, bfree), + disk_info->bused_percent, +- disk_info->mntpnt); ++ disk_info->files, ++ disk_info->fused, ++ disk_info->ffree, ++ disk_info->fused_percent, ++ MNTPNT_NAME(disk_info)); + } + + fprintf(CurrentClient, "\n"); +@@ -192,7 +221,7 @@ + + void printDiskStatInfo(const char* cmd) + { +- fprintf(CurrentClient, "Device\tBlocks\tUsed\tAvailable\tUsed %%\tMountPoint\nM\tD\tD\tD\td\ts\n"); ++ fprintf(CurrentClient, "Device\tCapacity\tUsed\tAvailable\tUsed %%\tInodes\tUsed Inodes\tFree Inodes\tInodes %%\tMountPoint\nM\tKB\tKB\tKB\td\td\td\td\td\ts\n"); + } + + void printDiskStatUsed(const char* cmd) +@@ -202,7 +231,8 @@ + + for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { + if (!strcmp(mntpnt, disk_info->mntpnt)) { +- fprintf(CurrentClient, "%ld\n", disk_info->bused); ++ fprintf(CurrentClient, "%ld\n", BLK2KB(disk_info, bused)); ++ return; + } + } + +@@ -211,7 +241,16 @@ + + void printDiskStatUsedInfo(const char* cmd) + { +- fprintf(CurrentClient, "Used Blocks\t0\t-\tBlocks\n"); ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "Used Space (%s)\t0\t%ld\tKB\n", MNTPNT_NAME(disk_info), BLK2KB(disk_info, blocks)); ++ return; ++ } ++ } ++ fprintf(CurrentClient, "Used Space (%s)\t0\t-\tKB\n", mntpnt); + } + + void printDiskStatFree(const char* cmd) +@@ -221,7 +260,8 @@ + + for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { + if (!strcmp(mntpnt, disk_info->mntpnt)) { +- fprintf(CurrentClient, "%ld\n", disk_info->bfree); ++ fprintf(CurrentClient, "%ld\n", BLK2KB(disk_info, bfree)); ++ return; + } + } + +@@ -230,7 +270,16 @@ + + void printDiskStatFreeInfo(const char* cmd) + { +- fprintf(CurrentClient, "Free Blocks\t0\t-\tBlocks\n"); ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "Free Space (%s)\t0\t%ld\tKB\n", MNTPNT_NAME(disk_info), BLK2KB(disk_info, blocks)); ++ return; ++ } ++ } ++ fprintf(CurrentClient, "Free Space (%s)\t0\t-\tKB\n", mntpnt); + } + + void printDiskStatPercent(const char* cmd) +@@ -241,6 +290,7 @@ + for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { + if (!strcmp(mntpnt, disk_info->mntpnt)) { + fprintf(CurrentClient, "%d\n", disk_info->bused_percent); ++ return; + } + } + +@@ -249,5 +299,88 @@ + + void printDiskStatPercentInfo(const char* cmd) + { +- fprintf(CurrentClient, "Used Blocks\t0\t100\t%%\n"); ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ fprintf(CurrentClient, "Used Space (%s)\t0\t100\t%%\n", mntpnt); ++} ++ ++void printDiskStatIUsed(const char* cmd) ++{ ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "%ld\n", disk_info->fused); ++ return; ++ } ++ } ++ ++ fprintf(CurrentClient, "\n"); + } ++ ++void printDiskStatIUsedInfo(const char* cmd) ++{ ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "Used Inodes (%s)\t0\t%ld\tKB\n", MNTPNT_NAME(disk_info), disk_info->files); ++ return; ++ } ++ } ++ fprintf(CurrentClient, "Used Inodes(%s)\t0\t-\tKB\n", mntpnt); ++} ++ ++void printDiskStatIFree(const char* cmd) ++{ ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "%ld\n", disk_info->ffree); ++ return; ++ } ++ } ++ ++ fprintf(CurrentClient, "\n"); ++} ++ ++void printDiskStatIFreeInfo(const char* cmd) ++{ ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "Free Inodes (%s)\t0\t%ld\tKB\n", MNTPNT_NAME(disk_info), disk_info->files); ++ return; ++ } ++ } ++ fprintf(CurrentClient, "Free Inodes (%s)\t0\t-\tKB\n", mntpnt); ++} ++ ++void printDiskStatIPercent(const char* cmd) ++{ ++ DiskInfo* disk_info; ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ for (disk_info = first_ctnr(DiskStatList); disk_info; disk_info = next_ctnr(DiskStatList)) { ++ if (!strcmp(mntpnt, disk_info->mntpnt)) { ++ fprintf(CurrentClient, "%d\n", disk_info->fused_percent); ++ return; ++ } ++ } ++ ++ fprintf(CurrentClient, "\n"); ++} ++ ++void printDiskStatIPercentInfo(const char* cmd) ++{ ++ char *mntpnt = (char *)getMntPnt(cmd); ++ ++ fprintf(CurrentClient, "Used Inodes (%s)\t0\t100\t%%\n", mntpnt); ++} ++ diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__diskstat.h b/sysutils/ksysguardd/files/patch-FreeBSD__diskstat.h new file mode 100644 index 000000000000..e805deca0bfc --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__diskstat.h @@ -0,0 +1,14 @@ +--- FreeBSD/diskstat.h 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/diskstat.h 2011-02-19 23:17:29.000000000 +0200 +@@ -38,4 +38,11 @@ + void printDiskStatPercent(const char* cmd); + void printDiskStatPercentInfo(const char* cmd); + ++void printDiskStatIUsed(const char* cmd); ++void printDiskStatIUsedInfo(const char* cmd); ++void printDiskStatIFree(const char* cmd); ++void printDiskStatIFreeInfo(const char* cmd); ++void printDiskStatIPercent(const char* cmd); ++void printDiskStatIPercentInfo(const char* cmd); ++ + #endif diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__logfile.c b/sysutils/ksysguardd/files/patch-FreeBSD__logfile.c new file mode 100644 index 000000000000..a2a172a3ba65 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__logfile.c @@ -0,0 +1,11 @@ +--- FreeBSD/logfile.c 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/logfile.c 2011-01-30 10:24:23.000000000 +0200 +@@ -79,8 +79,6 @@ + { + char line[1024]; + unsigned long id; +- int i; +- char ch; + LogFileEntry *entry; + + sscanf(cmd, "%*s %lu", &id); diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__netdev.c b/sysutils/ksysguardd/files/patch-FreeBSD__netdev.c new file mode 100644 index 000000000000..2ad65b25475e --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__netdev.c @@ -0,0 +1,11 @@ +--- FreeBSD/netdev.c 2011-03-17 20:50:04.000000000 +0200 ++++ FreeBSD/netdev.c 2010-11-08 17:54:42.000000000 +0200 +@@ -18,8 +18,6 @@ + + */ + +-#include <config-workspace.h> +- + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/sysctl.h> diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__stat.c b/sysutils/ksysguardd/files/patch-FreeBSD__stat.c new file mode 100644 index 000000000000..7f8d6dc63898 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__stat.c @@ -0,0 +1,382 @@ +--- FreeBSD/stat.c 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/stat.c 2011-02-10 15:37:53.000000000 +0200 +@@ -0,0 +1,379 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 2011 David Naylor <naylor.b.david@gmail.com> ++ ++ 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. ++*/ ++ ++/* ++ * TODO ++ * - stray irq ++ * - cpu*:timer ++ */ ++ ++#include "stat.h" ++ ++#include <errno.h> ++#include <sys/types.h> ++#include <sys/sysctl.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <string.h> ++ ++#include "Command.h" ++ ++#define IRQ_NAME 32 ++ ++char *sysctl_dynread(const char *); ++ ++static u_int context, context_last = 0; ++static u_int trap, trap_last = 0; ++static u_int syscall, syscall_last = 0; ++static u_int hardint, hardint_last = 0; ++static u_int softint, softint_last = 0; ++ ++static u_int intrcnt, nintr = 0, msi_offset = 0; ++static char **intrname = NULL, *intrnamebuf; ++static long *intr = NULL, *intr_last, *intr_current; ++static int *intr_map = NULL; ++ ++void initStat(struct SensorModul *sm) { ++ int irq, irq_len = 0, msi_len = 0; ++ size_t len = 0; ++ char name[IRQ_NAME], *cp; ++ ++ sysctlbyname("hw.intrcnt", NULL, &len, NULL, 0); ++ intrcnt = len / sizeof(unsigned long); ++ ++ if ((intr = malloc(intrcnt * 3 * sizeof (long))) == NULL) { ++ log_error("out of memory for intr"); ++ return; ++ } ++ intr_last = &intr[intrcnt]; ++ intr_current = &intr_last[intrcnt]; ++ ++ if ((intrname = malloc(intrcnt * sizeof(char *))) == NULL) { ++ log_error("out of memory for intrname"); ++ return; ++ } ++ ++ if ((intrnamebuf = sysctl_dynread("hw.intrnames")) == NULL) { ++ log_error("out of memory for intrnamebuf"); ++ return; ++ } ++ for (cp = intrnamebuf, irq = 0; irq < intrcnt; ++irq) { ++ char *nextcp; ++ for (nextcp = cp; *nextcp != '\0'; ++nextcp); ++ if (strncmp(cp, "irq", 3) == 0) { ++ long irq2; ++ sscanf(cp + 3, "%ld", &irq2); ++ if (irq2 > 255) ++ ++msi_len; ++ else ++ if (irq_len < irq2) ++ irq_len = irq2; ++ } else if (nextcp == cp) ++ intrcnt = irq; ++ cp = nextcp + 1; ++ } ++ if (msi_len) ++ msi_offset = 255 - irq_len; ++ nintr = irq_len + msi_len + 1; ++ if ((intr_map = malloc(nintr * sizeof(int))) == NULL) { ++ log_error("out of memory for intr_map"); ++ return; ++ } ++ ++ for (irq = 0; irq < nintr; ++irq) ++ intr_map[irq] = -1; ++ for (cp = intrnamebuf, irq = 0; irq < intrcnt; ++irq) { ++ char *nextcp; ++ for (nextcp = cp; *nextcp != '\0'; ++nextcp) ++ if (*nextcp == ' ' && (*(nextcp + 1) == ' ' || *(nextcp + 1) == '\0')) ++ *nextcp = '\0'; ++ intrname[irq] = cp; ++ if (strncmp(cp, "irq", 3) == 0) { ++ long irq2; ++ sscanf(cp + 3, "%ld", &irq2); ++ if (irq2 < 256) ++ intr_map[irq2] = irq; ++ else ++ intr_map[irq2 - msi_offset] = irq; ++ strncpy(cp, "IRQ", 3); ++ for(cp = cp + 4; *cp != ':'; ++cp); ++ for(; ; ++cp) ++ if (*cp == '\0') ++ break; ++ else if (*cp == ':') ++ if (*(cp + 1) == '\0') ++ *cp = '\0'; ++ else ++ *cp = '('; ++ else if (*(cp + 1) == '\0') ++ *cp = ')'; ++ else ++ *cp = *(cp + 1); ++ } else if (nextcp == cp) ++ intrcnt = irq; ++ cp = nextcp + 1; ++ } ++ ++ registerMonitor("cpu/interrupts/hardint", "integer", printHardInt, printHardIntInfo, sm); ++ registerMonitor("cpu/interrupts/softint", "integer", printSoftInt, printSoftIntInfo, sm); ++ registerLegacyMonitor("cpu/interrupts/int00", "integer", printHardInt, printHardIntInfo, sm); ++ ++ for (irq = 0; irq < nintr; ++irq) { ++ if (intr_map[irq] == -1) ++ continue; ++ if (irq > 255 - msi_offset) ++ snprintf(name, IRQ_NAME, "cpu/interrupts/int%03d", irq + msi_offset); ++ else ++ snprintf(name, IRQ_NAME, "cpu/interrupts/int%02d", irq + 1); ++ registerMonitor(name, "integer", printInterruptx, printInterruptxInfo, sm); ++ } ++ ++ registerMonitor("cpu/context", "integer", printContext, printContextInfo, sm); ++ registerMonitor("cpu/trap", "integer", printTrap, printTrapInfo, sm); ++ registerMonitor("cpu/syscall", "integer", printSyscall, printSyscallInfo, sm); ++ ++ updateStat(); ++} ++ ++void exitStat(void) { ++ int irq; ++ char name[IRQ_NAME]; ++ ++ if (intr != NULL) { ++ free(intr); ++ intr = NULL; ++ intr_current = NULL; ++ intr_last = NULL; ++ } ++ ++ if (intrname != NULL) { ++ free(intrname); ++ intrname = NULL; ++ } ++ ++ if (intrnamebuf != NULL) { ++ if (intr_map != NULL) { ++ removeMonitor("cpu/interrupts/hardint"); ++ removeMonitor("cpu/interrupts/softint"); ++ removeMonitor("cpu/interrupts/int00"); ++ ++ for (irq = 0; irq < nintr; ++irq) { ++ if (intr_map[irq] == -1) ++ continue; ++ if (irq > 255 - msi_offset) ++ snprintf(name, IRQ_NAME, "cpu/interrupts/int%03d", irq + msi_offset); ++ else ++ snprintf(name, IRQ_NAME, "cpu/interrupts/int%02d", irq + 1); ++ removeMonitor(name); ++ } ++ ++ removeMonitor("cpu/context"); ++ removeMonitor("cpu/trap"); ++ removeMonitor("cpu/syscall"); ++ ++ free(intr_map); ++ intr_map = NULL; ++ } ++ ++ free(intrnamebuf); ++ intrnamebuf = NULL; ++ } ++} ++ ++int updateStat(void) { ++ int irq; ++ size_t len; ++ unsigned int current; ++ long *swap; ++ ++#define GETSYSCTL(mib, var) \ ++ len = sizeof(var); \ ++ sysctlbyname(mib, &var, &len, NULL, 0); ++#define GETDIFFSYSCTL(mib, var) \ ++ GETSYSCTL(mib, current); \ ++ var = current - var##_last; \ ++ var##_last = current; ++ ++ GETDIFFSYSCTL("vm.stats.sys.v_swtch", context); ++ GETDIFFSYSCTL("vm.stats.sys.v_trap", trap); ++ GETDIFFSYSCTL("vm.stats.sys.v_syscall", syscall); ++ GETDIFFSYSCTL("vm.stats.sys.v_intr", hardint); ++ GETDIFFSYSCTL("vm.stats.sys.v_soft", softint); ++ ++ len = sizeof(long) * intrcnt; ++ sysctlbyname("hw.intrcnt", intr_current, &len, NULL, 0); ++ for (irq = 0; irq < nintr; ++irq) ++ if (intr_map[irq] != -1) ++ intr[intr_map[irq]] = intr_current[intr_map[irq]] - intr_last[intr_map[irq]]; ++ swap = intr_current; ++ intr_current = intr_last; ++ intr_last = swap; ++ ++ return (0); ++ ++#undef GETDIFFSYSCTL ++#undef GETSYSCTL ++} ++ ++void printHardInt(const char *cmd) { ++ fprintf(CurrentClient, "%d\n", hardint); ++} ++ ++void printHardIntInfo(const char *cmd) { ++ fprintf(CurrentClient, "Hardware Interrupts\t0\t0\t1/s\n"); ++} ++ ++void printSoftInt(const char *cmd) { ++ fprintf(CurrentClient, "%d\n", softint); ++} ++ ++void printSoftIntInfo(const char *cmd) { ++ fprintf(CurrentClient, "Software Interrupts\t0\t0\t1/s\n"); ++} ++ ++void printInterruptx(const char *cmd) { ++ int irq; ++ ++ sscanf(cmd + 18, "%d", &irq); ++ if (irq > 255 - msi_offset) ++ irq -= msi_offset - 1; ++ fprintf(CurrentClient, "%ld\n", intr[intr_map[irq - 1]]); ++} ++ ++void printInterruptxInfo(const char *cmd) { ++ int irq; ++ ++ sscanf(cmd + 18, "%d", &irq); ++ if (irq > 255 - msi_offset) ++ irq -= msi_offset - 1; ++ fprintf(CurrentClient, "%s\t0\t0\t1/s\n", intrname[intr_map[irq - 1]]); ++} ++ ++void printContext(const char *cmd) { ++ fprintf(CurrentClient, "%u\n", context); ++} ++ ++void printContextInfo(const char *cmd) { ++ fprintf(CurrentClient, "Context switches\t0\t0\t1/s\n"); ++} ++ ++void printTrap(const char *cmd) { ++ fprintf(CurrentClient, "%u\n", trap); ++} ++ ++void printTrapInfo(const char *cmd) { ++ fprintf(CurrentClient, "Traps\t0\t0\t1/s\n"); ++} ++ ++void printSyscall(const char *cmd) { ++ fprintf(CurrentClient, "%u\n", syscall); ++} ++ ++void printSyscallInfo(const char *cmd) { ++ fprintf(CurrentClient, "System Calls\t0\t0\t1/s\n"); ++} ++ ++/* ++ * Taken from http://cvsweb.freebsd.org/src/usr.bin/systat/fetch.c ++ */ ++/*- ++ * Copyright (c) 1983, 1989, 1992, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 4. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++/* ++ * Read sysctl data with variable size. Try some times (with increasing ++ * buffers), fail if still too small. ++ * This is needed sysctls with possibly raplidly increasing data sizes, ++ * but imposes little overhead in the case of constant sizes. ++ * Returns NULL on error, or a pointer to freshly malloc()'ed memory that holds ++ * the requested data. ++ * If szp is not NULL, the size of the returned data will be written into *szp. ++ */ ++ ++/* Some defines: Number of tries. */ ++#define SD_NTRIES 10 ++/* Percent of over-allocation (initial) */ ++#define SD_MARGIN 10 ++/* ++ * Factor for over-allocation in percent (the margin is increased by this on ++ * any failed try). ++ */ ++#define SD_FACTOR 50 ++/* Maximum supported MIB depth */ ++#define SD_MAXMIB 16 ++char * ++sysctl_dynread(const char *n) ++{ ++ char *rv = NULL; ++ int mib[SD_MAXMIB]; ++ size_t mibsz = SD_MAXMIB; ++ size_t mrg = SD_MARGIN; ++ size_t sz; ++ int i; ++ ++ /* cache the MIB */ ++ if (sysctlnametomib(n, mib, &mibsz) == -1) { ++ return NULL; ++ } ++ for (i = 0; i < SD_NTRIES; i++) { ++ /* get needed buffer size */ ++ if (sysctl(mib, mibsz, NULL, &sz, NULL, 0) == -1) ++ break; ++ sz += sz * mrg / 100; ++ if ((rv = (char *)malloc(sz)) == NULL) ++ return NULL; ++ if (sysctl(mib, mibsz, rv, &sz, NULL, 0) == -1) { ++ free(rv); ++ rv = NULL; ++ if (errno == ENOMEM) { ++ mrg += mrg * SD_FACTOR / 100; ++ } else ++ break; ++ } else { ++ /* success */ ++ break; ++ } ++ } ++ ++ return rv; ++} diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__stat.h b/sysutils/ksysguardd/files/patch-FreeBSD__stat.h new file mode 100644 index 000000000000..def01e07c6f0 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__stat.h @@ -0,0 +1,52 @@ +--- FreeBSD/stat.h 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/stat.h 2011-01-04 13:29:11.000000000 +0200 +@@ -0,0 +1,49 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 2011 David Naylor <naylor.b.david@gmail.com> ++ ++ 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. ++ ++*/ ++ ++#ifndef _stat_h_ ++#define _stat_h_ ++ ++struct SensorModul; ++ ++void initStat(struct SensorModul*); ++void exitStat(void); ++ ++int updateStat(void); ++ ++void printHardInt(const char *); ++void printHardIntInfo(const char *); ++ ++void printSoftInt(const char *); ++void printSoftIntInfo(const char *); ++ ++void printInterruptx(const char*); ++void printInterruptxInfo(const char*); ++ ++void printContext(const char*); ++void printContextInfo(const char*); ++ ++void printTrap(const char*); ++void printTrapInfo(const char*); ++ ++void printSyscall(const char*); ++void printSyscallInfo(const char*); ++ ++#endif /* _stat_h_ */ diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__uptime.c b/sysutils/ksysguardd/files/patch-FreeBSD__uptime.c new file mode 100644 index 000000000000..4c23f9d17ba3 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__uptime.c @@ -0,0 +1,51 @@ +--- FreeBSD/uptime.c 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/uptime.c 2010-11-08 19:07:02.000000000 +0200 +@@ -0,0 +1,48 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 2010 David Naylor <naylor.b.david@gmail.com> ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of version 2 or later 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 <time.h> ++ ++#include "Command.h" ++#include "ksysguardd.h" ++ ++#include "uptime.h" ++ ++void initUptime( struct SensorModul* sm ) { ++ registerMonitor( "system/uptime", "float", printUptime, printUptimeInfo, sm ); ++} ++ ++void exitUptime( void ) { ++ removeMonitor("system/uptime"); ++} ++ ++void printUptime( const char* cmd ) { ++ struct timespec tp; ++ float uptime = 0.; ++ ++ if (clock_gettime(CLOCK_UPTIME, &tp) != -1) ++ uptime = tp.tv_nsec / 1000000000.0 + tp.tv_sec; ++ fprintf( CurrentClient, "%f\n", uptime); ++} ++ ++void printUptimeInfo( const char* cmd ) { ++ fprintf( CurrentClient, "System uptime\t0\t0\ts\n" ); ++} diff --git a/sysutils/ksysguardd/files/patch-FreeBSD__uptime.h b/sysutils/ksysguardd/files/patch-FreeBSD__uptime.h new file mode 100644 index 000000000000..be4eecc1409f --- /dev/null +++ b/sysutils/ksysguardd/files/patch-FreeBSD__uptime.h @@ -0,0 +1,36 @@ +--- FreeBSD/uptime.h 1970-01-01 02:00:00.000000000 +0200 ++++ FreeBSD/uptime.h 2010-11-04 14:09:30.000000000 +0200 +@@ -0,0 +1,33 @@ ++/* ++ KSysGuard, the KDE System Guard ++ ++ Copyright (c) 2006 Greg Martyn <greg.martyn@gmail.com> ++ Copyright (c) 2010 David Naylor <naylor.b.david@gmail.com> ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of version 2 or later 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. ++ ++*/ ++ ++#ifndef _uptime_h_ ++#define _uptime_h_ ++ ++struct SensorModul; ++ ++void initUptime( struct SensorModul* ); ++void exitUptime( void ); ++ ++void printUptime( const char* cmd ); ++void printUptimeInfo( const char* cmd ); ++ ++#endif diff --git a/sysutils/ksysguardd/files/patch-config-ksysguardd.h.cmake b/sysutils/ksysguardd/files/patch-config-ksysguardd.h.cmake new file mode 100644 index 000000000000..e0c9355668ff --- /dev/null +++ b/sysutils/ksysguardd/files/patch-config-ksysguardd.h.cmake @@ -0,0 +1,7 @@ +--- ./config-ksysguardd.h.cmake.orig 2011-02-25 22:54:48.000000000 +0100 ++++ ./config-ksysguardd.h.cmake 2011-03-05 16:30:54.367061295 +0100 +@@ -1,3 +1,4 @@ + #cmakedefine HAVE_LMSENSORS 1 + #cmakedefine HAVE_XRES 1 + #cmakedefine HAVE_SYS_INOTIFY_H 1 ++#define kde_socklen_t socklen_t diff --git a/sysutils/ksysguardd/files/patch-ksysguardd.c b/sysutils/ksysguardd/files/patch-ksysguardd.c new file mode 100644 index 000000000000..f9e1f2be7ac7 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-ksysguardd.c @@ -0,0 +1,18 @@ +--- ksysguardd.c 2011-03-17 20:50:04.000000000 +0200 ++++ ksysguardd.c 2011-01-30 10:30:11.000000000 +0200 +@@ -392,6 +392,7 @@ + return highestFD; + } + ++#ifdef HAVE_SYS_INOTIFY_H + static void checkModules() + { + struct SensorModul *entry; +@@ -400,6 +401,7 @@ + if ( entry->checkCommand != NULL && entry->available ) + entry->checkCommand(); + } ++#endif + + static void handleSocketTraffic( int socketNo, const fd_set* fds ) + { diff --git a/sysutils/ksysguardd/files/patch-modules.h b/sysutils/ksysguardd/files/patch-modules.h new file mode 100644 index 000000000000..840c5fb4a937 --- /dev/null +++ b/sysutils/ksysguardd/files/patch-modules.h @@ -0,0 +1,48 @@ +--- modules.h 2011-03-17 20:50:04.000000000 +0200 ++++ modules.h 2011-01-28 10:05:57.000000000 +0200 +@@ -23,7 +23,6 @@ + #ifndef KSG_MODULES_H + #define KSG_MODULES_H + +-#include <config-ksysguardd.h> + #include "Command.h" + #include "conf.h" + #include "ksysguardd.h" +@@ -49,16 +48,19 @@ + + #if defined(OSTYPE_FreeBSD) || defined(OSTYPE_DragonFly) + #include <grp.h> ++#include "acpi.h" + #ifdef __i386__ + #include "apm.h" + #endif +-#include "CPU.h" ++#include "cpuinfo.h" + #include "diskstat.h" + #include "loadavg.h" + #include "logfile.h" + #include "Memory.h" + #include "netdev.h" + #include "ProcessList.h" ++#include "stat.h" ++#include "uptime.h" + #endif /* OSTYPE_FreeBSD */ + + #ifdef OSTYPE_Irix +@@ -134,6 +136,7 @@ + #endif /* OSTYPE_Linux */ + + #if defined OSTYPE_FreeBSD || defined OSTYPE_DragonFly ++ { "Acpi", initACPI, exitACPI, updateACPI, NULLVVFUNC, 0, NULLTIME }, + #ifdef __i386__ + { "Apm", initApm, exitApm, updateApm, NULLVVFUNC, 0, NULLTIME }, + #endif +@@ -144,6 +147,8 @@ + { "Memory", initMemory, exitMemory, updateMemory, NULLVVFUNC, 0, NULLTIME }, + { "NetDev", initNetDev, exitNetDev, updateNetDev, checkNetDev, 0, NULLTIME }, + { "ProcessList", initProcessList, exitProcessList, updateProcessList, NULLVVFUNC, 0, NULLTIME }, ++ { "Stat", initStat, exitStat, updateStat, NULLVVFUNC, 0, NULLTIME }, ++ { "Uptime", initUptime, exitUptime, NULLIVFUNC, NULLVVFUNC, 0, NULLTIME }, + #endif /* OSTYPE_FreeBSD */ + + #ifdef OSTYPE_Irix diff --git a/sysutils/ksysguardd/pkg-descr b/sysutils/ksysguardd/pkg-descr new file mode 100644 index 000000000000..313215a75f7e --- /dev/null +++ b/sysutils/ksysguardd/pkg-descr @@ -0,0 +1,5 @@ +KDE System Guard Daemon is the daemon part of ksysguard. The daemon +can be installed on a remote machine to enable ksysguard on another +machine to monitor it through the daemon running there. + +WWW: http://www.kde.org/ |