1d0054224SAdam Stevko#!/usr/perl5/bin/perl -w 2d0054224SAdam Stevko# The above invocation line was changed in 0.5 to allow for 3d0054224SAdam Stevko# interoperability with linux. 4d0054224SAdam Stevko# 5d0054224SAdam Stevko# Print out ZFS ARC Statistics exported via kstat(1) 6d0054224SAdam Stevko# For a definition of fields, or usage, use arctstat.pl -v 7d0054224SAdam Stevko# 8d0054224SAdam Stevko# This script is a fork of the original arcstat.pl (0.1) by 9d0054224SAdam Stevko# Neelakanth Nadgir, originally published on his Sun blog on 10d0054224SAdam Stevko# 09/18/2007 11d0054224SAdam Stevko# http://blogs.sun.com/realneel/entry/zfs_arc_statistics 12d0054224SAdam Stevko# 13d0054224SAdam Stevko# This version aims to improve upon the original by adding features 14d0054224SAdam Stevko# and fixing bugs as needed. This version is maintained by 15d0054224SAdam Stevko# Mike Harsch and is hosted in a public open source repository: 16d0054224SAdam Stevko# http://github.com/mharsch/arcstat 17d0054224SAdam Stevko# 18d0054224SAdam Stevko# Comments, Questions, or Suggestions are always welcome. 19d0054224SAdam Stevko# Contact the maintainer at ( mike at harschsystems dot com ) 20d0054224SAdam Stevko# 21d0054224SAdam Stevko# CDDL HEADER START 22d0054224SAdam Stevko# 23d0054224SAdam Stevko# The contents of this file are subject to the terms of the 24d0054224SAdam Stevko# Common Development and Distribution License, Version 1.0 only 25d0054224SAdam Stevko# (the "License"). You may not use this file except in compliance 26d0054224SAdam Stevko# with the License. 27d0054224SAdam Stevko# 28d0054224SAdam Stevko# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 29d0054224SAdam Stevko# or http://www.opensolaris.org/os/licensing. 30d0054224SAdam Stevko# See the License for the specific language governing permissions 31d0054224SAdam Stevko# and limitations under the License. 32d0054224SAdam Stevko# 33d0054224SAdam Stevko# When distributing Covered Code, include this CDDL HEADER in each 34d0054224SAdam Stevko# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 35d0054224SAdam Stevko# If applicable, add the following below this CDDL HEADER, with the 36d0054224SAdam Stevko# fields enclosed by brackets "[]" replaced with your own identifying 37d0054224SAdam Stevko# information: Portions Copyright [yyyy] [name of copyright owner] 38d0054224SAdam Stevko# 39d0054224SAdam Stevko# CDDL HEADER END 40d0054224SAdam Stevko# 41d0054224SAdam Stevko# 42d0054224SAdam Stevko# Fields have a fixed width. Every interval, we fill the "v" 43d0054224SAdam Stevko# hash with its corresponding value (v[field]=value) using calculate(). 44d0054224SAdam Stevko# @hdr is the array of fields that needs to be printed, so we 45d0054224SAdam Stevko# just iterate over this array and print the values using our pretty printer. 46d0054224SAdam Stevko 47*78d7e961SPrakash Surya# 48*78d7e961SPrakash Surya# Copyright (c) 2015 by Delphix. All rights reserved. 49*78d7e961SPrakash Surya# 50*78d7e961SPrakash Surya 51d0054224SAdam Stevkouse strict; 52d0054224SAdam Stevkouse warnings; 53d0054224SAdam Stevkouse POSIX qw(strftime); 54d0054224SAdam Stevkouse Sun::Solaris::Kstat; 55d0054224SAdam Stevkouse Getopt::Long; 56d0054224SAdam Stevkouse IO::Handle; 57d0054224SAdam Stevko 58d0054224SAdam Stevkomy %cols = (# HDR => [Size, Scale, Description] 59d0054224SAdam Stevko "time" =>[8, -1, "Time"], 60d0054224SAdam Stevko "hits" =>[4, 1000, "ARC reads per second"], 61d0054224SAdam Stevko "miss" =>[4, 1000, "ARC misses per second"], 62d0054224SAdam Stevko "read" =>[4, 1000, "Total ARC accesses per second"], 63d0054224SAdam Stevko "hit%" =>[4, 100, "ARC Hit percentage"], 64d0054224SAdam Stevko "miss%" =>[5, 100, "ARC miss percentage"], 65d0054224SAdam Stevko "dhit" =>[4, 1000, "Demand Data hits per second"], 66d0054224SAdam Stevko "dmis" =>[4, 1000, "Demand Data misses per second"], 67d0054224SAdam Stevko "dh%" =>[3, 100, "Demand Data hit percentage"], 68d0054224SAdam Stevko "dm%" =>[3, 100, "Demand Data miss percentage"], 69d0054224SAdam Stevko "phit" =>[4, 1000, "Prefetch hits per second"], 70d0054224SAdam Stevko "pmis" =>[4, 1000, "Prefetch misses per second"], 71d0054224SAdam Stevko "ph%" =>[3, 100, "Prefetch hits percentage"], 72d0054224SAdam Stevko "pm%" =>[3, 100, "Prefetch miss percentage"], 73d0054224SAdam Stevko "mhit" =>[4, 1000, "Metadata hits per second"], 74d0054224SAdam Stevko "mmis" =>[4, 1000, "Metadata misses per second"], 75d0054224SAdam Stevko "mread" =>[4, 1000, "Metadata accesses per second"], 76d0054224SAdam Stevko "mh%" =>[3, 100, "Metadata hit percentage"], 77d0054224SAdam Stevko "mm%" =>[3, 100, "Metadata miss percentage"], 78d0054224SAdam Stevko "arcsz" =>[5, 1024, "ARC Size"], 79d0054224SAdam Stevko "c" =>[4, 1024, "ARC Target Size"], 80d0054224SAdam Stevko "mfu" =>[4, 1000, "MFU List hits per second"], 81d0054224SAdam Stevko "mru" =>[4, 1000, "MRU List hits per second"], 82d0054224SAdam Stevko "mfug" =>[4, 1000, "MFU Ghost List hits per second"], 83d0054224SAdam Stevko "mrug" =>[4, 1000, "MRU Ghost List hits per second"], 84d0054224SAdam Stevko "eskip" =>[5, 1000, "evict_skip per second"], 85d0054224SAdam Stevko "mtxmis" =>[6, 1000, "mutex_miss per second"], 86d0054224SAdam Stevko "dread" =>[5, 1000, "Demand data accesses per second"], 87d0054224SAdam Stevko "pread" =>[5, 1000, "Prefetch accesses per second"], 88d0054224SAdam Stevko "l2hits" =>[6, 1000, "L2ARC hits per second"], 89d0054224SAdam Stevko "l2miss" =>[6, 1000, "L2ARC misses per second"], 90d0054224SAdam Stevko "l2read" =>[6, 1000, "Total L2ARC accesses per second"], 91d0054224SAdam Stevko "l2hit%" =>[6, 100, "L2ARC access hit percentage"], 92d0054224SAdam Stevko "l2miss%" =>[7, 100, "L2ARC access miss percentage"], 93d0054224SAdam Stevko "l2asize" =>[7, 1024, "Actual (compressed) size of the L2ARC"], 94d0054224SAdam Stevko "l2size" =>[6, 1024, "Size of the L2ARC"], 95d0054224SAdam Stevko "l2bytes" =>[7, 1024, "bytes read per second from the L2ARC"], 96d0054224SAdam Stevko); 97d0054224SAdam Stevkomy %v=(); 98d0054224SAdam Stevkomy @hdr = qw(time read miss miss% dmis dm% pmis pm% mmis mm% arcsz c); 99*78d7e961SPrakash Suryamy @xhdr = qw(time mfu mru mfug mrug eskip mtxmis dread pread read); 100d0054224SAdam Stevkomy $int = 1; # Default interval is 1 second 101d0054224SAdam Stevkomy $count = 1; # Default count is 1 102d0054224SAdam Stevkomy $hdr_intr = 20; # Print header every 20 lines of output 103d0054224SAdam Stevkomy $opfile = ""; 104d0054224SAdam Stevkomy $sep = " "; # Default separator is 2 spaces 105d0054224SAdam Stevkomy $raw_output; 106d0054224SAdam Stevkomy $version = "0.5"; 107d0054224SAdam Stevkomy $l2exist = 0; 108d0054224SAdam Stevkomy $cmd = "Usage: arcstat [-hvxr] [-f fields] [-o file] [-s string] " . 109d0054224SAdam Stevko "[interval [count]]\n"; 110d0054224SAdam Stevkomy %cur; 111d0054224SAdam Stevkomy %d; 112d0054224SAdam Stevkomy $out; 113d0054224SAdam Stevkomy $kstat = Sun::Solaris::Kstat->new(); 114d0054224SAdam StevkoSTDOUT->autoflush; 115d0054224SAdam Stevko 116d0054224SAdam Stevkosub detailed_usage { 117d0054224SAdam Stevko print STDERR "$cmd\n"; 118d0054224SAdam Stevko print STDERR "Field definitions are as follows:\n"; 119d0054224SAdam Stevko foreach my $hdr (keys %cols) { 120d0054224SAdam Stevko print STDERR sprintf("%11s : %s\n", $hdr, $cols{$hdr}[2]); 121d0054224SAdam Stevko } 122d0054224SAdam Stevko exit(1); 123d0054224SAdam Stevko} 124d0054224SAdam Stevko 125d0054224SAdam Stevkosub usage { 126d0054224SAdam Stevko print STDERR "$cmd\n"; 127d0054224SAdam Stevko print STDERR "\t -h : Print this help message\n"; 128d0054224SAdam Stevko print STDERR "\t -v : List all possible field headers " . 129d0054224SAdam Stevko "and definitions\n"; 130d0054224SAdam Stevko print STDERR "\t -x : Print extended stats\n"; 131d0054224SAdam Stevko print STDERR "\t -r : Raw output mode (values not scaled)\n"; 132d0054224SAdam Stevko print STDERR "\t -f : Specify specific fields to print (see -v)\n"; 133d0054224SAdam Stevko print STDERR "\t -o : Redirect output to the specified file\n"; 134d0054224SAdam Stevko print STDERR "\t -s : Override default field separator with custom " . 135d0054224SAdam Stevko "character or string\n"; 136d0054224SAdam Stevko print STDERR "\nExamples:\n"; 137d0054224SAdam Stevko print STDERR "\tarcstat -o /tmp/a.log 2 10\n"; 138d0054224SAdam Stevko print STDERR "\tarcstat -s \",\" -o /tmp/a.log 2 10\n"; 139d0054224SAdam Stevko print STDERR "\tarcstat -v\n"; 140d0054224SAdam Stevko print STDERR "\tarcstat -f time,hit%,dh%,ph%,mh% 1\n"; 141d0054224SAdam Stevko exit(1); 142d0054224SAdam Stevko} 143d0054224SAdam Stevko 144d0054224SAdam Stevkosub init { 145d0054224SAdam Stevko my $desired_cols; 146d0054224SAdam Stevko my $xflag = ''; 147d0054224SAdam Stevko my $hflag = ''; 148d0054224SAdam Stevko my $vflag; 149d0054224SAdam Stevko my $res = GetOptions('x' => \$xflag, 150d0054224SAdam Stevko 'o=s' => \$opfile, 151d0054224SAdam Stevko 'help|h|?' => \$hflag, 152d0054224SAdam Stevko 'v' => \$vflag, 153d0054224SAdam Stevko 's=s' => \$sep, 154d0054224SAdam Stevko 'f=s' => \$desired_cols, 155d0054224SAdam Stevko 'r' => \$raw_output); 156d0054224SAdam Stevko 157d0054224SAdam Stevko if (defined $ARGV[0] && defined $ARGV[1]) { 158d0054224SAdam Stevko $int = $ARGV[0]; 159d0054224SAdam Stevko $count = $ARGV[1]; 160d0054224SAdam Stevko } elsif (defined $ARGV[0]) { 161d0054224SAdam Stevko $int = $ARGV[0]; 162d0054224SAdam Stevko $count = 0; 163d0054224SAdam Stevko } 164d0054224SAdam Stevko 165d0054224SAdam Stevko usage() if !$res or $hflag or ($xflag and $desired_cols); 166d0054224SAdam Stevko detailed_usage() if $vflag; 167d0054224SAdam Stevko @hdr = @xhdr if $xflag; #reset headers to xhdr 168d0054224SAdam Stevko 169d0054224SAdam Stevko # check if L2ARC exists 170d0054224SAdam Stevko snap_stats(); 171d0054224SAdam Stevko if (defined $cur{"l2_size"}) { 172d0054224SAdam Stevko $l2exist = 1; 173d0054224SAdam Stevko } 174d0054224SAdam Stevko 175d0054224SAdam Stevko if ($desired_cols) { 176d0054224SAdam Stevko @hdr = split(/[ ,]+/, $desired_cols); 177d0054224SAdam Stevko # Now check if they are valid fields 178d0054224SAdam Stevko my @invalid = (); 179d0054224SAdam Stevko my @incompat = (); 180d0054224SAdam Stevko foreach my $ele (@hdr) { 181d0054224SAdam Stevko if (not exists($cols{$ele})) { 182d0054224SAdam Stevko push(@invalid, $ele); 183d0054224SAdam Stevko } elsif (($l2exist == 0) && ($ele =~ /^l2/)) { 184d0054224SAdam Stevko printf("No L2ARC here\n", $ele); 185d0054224SAdam Stevko push(@incompat, $ele); 186d0054224SAdam Stevko } 187d0054224SAdam Stevko } 188d0054224SAdam Stevko if (scalar @invalid > 0) { 189d0054224SAdam Stevko print STDERR "Invalid column definition! -- " 190d0054224SAdam Stevko . "@invalid\n\n"; 191d0054224SAdam Stevko usage(); 192d0054224SAdam Stevko } 193d0054224SAdam Stevko 194d0054224SAdam Stevko if (scalar @incompat > 0) { 195d0054224SAdam Stevko print STDERR "Incompatible field specified -- " 196d0054224SAdam Stevko . "@incompat\n\n"; 197d0054224SAdam Stevko usage(); 198d0054224SAdam Stevko } 199d0054224SAdam Stevko } 200d0054224SAdam Stevko 201d0054224SAdam Stevko if ($opfile) { 202d0054224SAdam Stevko open($out, ">$opfile") ||die "Cannot open $opfile for writing"; 203d0054224SAdam Stevko $out->autoflush; 204d0054224SAdam Stevko select $out; 205d0054224SAdam Stevko } 206d0054224SAdam Stevko} 207d0054224SAdam Stevko 208d0054224SAdam Stevko# Capture kstat statistics. We maintain 3 hashes, prev, cur, and 209d0054224SAdam Stevko# d (delta). As their names imply they maintain the previous, current, 210d0054224SAdam Stevko# and delta (cur - prev) statistics. 211d0054224SAdam Stevkosub snap_stats { 212d0054224SAdam Stevko my %prev = %cur; 213d0054224SAdam Stevko if ($kstat->update()) { 214d0054224SAdam Stevko printf("<State Changed>\n"); 215d0054224SAdam Stevko } 216d0054224SAdam Stevko my $hashref_cur = $kstat->{"zfs"}{0}{"arcstats"}; 217d0054224SAdam Stevko %cur = %$hashref_cur; 218d0054224SAdam Stevko foreach my $key (keys %cur) { 219d0054224SAdam Stevko next if $key =~ /class/; 220d0054224SAdam Stevko if (defined $prev{$key}) { 221d0054224SAdam Stevko $d{$key} = $cur{$key} - $prev{$key}; 222d0054224SAdam Stevko } else { 223d0054224SAdam Stevko $d{$key} = $cur{$key}; 224d0054224SAdam Stevko } 225d0054224SAdam Stevko } 226d0054224SAdam Stevko} 227d0054224SAdam Stevko 228d0054224SAdam Stevko# Pretty print num. Arguments are width, scale, and num 229d0054224SAdam Stevkosub prettynum { 230d0054224SAdam Stevko my @suffix = (' ', 'K', 'M', 'G', 'T'); 231d0054224SAdam Stevko my $num = $_[2] || 0; 232d0054224SAdam Stevko my $scale = $_[1]; 233d0054224SAdam Stevko my $sz = $_[0]; 234d0054224SAdam Stevko my $index = 0; 235d0054224SAdam Stevko my $save = 0; 236d0054224SAdam Stevko 237d0054224SAdam Stevko if ($scale == -1) { #special case for date field 238d0054224SAdam Stevko return sprintf("%s", $num); 239d0054224SAdam Stevko } elsif (($num > 0) && ($num < 1)) { #rounding error. return 0 240d0054224SAdam Stevko $num = 0; 241d0054224SAdam Stevko } 242d0054224SAdam Stevko 243d0054224SAdam Stevko while ($num > $scale and $index < 5) { 244d0054224SAdam Stevko $save = $num; 245d0054224SAdam Stevko $num = $num/$scale; 246d0054224SAdam Stevko $index++; 247d0054224SAdam Stevko } 248d0054224SAdam Stevko 249d0054224SAdam Stevko return sprintf("%*d", $sz, $num) if ($index == 0); 250d0054224SAdam Stevko if (($save / $scale) < 10) { 251d0054224SAdam Stevko return sprintf("%*.1f%s", $sz - 1, $num,$suffix[$index]); 252d0054224SAdam Stevko } else { 253d0054224SAdam Stevko return sprintf("%*d%s", $sz - 1, $num,$suffix[$index]); 254d0054224SAdam Stevko } 255d0054224SAdam Stevko} 256d0054224SAdam Stevko 257d0054224SAdam Stevkosub print_values { 258d0054224SAdam Stevko foreach my $col (@hdr) { 259d0054224SAdam Stevko if (not $raw_output) { 260d0054224SAdam Stevko printf("%s%s", prettynum($cols{$col}[0], $cols{$col}[1], 261d0054224SAdam Stevko $v{$col}), $sep); 262d0054224SAdam Stevko } else { 263d0054224SAdam Stevko printf("%d%s", $v{$col} || 0, $sep); 264d0054224SAdam Stevko } 265d0054224SAdam Stevko } 266d0054224SAdam Stevko printf("\n"); 267d0054224SAdam Stevko} 268d0054224SAdam Stevko 269d0054224SAdam Stevkosub print_header { 270d0054224SAdam Stevko if (not $raw_output) { 271d0054224SAdam Stevko foreach my $col (@hdr) { 272d0054224SAdam Stevko printf("%*s%s", $cols{$col}[0], $col, $sep); 273d0054224SAdam Stevko } 274d0054224SAdam Stevko } else { 275d0054224SAdam Stevko # Don't try to align headers in raw mode 276d0054224SAdam Stevko foreach my $col (@hdr) { 277d0054224SAdam Stevko printf("%s%s", $col, $sep); 278d0054224SAdam Stevko } 279d0054224SAdam Stevko } 280d0054224SAdam Stevko printf("\n"); 281d0054224SAdam Stevko} 282d0054224SAdam Stevko 283d0054224SAdam Stevkosub calculate { 284d0054224SAdam Stevko %v = (); 285d0054224SAdam Stevko 286d0054224SAdam Stevko if ($raw_output) { 287d0054224SAdam Stevko $v{"time"} = strftime("%s", localtime); 288d0054224SAdam Stevko } else { 289d0054224SAdam Stevko $v{"time"} = strftime("%H:%M:%S", localtime); 290d0054224SAdam Stevko } 291d0054224SAdam Stevko 292d0054224SAdam Stevko $v{"hits"} = $d{"hits"}/$int; 293d0054224SAdam Stevko $v{"miss"} = $d{"misses"}/$int; 294d0054224SAdam Stevko $v{"read"} = $v{"hits"} + $v{"miss"}; 295d0054224SAdam Stevko $v{"hit%"} = 100 * ($v{"hits"} / $v{"read"}) if $v{"read"} > 0; 296d0054224SAdam Stevko $v{"miss%"} = 100 - $v{"hit%"} if $v{"read"} > 0; 297d0054224SAdam Stevko 298d0054224SAdam Stevko $v{"dhit"} = ($d{"demand_data_hits"} + 299d0054224SAdam Stevko $d{"demand_metadata_hits"})/$int; 300d0054224SAdam Stevko $v{"dmis"} = ($d{"demand_data_misses"} + 301d0054224SAdam Stevko $d{"demand_metadata_misses"})/$int; 302d0054224SAdam Stevko 303d0054224SAdam Stevko $v{"dread"} = $v{"dhit"} + $v{"dmis"}; 304d0054224SAdam Stevko $v{"dh%"} = 100 * ($v{"dhit"} / $v{"dread"}) if $v{"dread"} > 0; 305d0054224SAdam Stevko $v{"dm%"} = 100 - $v{"dh%"} if $v{"dread"} > 0; 306d0054224SAdam Stevko 307d0054224SAdam Stevko $v{"phit"} = ($d{"prefetch_data_hits"} + 308d0054224SAdam Stevko $d{"prefetch_metadata_hits"})/$int; 309d0054224SAdam Stevko $v{"pmis"} = ($d{"prefetch_data_misses"} + 310d0054224SAdam Stevko $d{"prefetch_metadata_misses"})/$int; 311d0054224SAdam Stevko 312d0054224SAdam Stevko $v{"pread"} = $v{"phit"} + $v{"pmis"}; 313d0054224SAdam Stevko $v{"ph%"} = 100 * ($v{"phit"} / $v{"pread"}) if $v{"pread"} > 0; 314d0054224SAdam Stevko $v{"pm%"} = 100 - $v{"ph%"} if $v{"pread"} > 0; 315d0054224SAdam Stevko 316d0054224SAdam Stevko $v{"mhit"} = ($d{"prefetch_metadata_hits"} + 317d0054224SAdam Stevko $d{"demand_metadata_hits"})/$int; 318d0054224SAdam Stevko $v{"mmis"} = ($d{"prefetch_metadata_misses"} + 319d0054224SAdam Stevko $d{"demand_metadata_misses"})/$int; 320d0054224SAdam Stevko 321d0054224SAdam Stevko $v{"mread"} = $v{"mhit"} + $v{"mmis"}; 322d0054224SAdam Stevko $v{"mh%"} = 100 * ($v{"mhit"} / $v{"mread"}) if $v{"mread"} > 0; 323d0054224SAdam Stevko $v{"mm%"} = 100 - $v{"mh%"} if $v{"mread"} > 0; 324d0054224SAdam Stevko 325d0054224SAdam Stevko $v{"arcsz"} = $cur{"size"}; 326d0054224SAdam Stevko $v{"c"} = $cur{"c"}; 327d0054224SAdam Stevko $v{"mfu"} = $d{"mfu_hits"}/$int; 328d0054224SAdam Stevko $v{"mru"} = $d{"mru_hits"}/$int; 329d0054224SAdam Stevko $v{"mrug"} = $d{"mru_ghost_hits"}/$int; 330d0054224SAdam Stevko $v{"mfug"} = $d{"mfu_ghost_hits"}/$int; 331d0054224SAdam Stevko $v{"eskip"} = $d{"evict_skip"}/$int; 332d0054224SAdam Stevko $v{"mtxmis"} = $d{"mutex_miss"}/$int; 333d0054224SAdam Stevko 334d0054224SAdam Stevko if ($l2exist) { 335d0054224SAdam Stevko $v{"l2hits"} = $d{"l2_hits"}/$int; 336d0054224SAdam Stevko $v{"l2miss"} = $d{"l2_misses"}/$int; 337d0054224SAdam Stevko $v{"l2read"} = $v{"l2hits"} + $v{"l2miss"}; 338d0054224SAdam Stevko $v{"l2hit%"} = 100 * ($v{"l2hits"} / $v{"l2read"}) 339d0054224SAdam Stevko if $v{"l2read"} > 0; 340d0054224SAdam Stevko 341d0054224SAdam Stevko $v{"l2miss%"} = 100 - $v{"l2hit%"} if $v{"l2read"} > 0; 342d0054224SAdam Stevko $v{"l2size"} = $cur{"l2_size"}; 343d0054224SAdam Stevko $v{"l2asize"} = $cur{"l2_asize"}; 344d0054224SAdam Stevko $v{"l2bytes"} = $d{"l2_read_bytes"}/$int; 345d0054224SAdam Stevko } 346d0054224SAdam Stevko} 347d0054224SAdam Stevko 348d0054224SAdam Stevkosub main { 349d0054224SAdam Stevko my $i = 0; 350d0054224SAdam Stevko my $count_flag = 0; 351d0054224SAdam Stevko 352d0054224SAdam Stevko init(); 353d0054224SAdam Stevko if ($count > 0) { $count_flag = 1; } 354d0054224SAdam Stevko while (1) { 355d0054224SAdam Stevko print_header() if ($i == 0); 356d0054224SAdam Stevko snap_stats(); 357d0054224SAdam Stevko calculate(); 358d0054224SAdam Stevko print_values(); 359d0054224SAdam Stevko last if ($count_flag == 1 && $count-- <= 1); 360d0054224SAdam Stevko $i = (($i == $hdr_intr) && (not $raw_output)) ? 0 : $i+1; 361d0054224SAdam Stevko sleep($int); 362d0054224SAdam Stevko } 363d0054224SAdam Stevko close($out) if defined $out; 364d0054224SAdam Stevko} 365d0054224SAdam Stevko 366d0054224SAdam Stevko&main; 367