X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Ffhcount.c;h=97f0438c94f024fb4f526fef7130f38bdf5a1c18;hp=3fbabf0da0a51e51017863f53e9dc2c542db3692;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=79963d13c1884d1d92667cc502ad20758b084a12 diff --git a/src/fhcount.c b/src/fhcount.c index 3fbabf0d..97f0438c 100644 --- a/src/fhcount.c +++ b/src/fhcount.c @@ -49,22 +49,17 @@ static int fhcount_config(const char *key, const char *value) { ret = 0; } - return (ret); + return ret; } static void fhcount_submit(const char *type, const char *type_instance, gauge_t value) { - - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = value; - - vl.values = values; + vl.values = &(value_t){.gauge = value}; vl.values_len = 1; // Compose the metric - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "fhcount", sizeof(vl.plugin)); sstrncpy(vl.type, type, sizeof(vl.type)); sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance)); @@ -80,19 +75,18 @@ static int fhcount_read(void) { int prc_used, prc_unused; char *fields[3]; char buffer[buffer_len]; - char errbuf[1024]; FILE *fp; // Open file fp = fopen("/proc/sys/fs/file-nr", "r"); if (fp == NULL) { - ERROR("fhcount: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf))); - return (EXIT_FAILURE); + ERROR("fhcount: fopen: %s", STRERRNO); + return EXIT_FAILURE; } if (fgets(buffer, buffer_len, fp) == NULL) { - ERROR("fhcount: fgets: %s", sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("fhcount: fgets: %s", STRERRNO); fclose(fp); - return (EXIT_FAILURE); + return EXIT_FAILURE; } fclose(fp); @@ -101,7 +95,7 @@ static int fhcount_read(void) { if (numfields != 3) { ERROR("fhcount: Line doesn't contain 3 fields"); - return (EXIT_FAILURE); + return EXIT_FAILURE; } // Define the values @@ -122,7 +116,7 @@ static int fhcount_read(void) { fhcount_submit("percent", "unused", (gauge_t)prc_unused); } - return (0); + return 0; } void module_register(void) {