diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | cpu.c | 2 | ||||
-rw-r--r-- | cpu.h | 8 | ||||
-rw-r--r-- | diskstats.c | 2 | ||||
-rw-r--r-- | diskstats.h | 8 | ||||
-rw-r--r-- | filesystem.c | 2 | ||||
-rw-r--r-- | filesystem.h | 8 | ||||
-rw-r--r-- | hwmon.c | 2 | ||||
-rw-r--r-- | hwmon.h | 8 | ||||
-rw-r--r-- | main.c | 30 | ||||
-rw-r--r-- | meminfo.c | 2 | ||||
-rw-r--r-- | meminfo.h | 8 | ||||
-rw-r--r-- | network.c | 2 | ||||
-rw-r--r-- | network.h | 8 | ||||
-rw-r--r-- | textfile.c | 2 | ||||
-rw-r--r-- | textfile.h | 11 | ||||
-rw-r--r-- | uname.c | 2 | ||||
-rw-r--r-- | uname.h | 8 |
18 files changed, 26 insertions, 91 deletions
diff --git a/Makefile b/Makefile index 18f278e..e621c2f 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,10 @@ $(PROG): $(OBJS) $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@ +main.o: main.c $(DEPDIR)/main.d + $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -DXCOLLECTORS="$(foreach c,$(COLLECTORS),X($(c)))" -c -o $@ $< + @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@ + # make clean .PHONY: clean diff --git a/cpu.c b/cpu.c index f73e235..94dd4c5 100644 --- a/cpu.c +++ b/cpu.c @@ -3,7 +3,7 @@ #include <string.h> #include <unistd.h> -#include "cpu.h" +#include "collector.h" #include "util.h" // limits for CPU numbers diff --git a/cpu.h b/cpu.h deleted file mode 100644 index 3bc0d1f..0000000 --- a/cpu.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_CPU_H_ -#define PNANOE_CPU_H_ 1 - -#include "collector.h" - -extern const struct collector cpu_collector; - -#endif // PNANOE_CPU_H_ diff --git a/diskstats.c b/diskstats.c index 6fdcf01..da5ec6c 100644 --- a/diskstats.c +++ b/diskstats.c @@ -4,7 +4,7 @@ #include <stdlib.h> #include <string.h> -#include "diskstats.h" +#include "collector.h" #include "util.h" // size of input buffer for paths and lines diff --git a/diskstats.h b/diskstats.h deleted file mode 100644 index 15a867a..0000000 --- a/diskstats.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_DISKSTATS_H_ -#define PNANOE_DISKSTATS_H_ 1 - -#include "collector.h" - -extern const struct collector diskstats_collector; - -#endif // PNANOE_DISKSTATS_H_ diff --git a/filesystem.c b/filesystem.c index 84f6805..cbc98ff 100644 --- a/filesystem.c +++ b/filesystem.c @@ -3,7 +3,7 @@ #include <string.h> #include <sys/statvfs.h> -#include "filesystem.h" +#include "collector.h" #include "util.h" // size of input buffer for paths and lines diff --git a/filesystem.h b/filesystem.h deleted file mode 100644 index 60485cf..0000000 --- a/filesystem.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_FILESYSTEM_H_ -#define PNANOE_FILESYSTEM_H_ 1 - -#include "collector.h" - -extern const struct collector filesystem_collector; - -#endif // PNANOE_FILESYSTEM_H_ diff --git a/hwmon.c b/hwmon.c index 11b6b87..4ec7b8a 100644 --- a/hwmon.c +++ b/hwmon.c @@ -7,7 +7,7 @@ #include <string.h> #include <unistd.h> -#include "hwmon.h" +#include "collector.h" // size of input buffer for paths and lines #define BUF_SIZE 256 diff --git a/hwmon.h b/hwmon.h deleted file mode 100644 index 14315a1..0000000 --- a/hwmon.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_HWMON_H_ -#define PNANOE_HWMON_H_ 1 - -#include "collector.h" - -extern const struct collector hwmon_collector; - -#endif // PNANOE_HWMON_H_ diff --git a/main.c b/main.c index 036a06f..aba4269 100644 --- a/main.c +++ b/main.c @@ -5,27 +5,25 @@ #include <stdio.h> #include <string.h> -#include "cpu.h" -#include "diskstats.h" -#include "filesystem.h" -#include "hwmon.h" -#include "meminfo.h" -#include "network.h" +#include "collector.h" #include "scrape.h" -#include "textfile.h" -#include "uname.h" #include "util.h" +#ifndef XCOLLECTORS +#define XCOLLECTORS \ + X(cpu) X(diskstats) X(filesystem) X(hwmon) \ + X(meminfo) X(network) X(textfile) X(uname) +#endif + +#define X(c) extern const struct collector c##_collector; +XCOLLECTORS +#undef X + +#define X(c) &c##_collector, static const struct collector *collectors[] = { - &cpu_collector, - &diskstats_collector, - &filesystem_collector, - &hwmon_collector, - &meminfo_collector, - &network_collector, - &textfile_collector, - &uname_collector, + XCOLLECTORS }; +#undef X #define NCOLLECTORS (sizeof collectors / sizeof *collectors) enum tristate { flag_off = -1, flag_undef = 0, flag_on = 1 }; diff --git a/meminfo.c b/meminfo.c index 982400a..52641d2 100644 --- a/meminfo.c +++ b/meminfo.c @@ -4,7 +4,7 @@ #include <stdlib.h> #include <string.h> -#include "meminfo.h" +#include "collector.h" #include "util.h" // size of input buffer for paths and lines diff --git a/meminfo.h b/meminfo.h deleted file mode 100644 index 76c9339..0000000 --- a/meminfo.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_MEMINFO_H_ -#define PNANOE_MEMINFO_H_ 1 - -#include "collector.h" - -extern const struct collector meminfo_collector; - -#endif // PNANOE_MEMINFO_H_ diff --git a/network.c b/network.c index 86f3b43..798d813 100644 --- a/network.c +++ b/network.c @@ -5,7 +5,7 @@ #include <stdlib.h> #include <string.h> -#include "network.h" +#include "collector.h" #include "util.h" // size of input buffer for paths and lines diff --git a/network.h b/network.h deleted file mode 100644 index 98d7241..0000000 --- a/network.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_NETWORK_H_ -#define PNANOE_NETWORK_H_ 1 - -#include "collector.h" - -extern const struct collector network_collector; - -#endif // PNANOE_NETWORK_H_ diff --git a/textfile.c b/textfile.c index d9ab4fa..2ef877b 100644 --- a/textfile.c +++ b/textfile.c @@ -4,7 +4,7 @@ #include <string.h> #include <sys/types.h> -#include "textfile.h" +#include "collector.h" #include "util.h" // TODO: check default diff --git a/textfile.h b/textfile.h deleted file mode 100644 index 45c86b0..0000000 --- a/textfile.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef PNANOE_TEXTFILE_H_ -#define PNANOE_TEXTFILE_H_ 1 - -#include "collector.h" - -extern const struct collector textfile_collector; - -void *textfile_init(int argc, char *argv[]); -void textfile_collect(scrape_req *req, void *ctx); - -#endif // PNANOE_TEXTFILE_H_ diff --git a/uname.c b/uname.c index 6d71764..4fd4eac 100644 --- a/uname.c +++ b/uname.c @@ -2,7 +2,7 @@ #include <stdlib.h> #include <sys/utsname.h> -#include "uname.h" +#include "collector.h" #include "util.h" static void *uname_init(int argc, char *argv[]); diff --git a/uname.h b/uname.h deleted file mode 100644 index 660b603..0000000 --- a/uname.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PNANOE_UNAME_H_ -#define PNANOE_UNAME_H_ 1 - -#include "collector.h" - -extern const struct collector uname_collector; - -#endif // PNANOE_UNAME_H_ |