diskUtil.prl
3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/local/bin/perl5 -w
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
$inputFile = shift;
if( !defined( $inputFile ) ) {
$inputFile = "cpu.log";
}
open(LOG,$inputFile);
$startTime = 0;
$entries = 0;
$minDiff = 10000000000;
$maxDiff = 0;
$totalDiff = 0;
$proc = 0;
$disklabel = 0;
$disk = 0;
for $i ( 0..10 ) {
$usedTime[$i] = 0;
$freeTime[$i] = 0;
$lastUsed[$i] = 0;
$prevUsed[$i] = 0;
$diskInUse[$i] = 0;
}
while( <LOG>) {
($log,$time,$event,$cpu,$proc,$disklabel,$diskInfo,$op,$sizelabel,$size) =
split;
if( defined($log) ) {
if( $log eq "CONFIG") {
if( $time eq "CpuClock") {
$clockRate = $event;
$baseInt = $clockRate * 1000 * 40;
$nextInt = $clockRate * 1000 * 40 ;
$timeMS = 1;
}
}
if ($log eq "PARAM") {
if ($time eq "CPU.Clock") {
$clockRate = $event;
$baseInt = $clockRate * 1000 * 40;
$nextInt = $clockRate * 1000 * 40 ;
$timeMS = 1;
}
}
if( $log eq "LOG" ) {
while( $time > $nextInt ) {
printf( "%8.5f ", $nextInt/ ($clockRate * 1000000));
for $i (1..8) {
if( $diskInUse[$i] ) {
$usedTime[$i] += $nextInt - $savedStart[$i];
$savedStart[$i] = $nextInt;
}
printf( "%6.2f ", 100 * ($usedTime[$i]-$prevUsed[$i])/$baseInt);
$prevUsed[$i] = $usedTime[$i];
}
printf("\n");
$nextInt += $baseInt;
}
if( $event eq "DISK-req" ) {
if ($diskInfo eq "disk") {
($foo,$disk) = split(/\./,$op);
} else {
($foo,$disk) = split(/\./,$diskInfo);
}
$freeTime[$disk] += $time - $lastUsed[$disk];
$savedOp[$disk] = $op;
$savedStart[$disk] = $time;
$savedSize[$disk] = $size;
$diskInUse[$disk] = 1;
}
if( $event eq "DISK-ack" ) {
##
## deall with 'kernel idle' being a process name!
if ($diskInfo eq "disk") {
($foo,$foo2,$disk) = split(/\./,$op);
} else {
($foo,$foo2,$disk) = split(/\./,$diskInfo);
}
#print "XXX $diskInfo --> $foo|$foo2|$disk \n";
if( $savedStart[$disk] != 0 ) {
$diff = $time-$savedStart[$disk];
$usedTime[$disk] += $diff;
$savedStart[$disk] = 0;
$diskInUse[$disk] = 0;
} else {
print "No start for disk $disk in $remainder\n";
print $_;
}
}
}
}
}
# Unused variables - comment out if you ever use these
$cpu = 0;
$savedSize = 0;
$savedOp = 0;
$timeMS = 0;
$remainder = 0;
$entries = 0;
$totalDiff = 0;
$minDiff = 0;
$startTime = 0;
$maxDiff = 0;
$sizelabel = 0;