Want to subscribe to topics you're interested in?
Become a Member

Beta Branch update cminfo command add sar-json option in 123.09beta01

Discussion in 'Centmin Mod Github Commits' started by eva2000, Sep 16, 2020.

  1. eva2000

    eva2000 Administrator Staff Member

    45,671
    10,368
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,090
    Local Time:
    12:07 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    update cminfo command add sar-json option in 123.09beta01

    Add to cmfino command a new sar-json option to output system stats in json format using sadf.

    Example commands will respectively print out current system stats and print out 3x 1 second interval stats in pretty json format and the last 2 commands and do the same in compact json format

    cminfo sar-json
    cminfo sar-json 3
    cminfo sar-json | jq -c
    cminfo sar-json 3 | jq -c

    Continue reading...

    123.09beta01 branch
     
  2. eva2000

    eva2000 Administrator Staff Member

    45,671
    10,368
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,090
    Local Time:
    12:07 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    examples
    Code (Text):
    cminfo sar-json  
    {
      "timestamp": {
        "date": "2020-09-15",
        "time": "00:05:01",
        "utc": 1,
        "interval": 300
      },
      "cpu-load": [
        {
          "cpu": "all",
          "user": 0.44,
          "nice": 0,
          "system": 0.26,
          "iowait": 0.03,
          "steal": 0,
          "idle": 99.26
        }
      ],
      "process-and-context-switch": {
        "proc": 1.28,
        "cswch": 127.39
      },
      "io": {
        "tps": 2.73,
        "io-reads": {
          "rtps": 1.36,
          "bread": 123.14
        },
        "io-writes": {
          "wtps": 1.37,
          "bwrtn": 78.94
        }
      },
      "memory": {
        "memfree": 133904,
        "memused": 880780,
        "memused-percent": 86.8,
        "buffers": 100,
        "cached": 267904,
        "commit": 1398780,
        "commit-percent": 67.79,
        "active": 276412,
        "inactive": 343136,
        "dirty": 8,
        "swpfree": 959228,
        "swpused": 89344,
        "swpused-percent": 8.52,
        "swpcad": 3240,
        "swpcad-percent": 3.63
      },
      "queue": {
        "runq-sz": 2,
        "plist-sz": 125,
        "ldavg-1": 0,
        "ldavg-5": 0.01,
        "ldavg-15": 0.05,
        "blocked": 0
      },
      "disk": [
        {
          "disk-device": "dev253-0",
          "tps": 2.73,
          "rd_sec": 123.14,
          "wr_sec": 78.94,
          "avgrq-sz": 73.99,
          "avgqu-sz": 0.01,
          "await": 2.08,
          "svctm": 0.25,
          "util-percent": 0.07
        }
      ]
    }
    

    Code (Text):
    cminfo sar-json 3
    {
      "timestamp": {
        "date": "2020-09-15",
        "time": "00:05:01",
        "utc": 1,
        "interval": 300
      },
      "cpu-load": [
        {
          "cpu": "all",
          "user": 0.44,
          "nice": 0,
          "system": 0.26,
          "iowait": 0.03,
          "steal": 0,
          "idle": 99.26
        }
      ],
      "process-and-context-switch": {
        "proc": 1.28,
        "cswch": 127.39
      },
      "io": {
        "tps": 2.73,
        "io-reads": {
          "rtps": 1.36,
          "bread": 123.14
        },
        "io-writes": {
          "wtps": 1.37,
          "bwrtn": 78.94
        }
      },
      "memory": {
        "memfree": 133904,
        "memused": 880780,
        "memused-percent": 86.8,
        "buffers": 100,
        "cached": 267904,
        "commit": 1398780,
        "commit-percent": 67.79,
        "active": 276412,
        "inactive": 343136,
        "dirty": 8,
        "swpfree": 959228,
        "swpused": 89344,
        "swpused-percent": 8.52,
        "swpcad": 3240,
        "swpcad-percent": 3.63
      },
      "queue": {
        "runq-sz": 2,
        "plist-sz": 125,
        "ldavg-1": 0,
        "ldavg-5": 0.01,
        "ldavg-15": 0.05,
        "blocked": 0
      },
      "disk": [
        {
          "disk-device": "dev253-0",
          "tps": 2.73,
          "rd_sec": 123.14,
          "wr_sec": 78.94,
          "avgrq-sz": 73.99,
          "avgqu-sz": 0.01,
          "await": 2.08,
          "svctm": 0.25,
          "util-percent": 0.07
        }
      ]
    }
    {
      "timestamp": {
        "date": "2020-09-15",
        "time": "00:10:01",
        "utc": 1,
        "interval": 300
      },
      "cpu-load": [
        {
          "cpu": "all",
          "user": 0.07,
          "nice": 0,
          "system": 0.14,
          "iowait": 0,
          "steal": 0,
          "idle": 99.79
        }
      ],
      "process-and-context-switch": {
        "proc": 0.94,
        "cswch": 126.81
      },
      "io": {
        "tps": 0.3,
        "io-reads": {
          "rtps": 0,
          "bread": 0
        },
        "io-writes": {
          "wtps": 0.3,
          "bwrtn": 4.78
        }
      },
      "memory": {
        "memfree": 135092,
        "memused": 879592,
        "memused-percent": 86.69,
        "buffers": 100,
        "cached": 267920,
        "commit": 1396804,
        "commit-percent": 67.7,
        "active": 275268,
        "inactive": 343136,
        "dirty": 8,
        "swpfree": 959228,
        "swpused": 89344,
        "swpused-percent": 8.52,
        "swpcad": 3240,
        "swpcad-percent": 3.63
      },
      "queue": {
        "runq-sz": 1,
        "plist-sz": 122,
        "ldavg-1": 0,
        "ldavg-5": 0.01,
        "ldavg-15": 0.05,
        "blocked": 0
      },
      "disk": [
        {
          "disk-device": "dev253-0",
          "tps": 0.3,
          "rd_sec": 0,
          "wr_sec": 4.78,
          "avgrq-sz": 15.91,
          "avgqu-sz": 0,
          "await": 1.16,
          "svctm": 0.33,
          "util-percent": 0.01
        }
      ]
    }
    {
      "timestamp": {
        "date": "2020-09-15",
        "time": "00:15:01",
        "utc": 1,
        "interval": 300
      },
      "cpu-load": [
        {
          "cpu": "all",
          "user": 0.07,
          "nice": 0,
          "system": 0.15,
          "iowait": 0,
          "steal": 0,
          "idle": 99.78
        }
      ],
      "process-and-context-switch": {
        "proc": 0.96,
        "cswch": 134.31
      },
      "io": {
        "tps": 0.31,
        "io-reads": {
          "rtps": 0,
          "bread": 0.11
        },
        "io-writes": {
          "wtps": 0.31,
          "bwrtn": 4.7
        }
      },
      "memory": {
        "memfree": 133888,
        "memused": 880796,
        "memused-percent": 86.8,
        "buffers": 100,
        "cached": 267944,
        "commit": 1398780,
        "commit-percent": 67.79,
        "active": 276384,
        "inactive": 343136,
        "dirty": 8,
        "swpfree": 959228,
        "swpused": 89344,
        "swpused-percent": 8.52,
        "swpcad": 3240,
        "swpcad-percent": 3.63
      },
      "queue": {
        "runq-sz": 1,
        "plist-sz": 123,
        "ldavg-1": 0,
        "ldavg-5": 0.01,
        "ldavg-15": 0.05,
        "blocked": 0
      },
      "disk": [
        {
          "disk-device": "dev253-0",
          "tps": 0.31,
          "rd_sec": 0.11,
          "wr_sec": 4.7,
          "avgrq-sz": 15.47,
          "avgqu-sz": 0,
          "await": 1.17,
          "svctm": 0.38,
          "util-percent": 0.01
        }
      ]
    }
    

    and compact json
    Code (Text):
    cminfo sar-json | jq -c
    {"timestamp":{"date":"2020-09-15","time":"00:05:01","utc":1,"interval":300},"cpu-load":[{"cpu":"all","user":0.44,"nice":0,"system":0.26,"iowait":0.03,"steal":0,"idle":99.26}],"process-and-context-switch":{"proc":1.28,"cswch":127.39},"io":{"tps":2.73,"io-reads":{"rtps":1.36,"bread":123.14},"io-writes":{"wtps":1.37,"bwrtn":78.94}},"memory":{"memfree":133904,"memused":880780,"memused-percent":86.8,"buffers":100,"cached":267904,"commit":1398780,"commit-percent":67.79,"active":276412,"inactive":343136,"dirty":8,"swpfree":959228,"swpused":89344,"swpused-percent":8.52,"swpcad":3240,"swpcad-percent":3.63},"queue":{"runq-sz":2,"plist-sz":125,"ldavg-1":0,"ldavg-5":0.01,"ldavg-15":0.05,"blocked":0},"disk":[{"disk-device":"dev253-0","tps":2.73,"rd_sec":123.14,"wr_sec":78.94,"avgrq-sz":73.99,"avgqu-sz":0.01,"await":2.08,"svctm":0.25,"util-percent":0.07}]}
    

    Code (Text):
    cminfo sar-json 3 | jq -c
    {"timestamp":{"date":"2020-09-15","time":"00:05:01","utc":1,"interval":300},"cpu-load":[{"cpu":"all","user":0.44,"nice":0,"system":0.26,"iowait":0.03,"steal":0,"idle":99.26}],"process-and-context-switch":{"proc":1.28,"cswch":127.39},"io":{"tps":2.73,"io-reads":{"rtps":1.36,"bread":123.14},"io-writes":{"wtps":1.37,"bwrtn":78.94}},"memory":{"memfree":133904,"memused":880780,"memused-percent":86.8,"buffers":100,"cached":267904,"commit":1398780,"commit-percent":67.79,"active":276412,"inactive":343136,"dirty":8,"swpfree":959228,"swpused":89344,"swpused-percent":8.52,"swpcad":3240,"swpcad-percent":3.63},"queue":{"runq-sz":2,"plist-sz":125,"ldavg-1":0,"ldavg-5":0.01,"ldavg-15":0.05,"blocked":0},"disk":[{"disk-device":"dev253-0","tps":2.73,"rd_sec":123.14,"wr_sec":78.94,"avgrq-sz":73.99,"avgqu-sz":0.01,"await":2.08,"svctm":0.25,"util-percent":0.07}]}
    {"timestamp":{"date":"2020-09-15","time":"00:10:01","utc":1,"interval":300},"cpu-load":[{"cpu":"all","user":0.07,"nice":0,"system":0.14,"iowait":0,"steal":0,"idle":99.79}],"process-and-context-switch":{"proc":0.94,"cswch":126.81},"io":{"tps":0.3,"io-reads":{"rtps":0,"bread":0},"io-writes":{"wtps":0.3,"bwrtn":4.78}},"memory":{"memfree":135092,"memused":879592,"memused-percent":86.69,"buffers":100,"cached":267920,"commit":1396804,"commit-percent":67.7,"active":275268,"inactive":343136,"dirty":8,"swpfree":959228,"swpused":89344,"swpused-percent":8.52,"swpcad":3240,"swpcad-percent":3.63},"queue":{"runq-sz":1,"plist-sz":122,"ldavg-1":0,"ldavg-5":0.01,"ldavg-15":0.05,"blocked":0},"disk":[{"disk-device":"dev253-0","tps":0.3,"rd_sec":0,"wr_sec":4.78,"avgrq-sz":15.91,"avgqu-sz":0,"await":1.16,"svctm":0.33,"util-percent":0.01}]}
    {"timestamp":{"date":"2020-09-15","time":"00:15:01","utc":1,"interval":300},"cpu-load":[{"cpu":"all","user":0.07,"nice":0,"system":0.15,"iowait":0,"steal":0,"idle":99.78}],"process-and-context-switch":{"proc":0.96,"cswch":134.31},"io":{"tps":0.31,"io-reads":{"rtps":0,"bread":0.11},"io-writes":{"wtps":0.31,"bwrtn":4.7}},"memory":{"memfree":133888,"memused":880796,"memused-percent":86.8,"buffers":100,"cached":267944,"commit":1398780,"commit-percent":67.79,"active":276384,"inactive":343136,"dirty":8,"swpfree":959228,"swpused":89344,"swpused-percent":8.52,"swpcad":3240,"swpcad-percent":3.63},"queue":{"runq-sz":1,"plist-sz":123,"ldavg-1":0,"ldavg-5":0.01,"ldavg-15":0.05,"blocked":0},"disk":[{"disk-device":"dev253-0","tps":0.31,"rd_sec":0.11,"wr_sec":4.7,"avgrq-sz":15.47,"avgqu-sz":0,"await":1.17,"svctm":0.38,"util-percent":0.01}]}
    

    Filtering using jq command tool

    return only cpu-load stats
    Code (Text):
    sar-json | jq -r '.["cpu-load"]'
    [
      {
        "cpu": "all",
        "user": 0.44,
        "nice": 0,
        "system": 0.26,
        "iowait": 0.03,
        "steal": 0,
        "idle": 99.26
      }
    ]
    

    only memory
    Code (Text):
    cminfo sar-json | jq -r '.memory'  
    {
      "memfree": 133904,
      "memused": 880780,
      "memused-percent": 86.8,
      "buffers": 100,
      "cached": 267904,
      "commit": 1398780,
      "commit-percent": 67.79,
      "active": 276412,
      "inactive": 343136,
      "dirty": 8,
      "swpfree": 959228,
      "swpused": 89344,
      "swpused-percent": 8.52,
      "swpcad": 3240,
      "swpcad-percent": 3.63
    }
    

    only cpu load queue stats
    Code (Text):
    cminfo sar-json | jq -r '.queue'
    {
      "runq-sz": 2,
      "plist-sz": 125,
      "ldavg-1": 0,
      "ldavg-5": 0.01,
      "ldavg-15": 0.05,
      "blocked": 0
    }
    
     
    Last edited: Sep 16, 2020