#!/bin/sh
eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;'
if 0;

#!/usr/bin/perl

use strict;
use warnings;

our $VERSION = '1.140560';

use Getopt::Long;

use lib '/opt/hgmods/monitoring/lib';
use Sys::Statistics::Linux;

GetOptions(
	'v|version' => sub { print "$0 - $VERSION - By: Kevin Schottie\n" ; exit; },
	'h|help' => \&help,
);

my $lxs = Sys::Statistics::Linux->new( diskusage => 1 );
my $stat = $lxs->get;

foreach my $disk (sort $stat->diskusage){
	if($disk =~ m/^\/dev\//xms){
		my @status = split /\n/, `tune2fs -l $disk`;
		foreach (@status){
			if(m/(?<=Filesystem\sstate:)\s+(.*)/xms){
				print $disk . "\t-\t" . $stat->diskusage->{$disk}->{mountpoint} . "\t-\t" . $1 . "\n";
				last;
			}
		}
	}
}

sub help {
	print "This command takes no parameters and will is run with:\n\n";
	print "$0 checkfs\n\n";
	exit;
}