PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|C|nagios-plugins-1.4.10|plugins|check_mrtg.c =

page 1 of 4



/******************************************************************************
*
* Nagios check_mrtg plugin
*
* License: GPL
* Copyright (c) 1999-2006 nagios-plugins team
*
* Last Modified: $Date: 2007-02-06 21:03:21 +0000 (Tue, 06 Feb 2007) $
*
* Description:
*
* This file contains the check_mrtg plugin
*
*  This plugin will check either the average or maximum value of one of the
*  two variables recorded in an MRTG log file.
*
*
* License Information:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 $Id: check_mrtg.c 1611 2007-02-06 21:03:21Z opensides $
 
******************************************************************************/

const char *progname = "check_mrtg";
const char *revision =  "$Revision: 1611 $";
const char *copyright = "1999-2006";
const char *email = "nagiosplug-devel@lists.sourceforge.net";

#include "common.h"
#include "utils.h"

int process_arguments (int, char **);
int validate_arguments (void);
void print_help (void);
void print_usage (void);

char *log_file = NULL;
int expire_minutes = 0;
int use_average = TRUE;
int variable_number = -1;
unsigned long value_warning_threshold = 0L;
unsigned long value_critical_threshold = 0L;
char *label;
char *units;

int
main (int argc, char **argv)
{
	int result = STATE_UNKNOWN;
	FILE *fp;
	int line;
	char input_buffer[MAX_INPUT_BUFFER];
	char *temp_buffer;
	time_t current_time;
	time_t timestamp = 0L;
	unsigned long average_value_rate = 0L;
	unsigned long maximum_value_rate = 0L;
	unsigned long rate = 0L;

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments\n"));

	/* open the MRTG log file for reading */
	fp = fopen (log_file, "r");
	if (fp == NULL) {
		printf (_("Unable to open MRTG log file\n"));
		return STATE_UNKNOWN;
	}

	line = 0;
	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {

		line++;

		/* skip the first line of the log file */
		if (line == 1)
			continue;

		/* break out of read loop if we've passed the number of entries we want to read */
		if (line > 2)
			break;

=1=

= PAGE 1 = NEXT > |2|3|4

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0240099 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)