* v0.6.2.15
-** psensor-server: function 'sysinfo' is now optionnal to allow
- compilation on kfreebsd. It fixes Debian bug #650533.
+** psensor-server: user glibtop instead of 'sysinfo' which is not
+ available on kfreebsd. It fixes Debian bug #650533.
* v0.6.2.14
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
-/* Use sysinfo */
-#undef HAVE_SYSINFO_FCT
-
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
-/* Define to 1 if you have the <sys/sysinfo.h> header file. */
-#undef HAVE_SYS_SYSINFO_H
-
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
MSGFMT
GETTEXT_MACRO_VERSION
USE_NLS
-SYSINFO_FCT_FALSE
-SYSINFO_FCT_TRUE
LIBOBJS
EGREP
GREP
done
-for ac_header in arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h sys/sysinfo.h
+for ac_header in arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
done
-# Detects whether the function sysinfo is available
-# At least kfreebsd 6.0.3 does not provide it.
-SYSINFO_FCT=
-ac_fn_c_check_func "$LINENO" "sysinfo" "ac_cv_func_sysinfo"
-if test "x$ac_cv_func_sysinfo" = xyes; then :
- SYSINFO_FCT='1'
-$as_echo "#define HAVE_SYSINFO_FCT 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"sysinfo function not present\"" >&5
-$as_echo "$as_me: WARNING: \"sysinfo function not present\"" >&2;}
-fi
-
- if test -n "$SYSINFO_FCT"; then
- SYSINFO_FCT_TRUE=
- SYSINFO_FCT_FALSE='#'
-else
- SYSINFO_FCT_TRUE='#'
- SYSINFO_FCT_FALSE=
-fi
-
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5
as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
-if test -z "${SYSINFO_FCT_TRUE}" && test -z "${SYSINFO_FCT_FALSE}"; then
- as_fn_error $? "conditional \"SYSINFO_FCT\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
if test -z "${GTK_TRUE}" && test -z "${GTK_FALSE}"; then
as_fn_error $? "conditional \"GTK\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
# Checks for header files.
AC_PATH_X
-AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h sys/sysinfo.h])
+AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_FUNC_REALLOC
AC_CHECK_FUNCS([gettimeofday memmove socket strdup strtol])
-# Detects whether the function sysinfo is available
-# At least kfreebsd 6.0.3 does not provide it.
-SYSINFO_FCT=
-AC_CHECK_FUNC(sysinfo,
- [SYSINFO_FCT='1' AC_DEFINE([HAVE_SYSINFO_FCT],[1],[Use sysinfo])],
- [AC_MSG_WARN("sysinfo function not present")])
-AM_CONDITIONAL(SYSINFO_FCT, test -n "$SYSINFO_FCT")
-
AM_GNU_GETTEXT_VERSION([0.16])
AM_GNU_GETTEXT([external])
AM_CPPFLAGS += $(GTOP_CFLAGS)
LIBS += $(GTOP_LIBS)
AM_LDFLAGS = -Wl,--as-needed
-
-if SYSINFO_FCT
psensor_server_SOURCES += sysinfo.h sysinfo.c
endif
-endif
-
-
-
-
-
dist_man_MANS = psensor-server.1
EXTRA_DIST = description.txt
psensor-server.1: server.c $(top_srcdir)/configure.ac
bin_PROGRAMS = psensor-server$(EXEEXT)
@GTOP_TRUE@am__append_1 = $(GTOP_CFLAGS)
@GTOP_TRUE@am__append_2 = $(GTOP_LIBS)
-@GTOP_TRUE@@SYSINFO_FCT_TRUE@am__append_3 = sysinfo.h sysinfo.c
+@GTOP_TRUE@am__append_3 = sysinfo.h sysinfo.c
subdir = src/server
DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
PROGRAMS = $(bin_PROGRAMS)
am__psensor_server_SOURCES_DIST = server.c server.h sysinfo.h \
sysinfo.c
-@GTOP_TRUE@@SYSINFO_FCT_TRUE@am__objects_1 = sysinfo.$(OBJEXT)
+@GTOP_TRUE@am__objects_1 = sysinfo.$(OBJEXT)
am_psensor_server_OBJECTS = server.$(OBJEXT) $(am__objects_1)
psensor_server_OBJECTS = $(am_psensor_server_OBJECTS)
psensor_server_LDADD = $(LDADD)
if (!strcmp(nurl, URL_BASE_API_1_0_SENSORS)) {
page = sensors_to_json_string(server_data.sensors);
#ifdef HAVE_GTOP
-#ifdef HAVE_SYSINFO_FCT
} else if (!strcmp(nurl, URL_API_1_0_SYSINFO)) {
page = sysinfo_to_json_string(&server_data.psysinfo);
-#endif
} else if (!strcmp(nurl, URL_API_1_0_CPU_USAGE)) {
page = sensor_to_json_string(server_data.cpu_usage);
#endif
pthread_mutex_lock(&mutex);
#ifdef HAVE_GTOP
-#ifdef HAVE_SYSINFO_FCT
sysinfo_update(&server_data.psysinfo);
-#endif
cpu_usage_sensor_update(server_data.cpu_usage);
#endif
psensor_list_update_measures(server_data.sensors);
sensors_cleanup();
#ifdef HAVE_GTOP
-#ifdef HAVE_SYSINFO_FCT
sysinfo_cleanup();
-#endif
cpu_cleanup();
#endif
#include <glibtop/cpu.h>
#include <glibtop/netlist.h>
#include <glibtop/netload.h>
-#include <sys/sysinfo.h>
#include <json/json.h>
last_used = used;
last_total = cpu->total;
- /* memory */
- sysinfo(&info->sysinfo);
+ glibtop_get_loadavg(&info->loadavg);
+ glibtop_get_mem(&info->mem);
+ glibtop_get_swap(&info->swap);
+ glibtop_get_uptime(&info->uptime);
/* network */
if (!info->interfaces)
free(cpu);
}
-static json_object *ram_to_json_object(const struct sysinfo *s)
+static json_object *ram_to_json_object(const struct psysinfo *s)
{
json_object *obj = json_object_new_object();
json_object_object_add(obj, "total",
- json_object_new_double(s->totalram));
+ json_object_new_double(s->mem.total));
json_object_object_add(obj, "free",
- json_object_new_double(s->freeram));
+ json_object_new_double(s->mem.free));
json_object_object_add(obj, "shared",
- json_object_new_double(s->sharedram));
+ json_object_new_double(s->mem.shared));
json_object_object_add(obj, "buffer",
- json_object_new_double(s->bufferram));
+ json_object_new_double(s->mem.buffer));
return obj;
}
-static json_object *swap_to_json_object(const struct sysinfo *s)
+static json_object *swap_to_json_object(const struct psysinfo *s)
{
json_object *obj = json_object_new_object();
json_object_object_add(obj, "total",
- json_object_new_double(s->totalswap));
+ json_object_new_double(s->swap.total));
json_object_object_add(obj, "free",
- json_object_new_double(s->freeswap));
+ json_object_new_double(s->swap.free));
return obj;
}
static json_object *sysinfo_to_json_object(const struct psysinfo *s)
{
- static float load_scale = 1 << SI_LOAD_SHIFT;
- json_object *obj = json_object_new_object();
+ json_object *obj;
+
+ obj = json_object_new_object();
json_object_object_add(obj, "load",
json_object_new_double(s->cpu_rate));
json_object_object_add
(obj, "load_1",
- json_object_new_double(s->sysinfo.loads[0] / load_scale));
+ json_object_new_double(s->loadavg.loadavg[0]));
json_object_object_add
(obj, "load_5",
- json_object_new_double(s->sysinfo.loads[1] / load_scale));
+ json_object_new_double(s->loadavg.loadavg[1]));
json_object_object_add
(obj, "load_15",
- json_object_new_double(s->sysinfo.loads[2] / load_scale));
+ json_object_new_double(s->loadavg.loadavg[2]));
json_object_object_add
- (obj, "uptime", json_object_new_double(s->sysinfo.uptime));
+ (obj, "uptime", json_object_new_double(s->uptime.uptime));
json_object_object_add
- (obj, "mem_unit", json_object_new_double(s->sysinfo.mem_unit));
+ (obj, "mem_unit", json_object_new_double(1));
- json_object_object_add(obj, "ram", ram_to_json_object(&s->sysinfo));
- json_object_object_add(obj, "swap", swap_to_json_object(&s->sysinfo));
+ json_object_object_add(obj, "ram", ram_to_json_object(s));
+ json_object_object_add(obj, "swap", swap_to_json_object(s));
json_object_object_add(obj, "net", net_to_json_object(s));
return obj;
#define _PSENSOR_SYSINFO_H_
#include <config.h>
-#include <sys/sysinfo.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/uptime.h>
struct psysinfo {
- float cpu_rate;
+ glibtop_loadavg loadavg;
+ glibtop_mem mem;
+ glibtop_swap swap;
+ glibtop_uptime uptime;
-#ifdef HAVE_SYSINFO_FCT
- struct sysinfo sysinfo;
-#endif
+ float cpu_rate;
char **interfaces;
};