summaryrefslogtreecommitdiffstats
path: root/src/freeipmi_plugin.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
commit61aedf201c2c4bf0e5aa4db32e74f4d860b88593 (patch)
treebcf4f9a0cd8bc2daf38b2ff9f29bfcc1e5ed8968 /src/freeipmi_plugin.c
parentNew upstream version 1.8.0+dfsg (diff)
downloadnetdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.tar.xz
netdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.zip
New upstream version 1.9.0+dfsgupstream/1.9.0+dfsg
Diffstat (limited to 'src/freeipmi_plugin.c')
-rw-r--r--src/freeipmi_plugin.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/freeipmi_plugin.c b/src/freeipmi_plugin.c
index 42a1ac01d..9cd736bba 100644
--- a/src/freeipmi_plugin.c
+++ b/src/freeipmi_plugin.c
@@ -522,6 +522,49 @@ static void send_metrics_to_netdata() {
}
+static int *excluded_record_ids = NULL;
+size_t excluded_record_ids_length = 0;
+
+static void excluded_record_ids_parse(const char *s) {
+ if(!s) return;
+
+ while(*s) {
+ while(*s && !isdigit(*s)) s++;
+
+ if(isdigit(*s)) {
+ char *e;
+ unsigned long n = strtoul(s, &e, 10);
+ s = e;
+
+ if(n != 0) {
+ excluded_record_ids = realloc(excluded_record_ids, (excluded_record_ids_length + 1) * sizeof(int));
+ excluded_record_ids[excluded_record_ids_length++] = (int)n;
+ }
+ }
+ }
+
+ if(debug) {
+ fprintf(stderr, "freeipmi.plugin: excluded record ids:");
+ size_t i;
+ for(i = 0; i < excluded_record_ids_length; i++) {
+ fprintf(stderr, " %d", excluded_record_ids[i]);
+ }
+ fprintf(stderr, "\n");
+ }
+}
+
+
+static int excluded_record_ids_check(int record_id) {
+ size_t i;
+
+ for(i = 0; i < excluded_record_ids_length; i++) {
+ if(excluded_record_ids[i] == record_id)
+ return 1;
+ }
+
+ return 0;
+}
+
static void netdata_get_sensor(
int record_id
, int sensor_number
@@ -546,6 +589,10 @@ static void netdata_get_sensor(
if(!sn) {
// not found, create it
+ // check if it is excluded
+ if(excluded_record_ids_check(record_id))
+ return;
+
sn = calloc(1, sizeof(struct sensor));
if(!sn) {
fatal("cannot allocate %zu bytes of memory.", sizeof(struct sensor));
@@ -1482,6 +1529,9 @@ int main (int argc, char **argv) {
" sensor-config-file FILE filename to read sensor configuration\n"
" default: %s\n"
"\n"
+ " ignore N1,N2,N3,... sensor IDs to ignore\n"
+ " default: none\n"
+ "\n"
" -v\n"
" -V\n"
" version print version and exit\n"
@@ -1538,10 +1588,16 @@ int main (int argc, char **argv) {
if(debug) fprintf(stderr, "freeipmi.plugin: sensor config file set to '%s'\n", sensor_config_file);
continue;
}
+ else if(i < argc && strcmp("ignore", argv[i]) == 0) {
+ excluded_record_ids_parse(argv[++i]);
+ continue;
+ }
error("freeipmi.plugin: ignoring parameter '%s'", argv[i]);
}
+ errno = 0;
+
if(freq > netdata_update_every)
netdata_update_every = freq;