Ad Widget

Collapse

Производительность серверов

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • den_crane
    Senior Member
    • Feb 2006
    • 272

    #16
    Я пометил комментариями запросы в src/zabbix_server/poller/poller.c
    И долго смотрел SHOW PROCESSLIST;

    Чаще всего видел запрос из ветки
    default: /* ZBX_POLLER_TYPE_NORMAL */
    result = DBselect("select /*3*/ %s where i.nextcheck<

    Запрос там получается типа такого

    Code:
    select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,
    i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,
    h.errors_from,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,
    i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt,i.valuemapid,i.delay_flex,
    h.dns,i.params,i.trends,h.useipmi,h.ipmi_port,
    h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password,i.ipmi_sensor,i.lastlogsize
    from `hosts` h, `items` i
    where i.nextcheck<=1245237273 + 5 
    and h.hostid=i.hostid 
    and h.status=0 and i.status in (0) 
    and ((h.disable_until<=now() and h.errors_from=0 and i.type in (0,1,4,6)) or i.type in (3,5,8,10,11))
    and (h.proxy_hostid=0 or i.type in (5))
    and mod(i.itemid,30)=3 and i.`key_` not in ('status','icmpping','icmppingsec','zabbix[log]')
    order by i.nextcheck
    Создал индекс
    items_test2 on items (status, type,key_, nextcheck)
    судя по плану он используется.

    Идея mod(i.itemid,30)=3 понятна, каждый поллер проверяет только свои items. Жаль мускль не умеет функциональных индексов. У меня в таблице items 3тыс записей, а если у кого больше оно же сканирует постоянно лишнюю часть индекса.




    один запрос попал slow_queries.log наверно случайно, но
    src/libs/zbxserver/functions.c
    Code:
    result = DBselect("select distinct t.triggerid,t.expression,t.description,t.url,t.comments,t.status,t.value,t.priority,t.type from triggers t,functions f,items i where i.status<>%d and i.itemid=f.itemid and t.status=%d and f.triggerid=t.triggerid and f.itemid=" ZBX_FS_UI64
    distinct явно лишний, из items выберется одна строка т.к. i.itemid=, а в секции селект есть t.triggerid, короче я distinct убрал.
    Last edited by den_crane; 17-06-2009, 14:53.

    Comment

    • den_crane
      Senior Member
      • Feb 2006
      • 272

      #17
      Еще часто мелькает видимо запрос

      src/zabbix_server/timer/timer.c
      result = DBselect("select distinct %s, functions f where h.hostid=i.hostid and h.status=%d"
      " and i.status=%d and f.function in ('nodata','date','dayofweek','time','now')"
      " and i.itemid=f.itemid"

      типа такого
      Code:
      select distinct i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,
      i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,
      h.errors_from,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,
      i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt,i.valuemapid,i.delay_flex,
      h.dns,i.params,i.trends,h.useipmi,h.ipmi_port,
      h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password,i.ipmi_sensor,i.lastlogsize
      from `hosts` h, `items` i,`functions`  f
       where h.hostid=i.hostid and h.status=0 and i.status=0 and f.function in ('nodata','date','dayofweek','time','now')
                                      and i.itemid=f.itemid

      сделал индекс
      function_test on functions (function,itemid)

      Comment

      • den_crane
        Senior Member
        • Feb 2006
        • 272

        #18
        Все равно запрос с mod самый жручий. Идем дальше, нет функциональных индексов, а и не надо.

        ALTER TABLE items ADD moditemid int;
        update items set moditemid = mod(itemid,30); // у меня 30 поллеров
        create index items_test3 on items (moditemid, nextcheck);

        меняем запрос на and i.moditemid=%d, комментим //CONFIG_POLLER_FORKS

        Code:
                default:        /* ZBX_POLLER_TYPE_NORMAL */
                        result = DBselect("select /*3*/ %s where i.nextcheck<=%d and h.hostid=i.hostid and h.status=%d and i.status in (%s)"
                                        " and ((h.disable_until<=%d and h.errors_from=0 and i.type in (%d,%d,%d,%d)) or i.type in (%d,%d,%d,%d,%d))"
                                        " and (h.proxy_hostid=0 or i.type in (%d))"
                                        " and i.moditemid=%d and i.key_ not in ('%s','%s','%s','%s')"
                                        DB_NODE " order by i.nextcheck",
                                        ZBX_SQL_ITEM_SELECT,
                                        now + POLLER_DELAY,
                                        HOST_STATUS_MONITORED,
                                        istatus,
                                        now,
                                        ITEM_TYPE_ZABBIX, ITEM_TYPE_SNMPv1, ITEM_TYPE_SNMPv2c, ITEM_TYPE_SNMPv3,
                                        ITEM_TYPE_SIMPLE, ITEM_TYPE_INTERNAL, ITEM_TYPE_AGGREGATE, ITEM_TYPE_EXTERNAL, ITEM_TYPE_DB_MONITOR,
                                        ITEM_TYPE_INTERNAL,
                                        //CONFIG_POLLER_FORKS,
                                        poller_num-1,
                                        SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, SERVER_ZABBIXLOG_KEY,
                                        DBnode_local("h.hostid"));
        Все, загрузка процессора 0-2%, осталось добавить заполнение поля moditemid при добавлении item-ов. Перезаполнение moditemid при изменении числа поллеров.
        И для красоты положить "-1" в moditemid которые проверять не надо, типа шаблоны, выключенные и т.д.
        Last edited by den_crane; 18-06-2009, 07:16.

        Comment

        • Alexei
          Founder, CEO
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Sep 2004
          • 5654

          #19
          Originally posted by den_crane
          Все, загрузка процессора 0-2%, осталось добавить заполнение поля moditemid при добавлении item-ов.
          Интересует загрузка CPU при StartPollers=50 с и без индекса, если возможно.
          Alexei Vladishev
          Creator of Zabbix, Product manager
          New York | Tokyo | Riga
          My Twitter

          Comment

          • den_crane
            Senior Member
            • Feb 2006
            • 272

            #20
            Originally posted by Alexei
            Интересует загрузка CPU при StartPollers=50 с и без индекса, если возможно.
            раньше загрузка была 30% при StartPollers=30, тепер 0-2%, но Алексей на моих 3тыс. в таблице items мерять это смешно. Вот на 100 тыс. item эффект я думаю будет ошеломительный.
            В общем я проверю если меня не загрузят текучкой на работе.

            Comment

            • Alexei
              Founder, CEO
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Sep 2004
              • 5654

              #21
              Originally posted by den_crane
              раньше загрузка была 30% при StartPollers=30, тепер 0-2%, но Алексей на моих 3тыс. в таблице items мерять это смешно. Вот на 100 тыс. item эффект я думаю будет ошеломительный.
              В общем я проверю если меня не загрузят текучкой на работе.
              Даже при StartPollers=30 и 3К items загрузка процессора 0-2% впечатляет! Будем думать...
              Alexei Vladishev
              Creator of Zabbix, Product manager
              New York | Tokyo | Riga
              My Twitter

              Comment

              • den_crane
                Senior Member
                • Feb 2006
                • 272

                #22
                Originally posted by Alexei
                Даже при StartPollers=30 и 3К items загрузка процессора 0-2% впечатляет! Будем думать...
                И еще у меня обычный десктоп, с очень медленным древним ide диском
                HTML Code:
                # cat /proc/cpuinfo 
                processor	: 0
                vendor_id	: GenuineIntel
                cpu family	: 15
                model		: 2
                model name	: Intel(R) Pentium(R) 4 CPU 2.40GHz
                
                # free
                             total       used       free     shared    buffers     cached
                Mem:       1034040     998360      35680          0     124572     315872
                -/+ buffers/cache:     557916     476124
                Swap:      1550232      11432    1538800

                Comment

                • den_crane
                  Senior Member
                  • Feb 2006
                  • 272

                  #23
                  поставил 50 поллеров
                  пересобрал, запустил дождался хаузкипера
                  HTML Code:
                  # sar -u 2 10
                  Linux 2.6.25.18-0.2-pae (nag) 	18.06.2009
                  
                  13:59:03        CPU     %user     %nice   %system   %iowait    %steal     %idle
                  13:59:05        all     22,06      0,49      0,49      0,00      0,00     76,96
                  13:59:07        all     22,66      0,99      1,97      0,00      0,00     74,38
                  13:59:09        all     31,59      0,25      0,50      0,00      0,00     67,66
                  13:59:11        all     18,69      0,00      0,49      0,00      0,00     80,83
                  13:59:13        all     21,32      0,25      0,49      4,17      0,00     73,77
                  13:59:15        all     22,44      0,49      0,98      1,95      0,00     74,15
                  13:59:17        all     15,89      0,24      0,49      0,00      0,00     83,37
                  13:59:19        all     25,49      0,25      0,49      0,00      0,00     73,77
                  13:59:21        all     20,83      0,25      0,98      0,00      0,00     77,94
                  13:59:23        all     15,72      0,00      0,49      0,25      0,00     83,54
                  Среднее:     all     21,65      0,32      0,74      0,64      0,00     76,66
                  update items set moditemid = mod(itemid,50);
                  поменял код на свой, пересобрал, запустил дождался хаузкипера

                  HTML Code:
                  # sar -u 2 10
                  Linux 2.6.25.18-0.2-pae (nag) 	18.06.2009
                  
                  14:02:12        CPU     %user     %nice   %system   %iowait    %steal     %idle
                  14:02:14        all      2,18      0,49      0,24      0,00      0,00     97,09
                  14:02:16        all      3,18      0,24      0,73      8,31      0,00     87,53
                  14:02:18        all      2,62      0,24      0,24      0,00      0,00     96,90
                  14:02:20        all      1,96      0,00      0,25      0,00      0,00     97,79
                  14:02:22        all      3,16      0,00      0,24      0,24      0,00     96,35
                  14:02:24        all      1,89      0,47      0,94      0,00      0,00     96,70
                  14:02:26        all      2,92      0,00      0,49      9,00      0,00     87,59
                  14:02:28        all      1,92      0,00      0,48      0,00      0,00     97,60
                  14:02:30        all      5,57      0,73      1,69      0,00      0,00     92,01
                  14:02:32        all      2,18      0,24      0,24      0,00      0,00     97,34
                  Среднее:     all      2,76      0,24      0,56      1,74      0,00     94,71

                  Comment

                  • Alexei
                    Founder, CEO
                    Zabbix Certified Trainer
                    Zabbix Certified SpecialistZabbix Certified Professional
                    • Sep 2004
                    • 5654

                    #24
                    Originally posted by den_crane
                    пересобрал, запустил дождался хаузкипера
                    Спасибо. Надо будет протестировать на других объёмах.
                    Alexei Vladishev
                    Creator of Zabbix, Product manager
                    New York | Tokyo | Riga
                    My Twitter

                    Comment

                    • ugh
                      Senior Member
                      • Jun 2009
                      • 296

                      #25
                      в общем добавление
                      items_test2
                      модификация src + items_test3
                      существенного эффекта не принесло к сожалению
                      запрос помеченый /*3*/ в нашем случае проскакивает сравнительно редко

                      в процесслист так и висят 6-8 запросов
                      Code:
                      select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.errors_from,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt,i.valuemapid,i.delay_flex,h.dns,i.params,i.trends,h.useipmi,h.ipmi_port,h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password,i.ipmi_sensor,i.lastlogsize from hosts h, items i where mod(h.hostid,10)=5 and h.status=0 and h.hostid=i.hostid and h.proxy_hostid=0 and h.useip=1 and h.ip='10.7.106.46' and i.key_='icmpping' and i.status in (0,3) and i.type=3 and i.nextcheck<=1245385701 and h.hostid between 800000000000000 and 899999999999999
                      попробую найти и по аналогии с items_test3 изменить

                      Comment

                      • den_crane
                        Senior Member
                        • Feb 2006
                        • 272

                        #26
                        Originally posted by ugh
                        в общем добавление

                        существенного эффекта не принесло к сожалению

                        попробую найти и по аналогии с items_test3 изменить
                        этот запрос в src/zabbix_server/pinger/pinger.c
                        Code:
                                result = DBselect("select %s where " ZBX_SQL_MOD(h.hostid,%d) "=%d and h.status=%d and h.hostid=i.hostid"
                                                " and h.proxy_hostid=0 and h.useip=%d and h.%s='%s' and i.key_='%s' and i.status in (%s)"
                                                " and i.type=%d and i.nextcheck<=%d" DB_NODE,
                                                ZBX_SQL_ITEM_SELECT,
                                                CONFIG_PINGER_FORKS,
                                                pinger_num - 1,
                                                HOST_STATUS_MONITORED,
                                                host->useip,
                                                host->useip ? "ip" : "dns",
                                                host->addr,
                                                key,
                                                istatus,
                                                ITEM_TYPE_SIMPLE,
                                                now,
                                                DBnode_local("h.hostid"));
                        Только вот небольшое отличие " ZBX_SQL_MOD(h.hostid,%d) считается от CONFIG_PINGER_FORKS
                        т.е. mod(h.hostid,10)=5 у вас 10 пингеров.

                        update items set moditemid = mod(itemid,10) where key_='icmpping';
                        update items set moditemid = mod(itemid,30) key_ not in ('status','icmpping','icmppingsec','zabbix[log]');

                        и индекс
                        create index items_test3 on items (moditemid, key_ , nextcheck);

                        Я то пингами и (вообще simple проверками) не пользуюсь совсем, у меня либо agent.ping либо snmp
                        Last edited by den_crane; 19-06-2009, 08:30.

                        Comment

                        • den_crane
                          Senior Member
                          • Feb 2006
                          • 272

                          #27
                          А черт я тупой.
                          У вас mod(h.hostid,10) а у меня itemid


                          Вам поможет просто

                          create index host_test on hosts(ip);
                          Last edited by den_crane; 19-06-2009, 08:46.

                          Comment

                          • den_crane
                            Senior Member
                            • Feb 2006
                            • 272

                            #28
                            Originally posted by ugh
                            в pinger.c
                            как-то так?
                            не так. я первый раз неправильно написал. Таблица там hosts ZBX_SQL_MOD(h.hostid,%d
                            Т.е. поле надо добавлять и апдейтить в таблице hosts. С другой стороны h.hostid = i.hostid поэтому можно и в items попробовать.
                            И еще update items set modhostid = mod(hostid,30); надо mod(hostid,10) пингеров у вас 10!!!!!!
                            А вы как хосты заводите с use_ip или use_dns?
                            Индекс по ip должен был помочь очень сильно. Или вас другой запрос мучает.

                            добавьте еще индекс
                            create index host_test1 on hosts(dns);
                            Last edited by den_crane; 19-06-2009, 10:53.

                            Comment

                            • den_crane
                              Senior Member
                              • Feb 2006
                              • 272

                              #29
                              У меня с poller-ми была проблема что сканировалась таблица items, но в моем случае не было ограничения, которое бы отсекало меньшую часть выборки сразу.
                              У вас вроде как такое ограничение есть это h.ip='10.7.106.46' индекс должен был помочь.

                              from hosts h, items i
                              where mod(h.hostid,10)=5 and
                              h.status=0 and
                              h.hostid=i.hostid and
                              h.proxy_hostid=0 and
                              h.useip=1 and
                              h.ip='10.7.106.46' and
                              i.key_='icmpping' and
                              i.status in (0,3) and
                              i.type=3 and
                              i.nextcheck<=1245385701

                              План своего плохого запроса покажите?

                              Comment

                              • den_crane
                                Senior Member
                                • Feb 2006
                                • 272

                                #30
                                А что за запросы от вебморды у вас сервак грузят?
                                У меня вообще вебморда летает.

                                Правда я конечно за два года мог индексов уже своих напихать.


                                Вот смотрю у меня есть индекс
                                create unique index items_1_ on items (key_, hostid);

                                Comment

                                Working...