#!/usr/local/bin/perl # netapp-top - display current top NFS clients for a NetApp # Copyright (C) 1998 Daniel Quinlan # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $default_interval = 60; $prog = $0; $prog =~ s@.*/@@; require "getopts.pl"; &Getopts("hi:"); if (defined $ENV{"LINES"} && $ENV{"LINES"} ne "") { $lines = $ENV{"LINES"}; } else { $lines = 24; } if ($opt_h) { &usage; exit 0; } if ($opt_i && $opt_i > 0) { $interval = $opt_i; } else { $interval = $default_interval; } if ($ARGV[0]) { $host = $ARGV[0]; } else { &usage; exit 1; } sub usage { print < $recent{$a} } keys %recent) { printf "%6d\t%s\n", int ($recent{$key} / $interval + 0.5), $ip_name{$key}; last if ($i++ > ($lines - 5)); } } $first = 1; for (;;) { $time_0 = time(); open(NFSSTAT, "rsh $host nfsstat -l|"); while () { @tmp = split; # ip_address = tmp[0] # ip_name = tmp[1] # nfs_ops = tmp[4] # if hostname is "", we have two words,... if($tmp[1] eq " 1) && (($interval - ($time_1 - $time_0)) >= 0)) { sleep ($interval - ($time_1 - $time_0)); } else { sleep ($interval); } }