Sysstat is deployed on the server, and system monitoring records can be kept through sar. It is not very convenient to download data from the server for analysis elsewhere, so consider building a convenient Docker image to assist in the work.
sysstat: https://github.com/sysstat/sysstat
1. Bing AI creates Dockerfile
Let AI help write Dockerfile directly
The content is copied as follows:
# based on CentOS7 image FROM centos:7 # Install git and compilation tools RUN yum install -y git gcc make # Clone the sysstat repository via git RUN git clone https://github.com/sysstat/sysstat.git # Enter the sysstat directory, compile and install WORKDIR /sysstat RUN ./configure & amp; & amp; make & amp; & amp; make install # Clean up cached data and source code RUN yum clean all & amp; & amp; rm -rf /sysstat
After the creation is completed, git clone
cannot be downloaded during my local build process, so build it in another way.
2. GitHub Codespaces
2.1 Open the sysstat page and create a running environment
2.2 Check whether the docker environment is supported
@abel533 ? /workspaces/sysstat (master) $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2.3 Create Dockerfile
No problem, create Dockerfile from left explorer, enter above content.
In order to facilitate my local use, I changed the CentOS image version from 7 to the specific
7.6.1810
.
2.4 Execute command build
@abel533 ? /workspaces/sysstat (master) $ docker build -t sysstat:23-0323 . [ + ] Building 79.1s (11/11) FINISHED => [internal] load build definition from Dockerfile 0.5s => => transferring dockerfile: 398B 0.0s => [internal] load .dockerignore 0.4s => => transferring context: 2B 0.1s => [internal] load metadata for docker.io/library/centos:7.6.1810 3.0s => [auth] library/centos:pull token for registry-1.docker.io 0.0s => [1/6] FROM docker.io/library/centos:7.6.1810@sha256:62d9e1c2daa91166139b51577fe4f4f6b4cc41a3a2c7fc36bd895e2a17a3e4e6 4.9s => => resolve docker.io/library/centos:7.6.1810@sha256:62d9e1c2daa91166139b51577fe4f4f6b4cc41a3a2c7fc36bd895e2a17a3e4e6 0.1s => => sha256:62d9e1c2daa91166139b51577fe4f4f6b4cc41a3a2c7fc36bd895e2a17a3e4e6 534B/534B 0.0s => => sha256:747b2de199b6197a26eb1a24d69740d25483995842b2d2f75824095e9d1d19eb 529B/529B 0.0s => => sha256:f1cb7c7d58b73eac859c395882eec49d50651244e342cd6c68a5c7809785f427 2.18kB / 2.18kB 0.0s => => sha256:ac9208207adaac3a48e54a4dc6b49c69e78c3072d2b3add7efdabf814db2133b 75.16MB / 75.16MB 0.9s => => extracting sha256:ac9208207adaac3a48e54a4dc6b49c69e78c3072d2b3add7efdabf814db2133b 3.0s => [2/6] RUN yum install -y git gcc make 46.6s => [3/6] RUN git clone https://github.com/sysstat/sysstat.git 3.7s => [4/6] WORKDIR /sysstat 0.3s => [5/6] RUN ./configure & amp; & amp; make & amp; & amp; make install 13.0s => [6/6] RUN yum clean all & amp; & amp; rm -rf /sysstat 1.5s => exporting to image 5.2s => => exporting layers 5.2s => => writing image sha256:03d82c85a1f5df4f21558e8d43a9632a1119b6a4d52456ed3139bf76fb72c349 0.0s => => naming to docker.io/library/sysstat:23-0323
2.5 Run the image to verify the function
@abel533 ? /workspaces/sysstat (master) $ docker run -it --rm sysstat:23-0323 /bin/bash [root@38451f6af593 sysstat]# sar 1 10 Linux 5.4.0-1104-azure (38451f6af593) 03/23/23 _x86_64_ (2 CPUs) 02:17:43 CPU %user %nice %system %iowait %steal %idle 02:17:44 all 3.54 0.00 5.05 0.00 0.00 91.41 02:17:45 all 0.51 0.00 1.02 0.00 0.00 98.47 02:17:46 all 1.51 0.00 4.02 0.50 0.00 93.97 02:17:47 all 7.69 0.00 6.67 0.00 0.00 85.64 02:17:48 all 16.24 0.00 6.09 0.00 0.00 77.66 02:17:49 all 3.54 0.00 2.02 0.00 0.00 94.44 02:17:50 all 2.02 0.00 3.03 0.00 0.00 94.95 02:17:51 all 1.02 0.00 1.02 0.00 0.00 97.97 02:17:52 all 2.54 0.00 3.55 0.00 0.00 93.91 02:17:53 all 2.01 0.00 2.51 0.00 0.00 95.48 Average: all 4.05 0.00 3.50 0.05 0.00 92.40
2.6 Push image
Create a public image on DockerHub and rename the tag:
docker tag sysstat:23-0323 abel533/sysstat:23.03.23
log in to docker
docker login -u username -p password
push image
@abel533 ? /workspaces/sysstat (master) $ docker push abel533/sysstat:23.03.23 The push refers to repository [docker.io/abel533/sysstat] 68867ac04a78: Pushed 574e22f85afb: Pushed 5f70bf18a086: Pushed b5e26a4e7785: Pushed 6a7f717fb326: Pushed 89169d87dbe2: Pushed 23.03.23: digest: sha256:e5fdcb8c11f34a43e96e25ffef4572cc71113a47691980655f47871ef981346d size: 1581
This completes a mirror of the latest version of sysstat.
3. Mirror URL
If necessary, you can directly download the mirror and use:
https://hub.docker.com/r/abel533/sysstat/tags