GNUnet 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, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
static processor_cpu_load_info_t prev_cpu_load;
#endif
+#ifdef WINDOWS
+#include <winternl.h>
+#endif
#define DEBUG_STATUSCALLS GNUNET_NO
kc = kstat_open ();
if (kc == NULL)
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kstat_close");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kstat_close");
goto ABORT_KSTAT;
}
age = GNUNET_TIME_absolute_get_duration (lastCall);
if ( (agedCPULoad == -1)
- || (age.rel_value > 500) )
+ || (age.rel_value_us > 500000) )
{
/* use smoothing, but do NOT update lastRet at frequencies higher
than 500ms; this makes the smoothing (mostly) independent from
static unsigned int
mem_get_usage ()
{
- unsigned long currentMemUsage;
+ double percentage;
meminfo ();
- currentMemUsage = kb_main_total - kb_main_free;
- return (unsigned int) ((currentMemUsage / kb_main_total) * 100);
+ percentage = ( ((double) kb_main_used) / ((double) kb_main_total) * 100.0 );
+ return (unsigned int) percentage;
}
nproc = 0;
while (NULL != (ent = readdir (dir)))
{
- if((*ent->d_name > '0') && (*ent->d_name <= '9'))
+ if((*ent->d_name > '0') && (*ent->d_name <= '9'))
nproc++;
}
closedir (dir);
nproc = 0;
#endif
now = GNUNET_TIME_absolute_get ();
- nbs = GNUNET_asprintf (&str, "%llu %d %d %u %u\n", now.abs_value / 1000,
+ nbs = GNUNET_asprintf (&str, "%llu %d %d %u %u\n", now.abs_value_us / 1000LL / 1000LL,
ld_cpu, ld_disk, mem_usage, nproc);
- if (0 < nbs)
+ if (0 < nbs)
{
GNUNET_BIO_write (bw, str, nbs);
- GNUNET_free (str);
}
else
GNUNET_break (0);
+ GNUNET_free (str);
reschedule:
sample_load_task_id =
char *stats_dir;
char *fn;
size_t len;
-
+
#if MINGW
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Load statistics logging now available for windows\n");
GNUNET_free (hostname);
return;
}
- fn = NULL;
+ fn = NULL;
(void) GNUNET_asprintf (&fn, "%s/%.*s-%jd.dat", stats_dir, len,
hostname, (intmax_t) getpid());
GNUNET_free (stats_dir);
initMachCpuStats ();
#endif
updateUsage (); /* initialize */
-
+
}