zhaog / aspersa

Automatically exported from code.google.com/p/aspersa
0 stars 0 forks source link

script error in diskstats #81

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Running freshly checked out diskstats:

# ./diskstats -d sda 
./diskstats: line 550: group_by_: command not found

#./diskstats -d sda -g all
./diskstats: line 550: group_by_: command not found

Source around the line 550:

   if [ -z "${READ_FILE}" ]; then
      group_by_${OPT_g} "${OPT_k}"
   else
      group_by_${OPT_g} $@
   fi

Original issue reported on code.google.com by fig...@gmail.com on 6 Feb 2011 at 6:36

GoogleCodeExporter commented 8 years ago
Interesting, it must be an error in the command-line option parsing code.  What 
do you get if you do this?

. ./diskstats
generate_parse_options ./diskstats

And what is your awk and bash version, and operating system version?

Original comment by baron.schwartz on 6 Feb 2011 at 10:09

GoogleCodeExporter commented 8 years ago
It's a stock RHEL 5.6 x86-64, with stock awk and bash:

$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ awk --version
GNU Awk 3.1.5

Output of "generate_parse_options ./diskstats"

   for o; do
      case "${o}" in
         --)
            shift; break;
            ;;
         --help)
            usage;
            ;;
         -c)
            shift; OPT_c="${1}"; shift;
            ;;
         -d)
            shift; OPT_d="${1}"; shift;
            ;;
         -g)
            shift; OPT_g="${1}"; shift;
            case "${OPT_g}" in
               disk)
                  ;;
               sample)
                  ;;
               all)
                  ;;
               *) 
                  OPT_ERR="Bad option value";
                  usage
                  ;;
            esac
            ;;
         -i)
            shift; OPT_i="${1}"; shift;
            ;;
         -k)
            shift; OPT_k="${1}"; shift;
            ;;
         -n)
            shift; OPT_n="${1}"; shift;
            ;;
         -s)
            shift; OPT_s="${1}"; shift;
            ;;
         -*)
            OPT_ERR="Unknown option ${o}."
            usage
            ;;
      esac
   done
   export OPT_i="${OPT_i:-}";
   export OPT_k="${OPT_k:-/tmp/aspersa}";
   export OPT_n="${OPT_n:-}";
   export OPT_c="${OPT_c:-cnc|rt|mb|busy|prg}";
   export OPT_d="${OPT_d:-}";
   export OPT_s="${OPT_s:-1}";
   export OPT_g="${OPT_g:-disk}";

Original comment by fig...@gmail.com on 6 Feb 2011 at 12:06

GoogleCodeExporter commented 8 years ago
Hm, that's interesting.  I can repro it easily on a CentOS virtual box too.  I 
fixed it.  Apparently sourcing a file isn't a good way to parse command-line 
options.

Original comment by baron.schwartz on 6 Feb 2011 at 1:08

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r336.

Embed option-parsing code directly into tools

Original comment by baron.schwartz on 6 Feb 2011 at 1:27

GoogleCodeExporter commented 8 years ago
Yes, it fixed the issue. Thanks for the quick response!

Original comment by fig...@gmail.com on 6 Feb 2011 at 3:01

GoogleCodeExporter commented 8 years ago
I'm going to just include the generated command-line code directly instead of 
making it magically generate and source the code.  No further changes needed to 
the code.

Original comment by baron.schwartz on 10 Feb 2011 at 1:56