-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotpetesdata.pl
More file actions
326 lines (295 loc) · 12.6 KB
/
plotpetesdata.pl
File metadata and controls
326 lines (295 loc) · 12.6 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#!/bin/perl
# $Id: plotpetesdata.pl,v 1.19 2019/02/15 17:20:32 gbrandt Exp $
#
#
#
#
##########################################################################
############### S P A W A R S H A R E D S E R V I C E S ############
##########################################################################
#
# File: plotpetesdata
# Author:
# Date: Tuesday, February 16, 2016
#
# Generated by bshdr
# Developed by Gene Brandt
# 504 452-3250
#
##########################################################################
#
# Description:
# Build one line data file from Pete's tape data file and construct
# GNUplot scripts for 1, 3, and 7 day intervals.
#
#
#
##########################################################################
############### S P A W A R S H A R E D S E R V I C E S ############
##########################################################################
# Environmentals #
##########################################################################
#
#
$DEBUG=0; # Set to 1 to display debugging informaion.
$RecordSelectionYear=2018; # Only use records after this year.
$Host=lc($ARGV[0]); # Change the commandline argument to all lower case.
$Hostname=`hostname`;
chomp($Hostname);
#
# Specify the name and location of our output file.
# The file name include the location of the source either New Orleans or San Diego.
#
# $CookedDataOut="/home/gbrandt/scripts/perl/plotpetesdata/$Host-nsradmin_tape_monitor.dat";
$DataDir="/home/gbrandt/scripts/data";
$CookedDataOut="$DataDir/$Host-nsradmin_tape_monitor.dat";
$CookedCount=0; # Count the number of records written.
$MaxDots=10; # This the number (length) of dots displayed during processing.
# Field sample
# 0 1 2 3 Last
# 02/16/2016 Tue 10:29:06, #=1, LTO5=43
# ^ ^
# | |----- Total in Mbytes
# |
# |-----Number of sesstions
# New Field sample
# 0 1 2 3 4 Last
# 11/28/2016 Mon 16:00:38, #=31, LTO5=275, AFTD=0
# ^ ^
# | |----- Total in Mbytes
# |
# |-----Number of sesstions
#
#
##########################################################################
############### S P A W A R S H A R E D S E R V I C E S ############
##########################################################################
# Processing #
##########################################################################
#
#
use Time::Local;
unshift( @INC, "/home/scriptid/scripts/BACKUPS/SUBROUTINES" );
require introduction;
introduction("Plot Pete's Data");
#
# Get the location information from the command line.
#
if ( $#ARGV != 0 ) # Display usage information if the needed arguments
# not supplied.
{
printf " Usage: $0 NO or SD\n\n"; # Only checking New Orleans and
# San Diego.
exit;
}
#
# Get the input data file for the specific location.
#
if ( $Host eq 'sd' ) # For San Diego we need to retrieve the data over the WAN.
{
@sysout=`/usr/bin/scp -q gbrandt\@sdprodeng:/nsr/local/Tape_Monitoring/nsradmin_tape_monitor.out .`;
foreach $SYSLine (@sysout)
{
printf $SYSLine; # Display the output of the remote secure copy.
}
$DataInput="$DataDir/nsradmin_tape_monitor.out"; # Our input file is our copy.
}
else # Since there are only 2 options the other must be New Orleans.
{
$DataInput="/nsr/local/Tape_Monitoring/nsradmin_tape_monitor.out";
}
#
# Open the cooked data file for writing.
#
open (OUT,">$CookedDataOut") || die "Cannot open $CookedDataOut for writing! $!\n\n";
#
# Open Pete's tape data file.
#
open(INP, $DataInput) || die " Error: Unable to open $DataInput! $!\n\n";
#
# Read and pick out the LTO3 or LTO5 information. New Orleans will show only
# LTO5's and San Diego will show only LTO3's.
#
printf " Parcing %s.\n", $DataInput;
$Dots=0; # Initialize the dot count.
while(<INP>) # Start reading the data file.
{
tr/,//d; # Remove any ",".
if (/LTO3/ || /LTO5/ ) # Only look at lines containing these strings.
{
if($DEBUG)
{
print if (/LTO3/);
}
@field=split(/\s+/); # Split the line into fields based on while space separation.
($Dmon,$Dday,$Dyear)=split(/\//,$field[0]); # Split the first field into Month, Day, and Year.
if ($DEBUG)
{
printf " DEBUG: Dyear: $Dyear\n";
}
if ($Dyear < $RecordSelectionYear) # Because there is so much data we'll skip data not in 2016.
{
next;
}
$FileDate=$field[0];
$FileTime=$field[2];
if ($DEBUG)
{
printf "Date: %s Time: %s ", $FileDate,$FileTime;
}
@session=split(/=/, $field[3]); # Split field 4 on the "=" sign to get the sessions count.
$FileSessions=$session[-1];
if ($DEBUG)
{
printf "Sessions: %s ", $FileSessions;
}
@tmw=split(/=/, $field[4]); # Split the last field on the "=" sign to get the
# total megebytes written.
# total megebytes written.
$FileTMW=$tmw[-1];
if ($DEBUG)
{
printf "Total Megabets Written: %s\n", $FileTMW;
}
#
# Write data line.
# Date Time Sesion Count Total meg written.
printf OUT "%s %s %3d %10.3f\n",$FileDate, $FileTime, $FileSessions, $FileTMW;
if ( -t STDIN && STDOUT )
{
if ( $Dots < $MaxDots)
{
printf "."; # Display screen dots.....
$Dots++;
if ( $Dots >= $MaxDots)
{
while ( $Dots >= 0)
{
printf "\b \b";
$Dots--;
}
}
}
}
$CookedCount++; # Tally the records processed.
}
}
close(INP);
close(OUT);
chmod(0664,$CookedDataOut);
chmod(0664,"nsradmin_tape_monitor.out");
#
# Display the end of processing information.
#
printf "\n %7d records written to %s\n", $CookedCount, $DataInput;
printf "\n Generating plot file for 1,3, and 7 day history\n\n";
gen_plot_file(1); # Generate plot file for 1 day.
gen_plot_file(3); # Generate plot file for 3 days.
gen_plot_file(7); # Generate plot file for 7 days.
#
#
##########################################################################
############### S P A W A R S H A R E D S E R V I C E S ############
##########################################################################
# Sub Rouines #
##########################################################################
#
#
sub gen_plot_file()
{
$Duration =shift;
$PFName="$DataDir/$Host-PlotDays-$Duration.plt";
$VPFName="$DataDir/$Host-VPlotDays-$Duration.plt";
printf " Generating %s and %s plotfiles\n", $PFName, $VPFName;
printf " gnuplot %s\n",$VPFName;
printf " gnuplot %s|lp\n\n",$PFName;
@month = qw( January February March April May June July August September October November December );
( $sec, $min, $hour, $mday, $mon, $year ) = localtime();
$elapsed = 24 * 60 * 60 * $Duration; # Time duration.
$StartDate = timelocal( 0, 0, 12, $mday, $mon, $year ) - $elapsed;
( $ysec, $ymin, $yhour, $ymday, $ymon, $yyear ) = localtime($StartDate);
$Start = sprintf "%02d/%02d/%04d",$ymon + 1,$ymday,$yyear + 1900;
open (PLT, ">$PFName") || die " Unable to open $PFName $!!\n";
open(VPLT, ">$VPFName") || die " Unable to open $VPFName $!!\n";
printf PLT "set terminal postscript color\n";
printf VPLT "set terminal x11 persist\n";
if ( $Host eq 'sd' )
{
printf PLT "set title \"sdprodeng Tape I/O ($Start - Present)\" font \"CenturyGothic-BoldItalic.ttf,24\"\n";
printf VPLT "set title \"sdprodeng Tape I/O ($Start - Present)\" font \"CenturyGothic-BoldItalic.ttf,24\"\n";
}
else
{
printf PLT "set title \"$Hostname Tape I/O ($Start - Present)\" font \"CenturyGothic-BoldItalic.ttf,24\"textcolor \"sea-green\"\n";
printf VPLT "set title \"$Hostname Tape I/O ($Start - Present)\" font \"CenturyGothic-BoldItalic.ttf,24\" textcolor \"sea-green\"\n";
}
printf PLT "set grid\n";
printf VPLT "set grid\n";
printf PLT "set fontpath \"/usr/X11R6/lib/X11/fonts/Type1\" \"/usr/X11R6/lib/X11/fonts/TrueType\"\n";
printf VPLT "set fontpath \"/usr/X11R6/lib/X11/fonts/Type1\" \"/usr/X11R6/lib/X11/fonts/TrueType\"\n";
printf PLT "set timefmt \"%m/%%d/%Y %H:%M:%S\"\n";
printf VPLT "set timefmt \"%m/%%d/%Y %H:%M:%S\"\n";
printf PLT "set xdata time\n";
printf VPLT "set xdata time\n";
printf PLT "set format x \"%m/%%d %H:%M\"\n";
printf VPLT "set format x \"%m/%%d %H:%M\"\n";
printf PLT "set ylabel \"Megabytes written/second\"\n";
printf VPLT "set ylabel \"Megabytes written/second\"\n";
printf PLT "set xlabel \"Time\" offset 0, -2\n";
printf VPLT "set xlabel \"Time\" offset 0, -2\n";
printf PLT "set format x \"%m/%%d %H:%M\"\n";
printf VPLT "set format x \"%m/%%d %H:%M\"\n";
printf PLT "set ylabel \"Megabytes written/second\"\n";
printf VPLT "set ylabel \"Megabytes written/second\"\n";
printf PLT "set xlabel \"Time\" offset 0, -2\n";
printf VPLT "set xlabel \"Time\" offset 0, -2\n";
printf PLT "set xrange [\"$Start 15:00\":*]\n";
printf VPLT "set xrange [\"$Start 15:00\":*]\n";
printf PLT "set ytics axis font \"helvetica,16\"\n";
printf VPLT "set ytics axis font \"helvetica,16\"\n";
printf PLT "set xtics axis font \"helvetica,16\" rotate by -45\n";
printf VPLT "set xtics axis font \"helvetica,16\" rotate by -45\n";
if ( $Host eq 'sd' )
{
printf PLT "# set yrange [0: 500]\n";
printf VPLT "# set yrange [0: 500]\n";
printf PLT "set ytics scale 0 500 100\n";
printf VPLT "set ytics scale 0 500 100\n";
printf PLT "set y2range [0:60]\n";
printf VPLT "set y2range [0:60]\n";
printf PLT "set y2tics scale 0 60 5 textcolor \"red\"\n";
printf VPLT "set y2tics scale 0 60 5 textcolor \"red\"\n";
}
else
{
printf PLT "# set yrange [0: 1400]\n";
printf VPLT "# set yrange [0: 1400]\n";
printf PLT "set ytics scale 0 1400 100 textcolor \"sea-green\"\n";
printf VPLT "set ytics scale 0 1400 100 textcolor \"sea-green\"\n";
printf PLT "set y2range [0:60]\n";
printf VPLT "set y2range [0:60]\n";
printf PLT "set y2tics scale 0 60 5 textcolor \"black\"\n";
printf VPLT "set y2tics scale 0 60 5 textcolor \"black\"\n";
}
printf PLT "plot \"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:4 with lines lt 1 lc \"pink\" ti \"Total Mbytes/s\", \\\n";
printf PLT "\"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:4 with lines lt 1 lc \"green\" lw 2 ti \"Total Mbytes/s smoothed\" smooth csplines,\\\n";
printf PLT "\"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:3 with lines lt 1 lc \"blue\" ti \"Total Concurrent Sessions\", \\\n";
printf VPLT "plot \"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:4 with lines lt \"pink\" lc \"pink\" ti \"Total Mbytes/s\", \\\n";
printf VPLT "\"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:4 with lines lt 1 lc \"green\" lw 2 ti \"Total Mbytes/s smoothed\" smooth csplines,\\\n";
printf VPLT "\"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:3 with lines lt 1 lc \"blue\" ti \"Total Concurrent Sessions\", \\\n";
printf VPLT "\"$DataDir/$Host-nsradmin_tape_monitor.dat\" using 1:(\$4/\$3) with lines lt 1 lc \"black\" lw 2 ti \\\n";
printf VPLT "\"Ratio Total MB/s to Total Concurrent Sessions (scale 0 - 60)\" smooth sbezier axes x1y2\n";
close(PLT);
close(VPLT);
chmod(0664,PLT);
chmod(0664,VPLT);
}
#
#
##########################################################################
############### S P A W A R S H A R E D S E R V I C E S ############
##########################################################################
# House Keeping #
##########################################################################
#
#