Operating System - HP-UX
1835103 Members
1631 Online
110074 Solutions
New Discussion

Re: Perl Script to disk utilization report in csv format

 
manu_8
Occasional Contributor

Perl Script to disk utilization report in csv format

Has anybody got the perl script for Disk/Storage utilization in csv format and which puts output in pie chart.
2 REPLIES 2
H.Merijn Brand (procura
Honored Contributor

Re: Perl Script to disk utilization report in csv format

ETOOCOMPACT :) <= Too many questions in this line.

Disk usage to csv is easy.

--8<---
#!/opt/perl/bin/perl

use strict;
use warnings;

use Text::CSV_XS;
my $csv = Text::CSV_XS->new ({
binary => 1,
sep_char => ";", # Assuming M$ as target, who think the 'C'
always_quote => 1, # in CSV is for Semi-Colon :(
});

my %di;
my $sum = 0;
foreach (`bdf`) {
chomp;
my ($fs, $kb, $us, $av, $pct, $mnt) = split m/\s+/;
$pct =~ s/%//;
$sum += $kb;
$di{$fs} = [ $kb, $us, $av, $pct, $mnt ];
$csv->combine ($fs, @{$di{$fs}});
print $csv->string, "\r\n";
}

# Now you could use Tk to display a Pie Chart

#use Tk;

# create a canvas

# $sum is the total size available
foreach my $fs (sort { $di{$a}[0] <=> $di{$b}[0] } keys %di) { # sort by fs-size
# draw an arc
my $p = $di{$fs}[0] > 0 ? 360 * $sum / $di{$fs}[0] : 1; # size of the arc in
degrees
}

# MainLoop;
-->8---

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
H.Merijn Brand (procura
Honored Contributor

Re: Perl Script to disk utilization report in csv format

BTW skipping the header is left as an exercise to the reader. Skipping it will remove the warning :)

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn