3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ASCII textでgraph

Last updated at Posted at 2016-07-15

動機

JVM HEAPのOld領域使用量に増加傾向がないか、コンソールで確認したかった。

素材

以下のスクリプトで

#!/bin/bash
grep -B13 -A7 "^Heap af" \
|
grep  -e "^20" -e "^ par new" -e "^ concurrent" \
|
sed -e "s/^\([0-9T:-]\{19\}\).*$/\1/;" \
|
sed -e "s/^.*\(new\).* generation.*total \([0-9]\+\)K, used \([0-9]\+\)K.*$/\1 \2 \3/; " \
|
sed -e "s/^.*\(concurrent\).* generation.*total \([0-9]\+\)K, used \([0-9]\+\)K.*$/\1 \2 \3/; " \
|
awk '$1~/^20/{now=$1} $1~/new/{new=100*$3/$2} $1~/concurrent/{old=100*$3/$2; printf("%s %5.1f %5.1f\n",now,new,old)}'

以下の様な、時間、new領域使用率、old領域使用率を抽出した

% head xgc
2016-07-14T18:44:28  88.9   0.0
2016-07-14T18:44:28   0.7   0.0
2016-07-14T19:02:40  89.6   0.0
2016-07-14T19:02:41   1.7   0.1
2016-07-14T19:13:53  90.6   0.1
2016-07-14T19:13:54   1.4   0.7
2016-07-14T19:17:53  90.3   0.7
2016-07-14T19:17:53   0.5   0.8
2016-07-14T19:18:07  89.4   0.8
2016-07-14T19:18:08   0.3   0.8

実践

newはだしても意味がないのでoldをだしてみる

$ gnuplot
gnuplot> set terminal dumb 240, 50
gnuplot> set xdata time
gnuplot> set timefmt "%Y-%m-%dT%H:%M:%S"
gnuplot> set format x "%Y-%m-%dT%H:%M:%S"
gnuplot> set xrange ["2016-07-14T18:44:28":"2016-07-15T10:44:28"]
gnuplot> set yrange [0:100]
gnuplot> plot "xgc" using 1:3 with lines
  100 ++--+-------------+-------------+--------------+-------------+--------------+-------------+-------------+--------------+-------------+-------------+--------------+-------------+--------------+-------------+-------------+---------++
      |                 +                            +                            +                           +                            +                            +                            +               "xgc" using 1:3 ****** |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
   80 ++                                                                                                                                                                                                                                   ++
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                                                                                                                                                                                                     |
      |                                                      *                                                                                 *             *             *             *             *              *                    *|
      |                                                      *                                                                                 *             *             *             *             *              *                    *|
      |                                                      *                                                                        *       **            **            **             *            **              *                   **|
      |                                                     **                                                                       **       **            **            **            **            **              *                   **|
      |                                                     **                                                                       **       **            **            **            **            **             **                   **|
   60 ++                                                   ***                                                                       **       **            **           ***            **            **             **                   **+
      |                                                    * *              *                                                       ***      ***           ***           * *           ***     *     ***      *      **            *     ***|
      |                                                    * *              *                                                       * *      * *           * *           * *           * *     *     * *     **     ***           **     * *|
      |                                                   ** *             **                                                      ** *      * *           * *           * *           * *     *     * *     **     * *           **     * *|
      |                                                   *  *             **                                                      *  *     ** *          ** *          ** *     *     * *    **     * *     **     * *           **     * *|
      |                                                   *  *            ***                                                     **  *     *  *          *  *          *  *    **    ** *    **    ** *    ***     * *     *     **    ** *|
      |                               **********         **  *            * *                                                     *   *     *  *          *  *    *     *  *    **    *  *    **    *  *    * *    ** *     *    ***    *  *|
      |                               *        *         *   *            * *                                                    **   *    **  *          *  *    *     *  *    **    *  *    **    *  *    * *    *  *    **    * *    *  *|
      |                              *         *        **   *           ** *                                                    *    *    *   *         *   *    *    *   *    **    *  *   ***    *  *   ** *    *  *    **    * *   **  *|
   40 ++                             *         *        *    *           *  *                                                   **    *    *   *         *   *   **    *   *   ***   **  *   * *   **  *   *  *   **  *    **    * *   *   *+
      |                             **         *        *    *          **  *                                                  **     *    *   *    *    *   *   **    *   *   * *   *   *   * *   *   *   *  *   *   *   ***   *  *   *   *|
      |                             *          *       **    *          *   *                                                  *      *   **   *   **   **   *   **   **   *   * *   *   *   * *   *   *   *  *   *   *   * *   *  *   *   *|
      |                            **          *       *     *         **   *                                                 **      *   *    *   **   *    *   **   *    *  ** *  **   *  ** *   *   *  *   *  **   *   * *   *  *  **   *|
      |                            *           *       *     *         *    *               **************                    *       *   *    *   **   *    *  ***   *    *  *  *  *    *  *  *  **   *  *   *  *    *   * *  **  *  *    *|
      |                           **           *      **     *        **    *               *            *                   **       *  **    *   **  **    *  * *   *    *  *  *  *    *  *  *  *    *  *   *  *    *  ** *  *   *  *    *|
      |                           *            *      *      *        *     *               *            *                   *        *  *     *  ***  *     *  * *  *     *  *  *  *    *  *  *  *    * **   *  *    *  *  *  *   * **    *|
      |                           *            *      *      *       **     *   *********** *            *                  **        *  *     *  * *  *     * ** *  *     * **  * **    * **  *  *    * *    * **    *  *  *  *   * *     *|
      |                          *             *     *       *   *****      *  **         * *            *             *    *         * **     *  * *  *     * *  *  *     * *   * *     * *   * **    * *    * *     *  *  * **   * *     *|
   20 ++                         *             *     *       *   *          *  *          * *            *            **   **         * *      * ** * **     * *  * **     * *   * *     * *   * *     * *    * *      ***  * *    * *     *+
      |                         **             *    **       *  **          * **          * *            *            **   *          * *      * *  * *      * *  * *      ***   * *     ***   * *     ***    ***      **   * *    ***     *|
      |                  ********              *    *        *  *           * *           * *            *           ***  **          ***      * *  * *      ***  * *      **    ***     **    * *     **     **       **   ***    **      *|
      |                 **                     *   **        *  *           ***           * *            *          ** *  *           **       ***  ***      **   * *      **    **      **    ***     **     **       **   **     **      **
      |                 *                      *   *         * **           **            * *            *          *  * **           **       **   **       **   **       **    **      **    **      **     **       *    **     **      **
      |                **                      *  **         * *            **            * *            *         **  ***            **       **   **       **   **       **    **      **    **      **     **       *    **     **      **
      |                *                       * **          ***            **            * *            *        **   **             *        **   **       *    **       *     *       *     **      *      *        *    **     *       *|
      |               **                       ***           **             *             ***            **********    **             *        *    *        *    **       *     *       *     **      *      *        *    *      *       *|
      |        ******** +                            +                            +                           +        *              *    +                            +                            +                           +          |
    0 **********--------+-------------+--------------+-------------+--------------+-------------+-------------+--------------+-------------+-------------+--------------+-------------+--------------+-------------+-------------+---------++
               2016-07-14T20:00:00          2016-07-14T22:00:00          2016-07-15T00:00:00         2016-07-15T02:00:00          2016-07-15T04:00:00          2016-07-15T06:00:00          2016-07-15T08:00:00         2016-07-15T10:00:00

デフォルトのちっちゃいサイズ

gnuplot> set terminal dumb 79 24
gnuplot> replot

  100 ++---+----+---+---+----+---+---+----+---+---+----+---+---+---+----+-++
      |    +        +        +       +        +     "xgc" using 1:3 ****** |
      |                                                                    |
      |                                                                    |
   80 ++                                                                  ++
      |                                                                    |
      |               **                    *  *   *   *    *   *   **     *
      |               **                    *  *   *   *   **   *   **    **
   60 ++              **   *                *  *   *   *   ** *** * **  * **
      |               **   *               ** **   *   * * ****** * **  * **
      |         ***  ***  **               ** **  ** *** * ******** *** * **
   40 ++       ** *  * *  **               ** **  ** *** * ************ * **
      |        *  *  * *  **              *** ********** *********** *******
      |        *  *  * * ***    *****     * *************** ******** ***** *
      |       **  * ** * * ******   *    ** ** ************ *** **** ***** *
   20 ++      *   * *  *** **  **   *   **  ** *** ******** * * **** *****+*
      |     ***   * *  **  **  **   *  ***  ** *** *** **** * * * ** ***** *
      |    **     ***  *   *   **   *  ***  ** *** *** **** * * * *  ***** *
      |    *      **+  *   * + **   *****   **+* * * * ***  * *+* *  ** *  *
    0 ******----+---+---+----+---+---+--*-+---+---+----+---+---+---+----+-++
  2016-07-14T20:00:00T22:00:00T00:00:0002:00:00T04:00:00T06:00:0008:00:00:00:00

gnuplot>

画像の場合

画像で答え合わせ

gnuplot> set terminal png
gnuplot> set out "xgc.png"
gnuplot> replot

xgc.png

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?