blob: ccdef35b014bf4158061818182a05923ec06986a (
plain)
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
|
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# Copyright (c) 2013 EPAM Systems
#------------------------------------------------------------------------------
#
# This file is part of Nfstrace.
#
# Nfstrace is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# Nfstrace is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------
usage()
{
cat << EOF
Graph images by data provided by analyzers.
usage: analyzers/nst.sh -a analyzers/breakdown.plt -d . -p "breakdown*.dat"
OPTIONS:
-h Show this message.
-a Set path to the analyzer.
-d Directory contained i_files-files. Pattern: <analyzer>(.)*.dat
-f Use specific file as i_files-file.
-p Pattern used for file search.
-r Recursive search.
-v Verbose.
Known issues:
Supported just one analyzer ('-a' option) at a time.
EOF
}
o_ext=.png
analyzer=
directories=()
i_files=()
while getopts “ha:d:f:p:rv” option; do
case "$option" in
h)
usage
exit
;;
a)
if [[ ! -z "$analyzer" ]] ; then
usage
exit 1
fi
analyzer="$OPTARG"
;;
d)
directories+=("$OPTARG")
;;
f)
i_files+=("$OPTARG")
;;
p)
pattern="$OPTARG"
;;
r)
recursive=1
;;
v)
verbose=1
;;
?)
usage
exit
;;
esac
done
for directory in "${directories[@]}"; do
for filename in "$directory/$pattern"; do
i_files+=("$filename")
done
done
if [[ -z "$analyzer" ]] || [[ -z "$i_files" ]] ; then
usage
exit 1
fi
OIFS="${IFS}"
IFS=$'\n'
for i_file in "${i_files[@]}" ; do
o_file="${i_file/%$i_ext/$o_ext}"
gnuplot -e "i_file='$i_file';o_file='$o_file'" "$analyzer$e_ext" &>/dev/null
result=$?
if [[ ! -z "$verbose" ]] ; then
echo "gnuplot -e \"i_file='$i_file';o_file='$o_file'\" $analyzer$e_ext"
if [[ ! $result == 0 ]] ; then
echo "fail during $i_file processing (return: $result)" 1>&2
exit 1
fi
fi
done
IFS="${OIFS}"
|