[TriLUG] Boot "Partition" size

Ron Kelley via TriLUG trilug at trilug.org
Thu Sep 3 10:58:40 EDT 2015


To monitor disk usage, you might want to look at "monit".  It is a very 
good tool to monitor lots of stuff on a host (CPU, load, processes, 
disk, etc).  It can even restart services if they fail (php, web server, 
MySql, etc)

I use it to manage hundreds of VMs/servers - works really, really well.




On 9/3/2015 10:41 AM, Alan Porter via TriLUG wrote:
>
>>        I guess it depends on the OS. My Ubuntu and Centos installs have
>> /boot at most 512MB and I am yet to have issues. Besides learning to
>> keep the old cruft, that is.
>
> On this note, I have a cron job that runs on every server that I maintain.
> It checks the disk usage and sends me an email if disk usage gets higher
> than I'd like.  Sure, there are fancy tools to do this, but this is dirt
> stupid
> and it "just works".  Share and enjoy!
>
> Alan
>
>
>
>
>
> H03/10:38:24|root at aloha:~$ crontab -l
> # m h  dom mon dow   command
> SHELL=/bin/bash
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> HOME=/
>
> # SYSTEM ADMINISTRATION
> 21 *  * *  0-6  /root/cron/check_free.pl /dev/xvda=90
>
>
>
>
>
> H03/10:38:32|root at aloha:~$ cat cron/check_free.pl
> #!/usr/bin/perl
> use strict 'vars';
>
> my %PARTITION_LIMITS=();
>
> my $parm_help;
> my $arg=0;
> for $arg (0..$#ARGV) {
>     my ($parm, at val)=split('=',$ARGV[$arg]);
>     my $val=join('=', at val);
>     # now make sense of parm=value pairs
>     if ($parm eq "help") {
>        $parm_help++;
>     } elsif ($parm eq "-h") {
>        $parm_help++;
>     } elsif ($parm eq "--help") {
>        $parm_help++;
>     } else {
>        $PARTITION_LIMITS{$parm}=$val;
>     }
> }
>
> if ($#ARGV<0) { $parm_help++; }
>
> if ($parm_help) {
>     print("usage:   $0 disk=percentage ...\n");
>     print("example: $0 /dev/hda1=90 /dev/sda1=25\n");
>     print("         prints one line for each disk that is over the given
> limit\n");
>     print("         prints nothing if the disks are under their limits\n");
>     print("         this is useful to run via cron, output mailed to
> sysadmin\n");
>     print("\n");
>     exit 0;
> }
>
> my $hostname=`hostname`;
> $hostname=~s/[\r\n]//g;
>
> # run 'df' and save the values in arrays
> my %used_percentage=();
> my %mountpoint=();
> my $df_out=`df | grep -v "^Filesystem"`;
> my @df_lines=split("\n",$df_out);
> my $line;
> for $line (@df_lines) {
>     my
> ($partition,$totalblocks,$usedblocks,$availableblocks,$usedpct,$mountpt)=split("
> +",$line);
>     $usedpct=~s/[^0-9]//g;
>     $used_percentage{$partition}=$usedpct;
>     $mountpoint{$partition}=$mountpt;
> }
>
> # check the partitions in our list against the df-arrays
> my $partition;
> for $partition (keys(%PARTITION_LIMITS)) {
>     if ($used_percentage{$partition} > $PARTITION_LIMITS{$partition}) {
>        print "$hostname: partition $partition (mounted on
> $mountpoint{$partition}) is $used_percentage{$partition}% full\n";
>     }
> }
>
>
>
> H03/10:38:36|root at aloha:~$
>
>
>
>


More information about the TriLUG mailing list