src/daemon/sources/pressure-memory.h \
src/daemon/sources/processor.c \
src/daemon/sources/processor.h \
+ src/daemon/sources/test-error.c \
+ src/daemon/sources/test-error.h \
+ src/daemon/sources/test-flapping.c \
+ src/daemon/sources/test-flapping.h \
src/daemon/util.c \
src/daemon/util.h
#include "sources/pressure-io.h"
#include "sources/pressure-memory.h"
#include "sources/processor.h"
+#include "sources/test-error.h"
+#include "sources/test-flapping.h"
// Register all sources
static const collecty_source_impl* source_impls[] = {
&pressure_io_source,
&pressure_memory_source,
&processor_source,
+
+ // Tests
+ &test_error_source,
+ &test_flapping_source,
+
NULL,
};
--- /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 "../ctx.h"
+#include "../source.h"
+#include "error.h"
+
+/*
+ This is a test source which always fails.
+*/
+
+static int test_error_collect(collecty_ctx* ctx, collecty_source* source) {
+ return -ENOSPC;
+}
+
+const collecty_source_impl test_error_source = {
+ .name = "test-error",
+
+ // Methods
+ .collect = test_error_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_TEST_ERROR_H
+#define COLLECTY_SOURCE_TEST_ERROR_H
+
+#include "../source.h"
+
+extern const collecty_source_impl test_error_source;
+
+#endif /* COLLECTY_SOURCE_TEST_ERROR_H */
--- /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 <stdlib.h>
+
+#include "../ctx.h"
+#include "../source.h"
+#include "error.h"
+
+/*
+ This is a test source which fails with a certain probability.
+*/
+
+static int test_flapping_collect(collecty_ctx* ctx, collecty_source* source) {
+ int r;
+
+ // Fetch some random value
+ r = rand();
+
+ // With a chance of 50%, return an error
+ if (r < (RAND_MAX / 2))
+ return -ENOSPC;
+
+ // Otherwise return the random number
+ return collecty_source_submit(source, NULL, "%d", r);
+}
+
+const collecty_source_impl test_flapping_source = {
+ .name = "test-flapping",
+
+ // RRD Data Sources
+ .rrd_dss = {
+ { "random", "GAUGE", 0, RAND_MAX, },
+ { NULL },
+ },
+
+ // Methods
+ .collect = test_flapping_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_TEST_FLAPPING_H
+#define COLLECTY_SOURCE_TEST_FLAPPING_H
+
+#include "../source.h"
+
+extern const collecty_source_impl test_flapping_source;
+
+#endif /* COLLECTY_SOURCE_TEST_FLAPPING_H */