
gravindra1977
Novice
Jan 31, 2008, 1:26 PM
Post #1 of 11
(471 views)
|
|
Perl Programming help required
|
Can't Post
|
|
I have written the following code to obtain the diskspace of unix filesystem and all the /uXX filesystems installed on the server. I am gettting an error while executing the same. Code is as follows: #!/usr/bin/perl use strict; use warnings; my %env_to_fs = (DEV => 'FSDEV', QA => 'FSQA', PROD => 'FSPRD', ); #Get argument, set $fsmy $fs_arg = shift; die "Usage: $0 <Environment>\n" unless $fs_arg; die "Invalid environment, it must be one of: " . join(", ", keys %env_to_fs) . "\n" unless exists($env_to_fs{$fs_arg});my $fs = $env_to_fs{$fs_arg}; my $exitcode=0; open DF, "df|" or die "Can not run df $!\n";<DF>; #Get header line#Get all other lines while (<DF>) { my ($dev,$total,$used,$free,$percent,$fs) = split /\s+/; if($dev =~ m!($fs|/u\d+)!) { print "The filesystem is : $dev\n"; print " Total: $total\n"; print " Used : $used\n"; print " Free : $free\n"; if($free/$total < .1) { $exitcode=1; } } } close(DF); exit($exitcode); The output of this program is coming as The filesystem is : /u01 Total: (/dev/vx/dsk/oradg/u01):21596644 Used : blocks Free : 3254247 Argument "(/dev/vx/dsk/oradg/u01):21596644" isn't numeric in division.Illegal division by zero at df.pl line 33, <DF> line 10. I typed df in terminal server and I get the following output. I also uploaded the output that I got when I type in df in the terminal server as an attachment. / (/dev/vx/dsk/bootdg/rootvol): 3533744 blocks 417512 files /proc (/proc ): 0 blocks 29421 files /etc/mnttab (mnttab ): 0 blocks 0 files /dev/fd (fd ): 0 blocks 0 files /var (/dev/vx/dsk/bootdg/var): 3843060 blocks 489235 files /var/run (swap ):39591600 blocks 3219307 files /dev/vx/dmp (dmpfs ):39591600 blocks 3219307 files /dev/vx/rdmp (dmpfs ):39591600 blocks 3219307 files /tmp (swap ): 960928 blocks 3219307 files /redo002 (/dev/vx/dsk/orardodg02/redo002):104745016 blocks 7188431 fs /u01 (/dev/vx/dsk/oradg/u01):21100702 blocks 3254641 files /stage (/dev/vx/dsk/oradg/stage):24403074 blocks 1793502 files /redo001 (/dev/vx/dsk/orardodg01/redo001):104510852 blocks 7188416 fs /u008 (/dev/vx/dsk/oradatdg02/u008):177416744 blocks 14376930 files /arch001 (/dev/vx/dsk/oraarcdg01/arch001):224134440 blocks 28746140 fs /uhcdba (/dev/vx/dsk/oradg/uhcdba):57641054 blocks 7181513 files /u006 (/dev/vx/dsk/oradatdg01/u006):168425668 blocks 14376890 files /u007 (/dev/vx/dsk/oradatdg02/u007):16914724 blocks 14376720 files /u003 (/dev/vx/dsk/oradatdg01/u003):91315850 blocks 14376878 files /u005 (/dev/vx/dsk/oradatdg01/u005):182653128 blocks 14376909 files /u004 (/dev/vx/dsk/oradatdg01/u004):115505694 blocks 14376872 files /u009 (/dev/vx/dsk/oradatdg03/u009):53605372 blocks 14376936 files /u010 (/dev/vx/dsk/oradatdg03/u010):87544968 blocks 14376923 files /FSDEV (nasgw010pn:/vol/eagan15/fsdev):53315504 blocks 31712083 fis /u011 (/dev/vx/dsk/orau011dg/u011):40284380 blocks 14376919 files /u012 (/dev/vx/dsk/orau012dg/u012):12841628 blocks 14376924 files /u013 (/dev/vx/dsk/orau013dg/u013):189903986 blocks 14376917 files /u014 (/dev/vx/dsk/orau014dg/u014):202216442 blocks 14376934 files /u015 (/dev/vx/dsk/orau015dg/u015):202640584 blocks 14376934 files /INTERFACES_SIMS/SIMSDEV(nasgw010pn:/vol/eagan17/simsdev): 2097152 blocks 31320s /uhtrels (/dev/vx/dsk/rootdg/uhtrels): 4306766 blocks 362072 files /prdctl (/dev/vx/dsk/rootdg/prdctl): 1151956 blocks 291716 files /home (/dev/vx/dsk/bootdg/home): 1231912 blocks 517025 files I believe split is not working properly. How to correct this? Is there any other easy way of getting the total, allocated, free, capacity etc attributes of /FSDEV and /uXX filesystems. If so , how. Could you please let me know where I am going wrong and correct this accordingly. Thanks
|