Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Import Macro Repair

...

  1. SetupGeneralGlobal SettingsUser InterfaceProfile Request

    .
  2. Modify the URL to profile by adding '&_profile=1' and fire the request in your browser

    Code Block
    languagebash
    themeRDark
    http://localhost/nagnis_master/check_mk/view.py?view_name=allhosts&_profile=

    .

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

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

    .

  4. By executing 'multisite.py', you can get runtime statistics about the last processed page.

    Code Block
    languagebash
    themeRDark
    root@mylinuxhost:/opt/omd/sites/mysite/var/check_mk# ./multisite.py |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/mysite/lib/python/cmk/gui/modules.py:140(_cmk_gui_top_level_modules)
         4652    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}
    ...
    ...

    .

  5. 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
    languagebash
    themeRDark
    linuxuser@mylinuxhost:/omd/sites/mysite/var/check_mk$ sudo cp multisite.profile /tmp/
    linuxuser@mylinuxhost:/tmp$ sudo chown linuxuser:linuxuser multisite.profile
    

    .

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

    Code Block
    languagebash
    themeRDark
    root@mylinuxhost:~# pip install snakeviz
    root@mylinuxhost:~# pip3 install snakeviz

    .

  7. Now you can use snakeviz to view the profiling file.

    Code Block
    languagebash
    themeRDark
    linuxuser@mylinuxhost:/tmp$ snakeviz multisite.profile


.

...

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

Profiling via cli

  1. The cmk commands have the option to profile them.

    Code Block
    languagebash
    themeRDark
    OMD[mysite]:~$ 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[mysite]:~$ cd tmp
    OMD[mysite]:~$ cmk -Afv --profile


    Note

    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
        languagebash
        themeRDark
        OMD[mysite]:~/tmp$ ls |grep profile
        profile.out*
        show_profile.py*


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

        Code Block
        languagebash
        themeRDark
        OMD[mysite]:~/tmp$ cp show_profile.py profile.out /tmp/


      3. Now there are two ways to analyze these files:

        1. Open the profile file via the command line:

          Code Block
          languagebash
          themeRDark
          ➜  /tmp ./show_profile.py 


        2. Analyze via snakevize as described here: Checkmk profiling

Profile a Checkmk function

...

Network Analyze with the Internet browser

  1. Start the Network Monitor
    • Ctrl + Shift + I

...

  1. Reload the slow/ crashing view again and save/export this file as .har. Please submit this file to us.

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "gui" and type = "page" and space = "KB"
labelsagent_bakery user_roles_permissions roles user

...