全部产品
Search
文档中心

Cloud Monitor:Bagaimana cara menguninstall Agen CloudMonitor?

更新时间:Jun 26, 2025

Topik ini menjelaskan cara menguninstall Agen CloudMonitor untuk Java, Go, atau C++.

Penting

Pengelolaan Agen Cloud Monitor hanya dapat dilakukan menggunakan akun administrator. Untuk sistem operasi Linux, gunakan akun pengguna root. Untuk sistem operasi Windows, gunakan akun Administrator. Penggunaan akun administrator dapat menimbulkan risiko seperti masalah stabilitas sistem atau keamanan data. Lanjutkan dengan hati-hati.

Windows

  1. Masuk ke host tempat Agen CloudMonitor berada sebagai Administrator.
  2. Buat file .ps1, misalnya test.ps1.
  3. Salin konten berikut ke file test.ps1:
    if([System.Environment]::Is64BitOperatingSystem -eq $true)
    {
        $CMS_ARCH="amd64"
        $ARGUS_ARCH="win64"
    }else
    {
        $CMS_ARCH="386"
        $ARGUS_ARCH="win32"
    }
    
    $dest_path_prefix="C:\Program Files\Alibaba"
    $dest_path="$dest_path_prefix\cloudmonitor"
    
    echo "arsitektur saat ini adalah $CMS_ARCH"
    
    $go_dest_file="CmsGoAgent.windows-$CMS_ARCH.exe"
    $argus_dest_file="cloudmonitor_$ARGUS_ARCH.zip"
    $downloadpath="Argus/$CMS_VERSION/$argus_dest_file"
    
    if (Test-Path "$dest_path\wrapper\bin\AppCommand.bat")
    {
       echo "cloudmonitor java lama sudah terinstal - hapus..."
       & "$dest_path\wrapper\bin\AppCommand.bat" remove
       rm -Force -Recurse "$dest_path"
    }
    if (Test-Path "C:\Program Files (x86)\Alibaba\cloudmonitor\wrapper\bin\AppCommand.bat" )
    {
        echo "cloudmonitor java lama sudah terinstal - hapus..."
        & "C:\Program Files (x86)\Alibaba\cloudmonitor\wrapper\bin\AppCommand.bat" remove
        rm -Force -Recurse "C:\Program Files (x86)\Alibaba\cloudmonitor"
    }
    
    if (Test-Path "$dest_path\$go_dest_file")
    {
        "echo hapus go-agent"
        & "$dest_path\$go_dest_file" stop
        & "$dest_path\$go_dest_file" uninstall
        rm -Force -Recurse "$dest_path"
    }
  4. Simpan dan tutup file test.ps1.
  5. Klik kanan file test.ps1 dan pilih Run with PowerShell.

Linux

  1. Masuk ke host tempat Agen CloudMonitor berada sebagai pengguna root.
  2. Buat file skrip. Misalnya, jalankan perintah berikut untuk membuat file bernama test.sh:
    touch test.sh
  3. Jalankan perintah berikut untuk membuka file test.sh:
    vi test.sh
  4. Salin konten berikut ke file test.sh:
    #!/bin/bash
    
    if [ -z "${CMS_HOME}" ]; then
      CMS_HOME_PREFIX="/usr/local"
      if [ -f /etc/os-release -a ! -z "`egrep -i coreos /etc/os-release`" ];then
        CMS_HOME_PREFIX="/opt"
      fi
    fi
    CMS_HOME="${CMS_HOME_PREFIX}/cloudmonitor"
    
    if [ `uname -m` = "x86_64" ]; then
        ARCH="amd64"
        ARGUS_ARCH="64"
    else
        ARCH="386"
        ARGUS_ARCH="32"
    fi
    
    case `uname -s` in
      Linux)
        CMS_OS="linux"
        ;;
      *)
        echo "OS tidak didukung: $(uname -s)"
        exit 1
        ;;
    esac
    
    DEST_START_FILE=${CMS_HOME}/cloudmonitorCtl.sh
    # Uninstall the CloudMonitor agent. 
    GOAGENT_ELF_NAME=${CMS_HOME}/CmsGoAgent.${CMS_OS}-${ARCH}
    if [ -d ${CMS_HOME} ] ; then
      if [ -f ${DEST_START_FILE} ];then
        ${DEST_START_FILE} stop
      fi
      if [ -f ${CMS_HOME}/wrapper/bin/cloudmonitor.sh ] ; then
        ${CMS_HOME}/wrapper/bin/cloudmonitor.sh remove;
      fi
      if [ -f ${GOAGENT_ELF_NAME} ]; then
        ${GOAGENT_ELF_NAME} stop
      fi
      rm -rf ${CMS_HOME}
    fi
  5. Tekan tombol Esc, masukkan :wq, lalu tekan tombol Enter untuk menyimpan dan menutup file test.sh.
  6. Jalankan perintah berikut untuk menjalankan file test.sh:
    sh test.sh