Skip to content

Building cAdvisor

linuxonz edited this page Apr 12, 2024 · 53 revisions

Building cAdvisor

Below versions of cAdvisor are available in respective distributions at the time of creation of these build instructions:

  • Ubuntu 20.04 have 0.27.1
  • Ubuntu 22.04 have 0.38.7
  • SLES 15 SP5 have 0.46.0

The instructions provided below specify the steps to build cAdvisor version 0.49.1 on Linux on IBM Z for the following distributions:

  • RHEL (7.8, 7.9, 8.6, 8.8, 8.9, 9.0, 9.2, 9.3)
  • SLES (12 SP5, 15 SP5)
  • Ubuntu (20.04, 22.04, 23.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.
  • It is recommended to use cadvisor >= 0.23.9 on Kernel version >= 4.4 for SLES & Ubuntu, Kernel version >= 3.10.0-366 for RHEL in order to avoid inconsistent fs usage data from device thin pool. Click here for details.

Step 1: Build using script

If you want to build cAdvisor using manual steps, go to STEP 2.

Use the following commands to build cAdvisor using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/cAdvisor/0.49.1/build_cadvisor.sh

# Build cAdvisor
bash build_cadvisor.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 7. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install the dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.8, 7.9, 8.6, 8.8, 8.9, 9.0, 9.2, 9.3)

    sudo yum install -y wget curl git gcc patch make
  • SLES (12 SP5, 15 SP5)

    sudo zypper install -y git wget tar curl gcc patch make 
  • Ubuntu (20.04, 22.04, 23.10)

    sudo apt-get update
    sudo apt-get install -y wget git curl patch make gcc
    
  • Install Go v1.22.1

    cd $SOURCE_ROOT
    wget https://go.dev/dl/go1.22.1.linux-s390x.tar.gz
    tar -xzf go1.22.1.linux-s390x.tar.gz
    sudo rm -rf /usr/local/go /usr/bin/go
    sudo ln -sf $SOURCE_ROOT/go/bin/go /usr/bin/ 
    sudo ln -sf $SOURCE_ROOT/go/bin/gofmt /usr/bin/

Step 3: Set environment variables

export GOPATH=$SOURCE_ROOT/go
export PATH=$PATH:$GOPATH/bin

Step 4: Clone the source code

mkdir -p $GOPATH/src/github.com/google
cd $GOPATH/src/github.com/google
git clone https://github.com/google/cadvisor.git
cd $GOPATH/src/github.com/google/cadvisor/
git checkout v0.49.1

Step 5: Build cAdvisor

cd $GOPATH/src/github.com/google/cadvisor/
make build
sudo cp $GOPATH/src/github.com/google/cadvisor/_output/cadvisor /usr/bin/

Step 6: Run unit tests (Optional)

make test

Step 7: Run cAdvisor

sudo cadvisor

Step 8: Access cAdvisor web user interface from browser

http://<host-ip>:<http-port>/

Note: Default port number for cAdvisor is 8080

References:

Clone this wiki locally