File: amplot.sh.in

package info (click to toggle)
amanda 1%3A2.4.0-3
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 3,228 kB
  • ctags: 3,359
  • sloc: ansic: 30,812; sh: 3,768; makefile: 616; perl: 591; awk: 331; lex: 121; yacc: 73
file content (163 lines) | stat: -rw-r--r-- 4,574 bytes parent folder | download
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
#!/bin/sh
# Amanda, The Advanced Maryland Automatic Network Disk Archiver
# Copyright (c) 1992,1993,1994,1995 University of Maryland
# All Rights Reserved.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of U.M. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission.  U.M. makes no representations about the
# suitability of this software for any purpose.  It is provided "as is"
# without express or implied warranty.
#
# U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Author: Olafur Gudumundsson, (ogud@tis.com)  Trusted Information Systems
# Formerly at: 		  Systems Design and Analysis Group
#			  Computer Science Department
#			  University of Maryland at College Park
#
#	Amplot: a program to generate postscript plots of each nights amanda 
#	performance 
# 
#	Author: Olafur Gudmundsson (ogud@tis.com) 
#	Creation Date: April 1992 
#	Last modified: April 1995 
#	Input: list of amdumps 
#	Output: Plot of amdump files as either gnuplots on the screen or
#		Postscript files 
#

prefix=@prefix@
exec_prefix=@exec_prefix@
sbindir=@sbindir@
libexecdir=@libexecdir@
 
confdir=@CONFIG_DIR@
 
PATH=$libexecdir:@sbindir@:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:$PATH
export PATH

AWK=@AWK@
AVARFLAG=@AWK_VAR_ASSIGNMENT_OPT@
GNUPLOT=@GNUPLOT@
COMPRESS=@AMPLOT_COMPRESS@

if [ $# -eq 0 ] ; then
	echo "Usage: $0 [-c] [-e] [-g] [-l] [-p] [-t hours] <amdump_files.[gz,z,Z]>"
	echo "amplot generates plot for screen with fixed dimensions"
	echo "	-c	Compress the input amdump files after plotting"
	echo "	-e	Extends x (time) axes if needed"
	echo "	-g	Run gnuplot directly no postscript file generated DEFAULT"
	echo "	-l	Landscape mode suitable for printing"
	echo "	-p	Postscript output"
	echo "	-t T	Set the right edge of the plot to be T hours"
	exit 1 
fi

tmp_files="bandw_free disk_alloc dump_idle finished run_queue tape_* title" 

if [ -r disk_alloc ] ; then	# clean up
	/bin/rm -f $tmp_files 
fi 

my_plot=$libexecdir/amplot.g
paper=0 
gnuplot=1
cmpres=0
para=""
maxtime=4

# setting up the parameters to pass to [gn]awk 
while [	$1 = "-c" -o \
	$1 = "-e" -o \
	$1 = "-g" -o \
	$1 = "-l" -o \
	$1 = "-p" -o \
	$1 = "-t" ] ; do 
	if [ $1 = "-c" ] ; then
		cmpres=1
	fi
	if [ $1 = "-e" ] ; then 
		para=$para"$AVARFLAG extend=1 "
	fi
	if [ $1 = "-g" ] ; then
		gnuplot=1 
	fi
	if [ $1 = "-l" ] ; then 
		paper=1
		para=$para"$AVARFLAG paper=1 "
	fi		
	if [ $1 = "-p" ] ; then 
		gnuplot=0;
	fi
	if [ $1 = "-t" ] ; then
		shift
		if [ $# -eq 0 ] ; then
			echo "amplot: no argument for -t option" 1>&2
			exit 5
		fi
		maxtime=$1
	fi
	shift; 
	if [ $# -eq 0 ] ; then 
		echo "amplot: no input files" 1>&2
		exit 5
	fi
done
para=$para"$AVARFLAG maxtime=$maxtime"

if [ $gnuplot  -eq 1 ] ; then
	my_plot=$my_plot"p"		# use the plot prog that pauses
	plot=" -geometry 800x700+40+0" 
	para=$para"$AVARFLAG gnuplot=1 "
	echo "Displaying graph on the screen, <CR> for next graph"

	if [ $paper -eq 1 ] ; then
		echo "amplot: -l requires -p flag at the same time" 1>&2
		exit 6 
	fi
fi

list="";		# files to compress at the end

for i in $* 		# for all the input files
do
	f=$i;
	if [ ! -f $f ] ; then 
		f=`ls $i $i.*[zZ] 2>/dev/null`
	fi
	if [ -f "$f" ] ; then 		# found file 
                disp=`$AWK -f $libexecdir/amcat.awk $AVARFLAG f="$f"`
		if [ -z $disp ] ; then 
			echo "Do not know how to [gz|z]cat this file"
		else
			$disp $f | $AWK -f $libexecdir/amplot.awk $para
			$GNUPLOT $plot $my_plot
			if [ $disp = "cat" -a  $cmpres -eq 1 ] ; then
				list=$list" "$f
			fi
		fi
	else 				# check if file has been compressed
		echo "No such file $i or $i.*[zZ]"
	fi
done

if [ -r disk_alloc ] ; then
	/bin/rm -f $tmp_files 
fi 

if [ "$list" != "" ] ; then		# now compress the files we worked on
# comment out next line if you do not want compression at the end
	echo "Compressing $list"
	$COMPRESS $list
fi
exit 0