From: octo Date: Sat, 20 May 2006 10:27:04 +0000 (+0000) Subject: Rearranged the functions in the `apcups' plugin. X-Git-Tag: svn-trunk~15^2~9 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4ec014a1f6db6c736839a1a10d20c81459828752;p=collectd.git Rearranged the functions in the `apcups' plugin. --- diff --git a/src/apcups.c b/src/apcups.c index d7bf6be3..4f5f760e 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -427,11 +427,6 @@ int main(int argc, char **argv) return 0; } #else -static void apcups_init (void) -{ - return; -} - static int apcups_config (char *key, char *value) { static char lhost[126]; @@ -460,7 +455,55 @@ static int apcups_config (char *key, char *value) return(0); } -#define BUFSIZE 256 +static void apcups_init (void) +{ + return; +} + +static void apc_write_voltage (char *host, char *inst, char *val) +{ + char file[512]; + int status; + + status = snprintf (file, 512, bvolt_file_template, inst); + if ((status < 1) || (status >= 512)) + return; + + rrd_update_file (host, file, val, bvolt_ds_def, bvolt_ds_num); +} + +static void apc_write_charge (char *host, char *inst, char *val) +{ + rrd_update_file (host, charge_file_template, val, charge_ds_def, charge_ds_num); +} + +static void apc_write_percent (char *host, char *inst, char *val) +{ + rrd_update_file (host, load_file_template, val, load_ds_def, load_ds_num); +} + +static void apc_write_timeleft (char *host, char *inst, char *val) +{ + rrd_update_file (host, time_file_template, val, time_ds_def, time_ds_num); +} + +static void apc_write_temperature (char *host, char *inst, char *val) +{ + rrd_update_file (host, temp_file_template, val, temp_ds_def, temp_ds_num); +} + +static void apc_write_frequency (char *host, char *inst, char *val) +{ + char file[512]; + int status; + + status = snprintf (file, 512, freq_file_template, inst); + if ((status < 1) || (status >= 512)) + return; + + rrd_update_file (host, file, val, freq_ds_def, freq_ds_num); +} + static void apc_submit_generic (char *type, char *inst, double value) { @@ -486,7 +529,6 @@ static void apc_submit (struct apc_detail_s *apcups_detail) apc_submit_generic ("apcups_temp", "-", apcups_detail->itemp); apc_submit_generic ("apcups_frequency", "input", apcups_detail->linefreq); } -#undef BUFSIZE static void apcups_read (void) { @@ -517,50 +559,6 @@ static void apcups_read (void) apc_submit (&apcups_detail); } /* apcups_read */ -static void apc_write_voltage (char *host, char *inst, char *val) -{ - char file[512]; - int status; - - status = snprintf (file, 512, bvolt_file_template, inst); - if ((status < 1) || (status >= 512)) - return; - - rrd_update_file (host, file, val, bvolt_ds_def, bvolt_ds_num); -} - -static void apc_write_charge (char *host, char *inst, char *val) -{ - rrd_update_file (host, charge_file_template, val, charge_ds_def, charge_ds_num); -} - -static void apc_write_percent (char *host, char *inst, char *val) -{ - rrd_update_file (host, load_file_template, val, load_ds_def, load_ds_num); -} - -static void apc_write_timeleft (char *host, char *inst, char *val) -{ - rrd_update_file (host, time_file_template, val, time_ds_def, time_ds_num); -} - -static void apc_write_temperature (char *host, char *inst, char *val) -{ - rrd_update_file (host, temp_file_template, val, temp_ds_def, temp_ds_num); -} - -static void apc_write_frequency (char *host, char *inst, char *val) -{ - char file[512]; - int status; - - status = snprintf (file, 512, freq_file_template, inst); - if ((status < 1) || (status >= 512)) - return; - - rrd_update_file (host, file, val, freq_ds_def, freq_ds_num); -} - void module_register (void) { plugin_register (MODULE_NAME, apcups_init, apcups_read, NULL);