disk_u a sorta graphical disk usage thing
Rodney Peck II
rodney at sun.ipl.rpi.edu
Tue Nov 7 14:19:58 AEST 1989
Here is a thing that I threw together in perl for some accounting in my
lab. Many people in alt.sys.sun have asked me to post it so here it is.
If you come up with changes, please let me know. (ever notice how everyone
always says that?)
----- cut here 8< ------- 8< --------------------------------
#!/usr/local/bin/perl #-*- Mode: C -*- #
## $Id: disk_u,v 1.4 89/11/06 22:14:41 rodney Released $
########################################
# disk_u --- gives a graphical representation of the free space on disk
# Author : Rodney Peck II
# Created On : Thu Nov 2 11:21:49 1989
# Last Modified By: Rodney Peck II
# Last Modified On: Thu Nov 2 11:28:18 1989
# Update Count : 4
# Status : released to alt.source
#######################################
$machines = "hosts.accounting"; # this file has all the machines with disks
open machines || die "$0: can't open $machines: $!\n";
# 0 1 2 3 4 5
#Filesystem kbytes used avail capacity Mounted on
##########
while(<machines>) {
chop;
$host = $_;
$disks = "rsh $host df -t 4.2 |";
open disks || die "$0: can't open $disks: $!\n";
$_ = <disks>;
while (<disks>) {
s+^/dev/..++; s+/+$host:/+;
split;
$capacity = $_[4];
printf ("%-20s%s %6d %6d ", $_[5],$_[0],$_[1],$_[2]);
$capacity =~ s/%//;
# $stars = 35 * $capacity / 100;
$avail = ($_[1]-$_[2]);
$grand_total = $grand_total + $_[1];
$total = $total + $avail;
$stars = 35 * $avail / 200000;
print '*' x ($stars), ' 'x (35 - int($stars)),"| $capacity\n";
}
}
$percent = int(100 * $total / $grand_total);
print "total disk space: $grand_total\n";
print "total available disk space: $total ($percent%)\n";
print " (note: this does not include swap space for standalone\n";
print " machines or other unmounted partitions.)\n";
#----------cut again 8< ----------------------
--
Rodney
More information about the Alt.sources
mailing list