Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 37 Next »

bIt is possible to profile the rendering process of Multisite pages. This is done using the Python module cProfile. For viewing the profiling data, we use snakeviz.

SnakeViz is a viewer for Python profiling data that runs as a web application in your browser. It is inspired by the wxPython profile viewer RunSnakeRun.


Step-by-step guide

  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 you and at the most of the time it will be the slowest one.

    2. Install Python module

      root@cmk-VirtualBox:~# pip install snakeviz
      root@cmk-VirtualBox:~# pip3 install snakeviz
    3. Modify the URL to profile by adding '&_profile=1'

      http://localhost/nagnis_master/check_mk/view.py?view_name=allhosts&_profile=1
    4. Now two files are created in ~/var/check_mk/

      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 multisite.profile.py*
      1. By executing 'multisite.profile.py'  you can get runtime statistics about the last processed page

        root@klappanas:/opt/omd/sites/nagnis_master/var/check_mk# ./multisite.profile.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/nagnis_master/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}
        ...
        ...
        ...
        ...
      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

        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

      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. tbf

      OMD[at]:~$ cmk |grep profile
         --profile           Enable profiling mode
  3. Network Analyze with the internet browser

    1. Start the Network Monitor

      Ctrl + Shift + I

      or

      For Firefox follow this manual: https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor
      For Google Chrome follow this manual: https://developer.chrome.com/docs/devtools/network/

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





  • No labels