#!/usr/bin/perl
# -----------------------------------------------------------------------------
#  check_abrt_status : Nagios plugin for check on ABRT reports
# -----------------------------------------------------------------------------
#  Created by: Andriy Fomenko
#  Authors: Alex Titov, Alex Tsibulnik, Andriy Fomenko
#  QA by:
#  Copyright: videoNEXT Federal, Inc., 2015
# -----------------------------------------------------------------------------

use strict;
use warnings;

use Nagios::Plugin;
use Nagios::Plugin::Getopt;

my $np = Nagios::Plugin->new( usage => "Usage: %s [ -v|--verbose ]" );
$np->getopts;

my $APL=$ENV{APL} || $np->nagios_exit( UNKNOWN, 'APL environment variable is not defined' );

# check do we have directories in /var/tmp/abrt
my $crashes = `find /var/tmp/abrt -name "ccpp-*" 2>/dev/null`;

$np->nagios_exit( OK, 'No ABRT dump files' ) if ! $crashes;
$np->nagios_exit( WARNING, 'Crash reports were detected. Please send support files to system administrator' );
