#! /usr/bin/perl -w
###################################################################
# Oreon is developped with GPL Licence 2.0 
#
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#
# Developped by : Julien Mathis - Romain Le Merlus 
#                 Mathavarajan Sugumaran
#
###################################################################
# 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.
# 
#    For information : contact@merethis.com
####################################################################
#
# Plugin init
#

use strict;
use FindBin;

use vars qw($PROGNAME);
use Getopt::Long;
use vars qw($opt_h $opt_s $opt_o);

#################################################
### Plugin var init
##
$PROGNAME = "$0";

sub print_help ();
sub print_usage ();

Getopt::Long::Configure('bundling');
GetOptions
    ("h"   => \$opt_h, "help"         => \$opt_h,
     "s=s" => \$opt_s, "status=s"     => \$opt_s,
     "o=s" => \$opt_o, "output=s"     => \$opt_o);


##################################################
#### Verify Options
##

if ($opt_h) {
    print_help();
    exit 0;
}

if (!defined($opt_s)) {
    print_usage && exit 0;
}
if ($opt_s ne "0" && $opt_s ne "1" && $opt_s ne "2" && $opt_s ne "3") {
    print_usage;
    exit 0;
} 
if (!$opt_o) {
    $opt_o = "OK";
}

#################################################
## result
#

$opt_o .= "\n";
print $opt_o;
exit $opt_s;

sub print_usage () {
    print "Usage:";
    print "$PROGNAME\n";
    print "   -s (--status)     status that must be returned [0-3]\n";
    print "   -o (--output)     output that must be returned\n";
    print "   -h (--help)       usage help\n";
}

sub print_help () {
    print "##############################################\n";
    print "#    Copyright (c) 2004-2007 Centreon        #\n";
    print "#    Bugs to http://bugs.oreon-project.org/  #\n";
    print "##############################################\n";
    print_usage();
    print "\n";
}