[netperf-dev] netperf2 commit notice r255 - in trunk: . src
raj at netperf.org
raj at netperf.org
Mon Mar 10 13:10:50 PDT 2008
Author: raj
Date: 2008-03-10 13:10:48 -0700 (Mon, 10 Mar 2008)
New Revision: 255
Added:
trunk/src/netsys_linux.c
Modified:
trunk/config.h.in
trunk/configure
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/Makefile.in
trunk/src/netsys_hpux11i.c
Log:
first cpu model and frequency for linux
Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in 2008-03-10 17:47:38 UTC (rev 254)
+++ trunk/config.h.in 2008-03-10 20:10:48 UTC (rev 255)
@@ -271,10 +271,6 @@
/* Use Linux's ethtool interface to determine driver information. */
#undef USE_ETHTOOL
-/* Use HP-UX's sysinfo and pstat interfaces to determine system information.
- */
-#undef USE_HPUX
-
/* Use Solaris's kstat interface to measure CPU util. */
#undef USE_KSTAT
Modified: trunk/configure
===================================================================
--- trunk/configure 2008-03-10 17:47:38 UTC (rev 254)
+++ trunk/configure 2008-03-10 20:10:48 UTC (rev 255)
@@ -9716,28 +9716,26 @@
NETSYSLKUP_SOURCE="$enable_syslookup"
case "$enable_syslookup" in
hpux11i)
- use_drvlookup=true
-
-cat >>confdefs.h <<\_ACEOF
-#define USE_HPUX
-_ACEOF
-
+ use_syslookup=true
;;
-
+ linux)
+ use_syslookup=true;
+ ;;
'')
# guess it automagically in a nice big case statement
case $target in
*-*-hpux11*)
use_syslookup=true
-
-cat >>confdefs.h <<\_ACEOF
-#define USE_HPUX
-_ACEOF
-
enable_syslookup="hpux11i - auto"
NETSYSLKUP_SOURCE="hpux11i"
;;
+ *-*-linux*)
+ use_syslookup=true
+ enable_syslookup="linux - auto"
+ NETSYSLKUP_SOURCE="linux"
+ ;;
+
*)
use_syslookup=false
NETSYSLKUP_SOURCE="none"
@@ -9749,8 +9747,8 @@
use_syslookup=false
;;
*)
- { { echo "$as_me:$LINENO: error: --enable-syslookup takes hpux or none" >&5
-echo "$as_me: error: --enable-syslookup takes hpux or none" >&2;}
+ { { echo "$as_me:$LINENO: error: --enable-syslookup takes hpux11i, linux or none" >&5
+echo "$as_me: error: --enable-syslookup takes hpux11i, linux or none" >&2;}
{ (exit 1); exit 1; }; }
;;
esac
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2008-03-10 17:47:38 UTC (rev 254)
+++ trunk/configure.ac 2008-03-10 20:10:48 UTC (rev 255)
@@ -879,20 +879,26 @@
NETSYSLKUP_SOURCE="$enable_syslookup"
case "$enable_syslookup" in
hpux11i)
- use_drvlookup=true
- AC_DEFINE([USE_HPUX],,[Use pstat and sysinfo on HP-UX.])
+ use_syslookup=true
;;
-
+ linux)
+ use_syslookup=true;
+ ;;
'')
# guess it automagically in a nice big case statement
case $target in
*-*-hpux11*)
use_syslookup=true
- AC_DEFINE([USE_HPUX],,[Use HP-UX's sysinfo and pstat interfaces to determine system information.])
enable_syslookup="hpux11i - auto"
NETSYSLKUP_SOURCE="hpux11i"
;;
+ *-*-linux*)
+ use_syslookup=true
+ enable_syslookup="linux - auto"
+ NETSYSLKUP_SOURCE="linux"
+ ;;
+
*)
use_syslookup=false
NETSYSLKUP_SOURCE="none"
@@ -904,7 +910,7 @@
use_syslookup=false
;;
*)
- AC_MSG_ERROR([--enable-syslookup takes hpux or none])
+ AC_MSG_ERROR([--enable-syslookup takes hpux11i, linux or none])
;;
esac
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-03-10 17:47:38 UTC (rev 254)
+++ trunk/src/Makefile.am 2008-03-10 20:10:48 UTC (rev 255)
@@ -12,7 +12,7 @@
USE_SLOT_SOURCE=netslot_ at NETSLOTLKUP_SOURCE@.c
USE_SYS_SOURCE=netsys_ at NETSYSLKUP_SOURCE@.c
-EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c
+EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c netsys_linux.c
COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c
Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in 2008-03-10 17:47:38 UTC (rev 254)
+++ trunk/src/Makefile.in 2008-03-10 20:10:48 UTC (rev 255)
@@ -145,7 +145,7 @@
USE_SLOT_SOURCE = netslot_ at NETSLOTLKUP_SOURCE@.c
USE_SYS_SOURCE = netsys_ at NETSYSLKUP_SOURCE@.c
-EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c
+EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c netsys_linux.c
COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c
Modified: trunk/src/netsys_hpux11i.c
===================================================================
--- trunk/src/netsys_hpux11i.c 2008-03-10 17:47:38 UTC (rev 254)
+++ trunk/src/netsys_hpux11i.c 2008-03-10 20:10:48 UTC (rev 255)
@@ -10,7 +10,7 @@
#define _SI_MACHINE_MODEL 5
#endif
-extern int sysinfo(int info, char *buffer, int len);
+extern int sysinfo(int info, char *buffer, ssize_t len);
void
Added: trunk/src/netsys_linux.c
===================================================================
--- trunk/src/netsys_linux.c (rev 0)
+++ trunk/src/netsys_linux.c 2008-03-10 20:10:48 UTC (rev 255)
@@ -0,0 +1,81 @@
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void
+find_cpu_model(char **cpu_model) {
+ char linebuf[256];
+ char *cret;
+ int ret;
+ int c;
+
+ FILE *proccpu;
+
+ proccpu = fopen("/proc/cpuinfo","r");
+
+ if (NULL == proccpu) {
+ *cpu_model = strdup("fopen");
+ return;
+ }
+
+ do {
+ cret = fgets(linebuf,256,proccpu);
+ if (NULL != cret) {
+ char *target;
+ /* OK, so does it start with "model name" ? */
+ if (strstr(linebuf,"model name") != NULL) {
+ /* one for the money "model name" */
+ target = strtok(linebuf,":");
+ /* two for the show (the actual model name) */
+ target = strtok(NULL,":");
+ /* three to get ready - strip the eol */
+ target[strlen(target)-1] = 0;
+ /* and four to go! */
+ *cpu_model = strdup(target+1);
+ return;
+ }
+ }
+ } while (!feof(proccpu));
+ *cpu_model = strdup("model_name");
+}
+
+static int
+find_cpu_freq() {
+ char linebuf[256];
+ char *cret;
+ int ret;
+ int c;
+
+ FILE *proccpu;
+
+ proccpu = fopen("/proc/cpuinfo","r");
+
+ if (NULL == proccpu) {
+ return -1;
+ }
+
+ do {
+ cret = fgets(linebuf,256,proccpu);
+ if (NULL != cret) {
+ char *target;
+ /* OK, so does it start with "model name" ? */
+ if (strstr(linebuf,"cpu MHz") != NULL) {
+ target = strtok(linebuf,":");
+ target = strtok(NULL,":");
+ return rint(strtod(target+1,NULL));
+ }
+ }
+ } while (!feof(proccpu));
+ return -1;
+}
+
+void
+find_system_info(char **system_model, char **cpu_model, int *cpu_frequency) {
+ int ret;
+
+ *system_model = strdup("Teach Me DMI");
+ find_cpu_model(cpu_model);
+ *cpu_frequency = find_cpu_freq();
+
+}
More information about the netperf-dev
mailing list