static int sensors_config(const char *key, const char *value) { if (sensor_list == NULL) sensor_list = ignorelist_create(1); /* TODO: This setting exists for compatibility with old versions of * lm-sensors. Remove support for those ancient versions in the next * major release. */ if (strcasecmp(key, "SensorConfigFile") == 0) { char *tmp = strdup(value); if (tmp != NULL) { sfree(conffile); conffile = tmp; } } else if (strcasecmp(key, "Sensor") == 0) { if (ignorelist_add(sensor_list, value)) { ERROR("sensors plugin: " "Cannot add value to ignorelist."); return 1; } } else if (strcasecmp(key, "IgnoreSelected") == 0) { ignorelist_set_invert(sensor_list, 1); if (IS_TRUE(value)) ignorelist_set_invert(sensor_list, 0); } #if (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) else if (strcasecmp(key, "UseLabels") == 0) { use_labels = IS_TRUE(value); } #endif else { return -1; } return 0; }
static int cow_load_config (const char *key, const char *value) { if (sensor_list == NULL) sensor_list = ignorelist_create (1); if (strcasecmp (key, "Sensor") == 0) { if (direct_list_insert (value)) { DEBUG ("onewire plugin: Cannot add %s to direct_list_insert.", value); if (ignorelist_add (sensor_list, value)) { ERROR ("onewire plugin: Cannot add value to ignorelist."); return (1); } } else { DEBUG ("onewire plugin: %s is a direct access", value); direct_access = 1; } } else if (strcasecmp (key, "IgnoreSelected") == 0) { ignorelist_set_invert (sensor_list, 1); if (IS_TRUE (value)) ignorelist_set_invert (sensor_list, 0); } else if (strcasecmp (key, "Device") == 0) { char *temp; temp = strdup (value); if (temp == NULL) { ERROR ("onewire plugin: strdup failed."); return (1); } sfree (device_g); device_g = temp; } else if (strcasecmp ("Interval", key) == 0) { double tmp; tmp = atof (value); if (tmp > 0.0) ow_interval = DOUBLE_TO_CDTIME_T (tmp); else ERROR ("onewire plugin: Invalid `Interval' setting: %s", value); } else { return (-1); } return (0); }
static int interface_config (const char *key, const char *value) { if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (strcasecmp (key, "Interface") == 0) { ignorelist_add (ignorelist, value); } else if (strcasecmp (key, "IgnoreSelected") == 0) { int invert = 1; if (IS_TRUE (value)) invert = 0; ignorelist_set_invert (ignorelist, invert); } else if (strcasecmp (key, "UniqueName") == 0) { #ifdef HAVE_LIBKSTAT if (IS_TRUE (value)) unique_name = 1; #else WARNING ("interface plugin: the \"UniqueName\" option is only valid on Solaris."); #endif /* HAVE_LIBKSTAT */ } else { return (-1); } return (0); }
static int smart_config (const char *key, const char *value) { if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (ignorelist == NULL) return (1); if (strcasecmp ("Disk", key) == 0) { ignorelist_add (ignorelist, value); } else if (strcasecmp ("IgnoreSelected", key) == 0) { int invert = 1; if (IS_TRUE (value)) invert = 0; ignorelist_set_invert (ignorelist, invert); } else { return (-1); } return (0); } /* int smart_config */
static int disk_config (const char *key, const char *value) { if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (ignorelist == NULL) return (1); if (strcasecmp ("Disk", key) == 0) { ignorelist_add (ignorelist, value); } else if (strcasecmp ("IgnoreSelected", key) == 0) { int invert = 1; if (IS_TRUE (value)) invert = 0; ignorelist_set_invert (ignorelist, invert); } else if (strcasecmp ("UseBSDName", key) == 0) { #if HAVE_IOKIT_IOKITLIB_H use_bsd_name = IS_TRUE (value) ? 1 : 0; #else WARNING ("disk plugin: The \"UseBSDName\" option is only supported " "on Mach / Mac OS X and will be ignored."); #endif } else { return (-1); } return (0); } /* int disk_config */
static int interface_config (const char *key, const char *value) { if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (strcasecmp (key, "Interface") == 0) { ignorelist_add (ignorelist, value); } else if (strcasecmp (key, "IgnoreSelected") == 0) { int invert = 1; if ((strcasecmp (value, "True") == 0) || (strcasecmp (value, "Yes") == 0) || (strcasecmp (value, "On") == 0)) invert = 0; ignorelist_set_invert (ignorelist, invert); } else { return (-1); } return (0); }
static int cgroups_config(const char *key, const char *value) { cgroups_init(); if (strcasecmp(key, "CGroup") == 0) { if (ignorelist_add(il_cgroup, value)) return (1); return (0); } else if (strcasecmp(key, "IgnoreSelected") == 0) { if (IS_TRUE(value)) ignorelist_set_invert(il_cgroup, 0); else ignorelist_set_invert(il_cgroup, 1); return (0); } return (-1); }
static int df_config (const char *key, const char *value) { df_init (); if (strcasecmp (key, "Device") == 0) { if (ignorelist_add (il_device, value)) return (1); return (0); } else if (strcasecmp (key, "MountPoint") == 0) { if (ignorelist_add (il_mountpoint, value)) return (1); return (0); } else if (strcasecmp (key, "FSType") == 0) { if (ignorelist_add (il_fstype, value)) return (1); return (0); } else if (strcasecmp (key, "IgnoreSelected") == 0) { if (IS_TRUE (value)) { ignorelist_set_invert (il_device, 0); ignorelist_set_invert (il_mountpoint, 0); ignorelist_set_invert (il_fstype, 0); } else { ignorelist_set_invert (il_device, 1); ignorelist_set_invert (il_mountpoint, 1); ignorelist_set_invert (il_fstype, 1); } return (0); } else if (strcasecmp (key, "ReportByDevice") == 0) { if (IS_TRUE (value)) by_device = 1; return (0); } else if (strcasecmp (key, "ReportInodes") == 0) { if (IS_TRUE (value)) report_inodes = 1; else report_inodes = 0; return (0); } return (-1); }
static int thermal_config (const char *key, const char *value) { if (device_list == NULL) device_list = ignorelist_create (1); if (strcasecmp (key, "Device") == 0) { if (ignorelist_add (device_list, value)) { ERROR ("thermal plugin: " "Cannot add value to ignorelist."); return 1; } } else if (strcasecmp (key, "IgnoreSelected") == 0) { ignorelist_set_invert (device_list, 1); if ((strcasecmp (value, "True") == 0) || (strcasecmp (value, "Yes") == 0) || (strcasecmp (value, "On") == 0)) ignorelist_set_invert (device_list, 0); } else if (strcasecmp (key, "ForceUseProcfs") == 0) { force_procfs = 0; if ((strcasecmp (value, "True") == 0) || (strcasecmp (value, "Yes") == 0) || (strcasecmp (value, "On") == 0)) force_procfs = 1; } else { return -1; } return 0; }
static int disk_config (const char *key, const char *value) { if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (ignorelist == NULL) return (1); if (strcasecmp ("Disk", key) == 0) { ignorelist_add (ignorelist, value); } else if (strcasecmp ("IgnoreSelected", key) == 0) { int invert = 1; if (IS_TRUE (value)) invert = 0; ignorelist_set_invert (ignorelist, invert); } else if (strcasecmp ("UseBSDName", key) == 0) { #if HAVE_IOKIT_IOKITLIB_H use_bsd_name = IS_TRUE (value) ? 1 : 0; #else WARNING ("disk plugin: The \"UseBSDName\" option is only supported " "on Mach / Mac OS X and will be ignored."); #endif } else if (strcasecmp ("UdevNameAttr", key) == 0) { #if HAVE_LIBUDEV if (conf_udev_name_attr != NULL) { free (conf_udev_name_attr); conf_udev_name_attr = NULL; } if ((conf_udev_name_attr = strdup (value)) == NULL) return (1); #else WARNING ("disk plugin: The \"UdevNameAttr\" option is only supported " "if collectd is built with libudev support"); #endif } else { return (-1); } return (0); } /* int disk_config */
static int protocols_config(const char *key, const char *value) { if (values_list == NULL) values_list = ignorelist_create(/* invert = */ 1); if (strcasecmp(key, "Value") == 0) { ignorelist_add(values_list, value); } else if (strcasecmp(key, "IgnoreSelected") == 0) { int invert = 1; if (IS_TRUE(value)) invert = 0; ignorelist_set_invert(values_list, invert); } else { return (-1); } return (0); } /* int protocols_config */
static int md_config (const char *key, const char *value) { if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (ignorelist == NULL) return (1); if (strcasecmp (key, "Device") == 0) { ignorelist_add (ignorelist, value); } else if (strcasecmp (key, "IgnoreSelected") == 0) { ignorelist_set_invert (ignorelist, IS_TRUE (value) ? 0 : 1); } else { return (-1); } return (0); }
static int df_config (const char *key, const char *value) { df_init (); if (strcasecmp (key, "Device") == 0) { if (ignorelist_add (il_device, value)) return (1); return (0); } else if (strcasecmp (key, "MountPoint") == 0) { if (ignorelist_add (il_mountpoint, value)) return (1); return (0); } else if (strcasecmp (key, "FSType") == 0) { if (ignorelist_add (il_fstype, value)) return (1); return (0); } else if (strcasecmp (key, "IgnoreSelected") == 0) { if ((strcasecmp (value, "True") == 0) || (strcasecmp (value, "Yes") == 0) || (strcasecmp (value, "On") == 0)) { ignorelist_set_invert (il_device, 0); ignorelist_set_invert (il_mountpoint, 0); ignorelist_set_invert (il_fstype, 0); } else { ignorelist_set_invert (il_device, 1); ignorelist_set_invert (il_mountpoint, 1); ignorelist_set_invert (il_fstype, 1); } return (0); } return (-1); }
static int lv_config (const char *key, const char *value) { if (virInitialize () != 0) return 1; if (il_domains == NULL) il_domains = ignorelist_create (1); if (il_block_devices == NULL) il_block_devices = ignorelist_create (1); if (il_interface_devices == NULL) il_interface_devices = ignorelist_create (1); if (strcasecmp (key, "Connection") == 0) { char *tmp = strdup (value); if (tmp == NULL) { ERROR (PLUGIN_NAME " plugin: Connection strdup failed."); return 1; } sfree (conn_string); conn_string = tmp; return 0; } if (strcasecmp (key, "RefreshInterval") == 0) { char *eptr = NULL; interval = strtol (value, &eptr, 10); if (eptr == NULL || *eptr != '\0') return 1; return 0; } if (strcasecmp (key, "Domain") == 0) { if (ignorelist_add (il_domains, value)) return 1; return 0; } if (strcasecmp (key, "BlockDevice") == 0) { if (ignorelist_add (il_block_devices, value)) return 1; return 0; } if (strcasecmp (key, "InterfaceDevice") == 0) { if (ignorelist_add (il_interface_devices, value)) return 1; return 0; } if (strcasecmp (key, "IgnoreSelected") == 0) { if (IS_TRUE (value)) { ignorelist_set_invert (il_domains, 0); ignorelist_set_invert (il_block_devices, 0); ignorelist_set_invert (il_interface_devices, 0); } else { ignorelist_set_invert (il_domains, 1); ignorelist_set_invert (il_block_devices, 1); ignorelist_set_invert (il_interface_devices, 1); } return 0; } if (strcasecmp (key, "HostnameFormat") == 0) { char *value_copy; char *fields[HF_MAX_FIELDS]; int i, n; value_copy = strdup (value); if (value_copy == NULL) { ERROR (PLUGIN_NAME " plugin: strdup failed."); return -1; } n = strsplit (value_copy, fields, HF_MAX_FIELDS); if (n < 1) { sfree (value_copy); ERROR (PLUGIN_NAME " plugin: HostnameFormat: no fields"); return -1; } for (i = 0; i < n; ++i) { if (strcasecmp (fields[i], "hostname") == 0) hostname_format[i] = hf_hostname; else if (strcasecmp (fields[i], "name") == 0) hostname_format[i] = hf_name; else if (strcasecmp (fields[i], "uuid") == 0) hostname_format[i] = hf_uuid; else { ERROR (PLUGIN_NAME " plugin: unknown HostnameFormat field: %s", fields[i]); sfree (value_copy); return -1; } } sfree (value_copy); for (i = n; i < HF_MAX_FIELDS; ++i) hostname_format[i] = hf_none; return 0; } if (strcasecmp (key, "PluginInstanceFormat") == 0) { char *value_copy; char *fields[PLGINST_MAX_FIELDS]; int i, n; value_copy = strdup (value); if (value_copy == NULL) { ERROR (PLUGIN_NAME " plugin: strdup failed."); return -1; } n = strsplit (value_copy, fields, PLGINST_MAX_FIELDS); if (n < 1) { sfree (value_copy); ERROR (PLUGIN_NAME " plugin: PluginInstanceFormat: no fields"); return -1; } for (i = 0; i < n; ++i) { if (strcasecmp (fields[i], "none") == 0) { plugin_instance_format[i] = plginst_none; break; } else if (strcasecmp (fields[i], "name") == 0) plugin_instance_format[i] = plginst_name; else if (strcasecmp (fields[i], "uuid") == 0) plugin_instance_format[i] = plginst_uuid; else { ERROR (PLUGIN_NAME " plugin: unknown PluginInstanceFormat field: %s", fields[i]); sfree (value_copy); return -1; } } sfree (value_copy); for (i = n; i < PLGINST_MAX_FIELDS; ++i) plugin_instance_format[i] = plginst_none; return 0; } if (strcasecmp (key, "InterfaceFormat") == 0) { if (strcasecmp (value, "name") == 0) interface_format = if_name; else if (strcasecmp (value, "address") == 0) interface_format = if_address; else if (strcasecmp (value, "number") == 0) interface_format = if_number; else { ERROR (PLUGIN_NAME " plugin: unknown InterfaceFormat: %s", value); return -1; } return 0; } /* Unrecognised option. */ return -1; }
static int madwifi_config (const char *key, const char *value) { if (init_state != 1) madwifi_real_init(); init_state = 1; if (ignorelist == NULL) ignorelist = ignorelist_create (/* invert = */ 1); if (strcasecmp (key, "Interface") == 0) ignorelist_add (ignorelist, value); else if (strcasecmp (key, "IgnoreSelected") == 0) ignorelist_set_invert (ignorelist, IS_TRUE (value) ? 0 : 1); else if (strcasecmp (key, "Source") == 0) { if (strcasecmp (value, "ProcFS") == 0) use_sysfs = 0; else if (strcasecmp (value, "SysFS") == 0) use_sysfs = 1; else { ERROR ("madwifi plugin: The argument of the `Source' " "option must either be `SysFS' or " "`ProcFS'."); return -1; } } else if (strcasecmp (key, "WatchSet") == 0) { if (strcasecmp (value, "All") == 0) watchlist_set (watch_items, 0xFFFFFFFF); else if (strcasecmp (value, "None") == 0) watchlist_set (watch_items, 0); else return -1; } else if (strcasecmp (key, "WatchAdd") == 0) { int id = watchitem_find (value); if (id < 0) return (-1); else watchlist_add (watch_items, id); } else if (strcasecmp (key, "WatchRemove") == 0) { int id = watchitem_find (value); if (id < 0) return (-1); else watchlist_remove (watch_items, id); } else if (strcasecmp (key, "MiscSet") == 0) { if (strcasecmp (value, "All") == 0) watchlist_set (misc_items, 0xFFFFFFFF); else if (strcasecmp (value, "None") == 0) watchlist_set (misc_items, 0); else return -1; } else if (strcasecmp (key, "MiscAdd") == 0) { int id = watchitem_find (value); if (id < 0) return (-1); else watchlist_add (misc_items, id); } else if (strcasecmp (key, "MiscRemove") == 0) { int id = watchitem_find (value); if (id < 0) return (-1); else watchlist_remove (misc_items, id); } else return (-1); return (0); }
static int lv_config (const char *key, const char *value) { if (virInitialize () != 0) return 1; if (il_domains == NULL) il_domains = ignorelist_create (1); if (il_block_devices == NULL) il_block_devices = ignorelist_create (1); if (il_interface_devices == NULL) il_interface_devices = ignorelist_create (1); if (strcasecmp (key, "Connection") == 0) { if (conn != 0) { ERROR ("Connection may only be given once in config file"); return 1; } conn = virConnectOpenReadOnly (value); if (!conn) { VIRT_ERROR (NULL, "connection failed"); return 1; } return 0; } if (strcasecmp (key, "RefreshInterval") == 0) { char *eptr = NULL; interval = strtol (value, &eptr, 10); if (eptr == NULL || *eptr != '\0') return 1; return 0; } if (strcasecmp (key, "Domain") == 0) { if (ignorelist_add (il_domains, value)) return 1; return 0; } if (strcasecmp (key, "BlockDevice") == 0) { if (ignorelist_add (il_block_devices, value)) return 1; return 0; } if (strcasecmp (key, "InterfaceDevice") == 0) { if (ignorelist_add (il_interface_devices, value)) return 1; return 0; } if (strcasecmp (key, "IgnoreSelected") == 0) { if (strcasecmp (value, "True") == 0 || strcasecmp (value, "Yes") == 0 || strcasecmp (value, "On") == 0) { ignorelist_set_invert (il_domains, 0); ignorelist_set_invert (il_block_devices, 0); ignorelist_set_invert (il_interface_devices, 0); } else { ignorelist_set_invert (il_domains, 1); ignorelist_set_invert (il_block_devices, 1); ignorelist_set_invert (il_interface_devices, 1); } return 0; } if (strcasecmp (key, "HostnameFormat") == 0) { char *value_copy; char *fields[HF_MAX_FIELDS]; int i, n; value_copy = strdup (value); if (value_copy == NULL) { ERROR ("libvirt plugin: strdup failed."); return -1; } n = strsplit (value_copy, fields, HF_MAX_FIELDS); if (n < 1) { free (value_copy); ERROR ("HostnameFormat: no fields"); return -1; } for (i = 0; i < n; ++i) { if (strcasecmp (fields[i], "hostname") == 0) hostname_format[i] = hf_hostname; else if (strcasecmp (fields[i], "name") == 0) hostname_format[i] = hf_name; else if (strcasecmp (fields[i], "uuid") == 0) hostname_format[i] = hf_uuid; else { free (value_copy); ERROR ("unknown HostnameFormat field: %s", fields[i]); return -1; } } free (value_copy); for (i = n; i < HF_MAX_FIELDS; ++i) hostname_format[i] = hf_none; return 0; } /* Unrecognised option. */ return -1; }