src/daemon/sources/test-flapping.h \
src/daemon/sources/test-stall.c \
src/daemon/sources/test-stall.h \
+ src/daemon/sources/uptime.c \
+ src/daemon/sources/uptime.h \
src/daemon/string.h \
src/daemon/time.h \
src/daemon/util.c \
#include "sources/pressure-memory.h"
#include "sources/processor.h"
#include "sources/softirq.h"
+#include "sources/uptime.h"
+
+// Load test sources
#include "sources/test-error.h"
#include "sources/test-flapping.h"
#include "sources/test-stall.h"
&pressure_memory_source,
&processor_source,
&softirq_source,
+ &uptime_source,
// Tests
&test_error_source,
--- /dev/null
+/*#############################################################################
+# #
+# collecty - A system statistics collection daemon for IPFire #
+# Copyright (C) 2025 IPFire Development Team #
+# #
+# 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 3 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, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <errno.h>
+#include <sys/sysinfo.h>
+
+#include "../ctx.h"
+#include "../source.h"
+#include "uptime.h"
+
+static int uptime_collect(collecty_ctx* ctx, collecty_source* source) {
+ struct sysinfo info = {};
+ int r;
+
+ // Fetch system information
+ r = sysinfo(&info);
+ if (r < 0)
+ return -errno;
+
+ // Submit the uptime
+ return collecty_source_submit(source, NULL, "%ld", info.uptime);
+}
+
+const collecty_source_impl uptime_source = {
+ .name = "uptime",
+
+ // RRD Data Sources
+ .rrd_dss = {
+ { "uptime", "GAUGE", 0, -1, },
+ { NULL },
+ },
+
+ // Methods
+ .collect = uptime_collect,
+};
--- /dev/null
+/*#############################################################################
+# #
+# collecty - A system statistics collection daemon for IPFire #
+# Copyright (C) 2025 IPFire Development Team #
+# #
+# 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 3 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, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef COLLECTY_SOURCE_UPTIME_H
+#define COLLECTY_SOURCE_UPTIME_H
+
+#include "../source.h"
+
+extern const collecty_source_impl uptime_source;
+
+#endif /* COLLECTY_SOURCE_UPTIME_H */