MySQL  8.0.21
Source Code Documentation
srv0mon.h
Go to the documentation of this file.
1 /***********************************************************************
2 
3 Copyright (c) 2010, 2020, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2012, Facebook Inc.
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9 
10 This program is also distributed with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have included with MySQL.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 
26 ***********************************************************************/
27 
28 /** @file include/srv0mon.h
29  Server monitor counter related defines
30 
31  Created 12/15/2009 Jimmy Yang
32  *******************************************************/
33 
34 #ifndef srv0mon_h
35 #define srv0mon_h
36 
37 #include "univ.i"
38 
39 #ifndef __STDC_LIMIT_MACROS
40 /* Required for FreeBSD so that INT64_MAX is defined. */
41 #define __STDC_LIMIT_MACROS
42 #endif /* __STDC_LIMIT_MACROS */
43 
44 #include <stdint.h>
45 
46 /** Possible status values for "mon_status" in "struct monitor_value" */
48  MONITOR_STARTED = 1, /*!< Monitor has been turned on */
49  MONITOR_STOPPED = 2 /*!< Monitor has been turned off */
50 };
51 
53 
54 /** Monitor counter value type */
55 typedef int64_t mon_type_t;
56 
57 /** Two monitor structures are defined in this file. One is
58 "monitor_value_t" which contains dynamic counter values for each
59 counter. The other is "monitor_info_t", which contains
60 static information (counter name, desc etc.) for each counter.
61 In addition, an enum datatype "monitor_id_t" is also defined,
62 it identifies each monitor with an internally used symbol, whose
63 integer value indexes into above two structure for its dynamic
64 and static information.
65 Developer who intend to add new counters would require to
66 fill in counter information as described in "monitor_info_t" and
67 create the internal counter ID in "monitor_id_t". */
68 
69 /** Structure containing the actual values of a monitor counter. */
71  ib_time_t mon_start_time; /*!< Start time of monitoring */
72  ib_time_t mon_stop_time; /*!< Stop time of monitoring */
73  ib_time_t mon_reset_time; /*!< Time counter resetted */
74  mon_type_t mon_value; /*!< Current counter Value */
75  mon_type_t mon_max_value; /*!< Current Max value */
76  mon_type_t mon_min_value; /*!< Current Min value */
77  mon_type_t mon_value_reset; /*!< value at last reset */
78  mon_type_t mon_max_value_start; /*!< Max value since start */
79  mon_type_t mon_min_value_start; /*!< Min value since start */
80  mon_type_t mon_start_value; /*!< Value at the start time */
81  mon_type_t mon_last_value; /*!< Last set of values */
82  monitor_running_t mon_status; /* whether monitor still running */
83 };
84 
85 /** Follwoing defines are possible values for "monitor_type" field in
86 "struct monitor_info" */
88  MONITOR_NONE = 0, /*!< No monitoring */
89  MONITOR_MODULE = 1, /*!< This is a monitor module type,
90  not a counter */
91  MONITOR_EXISTING = 2, /*!< The monitor carries information from
92  an existing system status variable */
93  MONITOR_NO_AVERAGE = 4, /*!< Set this status if we don't want to
94  calculate the average value for the counter */
95  MONITOR_DISPLAY_CURRENT = 8, /*!< Display current value of the
96  counter, rather than incremental value
97  over the period. Mostly for counters
98  displaying current resource usage */
99  MONITOR_GROUP_MODULE = 16, /*!< Monitor can be turned on/off
100  only as a module, but not individually */
101  MONITOR_DEFAULT_ON = 32, /*!< Monitor will be turned on by default at
102  server start up */
103  MONITOR_SET_OWNER = 64, /*!< Owner of "monitor set", a set of
104  monitor counters */
105  MONITOR_SET_MEMBER = 128, /*!< Being part of a "monitor set" */
106  MONITOR_HIDDEN = 256 /*!< Do not display this monitor in the
107  metrics table */
108 };
109 
110 /** Counter minimum value is initialized to be max value of
111  mon_type_t (int64_t) */
112 #define MIN_RESERVED INT64_MAX
113 #define MAX_RESERVED (~MIN_RESERVED)
114 
115 /** This enumeration defines internal monitor identifier used internally
116 to identify each particular counter. Its value indexes into two arrays,
117 one is the "innodb_counter_value" array which records actual monitor
118 counter values, the other is "innodb_counter_info" array which describes
119 each counter's basic information (name, desc etc.). A couple of
120 naming rules here:
121 1) If the monitor defines a module, it starts with MONITOR_MODULE
122 2) If the monitor uses exisitng counters from "status variable", its ID
123 name shall start with MONITOR_OVLD
124 
125 Please refer to "innodb_counter_info" in srv/srv0mon.cc for detail
126 information for each monitor counter */
127 
129  /* This is to identify the default value set by the metrics
130  control global variables */
132 
133  /* Start of Metadata counter */
138 
139  /* Lock manager related counters */
163 
164  /* Buffer and I/O realted counters. */
196 
200 
206 
210 
213 
248 
249  /* Buffer Page I/O specific counters. */
288 
289  /* OS level counters (I/O) */
300 
301  /* Transaction related counters */
318 
319  /* Purge related counters */
330 
331  /* Undo tablespace truncation */
337 
338  /* Recovery related counters */
353 
358 
366 
372 
376 
380 
384 
386 
401 
402  /* Page Manager related counters */
408 
409  /* Index related counters */
417 
418  /* Adaptive Hash Index related counters */
428 
429  /* Tablespace related counters */
432 
433  /* InnoDB Change Buffer related counters */
443 
444  /* Counters for server operations */
468 
469  /* Data DML related counters */
479 
480  /* Sampling related counters */
484 
485  /* Data DDL related counters */
492 
498 
499  /* Mutex/RW-Lock related counters */
502 
503  /* CPU usage information */
510 
516 
522 
523  /* This is used only for control system to turn
524  on/off and reset all monitor counters */
526 
527  /* This must be the last member */
529 };
530 
531 /** This informs the monitor control system to turn
532 on/off and reset monitor counters through wild card match */
533 #define MONITOR_WILDCARD_MATCH (NUM_MONITOR + 1)
534 
535 /** Cannot find monitor counter with a specified name */
536 #define MONITOR_NO_MATCH (NUM_MONITOR + 2)
537 
538 /** struct monitor_info describes the basic/static information
539 about each monitor counter. */
541  const char *monitor_name; /*!< Monitor name */
542  const char *monitor_module; /*!< Sub Module the monitor
543  belongs to */
544  const char *monitor_desc; /*!< Brief desc of monitor counter */
545  monitor_type_t monitor_type; /*!< Type of Monitor Info */
546  monitor_id_t monitor_related_id; /*!< Monitor ID of counter that
547  related to this monitor. This is
548  set when the monitor belongs to
549  a "monitor set" */
550  monitor_id_t monitor_id; /*!< Monitor ID as defined in enum
551  monitor_id_t */
552 };
553 
554 /** Following are the "set_option" values allowed for
555 srv_mon_process_existing_counter() and srv_mon_process_existing_counter()
556 functions. To turn on/off/reset the monitor counters. */
558  MONITOR_TURN_ON = 1, /*!< Turn on the counter */
559  MONITOR_TURN_OFF, /*!< Turn off the counter */
560  MONITOR_RESET_VALUE, /*!< Reset current values */
561  MONITOR_RESET_ALL_VALUE, /*!< Reset all values */
562  MONITOR_GET_VALUE /*!< Option for
563  srv_mon_process_existing_counter()
564  function */
565 };
566 
567 #ifndef UNIV_HOTBACKUP
568 /** Number of bit in a ulint datatype */
569 #define NUM_BITS_ULINT (sizeof(ulint) * CHAR_BIT)
570 
571 /** This "monitor_set_tbl" is a bitmap records whether a particular monitor
572 counter has been turned on or off */
573 extern ulint
575 
576 /** Macros to turn on/off the control bit in monitor_set_tbl for a monitor
577 counter option. */
578 #define MONITOR_ON(monitor) \
579  (monitor_set_tbl[monitor / NUM_BITS_ULINT] |= \
580  ((ulint)1 << (monitor % NUM_BITS_ULINT)))
581 
582 #define MONITOR_OFF(monitor) \
583  (monitor_set_tbl[monitor / NUM_BITS_ULINT] &= \
584  ~((ulint)1 << (monitor % NUM_BITS_ULINT)))
585 
586 /** Check whether the requested monitor is turned on/off */
587 #define MONITOR_IS_ON(monitor) \
588  (monitor_set_tbl[monitor / NUM_BITS_ULINT] & \
589  ((ulint)1 << (monitor % NUM_BITS_ULINT)))
590 
591 /** The actual monitor counter array that records each monintor counter
592 value */
594 
595 /** Following are macro defines for basic montior counter manipulations.
596 Please note we do not provide any synchronization for these monitor
597 operations due to performance consideration. Most counters can
598 be placed under existing mutex protections in respective code
599 module. */
600 
601 /** Macros to access various fields of a monitor counters */
602 #define MONITOR_FIELD(monitor, field) (innodb_counter_value[monitor].field)
603 
604 #define MONITOR_VALUE(monitor) MONITOR_FIELD(monitor, mon_value)
605 
606 #define MONITOR_MAX_VALUE(monitor) MONITOR_FIELD(monitor, mon_max_value)
607 
608 #define MONITOR_MIN_VALUE(monitor) MONITOR_FIELD(monitor, mon_min_value)
609 
610 #define MONITOR_VALUE_RESET(monitor) MONITOR_FIELD(monitor, mon_value_reset)
611 
612 #define MONITOR_MAX_VALUE_START(monitor) \
613  MONITOR_FIELD(monitor, mon_max_value_start)
614 
615 #define MONITOR_MIN_VALUE_START(monitor) \
616  MONITOR_FIELD(monitor, mon_min_value_start)
617 
618 #define MONITOR_LAST_VALUE(monitor) MONITOR_FIELD(monitor, mon_last_value)
619 
620 #define MONITOR_START_VALUE(monitor) MONITOR_FIELD(monitor, mon_start_value)
621 
622 #define MONITOR_VALUE_SINCE_START(monitor) \
623  (MONITOR_VALUE(monitor) + MONITOR_VALUE_RESET(monitor))
624 
625 #define MONITOR_STATUS(monitor) MONITOR_FIELD(monitor, mon_status)
626 
627 #define MONITOR_SET_START(monitor) \
628  do { \
629  MONITOR_STATUS(monitor) = MONITOR_STARTED; \
630  MONITOR_FIELD((monitor), mon_start_time) = time(NULL); \
631  } while (0)
632 
633 #define MONITOR_SET_OFF(monitor) \
634  do { \
635  MONITOR_STATUS(monitor) = MONITOR_STOPPED; \
636  MONITOR_FIELD((monitor), mon_stop_time) = time(NULL); \
637  } while (0)
638 
639 #define MONITOR_INIT_ZERO_VALUE 0
640 
641 /** Max and min values are initialized when we first turn on the monitor
642 counter, and set the MONITOR_STATUS. */
643 #define MONITOR_MAX_MIN_NOT_INIT(monitor) \
644  (MONITOR_STATUS(monitor) == MONITOR_INIT_ZERO_VALUE && \
645  MONITOR_MIN_VALUE(monitor) == MONITOR_INIT_ZERO_VALUE && \
646  MONITOR_MAX_VALUE(monitor) == MONITOR_INIT_ZERO_VALUE)
647 
648 #define MONITOR_INIT(monitor) \
649  if (MONITOR_MAX_MIN_NOT_INIT(monitor)) { \
650  MONITOR_MIN_VALUE(monitor) = MIN_RESERVED; \
651  MONITOR_MIN_VALUE_START(monitor) = MIN_RESERVED; \
652  MONITOR_MAX_VALUE(monitor) = MAX_RESERVED; \
653  MONITOR_MAX_VALUE_START(monitor) = MAX_RESERVED; \
654  }
655 
656 /** Macros to increment/decrement the counters. The normal
657 monitor counter operation expects appropriate synchronization
658 already exists. No additional mutex is necessary when operating
659 on the counters */
660 #define MONITOR_INC(monitor) \
661  if (MONITOR_IS_ON(monitor)) { \
662  MONITOR_VALUE(monitor)++; \
663  if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
664  MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
665  } \
666  }
667 
668 /** Atomically increment a monitor counter.
669 Use MONITOR_INC if appropriate mutex protection exists.
670 @param monitor monitor to be incremented by 1 */
671 #define MONITOR_ATOMIC_INC(monitor) \
672  if (MONITOR_IS_ON(monitor)) { \
673  ib_uint64_t value; \
674  value = \
675  os_atomic_increment_uint64((ib_uint64_t *)&MONITOR_VALUE(monitor), 1); \
676  /* Note: This is not 100% accurate because of the \
677  inherent race, we ignore it due to performance. */ \
678  if (value > (ib_uint64_t)MONITOR_MAX_VALUE(monitor)) { \
679  MONITOR_MAX_VALUE(monitor) = value; \
680  } \
681  }
682 
683 /** Atomically decrement a monitor counter.
684 Use MONITOR_DEC if appropriate mutex protection exists.
685 @param monitor monitor to be decremented by 1 */
686 #define MONITOR_ATOMIC_DEC(monitor) \
687  if (MONITOR_IS_ON(monitor)) { \
688  ib_uint64_t value; \
689  value = \
690  os_atomic_decrement_uint64((ib_uint64_t *)&MONITOR_VALUE(monitor), 1); \
691  /* Note: This is not 100% accurate because of the \
692  inherent race, we ignore it due to performance. */ \
693  if (value < (ib_uint64_t)MONITOR_MIN_VALUE(monitor)) { \
694  MONITOR_MIN_VALUE(monitor) = value; \
695  } \
696  }
697 
698 #define MONITOR_DEC(monitor) \
699  if (MONITOR_IS_ON(monitor)) { \
700  MONITOR_VALUE(monitor)--; \
701  if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
702  MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor); \
703  } \
704  }
705 
706 #ifdef UNIV_DEBUG_VALGRIND
707 #define MONITOR_CHECK_DEFINED(value) \
708  do { \
709  mon_type_t m = value; \
710  UNIV_MEM_ASSERT_RW(&m, sizeof m); \
711  } while (0)
712 #else /* UNIV_DEBUG_VALGRIND */
713 #define MONITOR_CHECK_DEFINED(value) (void)0
714 #endif /* UNIV_DEBUG_VALGRIND */
715 
716 #define MONITOR_INC_VALUE(monitor, value) \
717  MONITOR_CHECK_DEFINED(value); \
718  if (MONITOR_IS_ON(monitor)) { \
719  MONITOR_VALUE(monitor) += (mon_type_t)(value); \
720  if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
721  MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
722  } \
723  }
724 
725 #define MONITOR_DEC_VALUE(monitor, value) \
726  MONITOR_CHECK_DEFINED(value); \
727  if (MONITOR_IS_ON(monitor)) { \
728  ut_ad(MONITOR_VALUE(monitor) >= (mon_type_t) (value); \
729  MONITOR_VALUE(monitor) -= (mon_type_t) (value); \
730  if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
731  MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor);\
732  } \
733  }
734 
735 /* Increment/decrement counter without check the monitor on/off bit, which
736 could already be checked as a module group */
737 #define MONITOR_INC_NOCHECK(monitor) \
738  do { \
739  MONITOR_VALUE(monitor)++; \
740  if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
741  MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
742  } \
743  } while (0)
744 
745 #define MONITOR_DEC_NOCHECK(monitor) \
746  do { \
747  MONITOR_VALUE(monitor)--; \
748  if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
749  MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor); \
750  } \
751  } while (0)
752 
753 /** Directly set a monitor counter's value */
754 #define MONITOR_SET(monitor, value) \
755  MONITOR_CHECK_DEFINED(value); \
756  if (MONITOR_IS_ON(monitor)) { \
757  MONITOR_VALUE(monitor) = (mon_type_t)(value); \
758  if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
759  MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
760  } \
761  if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
762  MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor); \
763  } \
764  }
765 
766 /** Add time difference between now and input "value" (in seconds) to the
767 monitor counter
768 @param monitor monitor to update for the time difference
769 @param value the start time value */
770 #define MONITOR_INC_TIME_IN_MICRO_SECS(monitor, value) \
771  MONITOR_CHECK_DEFINED(value); \
772  if (MONITOR_IS_ON(monitor)) { \
773  uintmax_t old_time = (value); \
774  value = ut_time_monotonic_us(); \
775  MONITOR_VALUE(monitor) += (mon_type_t)(value - old_time); \
776  }
777 
778 /** This macro updates 3 counters in one call. However, it only checks the
779 main/first monitor counter 'monitor', to see it is on or off to decide
780 whether to do the update.
781 @param monitor the main monitor counter to update. It accounts for
782  the accumulative value for the counter.
783 @param monitor_n_calls counter that counts number of times this macro is
784  called
785 @param monitor_per_call counter that records the current and max value of
786  each incremental value
787 @param value incremental value to record this time */
788 #define MONITOR_INC_VALUE_CUMULATIVE(monitor, monitor_n_calls, \
789  monitor_per_call, value) \
790  MONITOR_CHECK_DEFINED(value); \
791  if (MONITOR_IS_ON(monitor)) { \
792  MONITOR_VALUE(monitor_n_calls)++; \
793  MONITOR_VALUE(monitor_per_call) = (mon_type_t)(value); \
794  if (MONITOR_VALUE(monitor_per_call) > \
795  MONITOR_MAX_VALUE(monitor_per_call)) { \
796  MONITOR_MAX_VALUE(monitor_per_call) = (mon_type_t)(value); \
797  } \
798  MONITOR_VALUE(monitor) += (mon_type_t)(value); \
799  if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
800  MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
801  } \
802  }
803 
804 /** Directly set a monitor counter's value, and if the value
805 is monotonically increasing, only max value needs to be updated */
806 #define MONITOR_SET_UPD_MAX_ONLY(monitor, value) \
807  MONITOR_CHECK_DEFINED(value); \
808  if (MONITOR_IS_ON(monitor)) { \
809  MONITOR_VALUE(monitor) = (mon_type_t)(value); \
810  if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
811  MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
812  } \
813  }
814 
815 /** Some values such as log sequence number are montomically increasing
816 number, do not need to record max/min values */
817 #define MONITOR_SET_SIMPLE(monitor, value) \
818  MONITOR_CHECK_DEFINED(value); \
819  if (MONITOR_IS_ON(monitor)) { \
820  MONITOR_VALUE(monitor) = (mon_type_t)(value); \
821  }
822 
823 /** Reset the monitor value and max/min value to zero. The reset
824 operation would only be conducted when the counter is turned off */
825 #define MONITOR_RESET_ALL(monitor) \
826  do { \
827  MONITOR_VALUE(monitor) = MONITOR_INIT_ZERO_VALUE; \
828  MONITOR_MAX_VALUE(monitor) = MAX_RESERVED; \
829  MONITOR_MIN_VALUE(monitor) = MIN_RESERVED; \
830  MONITOR_VALUE_RESET(monitor) = MONITOR_INIT_ZERO_VALUE; \
831  MONITOR_MAX_VALUE_START(monitor) = MAX_RESERVED; \
832  MONITOR_MIN_VALUE_START(monitor) = MIN_RESERVED; \
833  MONITOR_LAST_VALUE(monitor) = MONITOR_INIT_ZERO_VALUE; \
834  MONITOR_FIELD(monitor, mon_start_time) = MONITOR_INIT_ZERO_VALUE; \
835  MONITOR_FIELD(monitor, mon_stop_time) = MONITOR_INIT_ZERO_VALUE; \
836  MONITOR_FIELD(monitor, mon_reset_time) = MONITOR_INIT_ZERO_VALUE; \
837  } while (0)
838 
839 /** Following four macros defines necessary operations to fetch and
840 consolidate information from existing system status variables. */
841 
842 /** Save the passed-in value to mon_start_value field of monitor
843 counters */
844 #define MONITOR_SAVE_START(monitor, value) \
845  do { \
846  MONITOR_CHECK_DEFINED(value); \
847  (MONITOR_START_VALUE(monitor) = \
848  (mon_type_t)(value)-MONITOR_VALUE_RESET(monitor)); \
849  } while (0)
850 
851 /** Save the passed-in value to mon_last_value field of monitor
852 counters */
853 #define MONITOR_SAVE_LAST(monitor) \
854  do { \
855  MONITOR_LAST_VALUE(monitor) = MONITOR_VALUE(monitor); \
856  MONITOR_START_VALUE(monitor) += MONITOR_VALUE(monitor); \
857  } while (0)
858 
859 /** Set monitor value to the difference of value and mon_start_value
860 compensated by mon_last_value if accumulated value is required. */
861 #define MONITOR_SET_DIFF(monitor, value) \
862  MONITOR_SET_UPD_MAX_ONLY(monitor, ((value)-MONITOR_VALUE_RESET(monitor) - \
863  MONITOR_FIELD(monitor, mon_start_value) + \
864  MONITOR_FIELD(monitor, mon_last_value)))
865 
866 /** Get monitor's monitor_info_t by its monitor id (index into the
867  innodb_counter_info array
868  @return Point to corresponding monitor_info_t, or NULL if no such
869  monitor */
871  monitor_id_t monitor_id); /*!< id index into the
872  innodb_counter_info array */
873 /** Get monitor's name by its monitor id (index into the
874  innodb_counter_info array
875  @return corresponding monitor name, or NULL if no such
876  monitor */
877 const char *srv_mon_get_name(
878  monitor_id_t monitor_id); /*!< id index into the
879  innodb_counter_info array */
880 
881 /** Turn on/off/reset monitor counters in a module. If module_value
882  is NUM_MONITOR then turn on all monitor counters. */
884  monitor_id_t module_id, /*!< in: Module ID as in
885  monitor_counter_id. If it is
886  set to NUM_MONITOR, this means
887  we shall turn on all the counters */
888  mon_option_t set_option); /*!< in: Turn on/off reset the
889  counter */
890 /** This function consolidates some existing server counters used
891  by "system status variables". These existing system variables do not have
892  mechanism to start/stop and reset the counters, so we simulate these
893  controls by remembering the corresponding counter values when the
894  corresponding monitors are turned on/off/reset, and do appropriate
895  mathematics to deduct the actual value. */
897  monitor_id_t monitor_id, /*!< in: the monitor's ID as in
898  monitor_counter_id */
899  mon_option_t set_option); /*!< in: Turn on/off reset the
900  counter */
901 /** This function is used to calculate the maximum counter value
902  since the start of monitor counter
903  @return max counter value since start. */
904 UNIV_INLINE
906  monitor_id_t monitor); /*!< in: monitor id */
907 /** This function is used to calculate the minimum counter value
908  since the start of monitor counter
909  @return min counter value since start. */
910 UNIV_INLINE
912  monitor_id_t monitor); /*!< in: monitor id*/
913 /** Reset a monitor, create a new base line with the current monitor
914  value. This baseline is recorded by MONITOR_VALUE_RESET(monitor) */
915 void srv_mon_reset(monitor_id_t monitor); /*!< in: monitor id*/
916 /** This function resets all values of a monitor counter */
917 UNIV_INLINE
918 void srv_mon_reset_all(monitor_id_t monitor); /*!< in: monitor id*/
919 /** Turn on monitor counters that are marked as default ON. */
920 void srv_mon_default_on(void);
921 
922 #include "srv0mon.ic"
923 #else /* !UNIV_HOTBACKUP */
924 #define MONITOR_INC(x) ((void)0)
925 #define MONITOR_DEC(x) ((void)0)
926 #endif /* !UNIV_HOTBACKUP */
927 
928 #define MONITOR_INC_WAIT_STATS_EX(monitor_prefix, monitor_sufix, wait_stats) \
929  if ((wait_stats).wait_loops == 0) { \
930  MONITOR_INC(monitor_prefix##NO_WAITS##monitor_sufix); \
931  } else { \
932  MONITOR_INC(monitor_prefix##WAITS##monitor_sufix); \
933  MONITOR_INC_VALUE(monitor_prefix##WAIT_LOOPS##monitor_sufix, \
934  (wait_stats).wait_loops); \
935  }
936 
937 #define MONITOR_INC_WAIT_STATS(monitor_prefix, wait_stats) \
938  MONITOR_INC_WAIT_STATS_EX(monitor_prefix, , wait_stats);
939 
940 #endif
monitor_running_status
Possible status values for "mon_status" in "struct monitor_value".
Definition: srv0mon.h:47
void srv_mon_reset(monitor_id_t monitor)
Reset a monitor, create a new base line with the current monitor value.
Definition: srv0mon.cc:2083
Definition: srv0mon.h:382
Set this status if we don&#39;t want to calculate the average value for the counter.
Definition: srv0mon.h:93
Definition: srv0mon.h:395
Definition: srv0mon.h:489
Definition: srv0mon.h:490
Definition: srv0mon.h:171
Definition: srv0mon.h:340
Definition: srv0mon.h:212
Definition: srv0mon.h:228
Definition: srv0mon.h:511
Definition: srv0mon.h:518
Definition: srv0mon.h:274
Definition: srv0mon.h:220
Definition: srv0mon.h:281
Definition: srv0mon.h:520
Definition: srv0mon.h:381
Definition: srv0mon.h:306
Definition: srv0mon.h:391
Definition: srv0mon.h:159
Definition: srv0mon.h:292
Definition: srv0mon.h:285
Definition: srv0mon.h:496
Definition: srv0mon.h:143
Definition: srv0mon.h:180
Definition: srv0mon.h:264
Definition: srv0mon.h:459
Definition: srv0mon.h:367
Definition: srv0mon.h:233
Definition: srv0mon.h:507
Definition: srv0mon.h:423
monitor_id_t monitor_id
Monitor ID as defined in enum monitor_id_t.
Definition: srv0mon.h:550
Definition: srv0mon.h:460
Definition: srv0mon.h:311
Definition: srv0mon.h:191
Definition: srv0mon.h:512
Definition: srv0mon.h:399
Definition: srv0mon.h:235
Definition: srv0mon.h:165
Definition: srv0mon.h:359
Definition: srv0mon.h:427
Definition: srv0mon.h:158
Definition: srv0mon.h:267
Definition: srv0mon.h:260
mon_type_t mon_value_reset
value at last reset
Definition: srv0mon.h:77
The monitor carries information from an existing system status variable.
Definition: srv0mon.h:91
Definition: srv0mon.h:463
Definition: srv0mon.h:481
Definition: srv0mon.h:321
Definition: srv0mon.h:261
Definition: srv0mon.h:314
Definition: srv0mon.h:298
Definition: srv0mon.h:151
Definition: srv0mon.h:413
Definition: srv0mon.h:304
Turn on the counter.
Definition: srv0mon.h:558
Definition: srv0mon.h:341
Definition: srv0mon.h:458
Definition: srv0mon.h:242
mon_option_t
Following are the "set_option" values allowed for srv_mon_process_existing_counter() and srv_mon_proc...
Definition: srv0mon.h:557
Definition: srv0mon.h:472
Definition: srv0mon.h:131
Definition: srv0mon.h:500
Definition: srv0mon.h:377
Definition: srv0mon.h:282
time_t ib_time_t
Time stamp.
Definition: ut0ut.h:85
Definition: srv0mon.h:379
Definition: srv0mon.h:141
Definition: srv0mon.h:189
monitor_id_t
This enumeration defines internal monitor identifier used internally to identify each particular coun...
Definition: srv0mon.h:128
Definition: srv0mon.h:154
Definition: srv0mon.h:307
Definition: srv0mon.h:135
Definition: srv0mon.h:232
Definition: srv0mon.h:344
Definition: srv0mon.h:412
monitor_info_t * srv_mon_get_info(monitor_id_t monitor_id)
Get monitor&#39;s monitor_info_t by its monitor id (index into the innodb_counter_info array...
Definition: srv0mon.cc:1442
Definition: srv0mon.h:403
Definition: srv0mon.h:431
Definition: srv0mon.h:241
Do not display this monitor in the metrics table.
Definition: srv0mon.h:106
Definition: srv0mon.h:482
Definition: srv0mon.h:244
Definition: srv0mon.h:168
Definition: srv0mon.h:145
Definition: srv0mon.h:509
Definition: srv0mon.h:234
Definition: srv0mon.h:269
Definition: srv0mon.h:186
Definition: srv0mon.h:276
const char * monitor_module
Sub Module the monitor belongs to.
Definition: srv0mon.h:542
Definition: srv0mon.h:255
monitor_value_t innodb_counter_value[NUM_MONITOR]
The actual monitor counter array that records each monintor counter value.
Definition: srv0mon.cc:1432
Definition: srv0mon.h:425
Definition: srv0mon.h:224
Definition: srv0mon.h:160
mon_type_t mon_max_value_start
Max value since start.
Definition: srv0mon.h:78
Definition: srv0mon.h:256
Definition: srv0mon.h:185
Definition: srv0mon.h:435
monitor_running_t mon_status
Definition: srv0mon.h:82
Definition: srv0mon.h:455
Definition: srv0mon.h:387
Definition: srv0mon.h:262
Definition: srv0mon.h:416
Definition: srv0mon.h:354
Definition: srv0mon.h:332
Definition: srv0mon.h:176
Definition: srv0mon.h:197
Definition: srv0mon.h:365
Definition: srv0mon.h:447
Definition: srv0mon.h:442
Definition: srv0mon.h:411
Definition: srv0mon.h:209
Definition: srv0mon.h:407
Definition: srv0mon.h:415
Definition: srv0mon.h:362
Definition: srv0mon.h:389
Definition: srv0mon.h:405
Definition: srv0mon.h:218
#define NUM_BITS_ULINT
Number of bit in a ulint datatype.
Definition: srv0mon.h:569
Definition: srv0mon.h:430
Definition: srv0mon.h:294
monitor_type_t
Follwoing defines are possible values for "monitor_type" field in "struct monitor_info".
Definition: srv0mon.h:87
Definition: srv0mon.h:465
Definition: srv0mon.h:461
Definition: srv0mon.h:199
Definition: srv0mon.h:136
Definition: srv0mon.h:283
Definition: srv0mon.h:494
Definition: srv0mon.h:157
Definition: srv0mon.h:436
Definition: srv0mon.h:147
Definition: srv0mon.h:140
Definition: srv0mon.h:219
Definition: srv0mon.h:155
Definition: srv0mon.h:174
Definition: srv0mon.h:404
ib_time_t mon_reset_time
Time counter resetted.
Definition: srv0mon.h:73
Definition: srv0mon.h:229
Definition: srv0mon.h:198
Definition: srv0mon.h:406
Definition: srv0mon.h:161
Definition: srv0mon.h:368
Display current value of the counter, rather than incremental value over the period.
Definition: srv0mon.h:95
Definition: srv0mon.h:217
Definition: srv0mon.h:476
Definition: srv0mon.h:328
Definition: srv0mon.h:258
Definition: srv0mon.h:221
Monitor has been turned on.
Definition: srv0mon.h:48
Definition: srv0mon.h:187
Definition: srv0mon.h:528
Definition: srv0mon.h:149
Definition: srv0mon.h:375
Definition: srv0mon.h:449
void srv_mon_set_module_control(monitor_id_t module_id, mon_option_t set_option)
Turn on/off/reset monitor counters in a module.
Definition: srv0mon.cc:1470
Definition: srv0mon.h:295
Definition: srv0mon.h:286
Definition: srv0mon.h:347
Definition: srv0mon.h:152
Definition: srv0mon.h:320
Definition: srv0mon.h:440
Definition: srv0mon.h:477
Definition: srv0mon.h:504
Definition: srv0mon.h:486
Definition: srv0mon.h:357
Definition: srv0mon.h:456
void srv_mon_process_existing_counter(monitor_id_t monitor_id, mon_option_t set_option)
This function consolidates some existing server counters used by "system status variables".
Definition: srv0mon.cc:1607
Definition: srv0mon.h:162
Definition: srv0mon.h:302
Definition: srv0mon.h:296
ib_time_t mon_stop_time
Stop time of monitoring.
Definition: srv0mon.h:72
Definition: srv0mon.h:225
Definition: srv0mon.h:317
void srv_mon_default_on(void)
Turn on monitor counters that are marked as default ON.
Definition: srv0mon.cc:2125
Definition: srv0mon.h:470
Definition: srv0mon.h:188
Definition: srv0mon.h:349
Definition: srv0mon.h:253
Definition: srv0mon.h:323
Definition: srv0mon.h:495
Definition: srv0mon.h:488
Definition: srv0mon.h:182
Two monitor structures are defined in this file.
Definition: srv0mon.h:70
Definition: srv0mon.h:400
Definition: srv0mon.h:310
Definition: srv0mon.h:153
struct monitor_info describes the basic/static information about each monitor counter.
Definition: srv0mon.h:540
Definition: srv0mon.h:457
Definition: srv0mon.h:419
Definition: srv0mon.h:169
mon_type_t mon_value
Current counter Value.
Definition: srv0mon.h:74
Definition: srv0mon.h:434
Definition: srv0mon.h:250
Definition: srv0mon.h:508
Definition: srv0mon.h:266
This is a monitor module type, not a counter.
Definition: srv0mon.h:89
Definition: srv0mon.h:369
Definition: srv0mon.h:392
UNIV_INLINE mon_type_t srv_mon_calc_max_since_start(monitor_id_t monitor)
This function is used to calculate the maximum counter value since the start of monitor counter...
Definition: srv0mon.h:324
Definition: srv0mon.h:215
Definition: srv0mon.h:356
Definition: srv0mon.h:309
Definition: srv0mon.h:466
Definition: srv0mon.h:446
Definition: srv0mon.h:346
Definition: srv0mon.h:179
Definition: srv0mon.h:491
Definition: srv0mon.h:355
Definition: srv0mon.h:183
Definition: srv0mon.h:278
Definition: srv0mon.h:263
Definition: srv0mon.h:396
Definition: srv0mon.h:505
Definition: srv0mon.h:471
Definition: srv0mon.h:410
Definition: srv0mon.h:467
Definition: srv0mon.h:208
Definition: srv0mon.h:277
Definition: srv0mon.h:173
mon_type_t mon_min_value_start
Min value since start.
Definition: srv0mon.h:79
Definition: srv0mon.h:203
Definition: srv0mon.h:192
Definition: srv0mon.h:478
Definition: srv0mon.h:268
Definition: srv0mon.h:487
Definition: srv0mon.h:420
Definition: srv0mon.h:204
Definition: srv0mon.h:291
Definition: srv0mon.h:299
Definition: srv0mon.h:284
Definition: srv0mon.h:474
Definition: srv0mon.h:265
Definition: srv0mon.h:350
Definition: srv0mon.h:343
Definition: srv0mon.h:378
Definition: srv0mon.h:501
Definition: srv0mon.h:178
Definition: srv0mon.h:170
Definition: srv0mon.h:451
Definition: srv0mon.h:146
Definition: srv0mon.h:333
Definition: srv0mon.h:360
Definition: srv0mon.h:303
Definition: srv0mon.h:374
Definition: srv0mon.h:175
Definition: srv0mon.h:211
Definition: srv0mon.h:493
Definition: srv0mon.h:454
Owner of "monitor set", a set of monitor counters.
Definition: srv0mon.h:103
Definition: srv0mon.h:313
const char * monitor_desc
Brief desc of monitor counter.
Definition: srv0mon.h:544
Definition: srv0mon.h:280
Definition: srv0mon.h:150
Definition: srv0mon.h:352
Monitor can be turned on/off only as a module, but not individually.
Definition: srv0mon.h:99
Definition: srv0mon.h:414
Definition: srv0mon.h:223
UNIV_INLINE mon_type_t srv_mon_calc_min_since_start(monitor_id_t monitor)
This function is used to calculate the minimum counter value since the start of monitor counter...
Definition: srv0mon.h:272
Definition: srv0mon.h:245
Definition: srv0mon.h:327
Definition: srv0mon.h:181
Definition: srv0mon.h:521
Definition: srv0mon.h:251
const char * srv_mon_get_name(monitor_id_t monitor_id)
Get monitor&#39;s name by its monitor id (index into the innodb_counter_info array.
Definition: srv0mon.cc:1456
Definition: srv0mon.h:230
Definition: srv0mon.h:448
Definition: srv0mon.h:237
Definition: srv0mon.h:214
mon_type_t mon_last_value
Last set of values.
Definition: srv0mon.h:81
Definition: srv0mon.h:231
Definition: srv0mon.h:137
Definition: srv0mon.h:216
Definition: srv0mon.h:424
ulint monitor_set_tbl[(NUM_MONITOR+NUM_BITS_ULINT - 1)/NUM_BITS_ULINT]
This "monitor_set_tbl" is a bitmap records whether a particular monitor counter has been turned on or...
Definition: srv0mon.cc:1436
Definition: srv0mon.h:193
Definition: srv0mon.h:305
mon_type_t mon_min_value
Current Min value.
Definition: srv0mon.h:76
Definition: srv0mon.h:388
Definition: srv0mon.h:398
Reset current values.
Definition: srv0mon.h:560
Being part of a "monitor set".
Definition: srv0mon.h:105
Reset all values.
Definition: srv0mon.h:561
Turn off the counter.
Definition: srv0mon.h:559
Definition: srv0mon.h:517
Definition: srv0mon.h:371
Definition: srv0mon.h:473
Definition: srv0mon.h:184
monitor_id_t monitor_related_id
Monitor ID of counter that related to this monitor.
Definition: srv0mon.h:546
Definition: srv0mon.h:325
Definition: srv0mon.h:308
Definition: srv0mon.h:315
mon_type_t mon_start_value
Value at the start time.
Definition: srv0mon.h:80
Monitor will be turned on by default at server start up.
Definition: srv0mon.h:101
Definition: srv0mon.h:464
Definition: srv0mon.h:422
const char * monitor_name
Monitor name.
Definition: srv0mon.h:541
Definition: srv0mon.h:252
Definition: srv0mon.h:166
Definition: srv0mon.h:462
Definition: srv0mon.h:205
Definition: srv0mon.h:290
enum monitor_running_status monitor_running_t
Definition: srv0mon.h:52
Definition: srv0mon.h:167
Definition: srv0mon.h:364
Definition: srv0mon.h:273
Definition: srv0mon.h:312
Definition: srv0mon.h:390
Definition: srv0mon.h:207
UNIV_INLINE void srv_mon_reset_all(monitor_id_t monitor)
This function resets all values of a monitor counter.
Definition: srv0mon.h:361
Definition: srv0mon.h:227
Definition: srv0mon.h:257
Definition: srv0mon.h:144
Definition: srv0mon.h:497
Definition: srv0mon.h:177
Definition: srv0mon.h:243
int64_t mon_type_t
Monitor counter value type.
Definition: srv0mon.h:55
Definition: srv0mon.h:322
Definition: srv0mon.h:194
Definition: srv0mon.h:142
Definition: srv0mon.h:453
Definition: srv0mon.h:148
mon_type_t mon_max_value
Current Max value.
Definition: srv0mon.h:75
Definition: srv0mon.h:279
Definition: srv0mon.h:270
No monitoring.
Definition: srv0mon.h:88
Definition: srv0mon.h:336
Definition: srv0mon.h:339
Monitor has been turned off.
Definition: srv0mon.h:49
ib_time_t mon_start_time
Start time of monitoring.
Definition: srv0mon.h:71
Option for srv_mon_process_existing_counter() function.
Definition: srv0mon.h:562
Definition: srv0mon.h:514
Definition: srv0mon.h:297
Definition: srv0mon.h:275
Definition: srv0mon.h:363
Definition: srv0mon.h:316
Definition: srv0mon.h:226
Definition: srv0mon.h:236
Definition: srv0mon.h:519
Definition: srv0mon.h:445
Definition: srv0mon.h:326
Definition: srv0mon.h:259
Definition: srv0mon.h:293
Definition: srv0mon.h:342
monitor_type_t monitor_type
Type of Monitor Info.
Definition: srv0mon.h:545
Definition: srv0mon.h:506
Definition: srv0mon.h:383
Definition: srv0mon.h:452
Definition: srv0mon.h:475
Definition: srv0mon.h:156
Definition: srv0mon.h:437
Definition: srv0mon.h:525
Definition: srv0mon.h:222
Definition: srv0mon.h:254
Definition: srv0mon.h:351
Definition: srv0mon.h:348
Definition: srv0mon.h:483
Definition: srv0mon.h:441
Definition: srv0mon.h:373
Definition: srv0mon.h:190
Definition: srv0mon.h:134