diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index 15252b19a1ba10fc8d3e52ec384ab9f6a2903be3..45162bd3de607170e3b34399e078b851fd4a58bd 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
* Florian octo Forster <octo at verplant.org>
**/
-/* Set to C99 and POSIX code */
-#ifndef _ISOC99_SOURCE
-# define _ISOC99_SOURCE
-#endif
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
-#ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200112L
-#endif
-#ifndef _REENTRANT
-# define _REENTRANT
-#endif
-
-/* Disable non-standard extensions */
-#ifdef _BSD_SOURCE
-# undef _BSD_SOURCE
-#endif
-#ifdef _SVID_SOURCE
-# undef _SVID_SOURCE
-#endif
-#ifdef _GNU_SOURCE
-# undef _GNU_SOURCE
+#if HAVE_CONFIG_H
+# include "config.h"
#endif
#if !defined(__GNUC__) || !__GNUC__
# define __attribute__(x) /**/
#endif
-#include "config.h"
-
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
return (RET_UNKNOWN);
}
- for (i = 0; i < match_ds_num_g; i++)
+ for (i = 0; i < (size_t) match_ds_num_g; i++)
{
size_t j;
" -d <ds> Select the DS to examine. May be repeated to examine multiple\n"
" DSes. By default all DSes are used.\n"
" -g <consol> Method to use to consolidate several DSes.\n"
- " Valid arguments are `none', `average' and `sum'\n"
+ " See below for a list of valid arguments.\n"
" -H <host> Hostname to query the values for.\n"
" -c <range> Critical range\n"
" -w <range> Warning range\n"
" average: Calculate the average of all matching DSes and apply the\n"
" warning- and critical-ranges to the calculated average.\n"
" sum: Apply the ranges to the sum of all DSes.\n"
+ " percentage: Apply the ranges to the ratio (in percent) of the first value\n"
+ " and the sum of all values."
"\n", name);
exit (1);
} /* void usage */
int num_okay = 0;
const char *status_str = "UNKNOWN";
int status_code = RET_UNKNOWN;
- int i;
+ size_t i;
for (i = 0; i < values_num; i++)
{
{
printf (" |");
for (i = 0; i < values_num; i++)
- printf (" %s=%g;;;;", values_names[i], values[i]);
+ printf (" %s=%f;;;;", values_names[i], values[i]);
}
printf ("\n");
static int do_check_con_average (size_t values_num,
double *values, char **values_names)
{
- int i;
+ size_t i;
double total;
int total_num;
double average;
printf ("%s: %g average |", status_str, average);
for (i = 0; i < values_num; i++)
- printf (" %s=%g;;;;", values_names[i], values[i]);
+ printf (" %s=%f;;;;", values_names[i], values[i]);
printf ("\n");
return (status_code);
static int do_check_con_sum (size_t values_num,
double *values, char **values_names)
{
- int i;
+ size_t i;
double total;
int total_num;
const char *status_str = "UNKNOWN";
printf ("%s: %g sum |", status_str, total);
for (i = 0; i < values_num; i++)
- printf (" %s=%g;;;;", values_names[i], values[i]);
+ printf (" %s=%f;;;;", values_names[i], values[i]);
printf ("\n");
return (status_code);
static int do_check_con_percentage (size_t values_num,
double *values, char **values_names)
{
- int i;
+ size_t i;
double sum = 0.0;
double percentage;
else if (strcasecmp (optarg, "percentage") == 0)
consolitation_g = CON_PERCENTAGE;
else
+ {
+ fprintf (stderr, "Unknown consolidation function `%s'.\n",
+ optarg);
usage (argv[0]);
+ }
break;
case 'd':
{
if ((socket_file_g == NULL) || (value_string_g == NULL)
|| (hostname_g == NULL))
+ {
+ fprintf (stderr, "Missing required arguments.\n");
usage (argv[0]);
+ }
return (do_check ());
} /* int main */