* Added NVidia fan support.
* Added 'Hide' menu item in the contextual menu of the list of
sensors.
+* Added free memory support.
v1.1.1
------
sensors.\r
</p>\r
</li>\r
+<li>\r
+<p>\r
+Added free memory support.\r
+</p>\r
+</li>\r
</ul></div>\r
</div>\r
</div>\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 2014-09-08 08:39:43 CEST\r
+Last updated 2014-09-08 21:59:03 CEST\r
</div>\r
</div>\r
</body>\r
endif
if GTOP
-libpsensor_a_SOURCES += cpu.c
+libpsensor_a_SOURCES += cpu.c pmem.c pmem.h
LIBS += $(GTOP_LIBS)
AM_CPPFLAGS += $(GTOP_CFLAGS)
endif
EXTRA_DIST=$(libpsensor_a_SOURCES) \
amd.c \
cpu.c \
- nvidia.c
+ nvidia.c \
+ pmem.c pmem.h
@LIBATIADL_TRUE@am__append_5 = $(LIBATIADL_LIBS)
@LIBATIADL_TRUE@am__append_6 = $(LIBATIADL_CFLAGS)
@LIBATIADL_TRUE@am__append_7 = amd.c
-@GTOP_TRUE@am__append_8 = cpu.c
+@GTOP_TRUE@am__append_8 = cpu.c pmem.c pmem.h
@GTOP_TRUE@am__append_9 = $(GTOP_LIBS)
@GTOP_TRUE@am__append_10 = $(GTOP_CFLAGS)
@JSON_TRUE@am__append_11 = psensor_json.h psensor_json.c
nvidia.h plog.h plog.c pmutex.h pmutex.c psensor.h psensor.c \
ptime.h ptime.c pio.h pio.c slog.c slog.h temperature.c \
temperature.h url.c url.h hdd_atasmart.c nvidia.c amd.c cpu.c \
- psensor_json.h psensor_json.c
+ pmem.c pmem.h psensor_json.h psensor_json.c
@ATASMART_TRUE@am__objects_1 = hdd_atasmart.$(OBJEXT)
@NVIDIA_TRUE@am__objects_2 = nvidia.$(OBJEXT)
@LIBATIADL_TRUE@am__objects_3 = amd.$(OBJEXT)
-@GTOP_TRUE@am__objects_4 = cpu.$(OBJEXT)
+@GTOP_TRUE@am__objects_4 = cpu.$(OBJEXT) pmem.$(OBJEXT)
@JSON_TRUE@am__objects_5 = psensor_json.$(OBJEXT)
am_libpsensor_a_OBJECTS = color.$(OBJEXT) hdd_hddtemp.$(OBJEXT) \
lmsensor.$(OBJEXT) measure.$(OBJEXT) plog.$(OBJEXT) \
EXTRA_DIST = $(libpsensor_a_SOURCES) \
amd.c \
cpu.c \
- nvidia.c
+ nvidia.c \
+ pmem.c pmem.h
all: all-am
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nvidia.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmutex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psensor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psensor_json.Po@am__quote@
static void add(struct psensor ***sensors, int id, int type, int values_len)
{
- struct psensor **tmp, *s;
+ struct psensor *s;
s = create_nvidia_sensor(id, type, values_len);
- if (s) {
- tmp = psensor_list_add(*sensors, s);
- free(*sensors);
- *sensors = tmp;
- }
+ if (s)
+ psensor_list_append(sensors, s);
}
struct psensor **
--- /dev/null
+/*
+ * Copyright (C) 2010-2014 jeanfi@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 <locale.h>
+#include <libintl.h>
+#define _(str) gettext(str)
+
+#include <glibtop/mem.h>
+
+#include <pmem.h>
+
+static const char *ID_MEM_FREE = "sys memory free";
+
+void mem_psensor_list_update(struct psensor **sensors)
+{
+ struct psensor *s;
+ glibtop_mem mem;
+ double v;
+
+ while (*sensors) {
+ s = *sensors;
+
+ if (!strcmp(s->id, ID_MEM_FREE)) {
+ glibtop_get_mem(&mem);
+ v = mem.free * 100 / mem.total;
+
+ psensor_set_current_value(s, v);
+ }
+
+ sensors++;
+ }
+}
+
+void mem_psensor_list_add(struct psensor ***sensors, int values_max_len)
+{
+ struct psensor *s;
+
+ s = psensor_create(strdup(ID_MEM_FREE),
+ _("free memory"),
+ _("memory"),
+ SENSOR_TYPE_MEMORY | SENSOR_TYPE_PERCENT,
+ values_max_len);
+
+ psensor_list_append(sensors, s);
+}
--- /dev/null
+/*
+ * Copyright (C) 2010-2014 jeanfi@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 _PSENSOR_MEM_H_
+#define _PSENSOR_MEM_H_
+
+#include <psensor.h>
+
+void mem_psensor_list_add(struct psensor ***, int values_max_len);
+void mem_psensor_list_update(struct psensor **);
+
+#endif
#include <temperature.h>
#ifdef HAVE_GTOP
-#include "cpu.h"
+#include <cpu.h>
+#include <pmem.h>
#endif
struct psensor *psensor_create(char *id,
struct psensor **psensor_list_add(struct psensor **sensors,
struct psensor *sensor)
{
- int size = psensor_list_size(sensors);
+ int size;
+
+ size = psensor_list_size(sensors);
struct psensor **result
= malloc((size + 1 + 1) * sizeof(struct psensor *));
return result;
}
+void psensor_list_append(struct psensor ***sensors, struct psensor *sensor)
+{
+ struct psensor **tmp;
+
+ if (!sensor)
+ return ;
+
+ tmp = psensor_list_add(*sensors, sensor);
+
+ if (tmp != *sensors) {
+ free(*sensors);
+ *sensors = tmp;
+ }
+}
+
+
struct psensor *psensor_list_get_by_id(struct psensor **sensors, const char *id)
{
struct psensor **sensors_cur = sensors;
}
#endif
+#ifdef HAVE_GTOP
+ mem_psensor_list_add(&psensors, values_max_length);
+#endif
+
if (!psensors) { /* there is no detected sensors */
psensors = malloc(sizeof(struct psensor *));
*psensors = NULL;
if (type & SENSOR_TYPE_TEMP)
return "Temperature";
- if (type & SENSOR_TYPE_FAN)
+ if (type & SENSOR_TYPE_RPM)
return "Fan";
if (type & SENSOR_TYPE_CPU)
if (type & SENSOR_TYPE_REMOTE)
return "Remote";
+ if (type & SENSOR_TYPE_MEMORY)
+ return "Memory";
+
return "N/A";
}
#ifdef HAVE_GTOP
cpu_psensor_list_update(sensors);
+ mem_psensor_list_update(sensors);
#endif
if (psensor_list_contains_type(sensors, SENSOR_TYPE_HDDTEMP))
struct psensor **psensor_list_add(struct psensor **sensors,
struct psensor *sensor);
+void psensor_list_append(struct psensor ***sensors, struct psensor *sensor);
+
struct psensor **psensor_list_copy(struct psensor **);
void psensor_set_current_value(struct psensor *sensor, double value);