#!usr/bin/perl #solo funciona para unix/linux/solaris(solaris ni idea) #si da el error "Undefined subroutine &main::SYS_statfs called at Filesys/DiskSpace.pm at line XXX", editar syscall.ph # (en el perl lib tree) y copiar la linea "SYS_statfs {196;}" fuera del "if (defined &__hp9000s800)" (alrededor de la linea 356) use strict ; use warnings ; use Filesys::DiskSpace ; use POSIX ; #sistema de archivos/particion a comprobar espacio #sacar fecha ; my $TIME = strftime("%d/%m/%Y %H:%M:%S", localtime(time) ) ; print "+----------+---+----------+\n" ; print "+Script made up by 0uts1de+\n" ; print "+----------+---+----------+\n" ; print "Today is $TIME \n" ; print "Write the filesystem/partiton you want to monitor, for example /home or /usr \n" ; my $monit = ; chomp $monit ; print "##warning level is by default about a 20 % of free space, if u want to change this##\n" ; print "##change the variable warn in the script with a editor like vim or gedit ##\n" ; ########## warn string ############ my $warn = 10 ; ################################### #consegir caracteristicas de la particion/filesystem (raw) my ($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df $monit ; my $monit_percentual = ( $avail / $avail+$used ) * 100 ; my $final_used = $used / 1000 ; my $final_avail = $avail / 1000 ; print "$monit is a $fs_type filesystem who has $final_used space used (in MB) and $final_avail of avalible space (in MB too) \n" ; #comparacion con el porcentaje de $monit_percentual if ($monit_percentual < $warn) { print "Less of the $warn % of the space of the filesystem $monit is avalible for use, consider uninstall unused software \n" ; } elsif ($monit_percentual eq $warn) { print "Be carefull, exactly the $warn % of the space of $monit is usable, consider uninstall unused software \n" ; } else { print "There is a $monit_percentual % of avarible space of the disk \n" ; }