Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  1. GUI Profiling

    1. Enable profiling in Checkmk


      SETUP→ General → Global Settings → USER INTERFACE

      Don't use 'Enable profiling for all request'. This option will profile a Multisite request randomly and at the most of the time it will be the slowest one.

    2. Install the Python module (for Python 2 or Python 3 respectively)

      Code Block
      root@cmk-VirtualBox:~# pip install snakeviz
      root@cmk-VirtualBox:~# pip3 install snakeviz

    3. Modify the URL to profile by adding '&_profile=1'

      Code Block

    4. Now two files are created in ~/var/check_mk/

      Code Block
      root@klappanas:/opt/omd/sites/nagnis_master/var/check_mk# ll |grep multisite
      -rw-rw---- 1 nagnis_master nagnis_master 100246 Nov 6 13:35 multisite.profile
      -rwxr-xr-x 1 nagnis_master nagnis_master 155 Nov 6 13:35*

      1. By executing ''  you can get runtime statistics about the last processed page

        Code Block
        root@klappanas:/opt/omd/sites/nagnis_master/var/check_mk# ./ |more
        Fri Nov  6 13:35:33 2020    /omd/sites/nagnis_master/var/check_mk/multisite.profile
                 9585 function calls (9480 primitive calls) in 0.007 seconds
           Ordered by: internal time
           ncalls  tottime  percall  cumtime  percall filename:lineno(function)
                1    0.001    0.001    0.002    0.002 /omd/sites/nagnis_master/lib/python/cmk/gui/
             4652    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}

      2. For viewing multisite.profile with snakeviz, move the file to another directory (e.g. /tmp) and change the owner to the owner of your Internet Browser

        Code Block
        anastasios@klappanas:/omd/sites/nagnis_master/var/check_mk$ sudo cp multisite.profile /tmp/
        anastasios@klappanas:/tmp$ sudo chown anastasios:anastasios multisite.profile

    5. Now you can use snakeviz for viewing the profiling file


      Code Block
      anastasios@klappanas:/tmp$ snakeviz multisite.profile

    6. Now you can analyze at which point of the request your view needs the most time!

  2. Profiling via cli

    1. The cmk commands have an option to profile them

      Code Block
      OMD[at]:~$ cmk |grep profile
         --profile           Enable profiling mode

    2. The profile file will be created in the current directory. Let's go to tmp and run the cmk command with the profile option

      Code Block
      ➜  ~ su - at                                        
      OMD[at]:~$ cd tmp
      OMD[at]:~$ cmk -Afv --profile


      cmk -Afv --profile is only one example. This command will trigger the agent baking via the cli. You may need to profile a different command

      1. Now we will see two files:

        Code Block
        OMD[at]:~/tmp$ ls |grep profile

      2. To work with these files we need to copy them outside the site

        Code Block
        OMD[at]:~/tmp$ cp profile.out /tmp/

      3. Now there are two ways to analyze these files:
        1. Open the profile file via the commandline:

          Code Block
          ➜  /tmp ./ 

        2. Analyze via snakevize like described here: GUIProfiling
  3. Profile a checkmk function


    Please note that we do not support any changes of our code. If you do this, please keep a backup of the file!

    There is an option to profile a function inside checkmk. This can be either your own code e.g. plugin or a checkmk specific code:

    Code Block
    from cmk.utils.profile import profile_call
    def my_func_to_profile(self):
        print("ding dong")

  4. Analyze a profiling file with python3 but generated on python2


    If you're running Checkmk <1.6 and >2.0 on your system, you will also have python2 und python3 installed.

    If you generate a profile on Checkmk 1.6 (pyhon2) you won't be able to open this file, if python3 is your default python on your system.

    There is a simple to achieve this anyway:


    The solution is: Python virtualenv inspired by:

    Here is my short step-by-step guide:

    Code Block
    # Install virtualenv
    sudo apt install virtualenv
    # Create a directory for virtualenv
    mkdir ~/.virtualenvs
    # Change to this directory and create a virtualenv with the python interpreter you want (we will use python2)
    cd ~/.virtualenvs
    virtualenv --python=python2 env
    # Confirm that the right python version is installed
    ls env/lib
    # Activate the new virtualenvironment
    source env/bin/activate
    # Now you can install all kind of modules inside this python2 context
    pip install snakeviz

    In this env you can analyse all profile files generated with python2!

  5. Network Analyze with the internet browser

    1. Start the Network Monitor


      Ctrl + Shift + I


      For Firefox follow this manual:
      For Google Chrome follow this manual:

    2. Now reload the slow/ crashing view again and save/export this file as .har. Please submit this file to us