[Orca-checkins] r372 - in trunk/orca/data_gatherers: aix hp
Blair Zajac
blair at orcaware.com
Tue Jul 6 22:48:38 PDT 2004
Author: blair
Date: Tue Jul 6 22:43:40 2004
New Revision: 372
Modified:
trunk/orca/data_gatherers/aix/orca-aix-stat.pl.in
trunk/orca/data_gatherers/hp/orca-hp-stat.pl.in
Log:
Begin massive Perl cleanup of orca-aix-stat.pl.in and orca-hp-stat.pl.in.
* data_gatherers/aix/orca-aix-stat.pl.in,
* data_gatherers/hp/orca-hp-stat.pl.in:
Whitespace fixes and indent using two spaces per level.
Modified: trunk/orca/data_gatherers/aix/orca-aix-stat.pl.in
==============================================================================
--- trunk/orca/data_gatherers/aix/orca-aix-stat.pl.in (original)
+++ trunk/orca/data_gatherers/aix/orca-aix-stat.pl.in Tue Jul 6 22:43:40 2004
@@ -76,30 +76,24 @@
##############################
# Parse the command line arguments
-while ( $#ARGV >= 0 ) {
-
- if ( $ARGV[0] eq "-r" ) {
- shift @ARGV;
- $OUT_ROOT = shift @ARGV;
- }
- elsif ( $ARGV[0] eq "-i" ) {
- shift @ARGV;
- $INTERVAL = shift @ARGV;
- }
- elsif ( $ARGV[0] eq "-d" ) {
- shift @ARGV;
- $DURATION = shift @ARGV;
- }
- elsif ( $ARGV[0] eq "-h" ) {
- print $Usage_Message;
- exit 0;
- }
- elsif ( $ARGV[0] =~ /^-/ ) {
- die "Invalid flag: $ARGV[0]\n$Usage_Message";
- }
- else {
- die "Invalid argument: $ARGV[0]\n$Usage_Message";
- }
+while ($#ARGV >= 0) {
+ if ($ARGV[0] eq "-r" ) {
+ shift @ARGV;
+ $OUT_ROOT = shift @ARGV;
+ } elsif ($ARGV[0] eq "-i" ) {
+ shift @ARGV;
+ $INTERVAL = shift @ARGV;
+ } elsif ($ARGV[0] eq "-d" ) {
+ shift @ARGV;
+ $DURATION = shift @ARGV;
+ } elsif ($ARGV[0] eq "-h" ) {
+ print $Usage_Message;
+ exit 0;
+ } elsif ($ARGV[0] =~ /^-/ ) {
+ die "Invalid flag: $ARGV[0]\n$Usage_Message";
+ } else {
+ die "Invalid argument: $ARGV[0]\n$Usage_Message";
+ }
}
## BEGIN set defaults
@@ -112,13 +106,18 @@
## Derived variables.
$iterations = $DURATION * 60 * 60 / $INTERVAL; # Number of checks.
-chomp( $HOST = `uname -n` );
+chomp($HOST = `uname -n`);
$out_dir = "${OUT_ROOT}/${HOST}";
-( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
+($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$stat_file =
- sprintf( "%s/percol-%.2d-%.2d-%.2d-%1d%.2d", $out_dir, $year + 1900, $mon + 1,
- $mday, $hour, $min );
+ sprintf("%s/percol-%.2d-%.2d-%.2d-%1d%.2d",
+ $out_dir,
+ $year + 1900,
+ $mon + 1,
+ $mday,
+ $hour,
+ $min);
# Base all timestamps on start time.
$start_time = time();
@@ -128,30 +127,28 @@
#open IN, "ifconfig -a|";
open IN, "netstat -ni|";
while (<IN>) {
-
- # if ( /^(\S+):/ ) {
- if (/^(\w+).*link/) {
- push @net_interfaces, $1;
- }
+ # if (/^(\S+):/ ) {
+ if (/^(\w+).*link/) {
+ push @net_interfaces, $1;
+ }
}
close IN;
# Grab some base system info prior to collecting stats.
open IN, "lsattr -El sys0 -a realmem |";
while (<IN>) {
- if (/^realmem (\d+) /) {
- $pagestotl = $1 * 1024 / 4096; # Grab realmem in KB and convert to pages.
- $mem_totl = $1 * 1024; # Grab realmem in KB and convert to Bytes.
-
- # this gets used down in the vmstat section
- }
+ if (/^realmem (\d+) /) {
+ $pagestotl = $1 * 1024 / 4096; # Grab realmem in KB and convert to pages.
+ $mem_totl = $1 * 1024; # Grab realmem in KB and convert to Bytes.
+ # this gets used down in the vmstat section
+ }
}
close IN;
## Make sure we can write output.
umask 0022; # make sure the file can be harvested
unless ( -d $out_dir ) {
- system( "mkdir", "-p", "$out_dir" );
+ system( "mkdir", "-p", "$out_dir" );
}
open OUT, ">$stat_file" or die "ERROR: Could not open $stat_file: $!";
my $oldfh = select OUT;
@@ -171,450 +168,431 @@
$prev_info_cnt = 0;
while ( $iterations-- > 0 ) {
-
- $timestamp = $timestamp ? time() : $start_time;
- ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
- localtime(time);
- $locltime = sprintf( "%.2d:%.2d:%.2d", $hour, $min, $sec );
-
- ## Get runq data
- ## Get runq data
- $uptime = 0;
- open IN, "uptime |";
- while (<IN>) {
- if (/load average:\s+(\S+),\s+(\S+),\s+(\S+)/) {
- $load_info = join "\t", $1, $2, $3;
- }
- @upt = split(/ +/,);
- $uptd = $upt[3];
- $nusr = $upt[6];
- $up_day = $uptd * 24 * 60 * 60;
- if (/days,\s+(\S+):(\S+), /) {
- $up_hrs = $1 * 60 * 60;
- $up_min = $2 * 60;
- }
- $uptime = $up_day + $up_hrs + $up_min;
- }
- close IN;
- $load_header = "1runq\t5runq\t15runq";
- $up_header = "uptime\tnusr";
- $up_info = "$uptime\t$nusr";
-
- if ( scalar( split ' ', $load_header ) != scalar( split ' ', $load_info ) )
- {
- $load_header = '';
- $load_info = '';
- $need_header = 1;
- print STDERR "WARNING: load header does not match load info.\n";
- }
- if ( scalar( split ' ', $up_header ) != scalar( split ' ', $up_info ) )
- {
- $up_header = '';
- $up_info = '';
- $need_header = 1;
- print STDERR "WARNING: UP header does not match load info.\n";
- }
-
-
- ## Get number of system processes
- $num_proc = -1; # Don't count the header.
- open IN, "ps -ek |";
- while (<IN>) {
- $num_proc++;
- }
- close IN;
- $proc_info = $num_proc;
- $proc_header = '#proc';
-
- if ( scalar( split ' ', $proc_header ) != scalar( split ' ', $proc_info ) )
- {
- $proc_header = '';
- $proc_info = '';
- $need_header = 1;
- print STDERR "WARNING: #proc header does not match #proc info.\n";
- }
-
- ## Get pstat data for pages
- $sw_used = 0;
- $sw_free = 0;
- open IN, "pstat -s |tail -3 |";
- while (<IN>) {
- @swp = split(/ +/,);
- if (/\d/) {
- $sw_used = $swp[1];
- $sw_free = $swp[2];
- $swap_used = $sw_used * 4096;
- $swap_free = $sw_free * 4096;
- }
- }
- close IN;
- $swap_info = "$swap_used\t$swap_free";
- $swap_header = "\tswap_used\tswap_free";
-
- if ( scalar( split ' ', $swap_header ) !=
- scalar( split ' ', $swap_info ) )
- {
- print STDERR "WARNING: pstat header does not match pstat info.\n";
- $swap_header = '';
- $swap_info = '';
- $need_header = 1;
- }
-
-
-
- ## Get vmstat data
- open IN, "vmstat 1 2|";
- while (<IN>) {
- chomp;
- if (/^[\s\d]+$/) {
-
- # overwrite first line on 2nd pass
- (
- $vmstat_r, $vmstat_b, $vmstat_avm, $vmstat_fre,
- $vmstat_re, $vmstat_pi, $vmstat_po, $vmstat_fr,
- $vmstat_sr, $vmstat_cy, $vmstat_inf, $vmstat_syf,
- $vmstat_csf, $vmstat_us, $vmstat_sy, $vmstat_id,
- $vmstat_wa )
- = split;
- $vmstat_info = join "\t", $vmstat_r, $vmstat_b, $vmstat_avm,
- $vmstat_fre, $pagestotl, $vmstat_pi, $vmstat_po, $vmstat_fr,
- $vmstat_sr, $vmstat_us, $vmstat_sy, $vmstat_wa, $vmstat_id;
- }
- }
- close IN;
- $vmstat_header =
-"runque\twaiting\tpagesactive\tpagesfree\tpagestotl\tPagesI/s\tPagesO/s\tPagesF/s\tscanrate\tusr%\tsys%\twio%\tidle%";
-
- if ( scalar( split ' ', $vmstat_header ) !=
- scalar( split ' ', $vmstat_info ) )
- {
- print STDERR "WARNING: vmstat header does not match vmstat info.\n";
- $vmstat_header = '';
- $vmstat_info = '';
- $need_header = 1;
- }
-
- ## Get filesystem data
- $fs_header = '';
- $fs_info = '';
- open IN, "df -k -v |";
- while (<IN>) {
- chomp;
-
- if (m%^/dev%) {
- ( $mnt_dev, $blocks, $used, $free, $pct_used, $iused, $ifree,
- $ipct_used, $mnt ) = split;
-
- # Recalculate percents because df rounds.
- $fs_info .= "\t"
- . sprintf( "%s\t%s\t%s\t%.5f\t%d\t%s\t%s\t%.5f", $blocks, $used,
- $free, ( $used / $blocks ) * 100, ( $iused + $ifree ), $iused,
- $ifree, ( $iused / ( $iused + $ifree ) ) * 100 );
- $fs_header .= "\t" . join "\t", "mntC_$mnt", "mntU_$mnt",
- "mntA_$mnt", "mntP_$mnt", "mntc_$mnt", "mntu_$mnt", "mnta_$mnt",
- "mntp_$mnt";
- }
- }
- close IN;
-
- if ( scalar( split ' ', $fs_header ) != scalar( split ' ', $fs_info ) ) {
- print STDERR
- "WARNING: filesystem header does not match filesystem info.\n";
- $fs_header = '';
- $fs_info = '';
- $need_header = 1;
- }
-
- ## Get iostat data
- $disk_t = 0;
- $disk_rK = 0;
- $disk_wK = 0;
- undef %disks;
- open IN, "iostat -d 1 2|";
-
- while (<IN>) {
- if (/^(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\d+)\s+(\d+)/) {
- my $disk = $1;
- my $tps = $2;
- my $rK = $3;
- my $wK = $4;
- if ( not $disks{$disk} ) {
- $disks{$disk}++; # Get rK & wK from first pass.
- $disk_rK += $rK;
- $disk_wK += $wK;
- }
- else {
- $disk_t += $tps; # Get trans per sec from second pass.
- }
- }
+ $timestamp = $timestamp ? time() : $start_time;
+ ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+ localtime(time);
+ $locltime = sprintf( "%.2d:%.2d:%.2d", $hour, $min, $sec );
+
+ ## Get runq data
+ $uptime = 0;
+ open IN, "uptime |";
+ while (<IN>) {
+ if (/load average:\s+(\S+),\s+(\S+),\s+(\S+)/) {
+ $load_info = join "\t", $1, $2, $3;
+ }
+ @upt = split(/ +/,);
+ $uptd = $upt[3];
+ $nusr = $upt[6];
+ $up_day = $uptd * 24 * 60 * 60;
+ if (/days,\s+(\S+):(\S+), /) {
+ $up_hrs = $1 * 60 * 60;
+ $up_min = $2 * 60;
+ }
+ $uptime = $up_day + $up_hrs + $up_min;
+ }
+ close IN;
+ $load_header = "1runq\t5runq\t15runq";
+ $up_header = "uptime\tnusr";
+ $up_info = "$uptime\t$nusr";
+
+ if (scalar(split ' ', $load_header) != scalar(split ' ', $load_info)) {
+ $load_header = '';
+ $load_info = '';
+ $need_header = 1;
+ warn "WARNING: load header does not match load info.\n";
+ }
+
+ if (scalar(split ' ', $up_header) != scalar(split ' ', $up_info)) {
+ $up_header = '';
+ $up_info = '';
+ $need_header = 1;
+ warn "WARNING: UP header does not match load info.\n";
+ }
+
+ ## Get number of system processes
+ $num_proc = -1; # Don't count the header.
+ open IN, "ps -ek |";
+ while (<IN>) {
+ $num_proc++;
+ }
+ close IN;
+ $proc_info = $num_proc;
+ $proc_header = '#proc';
+
+ if (scalar(split ' ', $proc_header) != scalar(split ' ', $proc_info)) {
+ $proc_header = '';
+ $proc_info = '';
+ $need_header = 1;
+ warn "WARNING: #proc header does not match #proc info.\n";
+ }
+
+ ## Get pstat data for pages
+ $sw_used = 0;
+ $sw_free = 0;
+ open IN, "pstat -s |tail -3 |";
+ while (<IN>) {
+ @swp = split(/ +/,);
+ if (/\d/) {
+ $sw_used = $swp[1];
+ $sw_free = $swp[2];
+ $swap_used = $sw_used * 4096;
+ $swap_free = $sw_free * 4096;
+ }
+ }
+ close IN;
+ $swap_info = "$swap_used\t$swap_free";
+ $swap_header = "\tswap_used\tswap_free";
+
+ if (scalar(split ' ', $swap_header) != scalar(split ' ', $swap_info)) {
+ warn "WARNING: pstat header does not match pstat info.\n";
+ $swap_header = '';
+ $swap_info = '';
+ $need_header = 1;
+ }
+
+ ## Get vmstat data
+ open IN, "vmstat 1 2|";
+ while (<IN>) {
+ chomp;
+ if (/^[\s\d]+$/) {
+ # overwrite first line on 2nd pass
+ my ($vmstat_r, $vmstat_b, $vmstat_avm, $vmstat_fre,
+ $vmstat_re, $vmstat_pi, $vmstat_po, $vmstat_fr,
+ $vmstat_sr, $vmstat_cy, $vmstat_inf, $vmstat_syf,
+ $vmstat_csf, $vmstat_us, $vmstat_sy, $vmstat_id,
+ $vmstat_wa)
+ = split;
+ $vmstat_info = join("\t",
+ $vmstat_r, $vmstat_b, $vmstat_avm, $vmstat_fre,
+ $pagestotl, $vmstat_pi, $vmstat_po, $vmstat_fr,
+ $vmstat_sr, $vmstat_us, $vmstat_sy, $vmstat_wa,
+ $vmstat_id);
+ }
+ }
+ close IN;
+ $vmstat_header = "runque\twaiting\tpagesactive\tpagesfree\tpagestotl\t" .
+ "PagesI/s\tPagesO/s\tPagesF/s\tscanrate\tusr%\tsys%\t" .
+ "wio%\tidle%";
+
+ if (scalar(split ' ', $vmstat_header) != scalar(split ' ', $vmstat_info)) {
+ warn "WARNING: vmstat header does not match vmstat info.\n";
+ $vmstat_header = '';
+ $vmstat_info = '';
+ $need_header = 1;
+ }
+
+ ## Get filesystem data
+ $fs_header = '';
+ $fs_info = '';
+ open IN, "df -k -v |";
+ while (<IN>) {
+ chomp;
+ if (m%^/dev%) {
+ my ($mnt_dev, $blocks, $used, $free, $pct_used, $iused, $ifree,
+ $ipct_used, $mnt) = split;
+
+ # Recalculate percents because df rounds.
+ $fs_info .= "\t"
+ . sprintf("%s\t%s\t%s\t%.5f\t%d\t%s\t%s\t%.5f",
+ $blocks,
+ $used,
+ $free,
+ 100*($used/$blocks),
+ ($iused + $ifree),
+ $iused,
+ $ifree,
+ 100*$iused/($iused + $ifree));
+ $fs_header .= "\t" . join("\t",
+ "mntC_$mnt", "mntU_$mnt", "mntA_$mnt",
+ "mntP_$mnt", "mntc_$mnt", "mntu_$mnt",
+ "mnta_$mnt", "mntp_$mnt");
+ }
+ }
+ close IN;
+
+ if (scalar(split ' ', $fs_header) != scalar(split ' ', $fs_info)) {
+ warn "WARNING: filesystem header does not match filesystem info.\n";
+ $fs_header = '';
+ $fs_info = '';
+ $need_header = 1;
+ }
+
+ ## Get iostat data
+ $disk_t = 0;
+ $disk_rK = 0;
+ $disk_wK = 0;
+ undef %disks;
+ open IN, "iostat -d 1 2|";
+
+ while (<IN>) {
+ if (/^(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\d+)\s+(\d+)/) {
+ my $disk = $1;
+ my $tps = $2;
+ my $rK = $3;
+ my $wK = $4;
+ if (not $disks{$disk}) {
+ $disks{$disk}++; # Get rK & wK from first pass.
+ $disk_rK += $rK;
+ $disk_wK += $wK;
+ } else {
+ $disk_t += $tps; # Get trans per sec from second pass.
+ }
+ }
+ }
+ close IN;
+ $iostat_header = "disk_t/s\tdisk_rK/s\tdisk_wK/s";
+ $iostat_info = "${disk_t}\t${disk_rK}\t${disk_wK}";
+
+ if (scalar(split ' ', $iostat_header) != scalar(split ' ', $iostat_info)) {
+ warn "WARNING: iostat header does not match iostat info.\n";
+ $iostat_header = '';
+ $iostat_info = '';
+ $need_header = 1;
+ }
+
+ ## Get packet data
+ $packet_header = '';
+ $packet_info = '';
+
+ #foreach $interface ( split(/\s+/, $NET_INTERFACES) ) {
+ foreach $interface (@net_interfaces) {
+ $packet_header .= "\t${interface}Ipkt/s\t${interface}IErr/s\t" .
+ "${interface}Opkt/s\t${interface}OErr/s\t" .
+ "${interface}Coll/s\t";
+
+ open IN, "netstat -n -I $interface 1|";
+ while (<IN>) {
+ if (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+/) {
+ $packet_info .= "\t" . join("\t", $1, $2, $3, $4, $5);
+ last;
+ }
}
close IN;
- $iostat_header = "disk_t/s\tdisk_rK/s\tdisk_wK/s";
- $iostat_info = "${disk_t}\t${disk_rK}\t${disk_wK}";
-
- if ( scalar( split ' ', $iostat_header ) !=
- scalar( split ' ', $iostat_info ) )
- {
- print STDERR "WARNING: iostat header does not match iostat info.\n";
- $iostat_header = '';
- $iostat_info = '';
- $need_header = 1;
- }
-
- ## Get packet data
- $packet_header = '';
- $packet_info = '';
-
- #foreach $interface ( split(/\s+/, $NET_INTERFACES) ) {
- foreach $interface (@net_interfaces) {
- $packet_header .=
-"\t${interface}Ipkt/s\t${interface}IErr/s\t${interface}Opkt/s\t${interface}OErr/s\t${interface}Coll/s\t";
- open IN, "netstat -n -I $interface 1|";
-
- while (<IN>) {
- if (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+/) {
- $packet_info .= "\t" . join "\t", $1, $2, $3, $4, $5;
- last;
- }
- }
- close IN;
- }
-
- if ( scalar( split ' ', $packet_header ) !=
- scalar( split ' ', $packet_info ) )
- {
- print STDERR "WARNING: packet header does not match packet info.\n";
- $packet_header = '';
- $packet_info = '';
- $need_header = 1;
- }
+ }
+}
- ## Get TCP Connection data
- $tcp_estb = 0;
- open IN, "netstat -an |";
- while (<IN>) {
- if (/^tcp.+ESTABLISHED$/) {
- $tcp_estb++;
- }
- }
- close IN;
- $tcp_info = $tcp_estb;
- $tcp_header = 'tcp_estb';
+if (scalar(split ' ', $packet_header) != scalar(split ' ', $packet_info)) {
+ warn "WARNING: packet header does not match packet info.\n";
+ $packet_header = '';
+ $packet_info = '';
+ $need_header = 1;
+}
- if ( scalar( split ' ', $tcp_estb_header ) !=
- scalar( split ' ', $tcp_estb_info ) )
- {
- print STDERR "WARNING: tcp_estb header does not match tcp_estb info.\n";
- $tcp_estb_header = '';
- $tcp_estb_info = '';
- $need_header = 1;
- }
+## Get TCP Connection data
+$tcp_estb = 0;
+open IN, "netstat -an |";
+while (<IN>) {
+ if (/^tcp.+ESTABLISHED$/) {
+ $tcp_estb++;
+ }
+}
+close IN;
- ## Get TSM Database space usage
- $tsmdb = 0;
- open IN, "dsmadmc -id=view -password=view 'query db' |tail -r -n 5 |";
- while (<IN>) {
- @fld = split(/ +/,);
- if (/\d/) {
- $tsmdb = $fld[8];
- }
- }
- close IN;
- $tsm_info = $tsmdb;
- $tsm_header = "tsmdb\t";
+$tcp_info = $tcp_estb;
+$tcp_header = 'tcp_estb';
- if ( scalar( split ' ', $tsm_header ) !=
- scalar( split ' ', $tsm_info ) )
- {
- print STDERR "WARNING: tsmdb header does not match tsmdb info.\n";
- $tsm_header = '';
- $tsm_info = '';
- $need_header = 1;
- }
+if (scalar(split ' ', $tcp_estb_header) != scalar(split ' ', $tcp_estb_info)) {
+ warn "WARNING: tcp_estb header does not match tcp_estb info.\n";
+ $tcp_estb_header = '';
+ $tcp_estb_info = '';
+ $need_header = 1;
+}
- ## Get Memory Usage breakup using SVMON
- $mem_work = 0;
- $mem_pres = 0;
- $mem_clnt = 0;
- open IN, "svmon -G |tail -2 |";
- while (<IN>) {
- @memp = split(/ +/,);
- if (/use\s+(\d+) /) {
- $m_work = $memp[2];
- $m_pres = $memp[3];
- $m_clnt = $memp[4];
- $mem_work = $m_work * 4096;
- $mem_pres = $m_pres * 4096;
- $mem_clnt = $m_clnt * 4096;
- }
- }
- close IN;
- $mem_info = "$mem_work\t$mem_pres\t$mem_clnt\t$mem_totl";
- $mem_header = "mem_work\tmem_pres\tmem_clnt\tmem_totl";
+## Get TSM Database space usage
+$tsmdb = 0;
+open IN, "dsmadmc -id=view -password=view 'query db' |tail -r -n 5 |";
+while (<IN>) {
+ @fld = split(/ +/,);
+ if (/\d/) {
+ $tsmdb = $fld[8];
+ }
+}
+close IN;
+$tsm_info = $tsmdb;
+$tsm_header = "tsmdb\t";
- if ( scalar( split ' ', $mem_header ) !=
- scalar( split ' ', $mem_info ) )
- {
- print STDERR "WARNING: memory header does not match memory info.\n";
- $mem_header = '';
- $mem_info = '';
- $need_header = 1;
- }
+if (scalar(split ' ', $tsm_header) != scalar(split ' ', $tsm_info)) {
+ warn "WARNING: tsmdb header does not match tsmdb info.\n";
+ $tsm_header = '';
+ $tsm_info = '';
+ $need_header = 1;
+}
- ## Get TSM Tape Drive usage
- $rmt = 0;
- $rmt5 = 5;
- open IN, "dsmadmc -id=view -password=view 'query mount' |grep matches |";
- while (<IN>) {
- @fld = split(/ +/,);
- if (/\d/) {
- $rmt = $fld[1];
- }
- }
- close IN;
- $tsm_rmt_header = "rmt5\trmt\t";
- $tsm_rmt_info = "$rmt5\t$rmt";
+## Get Memory Usage breakup using SVMON
+$mem_work = 0;
+$mem_pres = 0;
+$mem_clnt = 0;
+open IN, "svmon -G |tail -2 |";
+while (<IN>) {
+ @memp = split(/ +/,);
+ if (/use\s+(\d+) /) {
+ $m_work = $memp[2];
+ $m_pres = $memp[3];
+ $m_clnt = $memp[4];
+ $mem_work = $m_work * 4096;
+ $mem_pres = $m_pres * 4096;
+ $mem_clnt = $m_clnt * 4096;
+ }
+}
+close IN;
- if ( scalar( split ' ', $tsm_rmt_header ) !=
- scalar( split ' ', $tsm_rmt_info ) )
- {
- print STDERR "WARNING: TSM RMT header does not match TSM RMT info.\n";
- $tsm_rmt_header = '';
- $tsm_rmt_info = '';
- $need_header = 1;
- }
+$mem_info = "$mem_work\t$mem_pres\t$mem_clnt\t$mem_totl";
+$mem_header = "mem_work\tmem_pres\tmem_clnt\tmem_totl";
- ## Get TSM Recovery Log space usage
- $tsmdb = 0;
- open IN, "dsmadmc -id=view -password=view 'query log' |tail -r -n 4 |";
- while (<IN>) {
- @fld = split(/ +/,);
- if (/\d/) {
- $tsmlog = $fld[8];
- }
- }
- close IN;
- $tsm_log_info = $tsmlog;
- $tsm_log_header = 'tsmlog';
+if (scalar(split ' ', $mem_header) != scalar(split ' ', $mem_info)) {
+ warn "WARNING: memory header does not match memory info.\n";
+ $mem_header = '';
+ $mem_info = '';
+ $need_header = 1;
+}
- if ( scalar( split ' ', $tsm_log_header ) !=
- scalar( split ' ', $tsm_log_info ) )
- {
- print STDERR "WARNING: TSM Log header does not match TSM Log info.\n";
- $tsm_log_header = '';
- $tsm_log_info = '';
- $need_header = 1;
- }
+## Get TSM Tape Drive usage
+$rmt = 0;
+$rmt5 = 5;
+open IN, "dsmadmc -id=view -password=view 'query mount' |grep matches |";
+while (<IN>) {
+ @fld = split(/ +/,);
+ if (/\d/) {
+ $rmt = $fld[1];
+ }
+}
+close IN;
+$tsm_rmt_header = "rmt5\trmt\t";
+$tsm_rmt_info = "$rmt5\t$rmt";
- ## Get TSM Tape usage
- $tsmpvt = 0;
- open IN, "dsmadmc -id=view -password=view 'query libvol' | grep 'Private' | wc -l |";
- while (<IN>) {
- chomp;
- @fld = split(/ +/,);
- if (/\d/) {
- $tsmpvt = $fld[1];
- }
- }
- close IN;
+if (scalar(split ' ', $tsm_rmt_header) != scalar(split ' ', $tsm_rmt_info)) {
+ warn "WARNING: TSM RMT header does not match TSM RMT info.\n";
+ $tsm_rmt_header = '';
+ $tsm_rmt_info = '';
+ $need_header = 1;
+}
- $tsmscr = 0;
- open IN, "dsmadmc -id=view -password=view 'query libvol' | grep 'Scratch' | wc -l |";
- while (<IN>) {
- chomp;
- @fld = split(/ +/,);
- if (/\d/) {
- $tsmscr = $fld[1];
- }
- }
- close IN;
+## Get TSM Recovery Log space usage
+$tsmdb = 0;
+open IN, "dsmadmc -id=view -password=view 'query log' |tail -r -n 4 |";
+while (<IN>) {
+ @fld = split(/ +/,);
+ if (/\d/) {
+ $tsmlog = $fld[8];
+ }
+}
+close IN;
+$tsm_log_info = $tsmlog;
+$tsm_log_header = 'tsmlog';
- $tsmvlt = 0;
- open IN, "dsmadmc -id=view -password=view 'query drmedia' | grep 'Vault' | wc -l |";
- while (<IN>) {
- chomp;
- @fld = split(/ +/,);
- if (/\d/) {
- $tsmvlt = $fld[1];
- }
- }
+if (scalar(split ' ', $tsm_log_header) != scalar(split ' ', $tsm_log_info)) {
+ warn "WARNING: TSM Log header does not match TSM Log info.\n";
+ $tsm_log_header = '';
+ $tsm_log_info = '';
+ $need_header = 1;
+}
- $tsm_tape_info = join "\t", $tsmpvt, $tsmscr, $tsmvlt;
- $tsm_tape_header = join "\t", tsmpvt, tsmscr, tsmvlt;
+## Get TSM Tape usage
+$tsmpvt = 0;
+open IN, "dsmadmc -id=view -password=view 'query libvol' | grep 'Private' | wc -l |";
+while (<IN>) {
+ chomp;
+ @fld = split(/ +/,);
+ if (/\d/) {
+ $tsmpvt = $fld[1];
+ }
+}
+close IN;
- if ( scalar( split ' ', $tsm_tape_header ) !=
- scalar( split ' ', $tsm_tape_info ) )
- {
- print STDERR "WARNING: TSM Tape header does not match TSM Tape info.\n";
- $tsm_tape_header = '';
- $tsm_tape_info = '';
- $need_header = 1;
- }
+$tsmscr = 0;
+open IN, "dsmadmc -id=view -password=view 'query libvol' | grep 'Scratch' | wc -l |";
+while (<IN>) {
+ chomp;
+ @fld = split(/ +/,);
+ if (/\d/) {
+ $tsmscr = $fld[1];
+ }
+}
+close IN;
- ## Get TSM Disk Storage Pool usage
- $tsmphcy = 0;
- $tsmphcn = 0;
- open IN, "dsmadmc -id=view -password=view 'query stgpool' |";
- while (<IN>) {
- @fld = split(/ +/,);
- if (/\d/) {
- if ( $fld[0] eq "PHCYDISKPO-" ) {
- $tsmphcy = $fld[3];
- }
- elsif ( $fld[0] eq "PHCNDISKPO-" ) {
- $tsmphcn = $fld[3];
- }
- }
- }
- close IN;
+$tsmvlt = 0;
+open IN, "dsmadmc -id=view -password=view 'query drmedia' | grep 'Vault' | wc -l |";
+while (<IN>) {
+ chomp;
+ @fld = split(/ +/,);
+ if (/\d/) {
+ $tsmvlt = $fld[1];
+ }
+}
- $tsm_stg_info = join "\t", $tsmphcy, $tsmphcn;
- $tsm_stg_header = join "\t", tsmphcy, tsmphcn;
+$tsm_tape_info = join "\t", $tsmpvt, $tsmscr, $tsmvlt;
+$tsm_tape_header = join "\t", tsmpvt, tsmscr, tsmvlt;
- if ( scalar( split ' ', $tsm_stg_header ) !=
- scalar( split ' ', $tsm_stg_info ) )
- {
- print STDERR "WARNING: TSM Storage Pool header does not match TSM Storage Pool info.\n";
- $tsm_stg_header = '';
- $tsm_stg_info = '';
- $need_header = 1;
- }
+if (scalar(split ' ', $tsm_tape_header) != scalar(split ' ', $tsm_tape_info)) {
+{
+ warn "WARNING: TSM Tape header does not match TSM Tape info.\n";
+ $tsm_tape_header = '';
+ $tsm_tape_info = '';
+ $need_header = 1;
+}
- ## Join header and info then verify column counts.
- $out_header = join "\t", "timestamp", "locltime", $load_header, $up_header,
- $proc_header, $vmstat_header, $fs_header, $iostat_header, $packet_header,
- $tcp_header, $tsm_header, $swap_header, $mem_header, $tsm_rmt_header,
- $tsm_log_header, $tsm_tape_header, $tsm_stg_header;
- $out_header =~ tr/ \t/\t/s; # translate whitespace to single tabs
-
- $out_info = join "\t", $timestamp, $locltime, $load_info, $up_info, $proc_info,
- $vmstat_info, $fs_info, $iostat_info, $packet_info, $tcp_info, $tsm_info,
- $swap_info, $mem_info, $tsm_rmt_info, $tsm_log_info, $tsm_tape_info,
- $tsm_stg_info;
- $out_info =~ tr/ \t/\t/s; # translate whitespace to single tabs
-
- $header_cnt = split ' ', $out_header;
- $info_cnt = split ' ', $out_info;
- if ( $header_cnt != $info_cnt ) {
- print STDERR
- "ERROR: header columns do not equal data columns. Exiting.\n";
- &exit_nicely;
- }
- elsif ( $header_cnt != $prev_header_cnt or $info_cnt != $prev_info_cnt ) {
- $need_header = 1;
+## Get TSM Disk Storage Pool usage
+$tsmphcy = 0;
+$tsmphcn = 0;
+open IN, "dsmadmc -id=view -password=view 'query stgpool' |";
+while (<IN>) {
+ @fld = split(/ +/,);
+ if (/\d/) {
+ if ($fld[0] eq "PHCYDISKPO-" ) {
+ $tsmphcy = $fld[3];
+ } elsif ($fld[0] eq "PHCNDISKPO-" ) {
+ $tsmphcn = $fld[3];
}
- $prev_header_cnt = $header_cnt;
- $prev_info_cnt = $info_cnt;
+ }
+}
+close IN;
- ## Write output
- if ($need_header) {
- print OUT $out_header, "\n";
- $need_header = 0;
- }
- print OUT $out_info, "\n";
+$tsm_stg_info = join "\t", $tsmphcy, $tsmphcn;
+$tsm_stg_header = join "\t", tsmphcy, tsmphcn;
- sleep $INTERVAL - ( time() - $timestamp );
+if (scalar(split ' ', $tsm_stg_header) != scalar(split ' ', $tsm_stg_info)) {
+ warn "WARNING: TSM Storage Pool header does not match ",
+ "TSM Storage Pool info.\n";
+ $tsm_stg_header = '';
+ $tsm_stg_info = '';
+ $need_header = 1;
+ }
+
+ ## Join header and info then verify column counts.
+ $out_header = join("\t",
+ "timestamp", "locltime", $load_header, $up_header,
+ $proc_header, $vmstat_header, $fs_header, $iostat_header,
+ $packet_header, $tcp_header, $tsm_header, $swap_header,
+ $mem_header, $tsm_rmt_header, $tsm_log_header,
+ $tsm_tape_header, $tsm_stg_header);
+ $out_header =~ tr/ \t/\t/s; # translate whitespace to single tabs
+
+ $out_info = join("\t",
+ $timestamp, $locltime, $load_info, $up_info, $proc_info,
+ $vmstat_info, $fs_info, $iostat_info, $packet_info,
+ $tcp_info, $tsm_info, $swap_info, $mem_info, $tsm_rmt_info,
+ $tsm_log_info, $tsm_tape_info, $tsm_stg_info);
+ $out_info =~ tr/ \t/\t/s; # translate whitespace to single tabs
+
+ $header_cnt = split ' ', $out_header;
+ $info_cnt = split ' ', $out_info;
+ if ($header_cnt != $info_cnt) {
+ warn "ERROR: header columns do not equal data columns. Exiting.\n";
+ &exit_nicely;
+ } elsif ($header_cnt != $prev_header_cnt or $info_cnt != $prev_info_cnt) {
+ $need_header = 1;
+ }
+ $prev_header_cnt = $header_cnt;
+ $prev_info_cnt = $info_cnt;
+
+ ## Write output
+ if ($need_header) {
+ print OUT $out_header, "\n";
+ $need_header = 0;
+ }
+ print OUT $out_info, "\n";
+ sleep $INTERVAL - ( time() - $timestamp );
}
close OUT;
@@ -625,8 +603,8 @@
# This subroutine is called by the signal handler.
sub exit_nicely {
- close OUT;
- @args = ($COMPRESS, "-f", $stat_file);
- system(@args);
- exit 0;
+ close OUT;
+ @args = ($COMPRESS, "-f", $stat_file);
+ system(@args);
+ exit 0;
}
Modified: trunk/orca/data_gatherers/hp/orca-hp-stat.pl.in
==============================================================================
--- trunk/orca/data_gatherers/hp/orca-hp-stat.pl.in (original)
+++ trunk/orca/data_gatherers/hp/orca-hp-stat.pl.in Tue Jul 6 22:43:40 2004
@@ -63,7 +63,7 @@
#
#To compile: cc -o phys_mem phys_mem.c
#
- #*/
+#*/
#
#static char SCCSid[] = "@(#)phys_mem 1.1";
#
@@ -111,30 +111,24 @@
';
# Parse the command line arguments
-while ( $#ARGV >= 0 ) {
-
- if ( $ARGV[0] eq "-r" ) {
- shift @ARGV;
- $OUT_ROOT = shift @ARGV;
- }
- elsif ( $ARGV[0] eq "-i" ) {
- shift @ARGV;
- $INTERVAL = shift @ARGV;
- }
- elsif ( $ARGV[0] eq "-d" ) {
- shift @ARGV;
- $DURATION = shift @ARGV;
- }
- elsif ( $ARGV[0] eq "-h" ) {
- print $Usage_Message;
- exit 0;
- }
- elsif ( $ARGV[0] =~ /^-/ ) {
- die "Invalid flag: $ARGV[0]\n$Usage_Message";
- }
- else {
- die "Invalid argument: $ARGV[0]\n$Usage_Message";
- }
+while ($#ARGV >= 0) {
+ if ($ARGV[0] eq "-r") {
+ shift @ARGV;
+ $OUT_ROOT = shift @ARGV;
+ } elsif ($ARGV[0] eq "-i") {
+ shift @ARGV;
+ $INTERVAL = shift @ARGV;
+ } elsif ($ARGV[0] eq "-d") {
+ shift @ARGV;
+ $DURATION = shift @ARGV;
+ } elsif ($ARGV[0] eq "-h") {
+ print $Usage_Message;
+ exit 0;
+ } elsif ($ARGV[0] =~ /^-/) {
+ die "Invalid flag: $ARGV[0]\n$Usage_Message";
+ } else {
+ die "Invalid argument: $ARGV[0]\n$Usage_Message";
+ }
}
## BEGIN set defaults
@@ -147,13 +141,18 @@
## Derived variables.
$iterations = $DURATION * 60 * 60 / $INTERVAL; # Number of checks.
-chomp( $HOST = `uname -n` );
+chomp($HOST = `uname -n`);
$out_dir = "${OUT_ROOT}/${HOST}";
-( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
+($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$stat_file =
- sprintf( "%s/percol-%.2d-%.2d-%.2d-%1d%.2d", $out_dir, $year + 1900, $mon + 1,
- $mday, $hour, $min );
+ sprintf("%s/percol-%.2d-%.2d-%.2d-%1d%.2d",
+ $out_dir,
+ $year + 1900,
+ $mon + 1,
+ $mday,
+ $hour,
+ $min);
# Base all timestamps on start time.
$start_time = time();
@@ -163,29 +162,26 @@
#open IN, "ifconfig -a|";
open IN, "netstat -i|";
while (<IN>) {
-
- # if ( /^(\S+):/ ) {
- if (/^(\w+).*link/) {
- push @net_interfaces, $1;
- }
+ # if (/^(\S+):/) {
+ if (/^(\w+).*link/) {
+ push @net_interfaces, $1;
+ }
}
close IN;
# Grab some base system info prior to collecting stats.
open IN, "/usr/local/bin/phymem|";
while (<IN>) {
- if (/Physical (\d+) /) {
- $pagestotl =
- $1 * 1024 / 4096; # Grab realmem in KB and convert to pages.
-
- ## this gets used down in the vmstat section
- }
+ if (/Physical (\d+) /) {
+ $pagestotl = $1 * 1024 / 4096; # Grab realmem in KB and convert to pages.
+ # this gets used down in the vmstat section
+ }
}
close IN;
## Make sure we can write output.
umask 0022; # make sure the file can be harvested
-unless ( -d $out_dir ) {
+unless ( -d $out_dir) {
system( "mkdir", "-p", "$out_dir" );
}
open OUT, ">$stat_file" or die "ERROR: Could not open $stat_file: $!";
@@ -205,229 +201,223 @@
$prev_header_cnt = 0;
$prev_info_cnt = 0;
-while ( $iterations-- > 0 ) {
-
- $timestamp = $timestamp ? time() : $start_time;
- ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
- localtime(time);
- $locltime = sprintf( "%.2d:%.2d:%.2d", $hour, $min, $sec );
-
- ## Get runq data
- open IN, "uptime |";
- while (<IN>) {
- if (/load average:\s+(\S+),\s+(\S+),\s+(\S+)/) {
- $load_info = join "\t", $1, $2, $3;
- }
- }
- close IN;
- $load_header = "1runq\t5runq\t15runq";
-
- if ( scalar( split ' ', $load_header ) != scalar( split ' ', $load_info ) )
- {
- $load_header = '';
- $load_info = '';
- $need_header = 1;
- print STDERR "WARNING: load header does not match load info.\n";
- }
-
- ## Get number of system processes
- $num_proc = -1; # Don't count the header.
- open IN, "ps -e |";
- while (<IN>) {
- $num_proc++;
- }
- close IN;
- $proc_info = $num_proc;
- $proc_header = '#proc';
-
- if ( scalar( split ' ', $proc_header ) != scalar( split ' ', $proc_info ) )
- {
- $proc_header = '';
- $proc_info = '';
- $need_header = 1;
- print STDERR "WARNING: #proc header does not match #proc info.\n";
- }
-
- ## Get vmstat data
- open IN, "vmstat 1 2|";
- while (<IN>) {
- chomp;
- if (/^[\s\d]+$/) {
-
- # overwrite first line on 2nd pass
- (
- $vmstat_r, $vmstat_b, $vmstat_wa, $vmstat_avm, $vmstat_fre,
- $vmstat_re, $vmstat_at, $vmstat_pi, $vmstat_po, $vmstat_fr,
- $vmstat_cy, $vmstat_sr, $vmstat_inf, $vmstat_syf,
- $vmstat_csf, $vmstat_us, $vmstat_sy, $vmstat_id
- )
- = split;
- $vmstat_info = join "\t", $vmstat_avm, $vmstat_fre, $pagestotl,
- $vmstat_pi, $vmstat_po, $vmstat_fr, $vmstat_sr, $vmstat_us,
- $vmstat_sy, $vmstat_wa, $vmstat_id;
- }
- }
- close IN;
- $vmstat_header =
-"pagesactive\tpagesfree\tpagestotl\tPagesI/s\tPagesO/s\tPagesF/s\tscanrate\tusr%\tsys%\twio%\tidle%";
-
- if ( scalar( split ' ', $vmstat_header ) !=
- scalar( split ' ', $vmstat_info ) )
- {
- print STDERR "WARNING: vmstat header does not match vmstat info.\n";
- $vmstat_header = '';
- $vmstat_info = '';
- $need_header = 1;
- }
+while ( $iterations-- > 0) {
+ $timestamp = $timestamp ? time() : $start_time;
+ ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+ localtime(time);
+ $locltime = sprintf("%.2d:%.2d:%.2d", $hour, $min, $sec);
+
+ ## Get runq data
+ open IN, "uptime |";
+ while (<IN>) {
+ if (/load average:\s+(\S+),\s+(\S+),\s+(\S+)/) {
+ $load_info = join "\t", $1, $2, $3;
+ }
+ }
+ close IN;
+ $load_header = "1runq\t5runq\t15runq";
+
+ if (scalar(split ' ', $load_header) != scalar(split ' ', $load_info)) {
+ $load_header = '';
+ $load_info = '';
+ $need_header = 1;
+ warn "WARNING: load header does not match load info.\n";
+ }
+
+ ## Get number of system processes
+ $num_proc = -1; # Don't count the header.
+ open IN, "ps -e |";
+ while (<IN>) {
+ $num_proc++;
+ }
+ close IN;
+ $proc_info = $num_proc;
+ $proc_header = '#proc';
+
+ if (scalar(split ' ', $proc_header) != scalar(split ' ', $proc_info)) {
+ $proc_header = '';
+ $proc_info = '';
+ $need_header = 1;
+ warn "WARNING: #proc header does not match #proc info.\n";
+ }
+
+ ## Get vmstat data
+ open IN, "vmstat 1 2|";
+ while (<IN>) {
+ chomp;
+ if (/^[\s\d]+$/) {
+
+ # overwrite first line on 2nd pass
+ my ($vmstat_r, $vmstat_b, $vmstat_wa, $vmstat_avm, $vmstat_fre,
+ $vmstat_re, $vmstat_at, $vmstat_pi, $vmstat_po, $vmstat_fr,
+ $vmstat_cy, $vmstat_sr, $vmstat_inf, $vmstat_syf,
+ $vmstat_csf, $vmstat_us, $vmstat_sy, $vmstat_id)
+ = split;
+ $vmstat_info = join("\t",
+ $vmstat_avm, $vmstat_fre, $pagestotl, $vmstat_pi,
+ $vmstat_po, $vmstat_fr, $vmstat_sr, $vmstat_us,
+ $vmstat_sy, $vmstat_wa, $vmstat_id);
+ }
+ }
+ close IN;
+ $vmstat_header = "pagesactive\tpagesfree\tpagestotl\tPagesI/s\tPagesO/s\t" .
+ "PagesF/s\tscanrate\tusr%\tsys%\twio%\tidle%";
+
+ if (scalar(split ' ', $vmstat_header) != scalar(split ' ', $vmstat_info)) {
+ warn "WARNING: vmstat header does not match vmstat info.\n";
+ $vmstat_header = '';
+ $vmstat_info = '';
+ $need_header = 1;
+ }
+
+ ## Get filesystem data
+ $fs_header = '';
+ $fs_info = '';
+ open IN, "/usr/local/bin/hpdf |";
+ while (<IN>) {
+ chomp;
+
+ if (m%^/%) {
+ my ($mnt_dev, $blocks, $used, $free, $pct_used, $iused, $ifree,
+ $ipct_used, $mnt) = split;
+
+ # Recalculate percents because df rounds.
+ $fs_info .= "\t"
+ . sprintf("%s\t%s\t%s\t%.5f\t%d\t%s\t%s\t%.5f",
+ $blocks,
+ $used,
+ $free,
+ 100*($used/$blocks),
+ ($iused + $ifree),
+ $iused,
+ $ifree,
+ 100*($iused/($iused + $ifree)));
+ $fs_header .= "\t" . join("\t",
+ "mntC_$mnt", "mntU_$mnt", "mntA_$mnt",
+ "mntP_$mnt", "mntc_$mnt", "mntu_$mnt",
+ "mnta_$mnt", "mntp_$mnt");
+ }
+ }
+ close IN;
+
+ if (scalar(split ' ', $fs_header) != scalar(split ' ', $fs_info )) {
+ warn "WARNING: filesystem header does not match filesystem info.\n";
+ $fs_header = '';
+ $fs_info = '';
+ $need_header = 1;
+ }
+
+ ## Get iostat data
+ $disk_t = 0;
+ $disk_rK = 0;
+ $disk_wK = 0;
+ undef %disks;
+ open IN, "iostat 1 2|";
+
+ while (<IN>) {
+ if (/^(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\d+)\s+(\d+)/) {
+ my $disk = $1;
+ my $tps = $2;
+ my $rK = $3;
+ my $wK = $4;
+ if (not $disks{$disk}) {
+ $disks{$disk}++; # Get rK & wK from first pass.
+ $disk_rK += $rK;
+ $disk_wK += $wK;
+ } else {
+ $disk_t += $tps; # Get trans per sec from second pass.
+ }
+ }
+ }
+ close IN;
+ $iostat_header = "disk_t/s\tdisk_rK/s\tdisk_wK/s\t";
+ $iostat_info = "${disk_t}\t${disk_rK}\t${disk_wK}";
+
+ if (scalar(split ' ', $iostat_header) != scalar(split ' ', $iostat_info)) {
+ warn "WARNING: iostat header does not match iostat info.\n";
+ $iostat_header = '';
+ $iostat_info = '';
+ $need_header = 1;
+ }
+
+ ## Get packet data
+ $packet_header = '';
+ $packet_info = '';
+
+ #foreach $interface ( split(/\s+/, $NET_INTERFACES)) {
+ foreach $interface (@net_interfaces) {
+ $packet_header .= "${interface}Ipkt/s\t${interface}IErr/s\t" .
+ "${interface}Opkt/s\t${interface}OErr/s\t" .
+ "${interface}Coll/s\t";
+ open IN, "netstat -I $interface 1|";
- ## Get filesystem data
- $fs_header = '';
- $fs_info = '';
- open IN, "/usr/local/bin/hpdf |";
while (<IN>) {
- chomp;
-
- if (m%^/%) {
- ( $mnt_dev, $blocks, $used, $free, $pct_used, $iused, $ifree,
- $ipct_used, $mnt ) = split;
-
- # Recalculate percents because df rounds.
- $fs_info .= "\t"
- . sprintf( "%s\t%s\t%s\t%.5f\t%d\t%s\t%s\t%.5f", $blocks, $used,
- $free, ( $used / $blocks ) * 100, ( $iused + $ifree ), $iused,
- $ifree, ( $iused / ( $iused + $ifree ) ) * 100 );
- $fs_header .= "\t" . join "\t", "mntC_$mnt", "mntU_$mnt",
- "mntA_$mnt", "mntP_$mnt", "mntc_$mnt", "mntu_$mnt", "mnta_$mnt",
- "mntp_$mnt";
- }
+ if (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+/) {
+ $packet_info .= "\t" . join("\t", $1, $2, $3, $4, $5);
+ last;
+ }
}
close IN;
+ }
- if ( scalar( split ' ', $fs_header ) != scalar( split ' ', $fs_info ) ) {
- print STDERR
- "WARNING: filesystem header does not match filesystem info.\n";
- $fs_header = '';
- $fs_info = '';
- $need_header = 1;
- }
-
- ## Get iostat data
- $disk_t = 0;
- $disk_rK = 0;
- $disk_wK = 0;
- undef %disks;
- open IN, "iostat 1 2|";
-
- while (<IN>) {
- if (/^(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\d+)\s+(\d+)/) {
- my $disk = $1;
- my $tps = $2;
- my $rK = $3;
- my $wK = $4;
- if ( not $disks{$disk} ) {
- $disks{$disk}++; # Get rK & wK from first pass.
- $disk_rK += $rK;
- $disk_wK += $wK;
- }
- else {
- $disk_t += $tps; # Get trans per sec from second pass.
- }
- }
- }
- close IN;
- $iostat_header = "disk_t/s\tdisk_rK/s\tdisk_wK/s\t";
- $iostat_info = "${disk_t}\t${disk_rK}\t${disk_wK}";
-
- if ( scalar( split ' ', $iostat_header ) !=
- scalar( split ' ', $iostat_info ) )
- {
- print STDERR "WARNING: iostat header does not match iostat info.\n";
- $iostat_header = '';
- $iostat_info = '';
- $need_header = 1;
- }
-
- ## Get packet data
+ if (scalar(split ' ', $packet_header) != scalar(split ' ', $packet_info)) {
+ warn "WARNING: packet header does not match packet info.\n";
$packet_header = '';
$packet_info = '';
+ $need_header = 1;
+ }
- #foreach $interface ( split(/\s+/, $NET_INTERFACES) ) {
- foreach $interface (@net_interfaces) {
- $packet_header .=
-"${interface}Ipkt/s\t${interface}IErr/s\t${interface}Opkt/s\t${interface}OErr/s\t${interface}Coll/s\t";
- open IN, "netstat -I $interface 1|";
-
- while (<IN>) {
- if (/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+/) {
- $packet_info .= "\t" . join "\t", $1, $2, $3, $4, $5;
- last;
- }
- }
- close IN;
- }
-
- if ( scalar( split ' ', $packet_header ) !=
- scalar( split ' ', $packet_info ) )
- {
- print STDERR "WARNING: packet header does not match packet info.\n";
- $packet_header = '';
- $packet_info = '';
- $need_header = 1;
- }
-
- ## Get TCP Connection data
- $tcp_estb = 0;
- open IN, "netstat -a |";
- while (<IN>) {
- if (/^tcp.+ESTABLISHED$/) {
- $tcp_estb++;
- }
- }
- close IN;
- $tcp_info = $tcp_estb;
- $tcp_header = 'tcp_estb';
-
- if ( scalar( split ' ', $tcp_estb_header ) !=
- scalar( split ' ', $tcp_estb_info ) )
- {
- print STDERR "WARNING: tcp_estb header does not match tcp_estb info.\n";
- $tcp_estb_header = '';
- $tcp_estb_info = '';
- $need_header = 1;
- }
-
- ## Join header and info then verify column counts.
- $out_header = join "\t", "timestamp", "locltime", $load_header,
- $proc_header, $vmstat_header, $fs_header, $iostat_header, $packet_header,
- $tcp_header;
- $out_header =~ tr/ \t/\t/s; # translate whitespace to single tabs
-
- $out_info = join "\t", $timestamp, $locltime, $load_info, $proc_info,
- $vmstat_info, $fs_info, $iostat_info, $packet_info, $tcp_info;
- $out_info =~ tr/ \t/\t/s; # translate whitespace to single tabs
-
- $header_cnt = split ' ', $out_header;
- $info_cnt = split ' ', $out_info;
- if ( $header_cnt != $info_cnt ) {
- print STDERR
- "ERROR: header columns do not equal data columns. Exiting.\n";
- &exit_nicely;
- }
- elsif ( $header_cnt != $prev_header_cnt or $info_cnt != $prev_info_cnt ) {
- $need_header = 1;
- }
- $prev_header_cnt = $header_cnt;
- $prev_info_cnt = $info_cnt;
-
- ## Write output
- if ($need_header) {
- print OUT $out_header, "\n";
- $need_header = 0;
- }
- print OUT $out_info, "\n";
-
- sleep $INTERVAL - ( time() - $timestamp );
+ ## Get TCP Connection data
+ $tcp_estb = 0;
+ open IN, "netstat -a |";
+ while (<IN>) {
+ if (/^tcp.+ESTABLISHED$/) {
+ $tcp_estb++;
+ }
+ }
+ close IN;
+ $tcp_info = $tcp_estb;
+ $tcp_header = 'tcp_estb';
+
+ if (scalar(split ' ', $tcp_estb_header) != scalar(split ' ', $tcp_estb_info)){
+ warn "WARNING: tcp_estb header does not match tcp_estb info.\n";
+ $tcp_estb_header = '';
+ $tcp_estb_info = '';
+ $need_header = 1;
+ }
+
+ ## Join header and info then verify column counts.
+ $out_header = join("\t",
+ "timestamp", "locltime", $load_header, $proc_header,
+ $vmstat_header, $fs_header, $iostat_header,
+ $packet_header, $tcp_header);
+ $out_header =~ tr/ \t/\t/s; # translate whitespace to single tabs
+
+ $out_info = join("\t",
+ $timestamp, $locltime, $load_info, $proc_info,
+ $vmstat_info, $fs_info, $iostat_info, $packet_info,
+ $tcp_info);
+ $out_info =~ tr/ \t/\t/s; # translate whitespace to single tabs
+
+ $header_cnt = split ' ', $out_header;
+ $info_cnt = split ' ', $out_info;
+ if ($header_cnt != $info_cnt) {
+ warn "ERROR: header columns do not equal data columns. Exiting.\n";
+ &exit_nicely;
+ } elsif ($header_cnt != $prev_header_cnt or $info_cnt != $prev_info_cnt) {
+ $need_header = 1;
+ }
+ $prev_header_cnt = $header_cnt;
+ $prev_info_cnt = $info_cnt;
+
+ ## Write output
+ if ($need_header) {
+ print OUT $out_header, "\n";
+ $need_header = 0;
+ }
+ print OUT $out_info, "\n";
+ sleep $INTERVAL - ( time() - $timestamp );
}
close OUT;
@@ -438,8 +428,8 @@
# This subroutine is called by the signal handler.
sub exit_nicely {
- close OUT;
- @args = ($COMPRESS, "-f", $stat_file);
- system(@args);
- exit 0;
+ close OUT;
+ @args = ($COMPRESS, "-f", $stat_file);
+ system(@args);
+ exit 0;
}
More information about the Orca-checkins
mailing list