How to use is_hidden method in Playwright Python

Best Python code snippet using playwright-python

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

variable.py

Source: variable.py Github

copy
1import re
2
3from .entity import EntityType, Entity
4from .validator import PropertyValidator
5from .task_input import _task_input
6
7
8# Variable
9
10VARIABLE_VALUE_TYPES = {
11    "int": "INT",
12    "date": "DATE",
13    "time": "TIME",
14    "dict": "DICT",
15    "string": "STRING",
16    "data_time": "DATE_TIME",
17    "multiline_string": "MULTILINE_STRING",
18}
19
20VARIABLE_DATA_TYPES = {
21    "base": "BASE",
22    "list": "LIST",
23    "single_select_list": "SINGLE_SELECT_LIST",
24}
25
26
27class VariableType(EntityType):
28    __schema_name__ = "Variable"
29    __openapi_type__ = "app_variable"
30
31    def compile(cls):
32        cdict = super().compile()
33        if not cdict.get("options", {}):
34            del cdict["options"]
35        if not cdict.get("regex", {}):
36            del cdict["regex"]
37        if not cdict.get("editables", {}):
38            del cdict["editables"]
39
40        if cdict.get("options", None):
41            options = cdict["options"]
42            # Only EScript/HTTP request info needed for dynamically fetching options
43            if options["type"] == "PREDEFINED":
44                del options["attrs"]
45            else:
46                del options["choices"]  # Choices are only for PREDEFINED Type
47
48        return cdict
49
50
51class VariableValidator(PropertyValidator, openapi_type="app_variable"):
52    __default__ = None
53    __kind__ = VariableType
54
55
56def _var(**kwargs):
57    name = kwargs.get("name", None)
58    bases = (Entity,)
59    return VariableType(name, bases, kwargs)
60
61
62Variable = _var()
63
64
65def setvar(name, value, type_="LOCAL", **kwargs):
66
67    kwargs["name"] = name
68    if value is not None:
69        kwargs["value"] = value
70    kwargs["type"] = type_
71
72    return VariableType(name, (Variable,), kwargs)
73
74
75def simple_variable(
76    value,
77    name=None,
78    label=None,
79    regex=None,
80    validate_regex=False,
81    is_hidden=False,
82    is_mandatory=False,
83    runtime=False,
84    description="",
85):
86    kwargs = {"is_hidden": is_hidden, "is_mandatory": is_mandatory}
87    editables = {}
88    if runtime:
89        editables = {"value": True}
90        kwargs["editables"] = editables
91    if label is not None:
92        kwargs["label"] = label
93    if regex is not None:
94        if not isinstance(regex, str):
95            raise TypeError(
96                "Expected string in field regex for variable "
97                + (name or "")
98                + ", got {}".format(type(regex))
99            )
100        if validate_regex and regex and value:
101            regex_result = re.match(regex, value)
102            if not regex_result:
103                raise ValueError(
104                    "Value '{}' doesn't match with specified regex '{}'".format(
105                        value, regex
106                    )
107                )
108
109        regex = {"value": regex, "should_validate": validate_regex}
110        kwargs["regex"] = regex
111    if description is not None:
112        kwargs["description"] = description
113
114    return setvar(name, value, **kwargs)
115
116
117def simple_variable_secret(
118    value,
119    name=None,
120    label=None,
121    regex=None,
122    validate_regex=False,
123    is_hidden=False,
124    is_mandatory=False,
125    runtime=False,
126    description="",
127):
128    kwargs = {"is_hidden": is_hidden, "is_mandatory": is_mandatory}
129    editables = {}
130    if runtime:
131        editables = {"value": True}
132        kwargs["editables"] = editables
133    if label is not None:
134        kwargs["label"] = label
135    if regex is not None:
136        if not isinstance(regex, str):
137            raise TypeError(
138                "Expected string in field regex for variable "
139                + (name or "")
140                + ", got {}".format(type(regex))
141            )
142        if validate_regex and regex and value:
143            regex_result = re.match(regex, value)
144            if not regex_result:
145                raise ValueError(
146                    "Value '{}' doesn't match with specified regex '{}'".format(
147                        value, regex
148                    )
149                )
150
151        regex = {"value": regex, "should_validate": validate_regex}
152        kwargs["regex"] = regex
153    if description is not None:
154        kwargs["description"] = description
155    return setvar(name, value, type_="SECRET", **kwargs)
156
157
158def _advanced_variable(
159    type_,
160    name=None,
161    value="",
162    label=None,
163    task=None,
164    value_type=None,
165    data_type=None,
166    regex=None,
167    validate_regex=False,
168    options=None,
169    is_hidden=False,
170    is_mandatory=False,
171    runtime=False,
172    description="",
173):
174    kwargs = {"name": name, "value": value, "type_": type_}
175    if runtime:
176        kwargs["editables"] = {"value": True}
177    if label is not None:
178        kwargs["label"] = label
179    if task is not None:
180        if not getattr(task, "__kind__") == "app_task":
181            raise TypeError(
182                "Expected a Task for variable "
183                + (name or "")
184                + ", got {}".format(type(task))
185            )
186        task_attrs = task.compile().get("attrs")
187        if not task_attrs:
188            raise ValueError("Task for variable " + (name or "") + ", is not valid.")
189        task_type = getattr(task, "type")
190        if task_type not in ["HTTP", "EXEC"]:
191            raise ValueError(
192                "Task type for variable "
193                + (name or "")
194                + ", is not valid, Expected one of"
195                + " ['HTTP', 'EXEC'], got {}".format(task_type)
196            )
197        task_attrs["type"] = task_type
198        kwargs["type_"] = task_type + "_" + type_
199        kwargs["options"] = {"type": task_type, "attrs": task_attrs}
200    if value_type is not None:
201        value_type = value_type.upper()
202        if value_type not in VARIABLE_VALUE_TYPES.values():
203            raise ValueError(
204                "Value type for variable "
205                + (name or "")
206                + ", is not valid, Expected one of"
207                + " {}, got {}".format(list(VARIABLE_VALUE_TYPES.values()), value_type)
208            )
209        kwargs["value_type"] = value_type
210    if data_type is not None:
211        data_type = data_type.upper()
212        if data_type not in VARIABLE_DATA_TYPES.values():
213            raise ValueError(
214                "Data type for variable "
215                + (name or "")
216                + ", is not valid, Expected one of"
217                + " {}, got {}".format(list(VARIABLE_DATA_TYPES.values()), data_type)
218            )
219        kwargs["data_type"] = data_type
220    if regex is not None:
221        if not isinstance(regex, str):
222            raise TypeError(
223                "Expected string in field regex for variable "
224                + (name or "")
225                + ", got {}".format(type(regex))
226            )
227        regex = {"value": regex, "should_validate": validate_regex}
228        kwargs["regex"] = regex
229    if options is not None:
230        if kwargs.get("options", None) is not None:
231            raise ValueError(
232                "Variable options for variable "
233                + (name or "")
234                + "cannot be specified since it is being "
235                + "fetched from a {} task".format(kwargs["options"]["type"])
236            )
237        if not isinstance(options, list):
238            raise TypeError(
239                "Expected list of options for variable "
240                + (name or "")
241                + ", got {}".format(type(options))
242            )
243        choices = []
244        for choice in options:
245            if not isinstance(choice, str):
246                raise TypeError(
247                    "Expected list of string choices for options for variable "
248                    + (name or "")
249                    + ", got {}".format(type(choice))
250                )
251            if validate_regex and regex:
252                regex_result = re.match(regex["value"], choice)
253                if not regex_result:
254                    raise ValueError(
255                        "Option '{}' doesn't match with specified regex '{}'".format(
256                            choice, regex["value"]
257                        )
258                    )
259
260            choices.append(choice)
261        if isinstance(value, list) and data_type == "LIST":
262            for val in value:
263                if not isinstance(val, str):
264                    raise TypeError(
265                        "Expected list of string defaults for variable "
266                        + (name or "")
267                        + ", got {}".format(type(val))
268                    )
269                if val not in choices:
270                    raise TypeError(
271                        "Default value for variable array with options "
272                        + (name or "")
273                        + ", contains {}, which is not one of the options".format(val)
274                    )
275            value = ",".join(value)
276            kwargs["value"] = value
277        if value is None and len(choices) > 0:
278            value = choices[0]
279            kwargs["value"] = value
280        if data_type != "LIST" and value not in choices:
281            raise TypeError(
282                "Default value for variable with options "
283                + (name or "")
284                + ", is {}, which is not one of the options".format(value)
285            )
286        options = {"type": "PREDEFINED", "choices": choices}
287        kwargs["options"] = options
288    else:
289        # If options are None, just regex validate the value
290        if validate_regex and regex and value:
291            regex_result = re.match(regex["value"], value)
292            if not regex_result:
293                raise ValueError(
294                    "Value '{}' doesn't match with specified regex '{}'".format(
295                        value, regex["value"]
296                    )
297                )
298    if is_hidden is not None:
299        kwargs["is_hidden"] = bool(is_hidden)
300    if is_mandatory is not None:
301        kwargs["is_mandatory"] = bool(is_mandatory)
302    if description is not None:
303        kwargs["description"] = description
304
305    return setvar(**kwargs)
306
307
308def simple_variable_int(
309    value,
310    name=None,
311    label=None,
312    regex=r"^[\d]*$",
313    validate_regex=False,
314    is_hidden=False,
315    is_mandatory=False,
316    runtime=False,
317    description="",
318):
319    return _advanced_variable(
320        "LOCAL",
321        name=name,
322        value=value,
323        label=label,
324        value_type="INT",
325        data_type="BASE",
326        regex=regex,
327        validate_regex=validate_regex,
328        is_hidden=is_hidden,
329        is_mandatory=is_mandatory,
330        runtime=runtime,
331        description=description,
332    )
333
334
335def simple_variable_date(
336    value,
337    name=None,
338    label=None,
339    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})$",
340    validate_regex=False,
341    is_hidden=False,
342    is_mandatory=False,
343    runtime=False,
344    description="",
345):
346    return _advanced_variable(
347        "LOCAL",
348        name=name,
349        value=value,
350        label=label,
351        value_type="DATE",
352        data_type="BASE",
353        regex=regex,
354        validate_regex=validate_regex,
355        is_hidden=is_hidden,
356        is_mandatory=is_mandatory,
357        runtime=runtime,
358        description=description,
359    )
360
361
362def simple_variable_time(
363    value,
364    name=None,
365    label=None,
366    regex=r"^[\d]{2}:[\d]{2}(:[0-5]\d)?$",
367    validate_regex=False,
368    is_hidden=False,
369    is_mandatory=False,
370    runtime=False,
371    description="",
372):
373    return _advanced_variable(
374        "LOCAL",
375        name=name,
376        value=value,
377        label=label,
378        value_type="TIME",
379        data_type="BASE",
380        regex=regex,
381        validate_regex=validate_regex,
382        is_hidden=is_hidden,
383        is_mandatory=is_mandatory,
384        runtime=runtime,
385        description=description,
386    )
387
388
389def simple_variable_datetime(
390    value,
391    name=None,
392    label=None,
393    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})((T)|(\s-\s))[\d]{2}:[\d]{2}(:[0-5]\d)?$",
394    validate_regex=False,
395    is_hidden=False,
396    is_mandatory=False,
397    runtime=False,
398    description="",
399):
400    return _advanced_variable(
401        "LOCAL",
402        name=name,
403        value=value,
404        label=label,
405        value_type="DATE_TIME",
406        data_type="BASE",
407        regex=regex,
408        validate_regex=validate_regex,
409        is_hidden=is_hidden,
410        is_mandatory=is_mandatory,
411        runtime=runtime,
412        description=description,
413    )
414
415
416def simple_variable_multiline(
417    value,
418    name=None,
419    label=None,
420    regex=None,
421    validate_regex=False,
422    is_hidden=False,
423    is_mandatory=False,
424    runtime=False,
425    description="",
426):
427    return _advanced_variable(
428        "LOCAL",
429        name=name,
430        value=value,
431        label=label,
432        value_type="MULTILINE_STRING",
433        data_type="BASE",
434        regex=regex,
435        validate_regex=validate_regex,
436        is_hidden=is_hidden,
437        is_mandatory=is_mandatory,
438        runtime=runtime,
439        description=description,
440    )
441
442
443def simple_variable_int_secret(
444    value,
445    name=None,
446    label=None,
447    regex=r"^[\d]*$",
448    validate_regex=False,
449    is_hidden=False,
450    is_mandatory=False,
451    runtime=False,
452    description="",
453):
454    return _advanced_variable(
455        "SECRET",
456        name=name,
457        value=value,
458        label=label,
459        value_type="INT",
460        data_type="BASE",
461        regex=regex,
462        validate_regex=validate_regex,
463        is_hidden=is_hidden,
464        is_mandatory=is_mandatory,
465        runtime=runtime,
466        description=description,
467    )
468
469
470def simple_variable_date_secret(
471    value,
472    name=None,
473    label=None,
474    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})$",
475    validate_regex=False,
476    is_hidden=False,
477    is_mandatory=False,
478    runtime=False,
479    description="",
480):
481    return _advanced_variable(
482        "SECRET",
483        name=name,
484        value=value,
485        label=label,
486        value_type="DATE",
487        data_type="BASE",
488        regex=regex,
489        validate_regex=validate_regex,
490        is_hidden=is_hidden,
491        is_mandatory=is_mandatory,
492        runtime=runtime,
493        description=description,
494    )
495
496
497def simple_variable_time_secret(
498    value,
499    name=None,
500    label=None,
501    regex=r"^[\d]{2}:[\d]{2}(:[0-5]\d)?$",
502    validate_regex=False,
503    is_hidden=False,
504    is_mandatory=False,
505    runtime=False,
506    description="",
507):
508    return _advanced_variable(
509        "SECRET",
510        name=name,
511        value=value,
512        label=label,
513        value_type="TIME",
514        data_type="BASE",
515        regex=regex,
516        validate_regex=validate_regex,
517        is_hidden=is_hidden,
518        is_mandatory=is_mandatory,
519        runtime=runtime,
520        description=description,
521    )
522
523
524def simple_variable_datetime_secret(
525    value,
526    name=None,
527    label=None,
528    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})((T)|(\s-\s))[\d]{2}:[\d]{2}(:[0-5]\d)?$",
529    validate_regex=False,
530    is_hidden=False,
531    is_mandatory=False,
532    runtime=False,
533    description="",
534):
535    return _advanced_variable(
536        "SECRET",
537        name=name,
538        value=value,
539        label=label,
540        value_type="DATE_TIME",
541        data_type="BASE",
542        regex=regex,
543        validate_regex=validate_regex,
544        is_hidden=is_hidden,
545        is_mandatory=is_mandatory,
546        runtime=runtime,
547        description=description,
548    )
549
550
551def simple_variable_multiline_secret(
552    value,
553    name=None,
554    label=None,
555    regex=None,
556    validate_regex=False,
557    is_hidden=False,
558    is_mandatory=False,
559    runtime=False,
560    description="",
561):
562    return _advanced_variable(
563        "SECRET",
564        name=name,
565        value=value,
566        label=label,
567        value_type="MULTILINE_STRING",
568        data_type="BASE",
569        regex=regex,
570        validate_regex=validate_regex,
571        is_hidden=is_hidden,
572        is_mandatory=is_mandatory,
573        runtime=runtime,
574        description=description,
575    )
576
577
578def variable_string_with_predefined_options(
579    options,
580    default=None,
581    name=None,
582    label=None,
583    regex=None,
584    validate_regex=False,
585    is_hidden=False,
586    is_mandatory=False,
587    runtime=False,
588    description="",
589):
590    return _advanced_variable(
591        "LOCAL",
592        name=name,
593        value=default,
594        label=label,
595        value_type="STRING",
596        data_type="BASE",
597        regex=regex,
598        validate_regex=validate_regex,
599        options=options,
600        is_hidden=is_hidden,
601        is_mandatory=is_mandatory,
602        runtime=runtime,
603        description=description,
604    )
605
606
607def variable_int_with_predefined_options(
608    options,
609    default=None,
610    name=None,
611    label=None,
612    regex=r"^[\d]*$",
613    validate_regex=False,
614    is_hidden=False,
615    is_mandatory=False,
616    runtime=False,
617    description="",
618):
619    return _advanced_variable(
620        "LOCAL",
621        name=name,
622        value=default,
623        label=label,
624        value_type="INT",
625        data_type="BASE",
626        regex=regex,
627        validate_regex=validate_regex,
628        options=options,
629        is_hidden=is_hidden,
630        is_mandatory=is_mandatory,
631        runtime=runtime,
632        description=description,
633    )
634
635
636def variable_date_with_predefined_options(
637    options,
638    default=None,
639    name=None,
640    label=None,
641    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})$",
642    validate_regex=False,
643    is_hidden=False,
644    is_mandatory=False,
645    runtime=False,
646    description="",
647):
648    return _advanced_variable(
649        "LOCAL",
650        name=name,
651        value=default,
652        label=label,
653        value_type="DATE",
654        data_type="BASE",
655        regex=regex,
656        validate_regex=validate_regex,
657        options=options,
658        is_hidden=is_hidden,
659        is_mandatory=is_mandatory,
660        runtime=runtime,
661        description=description,
662    )
663
664
665def variable_time_with_predefined_options(
666    options,
667    default=None,
668    name=None,
669    label=None,
670    regex=r"^[\d]{2}:[\d]{2}(:[0-5]\d)?$",
671    validate_regex=False,
672    is_hidden=False,
673    is_mandatory=False,
674    runtime=False,
675    description="",
676):
677    return _advanced_variable(
678        "LOCAL",
679        name=name,
680        value=default,
681        label=label,
682        value_type="TIME",
683        data_type="BASE",
684        regex=regex,
685        validate_regex=validate_regex,
686        options=options,
687        is_hidden=is_hidden,
688        is_mandatory=is_mandatory,
689        runtime=runtime,
690        description=description,
691    )
692
693
694def variable_datetime_with_predefined_options(
695    options,
696    default=None,
697    name=None,
698    label=None,
699    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})((T)|(\s-\s))[\d]{2}:[\d]{2}(:[0-5]\d)?$",
700    validate_regex=False,
701    is_hidden=False,
702    is_mandatory=False,
703    runtime=False,
704    description="",
705):
706    return _advanced_variable(
707        "LOCAL",
708        name=name,
709        value=default,
710        label=label,
711        value_type="DATE_TIME",
712        data_type="BASE",
713        regex=regex,
714        validate_regex=validate_regex,
715        options=options,
716        is_hidden=is_hidden,
717        is_mandatory=is_mandatory,
718        runtime=runtime,
719        description=description,
720    )
721
722
723def variable_multiline_with_predefined_options(
724    options,
725    default=None,
726    name=None,
727    label=None,
728    regex=None,
729    validate_regex=False,
730    is_hidden=False,
731    is_mandatory=False,
732    runtime=False,
733    description="",
734):
735    return _advanced_variable(
736        "LOCAL",
737        name=name,
738        value=default,
739        label=label,
740        value_type="MULTILINE_STRING",
741        data_type="BASE",
742        regex=regex,
743        validate_regex=validate_regex,
744        options=options,
745        is_hidden=is_hidden,
746        is_mandatory=is_mandatory,
747        runtime=runtime,
748        description=description,
749    )
750
751
752def variable_string_with_predefined_options_array(
753    options,
754    defaults=None,
755    name=None,
756    label=None,
757    regex=None,
758    validate_regex=False,
759    is_hidden=False,
760    is_mandatory=False,
761    runtime=False,
762    description="",
763):
764    return _advanced_variable(
765        "LOCAL",
766        name=name,
767        value=defaults,
768        label=label,
769        value_type="STRING",
770        data_type="LIST",
771        regex=regex,
772        validate_regex=validate_regex,
773        options=options,
774        is_hidden=is_hidden,
775        is_mandatory=is_mandatory,
776        runtime=runtime,
777        description=description,
778    )
779
780
781def variable_int_with_predefined_options_array(
782    options,
783    defaults=None,
784    name=None,
785    label=None,
786    regex=r"^[\d]*$",
787    validate_regex=False,
788    is_hidden=False,
789    is_mandatory=False,
790    runtime=False,
791    description="",
792):
793    return _advanced_variable(
794        "LOCAL",
795        name=name,
796        value=defaults,
797        label=label,
798        value_type="INT",
799        data_type="LIST",
800        regex=regex,
801        validate_regex=validate_regex,
802        options=options,
803        is_hidden=is_hidden,
804        is_mandatory=is_mandatory,
805        runtime=runtime,
806        description=description,
807    )
808
809
810def variable_date_with_predefined_options_array(
811    options,
812    defaults=None,
813    name=None,
814    label=None,
815    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})$",
816    validate_regex=False,
817    is_hidden=False,
818    is_mandatory=False,
819    runtime=False,
820    description="",
821):
822    return _advanced_variable(
823        "LOCAL",
824        name=name,
825        value=defaults,
826        label=label,
827        value_type="DATE",
828        data_type="LIST",
829        regex=regex,
830        validate_regex=validate_regex,
831        options=options,
832        is_hidden=is_hidden,
833        is_mandatory=is_mandatory,
834        runtime=runtime,
835        description=description,
836    )
837
838
839def variable_time_with_predefined_options_array(
840    options,
841    defaults=None,
842    name=None,
843    label=None,
844    regex=r"^[\d]{2}:[\d]{2}(:[0-5]\d)?$",
845    validate_regex=False,
846    is_hidden=False,
847    is_mandatory=False,
848    runtime=False,
849    description="",
850):
851    return _advanced_variable(
852        "LOCAL",
853        name=name,
854        value=defaults,
855        label=label,
856        value_type="TIME",
857        data_type="LIST",
858        regex=regex,
859        validate_regex=validate_regex,
860        options=options,
861        is_hidden=is_hidden,
862        is_mandatory=is_mandatory,
863        runtime=runtime,
864        description=description,
865    )
866
867
868def variable_datetime_with_predefined_options_array(
869    options,
870    defaults=None,
871    name=None,
872    label=None,
873    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})((T)|(\s-\s))[\d]{2}:[\d]{2}(:[0-5]\d)?$",
874    validate_regex=False,
875    is_hidden=False,
876    is_mandatory=False,
877    runtime=False,
878    description="",
879):
880    return _advanced_variable(
881        "LOCAL",
882        name=name,
883        value=defaults,
884        label=label,
885        value_type="DATE_TIME",
886        data_type="LIST",
887        regex=regex,
888        validate_regex=validate_regex,
889        options=options,
890        is_hidden=is_hidden,
891        is_mandatory=is_mandatory,
892        runtime=runtime,
893        description=description,
894    )
895
896
897def variable_multiline_with_predefined_options_array(
898    options,
899    defaults=None,
900    name=None,
901    label=None,
902    regex=None,
903    validate_regex=False,
904    is_hidden=False,
905    is_mandatory=False,
906    runtime=False,
907    description="",
908):
909    return _advanced_variable(
910        "LOCAL",
911        name=name,
912        value=defaults,
913        label=label,
914        value_type="MULTILINE_STRING",
915        data_type="LIST",
916        regex=regex,
917        validate_regex=validate_regex,
918        options=options,
919        is_hidden=is_hidden,
920        is_mandatory=is_mandatory,
921        runtime=runtime,
922        description=description,
923    )
924
925
926def variable_string_with_options_from_task(
927    task,
928    name=None,
929    label=None,
930    regex=None,
931    validate_regex=False,
932    is_hidden=False,
933    is_mandatory=False,
934    description="",
935):
936    return _advanced_variable(
937        "LOCAL",
938        name=name,
939        label=label,
940        value_type="STRING",
941        data_type="BASE",
942        regex=regex,
943        validate_regex=validate_regex,
944        task=task,
945        is_hidden=is_hidden,
946        is_mandatory=is_mandatory,
947        runtime=True,
948        description=description,
949    )
950
951
952def variable_int_with_options_from_task(
953    task,
954    name=None,
955    label=None,
956    regex=r"^[\d]*$",
957    validate_regex=False,
958    is_hidden=False,
959    is_mandatory=False,
960    description="",
961):
962    return _advanced_variable(
963        "LOCAL",
964        name=name,
965        label=label,
966        value_type="INT",
967        data_type="BASE",
968        regex=regex,
969        validate_regex=validate_regex,
970        task=task,
971        is_hidden=is_hidden,
972        is_mandatory=is_mandatory,
973        runtime=True,
974        description=description,
975    )
976
977
978def variable_date_with_options_from_task(
979    task,
980    name=None,
981    label=None,
982    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})$",
983    validate_regex=False,
984    is_hidden=False,
985    is_mandatory=False,
986    description="",
987):
988    return _advanced_variable(
989        "LOCAL",
990        name=name,
991        label=label,
992        value_type="DATE",
993        data_type="BASE",
994        regex=regex,
995        validate_regex=validate_regex,
996        task=task,
997        is_hidden=is_hidden,
998        is_mandatory=is_mandatory,
999        runtime=True,
1000        description=description,
1001    )
1002
1003
1004def variable_time_with_options_from_task(
1005    task,
1006    name=None,
1007    label=None,
1008    regex=r"^[\d]{2}:[\d]{2}(:[0-5]\d)?$",
1009    validate_regex=False,
1010    is_hidden=False,
1011    is_mandatory=False,
1012    description="",
1013):
1014    return _advanced_variable(
1015        "LOCAL",
1016        name=name,
1017        label=label,
1018        value_type="TIME",
1019        data_type="BASE",
1020        regex=regex,
1021        validate_regex=validate_regex,
1022        task=task,
1023        is_hidden=is_hidden,
1024        is_mandatory=is_mandatory,
1025        runtime=True,
1026        description=description,
1027    )
1028
1029
1030def variable_datetime_with_options_from_task(
1031    task,
1032    name=None,
1033    label=None,
1034    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})((T)|(\s-\s))[\d]{2}:[\d]{2}(:[0-5]\d)?$",
1035    validate_regex=False,
1036    is_hidden=False,
1037    is_mandatory=False,
1038    description="",
1039):
1040    return _advanced_variable(
1041        "LOCAL",
1042        name=name,
1043        label=label,
1044        value_type="DATE_TIME",
1045        data_type="BASE",
1046        regex=regex,
1047        validate_regex=validate_regex,
1048        task=task,
1049        is_hidden=is_hidden,
1050        is_mandatory=is_mandatory,
1051        runtime=True,
1052        description=description,
1053    )
1054
1055
1056def variable_multiline_with_options_from_task(
1057    task,
1058    name=None,
1059    label=None,
1060    regex=None,
1061    validate_regex=False,
1062    is_hidden=False,
1063    is_mandatory=False,
1064    description="",
1065):
1066    return _advanced_variable(
1067        "LOCAL",
1068        name=name,
1069        label=label,
1070        value_type="MULTILINE_STRING",
1071        data_type="BASE",
1072        regex=regex,
1073        validate_regex=validate_regex,
1074        task=task,
1075        is_hidden=is_hidden,
1076        is_mandatory=is_mandatory,
1077        runtime=True,
1078        description=description,
1079    )
1080
1081
1082def variable_string_with_options_from_task_array(
1083    task,
1084    name=None,
1085    label=None,
1086    regex=None,
1087    validate_regex=False,
1088    is_hidden=False,
1089    is_mandatory=False,
1090    description="",
1091):
1092    return _advanced_variable(
1093        "LOCAL",
1094        name=name,
1095        label=label,
1096        value_type="STRING",
1097        data_type="LIST",
1098        regex=regex,
1099        validate_regex=validate_regex,
1100        task=task,
1101        is_hidden=is_hidden,
1102        is_mandatory=is_mandatory,
1103        runtime=True,
1104        description=description,
1105    )
1106
1107
1108def variable_int_with_options_from_task_array(
1109    task,
1110    name=None,
1111    label=None,
1112    regex=r"^[\d]*$",
1113    validate_regex=False,
1114    is_hidden=False,
1115    is_mandatory=False,
1116    description="",
1117):
1118    return _advanced_variable(
1119        "LOCAL",
1120        name=name,
1121        label=label,
1122        value_type="INT",
1123        data_type="LIST",
1124        regex=regex,
1125        validate_regex=validate_regex,
1126        task=task,
1127        is_hidden=is_hidden,
1128        is_mandatory=is_mandatory,
1129        runtime=True,
1130        description=description,
1131    )
1132
1133
1134def variable_date_with_options_from_task_array(
1135    task,
1136    name=None,
1137    label=None,
1138    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})$",
1139    validate_regex=False,
1140    is_hidden=False,
1141    is_mandatory=False,
1142    description="",
1143):
1144    return _advanced_variable(
1145        "LOCAL",
1146        name=name,
1147        label=label,
1148        value_type="DATE",
1149        data_type="LIST",
1150        regex=regex,
1151        validate_regex=validate_regex,
1152        task=task,
1153        is_hidden=is_hidden,
1154        is_mandatory=is_mandatory,
1155        runtime=True,
1156        description=description,
1157    )
1158
1159
1160def variable_time_with_options_from_task_array(
1161    task,
1162    name=None,
1163    label=None,
1164    regex=r"^[\d]{2}:[\d]{2}(:[0-5]\d)?$",
1165    validate_regex=False,
1166    is_hidden=False,
1167    is_mandatory=False,
1168    description="",
1169):
1170    return _advanced_variable(
1171        "LOCAL",
1172        name=name,
1173        label=label,
1174        value_type="TIME",
1175        data_type="LIST",
1176        regex=regex,
1177        validate_regex=validate_regex,
1178        task=task,
1179        is_hidden=is_hidden,
1180        is_mandatory=is_mandatory,
1181        runtime=True,
1182        description=description,
1183    )
1184
1185
1186def variable_datetime_with_options_from_task_array(
1187    task,
1188    name=None,
1189    label=None,
1190    regex=r"^((0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/[12]\d{3})((T)|(\s-\s))[\d]{2}:[\d]{2}(:[0-5]\d)?$",
1191    validate_regex=False,
1192    is_hidden=False,
1193    is_mandatory=False,
1194    description="",
1195):
1196    return _advanced_variable(
1197        "LOCAL",
1198        name=name,
1199        label=label,
1200        value_type="DATE_TIME",
1201        data_type="LIST",
1202        regex=regex,
1203        validate_regex=validate_regex,
1204        task=task,
1205        is_hidden=is_hidden,
1206        is_mandatory=is_mandatory,
1207        runtime=True,
1208        description=description,
1209    )
1210
1211
1212def variable_multiline_with_options_from_task_array(
1213    task,
1214    name=None,
1215    label=None,
1216    regex=None,
1217    validate_regex=False,
1218    is_hidden=False,
1219    is_mandatory=False,
1220    description="",
1221):
1222    return _advanced_variable(
1223        "LOCAL",
1224        name=name,
1225        label=label,
1226        value_type="MULTILINE_STRING",
1227        data_type="LIST",
1228        regex=regex,
1229        validate_regex=validate_regex,
1230        task=task,
1231        is_hidden=is_hidden,
1232        is_mandatory=is_mandatory,
1233        runtime=True,
1234        description=description,
1235    )
1236
1237
1238class CalmVariable:
1239    def __new__(
1240        cls,
1241        value,
1242        name=None,
1243        label=None,
1244        regex=None,
1245        validate_regex=False,
1246        is_hidden=False,
1247        is_mandatory=False,
1248        runtime=False,
1249        description="",
1250    ):
1251        return simple_variable(
1252            value,
1253            name=name,
1254            label=label,
1255            regex=regex,
1256            validate_regex=validate_regex,
1257            is_hidden=is_hidden,
1258            is_mandatory=is_mandatory,
1259            runtime=runtime,
1260            description=description,
1261        )
1262
1263    class Simple:
1264        def __new__(
1265            cls,
1266            value,
1267            name=None,
1268            label=None,
1269            regex=None,
1270            validate_regex=False,
1271            is_hidden=False,
1272            is_mandatory=False,
1273            runtime=False,
1274            description="",
1275        ):
1276            return simple_variable(
1277                value,
1278                name=name,
1279                label=label,
1280                regex=regex,
1281                validate_regex=validate_regex,
1282                is_hidden=is_hidden,
1283                is_mandatory=is_mandatory,
1284                runtime=runtime,
1285                description=description,
1286            )
1287
1288        string = simple_variable
1289        int = simple_variable_int
1290        date = simple_variable_date
1291        time = simple_variable_time
1292        datetime = simple_variable_datetime
1293        multiline = simple_variable_multiline
1294
1295        class Secret:
1296            def __new__(
1297                cls,
1298                value,
1299                name=None,
1300                label=None,
1301                regex=None,
1302                validate_regex=False,
1303                is_hidden=False,
1304                is_mandatory=False,
1305                runtime=False,
1306                description="",
1307            ):
1308                return simple_variable_secret(
1309                    value,
1310                    name=name,
1311                    label=label,
1312                    regex=regex,
1313                    validate_regex=validate_regex,
1314                    is_hidden=is_hidden,
1315                    is_mandatory=is_mandatory,
1316                    runtime=runtime,
1317                    description=description,
1318                )
1319
1320            string = simple_variable_secret
1321            int = simple_variable_int_secret
1322            date = simple_variable_date_secret
1323            time = simple_variable_time_secret
1324            datetime = simple_variable_datetime_secret
1325            multiline = simple_variable_multiline_secret
1326
1327    class WithOptions:
1328        def __new__(
1329            cls,
1330            options,
1331            default=None,
1332            name=None,
1333            label=None,
1334            regex=None,
1335            validate_regex=False,
1336            is_hidden=False,
1337            is_mandatory=False,
1338            runtime=False,
1339            description="",
1340        ):
1341            return variable_string_with_predefined_options(
1342                options,
1343                default=default,
1344                name=name,
1345                label=label,
1346                regex=regex,
1347                validate_regex=validate_regex,
1348                is_hidden=is_hidden,
1349                is_mandatory=is_mandatory,
1350                runtime=runtime,
1351                description=description,
1352            )
1353
1354        class Predefined:
1355            def __new__(
1356                cls,
1357                options,
1358                default=None,
1359                name=None,
1360                label=None,
1361                regex=None,
1362                validate_regex=False,
1363                is_hidden=False,
1364                is_mandatory=False,
1365                runtime=False,
1366                description="",
1367            ):
1368                return variable_string_with_predefined_options(
1369                    options,
1370                    default=default,
1371                    name=name,
1372                    label=label,
1373                    regex=regex,
1374                    validate_regex=validate_regex,
1375                    is_hidden=is_hidden,
1376                    is_mandatory=is_mandatory,
1377                    runtime=runtime,
1378                    description=description,
1379                )
1380
1381            string = variable_string_with_predefined_options
1382            int = variable_int_with_predefined_options
1383            date = variable_date_with_predefined_options
1384            time = variable_time_with_predefined_options
1385            datetime = variable_datetime_with_predefined_options
1386            multiline = variable_multiline_with_predefined_options
1387
1388            class Array:
1389                def __new__(
1390                    cls,
1391                    options,
1392                    defaults=None,
1393                    name=None,
1394                    label=None,
1395                    regex=None,
1396                    validate_regex=False,
1397                    is_hidden=False,
1398                    is_mandatory=False,
1399                    runtime=False,
1400                    description="",
1401                ):
1402                    return variable_string_with_predefined_options_array(
1403                        options,
1404                        defaults=defaults,
1405                        name=name,
1406                        label=label,
1407                        regex=regex,
1408                        validate_regex=validate_regex,
1409                        is_hidden=is_hidden,
1410                        is_mandatory=is_mandatory,
1411                        runtime=runtime,
1412                        description=description,
1413                    )
1414
1415                string = variable_string_with_predefined_options_array
1416                int = variable_int_with_predefined_options_array
1417                date = variable_date_with_predefined_options_array
1418                time = variable_time_with_predefined_options_array
1419                datetime = variable_datetime_with_predefined_options_array
1420                multiline = variable_multiline_with_predefined_options_array
1421
1422        class FromTask:
1423            def __new__(
1424                cls,
1425                task,
1426                name=None,
1427                label=None,
1428                regex=None,
1429                validate_regex=False,
1430                is_hidden=False,
1431                is_mandatory=False,
1432                description="",
1433            ):
1434                return variable_string_with_options_from_task(
1435                    task,
1436                    name=name,
1437                    label=label,
1438                    regex=regex,
1439                    validate_regex=validate_regex,
1440                    is_hidden=is_hidden,
1441                    is_mandatory=is_mandatory,
1442                    description=description,
1443                )
1444
1445            string = variable_string_with_options_from_task
1446            int = variable_int_with_options_from_task
1447            date = variable_date_with_options_from_task
1448            time = variable_time_with_options_from_task
1449            datetime = variable_datetime_with_options_from_task
1450            multiline = variable_multiline_with_options_from_task
1451
1452            class Array:
1453                def __new__(
1454                    cls,
1455                    task,
1456                    name=None,
1457                    label=None,
1458                    regex=None,
1459                    validate_regex=False,
1460                    is_hidden=False,
1461                    is_mandatory=False,
1462                    description="",
1463                ):
1464                    return variable_string_with_options_from_task_array(
1465                        task,
1466                        name=name,
1467                        label=label,
1468                        regex=regex,
1469                        validate_regex=validate_regex,
1470                        is_hidden=is_hidden,
1471                        is_mandatory=is_mandatory,
1472                        description=description,
1473                    )
1474
1475                string = variable_string_with_options_from_task_array
1476                int = variable_int_with_options_from_task_array
1477                date = variable_date_with_options_from_task_array
1478                time = variable_time_with_options_from_task_array
1479                datetime = variable_datetime_with_options_from_task_array
1480                multiline = variable_multiline_with_options_from_task_array
1481
1482
1483class RunbookVariable(CalmVariable):
1484    class TaskInput:
1485        def __new__(cls, *args, **kwargs):
1486            return _task_input(*args, **kwargs)
1487
Full Screen

init_alert_alarm_type_v5.py

Source: init_alert_alarm_type_v5.py Github

copy
1# -*- coding: utf-8 -*-
2"""
3Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
4Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
5Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
6http://opensource.org/licenses/MIT
7Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8""" # noqa
9"""更新蓝鲸监控告警类型
102018-09-14
11- 替换 False
12- 替换 True
13"""
14from fta_solutions_app.models import AlarmType
15
16MODEL = AlarmType
17
18
19def RUNNER(apps, schema_editor, module, silent):  # noqa
20    # 先删除所有的蓝鲸监控告警类型
21    module.MODEL.objects.filter(source_type='ALERT').delete()
22    for item in module.DATA:
23        try:
24            module.MODEL.objects.create(**item)
25        except Exception:
26            pass
27
28
29DATA = [
30    {
31        "is_enabled": True,
32        "match_mode": 0,
33        "source_type": "ALERT",
34        "description": "可用物理内存",
35        "scenario": "主机监控",
36        "exclude": "",
37        "alarm_type": "mem_60",
38        "pattern": "mem_60",
39        "is_hidden": False,
40        "cc_biz_id": 0
41    },
42    {
43        "is_enabled": True,
44        "match_mode": 0,
45        "source_type": "ALERT",
46        "description": "交换分区使用量",
47        "scenario": "主机监控",
48        "exclude": "",
49        "alarm_type": "mem_63",
50        "pattern": "mem_63",
51        "is_hidden": False,
52        "cc_biz_id": 0
53    },
54    {
55        "is_enabled": True,
56        "match_mode": 0,
57        "source_type": "ALERT",
58        "description": "物理内存使用率",
59        "scenario": "主机监控",
60        "exclude": "",
61        "alarm_type": "mem_64",
62        "pattern": "mem_64",
63        "is_hidden": False,
64        "cc_biz_id": 0
65    },
66    {
67        "is_enabled": True,
68        "match_mode": 0,
69        "source_type": "ALERT",
70        "description": "物理内存使用量",
71        "scenario": "主机监控",
72        "exclude": "",
73        "alarm_type": "mem_97",
74        "pattern": "mem_97",
75        "is_hidden": False,
76        "cc_biz_id": 0
77    },
78    {
79        "is_enabled": True,
80        "match_mode": 0,
81        "source_type": "ALERT",
82        "description": "应用内存使用量",
83        "scenario": "主机监控",
84        "exclude": "",
85        "alarm_type": "mem_98",
86        "pattern": "mem_98",
87        "is_hidden": False,
88        "cc_biz_id": 0
89    },
90    {
91        "is_enabled": True,
92        "match_mode": 0,
93        "source_type": "ALERT",
94        "description": "应用内存使用率",
95        "scenario": "主机监控",
96        "exclude": "",
97        "alarm_type": "mem_99",
98        "pattern": "mem_99",
99        "is_hidden": False,
100        "cc_biz_id": 0
101    },
102    {
103        "is_enabled": True,
104        "match_mode": 0,
105        "source_type": "ALERT",
106        "description": "CPU使用率",
107        "scenario": "主机监控",
108        "exclude": "",
109        "alarm_type": "process_122",
110        "pattern": "process_122",
111        "is_hidden": False,
112        "cc_biz_id": 0
113    },
114    {
115        "is_enabled": True,
116        "match_mode": 0,
117        "source_type": "ALERT",
118        "description": "内存使用率",
119        "scenario": "主机监控",
120        "exclude": "",
121        "alarm_type": "process_123",
122        "pattern": "process_123",
123        "is_hidden": False,
124        "cc_biz_id": 0
125    },
126    {
127        "is_enabled": True,
128        "match_mode": 0,
129        "source_type": "ALERT",
130        "description": "物理内存使用量",
131        "scenario": "主机监控",
132        "exclude": "",
133        "alarm_type": "process_124",
134        "pattern": "process_124",
135        "is_hidden": False,
136        "cc_biz_id": 0
137    },
138    {
139        "is_enabled": True,
140        "match_mode": 0,
141        "source_type": "ALERT",
142        "description": "虚拟内存使用量",
143        "scenario": "主机监控",
144        "exclude": "",
145        "alarm_type": "process_125",
146        "pattern": "process_125",
147        "is_hidden": False,
148        "cc_biz_id": 0
149    },
150    {
151        "is_enabled": True,
152        "match_mode": 0,
153        "source_type": "ALERT",
154        "description": "文件句柄数",
155        "scenario": "主机监控",
156        "exclude": "",
157        "alarm_type": "process_126",
158        "pattern": "process_126",
159        "is_hidden": False,
160        "cc_biz_id": 0
161    },
162    {
163        "is_enabled": True,
164        "match_mode": 0,
165        "source_type": "ALERT",
166        "description": "接收字节流量",
167        "scenario": "主机监控",
168        "exclude": "",
169        "alarm_type": "net_10",
170        "pattern": "net_10",
171        "is_hidden": False,
172        "cc_biz_id": 0
173    },
174    {
175        "is_enabled": True,
176        "match_mode": 0,
177        "source_type": "ALERT",
178        "description": "发送字节流量",
179        "scenario": "主机监控",
180        "exclude": "",
181        "alarm_type": "net_14",
182        "pattern": "net_14",
183        "is_hidden": False,
184        "cc_biz_id": 0
185    },
186    {
187        "is_enabled": True,
188        "match_mode": 0,
189        "source_type": "ALERT",
190        "description": "发送包速率",
191        "scenario": "主机监控",
192        "exclude": "",
193        "alarm_type": "net_16",
194        "pattern": "net_16",
195        "is_hidden": False,
196        "cc_biz_id": 0
197    },
198    {
199        "is_enabled": True,
200        "match_mode": 0,
201        "source_type": "ALERT",
202        "description": "接收包速率",
203        "scenario": "主机监控",
204        "exclude": "",
205        "alarm_type": "net_20",
206        "pattern": "net_20",
207        "is_hidden": False,
208        "cc_biz_id": 0
209    },
210    {
211        "is_enabled": True,
212        "match_mode": 0,
213        "source_type": "ALERT",
214        "description": "ESTABLISHED连接数",
215        "scenario": "主机监控",
216        "exclude": "",
217        "alarm_type": "net_110",
218        "pattern": "net_110",
219        "is_hidden": False,
220        "cc_biz_id": 0
221    },
222    {
223        "is_enabled": True,
224        "match_mode": 0,
225        "source_type": "ALERT",
226        "description": "TIME_WAIT连接数",
227        "scenario": "主机监控",
228        "exclude": "",
229        "alarm_type": "net_111",
230        "pattern": "net_111",
231        "is_hidden": False,
232        "cc_biz_id": 0
233    },
234    {
235        "is_enabled": True,
236        "match_mode": 0,
237        "source_type": "ALERT",
238        "description": "LISTEN连接数",
239        "scenario": "主机监控",
240        "exclude": "",
241        "alarm_type": "net_112",
242        "pattern": "net_112",
243        "is_hidden": False,
244        "cc_biz_id": 0
245    },
246    {
247        "is_enabled": True,
248        "match_mode": 0,
249        "source_type": "ALERT",
250        "description": "LAST_ACK连接数",
251        "scenario": "主机监控",
252        "exclude": "",
253        "alarm_type": "net_113",
254        "pattern": "net_113",
255        "is_hidden": False,
256        "cc_biz_id": 0
257    },
258    {
259        "is_enabled": True,
260        "match_mode": 0,
261        "source_type": "ALERT",
262        "description": "SYN_RECV连接数",
263        "scenario": "主机监控",
264        "exclude": "",
265        "alarm_type": "net_114",
266        "pattern": "net_114",
267        "is_hidden": False,
268        "cc_biz_id": 0
269    },
270    {
271        "is_enabled": True,
272        "match_mode": 0,
273        "source_type": "ALERT",
274        "description": "SYN_SENT连接数",
275        "scenario": "主机监控",
276        "exclude": "",
277        "alarm_type": "net_115",
278        "pattern": "net_115",
279        "is_hidden": False,
280        "cc_biz_id": 0
281    },
282    {
283        "is_enabled": True,
284        "match_mode": 0,
285        "source_type": "ALERT",
286        "description": "FIN_WAIT1连接数",
287        "scenario": "主机监控",
288        "exclude": "",
289        "alarm_type": "net_116",
290        "pattern": "net_116",
291        "is_hidden": False,
292        "cc_biz_id": 0
293    },
294    {
295        "is_enabled": True,
296        "match_mode": 0,
297        "source_type": "ALERT",
298        "description": "FIN_WAIT2连接数",
299        "scenario": "主机监控",
300        "exclude": "",
301        "alarm_type": "net_117",
302        "pattern": "net_117",
303        "is_hidden": False,
304        "cc_biz_id": 0
305    },
306    {
307        "is_enabled": True,
308        "match_mode": 0,
309        "source_type": "ALERT",
310        "description": "CLOSING连接数",
311        "scenario": "主机监控",
312        "exclude": "",
313        "alarm_type": "net_118",
314        "pattern": "net_118",
315        "is_hidden": False,
316        "cc_biz_id": 0
317    },
318    {
319        "is_enabled": True,
320        "match_mode": 0,
321        "source_type": "ALERT",
322        "description": "CLOSED状态连接数",
323        "scenario": "主机监控",
324        "exclude": "",
325        "alarm_type": "net_119",
326        "pattern": "net_119",
327        "is_hidden": False,
328        "cc_biz_id": 0
329    },
330    {
331        "is_enabled": True,
332        "match_mode": 0,
333        "source_type": "ALERT",
334        "description": "UDP接收包量",
335        "scenario": "主机监控",
336        "exclude": "",
337        "alarm_type": "net_120",
338        "pattern": "net_120",
339        "is_hidden": False,
340        "cc_biz_id": 0
341    },
342    {
343        "is_enabled": True,
344        "match_mode": 0,
345        "source_type": "ALERT",
346        "description": "UDP发送包量",
347        "scenario": "主机监控",
348        "exclude": "",
349        "alarm_type": "net_121",
350        "pattern": "net_121",
351        "is_hidden": False,
352        "cc_biz_id": 0
353    },
354    {
355        "is_enabled": True,
356        "match_mode": 0,
357        "source_type": "ALERT",
358        "description": "CLOSE_WAIT连接数",
359        "scenario": "主机监控",
360        "exclude": "",
361        "alarm_type": "net_128",
362        "pattern": "net_128",
363        "is_hidden": False,
364        "cc_biz_id": 0
365    },
366    {
367        "is_enabled": True,
368        "match_mode": 0,
369        "source_type": "ALERT",
370        "description": "磁盘使用率",
371        "scenario": "主机监控",
372        "exclude": "",
373        "alarm_type": "disk_81",
374        "pattern": "disk_81",
375        "is_hidden": False,
376        "cc_biz_id": 0
377    },
378    {
379        "is_enabled": True,
380        "match_mode": 0,
381        "source_type": "ALERT",
382        "description": "读速率",
383        "scenario": "主机监控",
384        "exclude": "",
385        "alarm_type": "disk_86",
386        "pattern": "disk_86",
387        "is_hidden": False,
388        "cc_biz_id": 0
389    },
390    {
391        "is_enabled": True,
392        "match_mode": 0,
393        "source_type": "ALERT",
394        "description": "写速率",
395        "scenario": "主机监控",
396        "exclude": "",
397        "alarm_type": "disk_87",
398        "pattern": "disk_87",
399        "is_hidden": False,
400        "cc_biz_id": 0
401    },
402    {
403        "is_enabled": True,
404        "match_mode": 0,
405        "source_type": "ALERT",
406        "description": "磁盘IO使用率",
407        "scenario": "主机监控",
408        "exclude": "",
409        "alarm_type": "disk_96",
410        "pattern": "disk_96",
411        "is_hidden": False,
412        "cc_biz_id": 0
413    },
414    {
415        "is_enabled": True,
416        "match_mode": 0,
417        "source_type": "ALERT",
418        "description": "5分钟平均负载",
419        "scenario": "主机监控",
420        "exclude": "",
421        "alarm_type": "cpu_3",
422        "pattern": "cpu_3",
423        "is_hidden": False,
424        "cc_biz_id": 0
425    },
426    {
427        "is_enabled": True,
428        "match_mode": 0,
429        "source_type": "ALERT",
430        "description": "CPU总使用率",
431        "scenario": "主机监控",
432        "exclude": "",
433        "alarm_type": "cpu_7",
434        "pattern": "cpu_7",
435        "is_hidden": False,
436        "cc_biz_id": 0
437    },
438    {
439        "is_enabled": True,
440        "match_mode": 0,
441        "source_type": "ALERT",
442        "description": "CPU单核使用率",
443        "scenario": "主机监控",
444        "exclude": "",
445        "alarm_type": "cpu_8",
446        "pattern": "cpu_8",
447        "is_hidden": False,
448        "cc_biz_id": 0
449    },
450    {
451        "is_enabled": True,
452        "match_mode": 0,
453        "source_type": "ALERT",
454        "description": "Agent心跳丢失",
455        "scenario": "主机监控",
456        "exclude": "",
457        "alarm_type": "base_alarm_2",
458        "pattern": "base_alarm_2",
459        "is_hidden": False,
460        "cc_biz_id": 0
461    },
462    {
463        "is_enabled": True,
464        "match_mode": 0,
465        "source_type": "ALERT",
466        "description": "磁盘只读",
467        "scenario": "主机监控",
468        "exclude": "",
469        "alarm_type": "base_alarm_3",
470        "pattern": "base_alarm_3",
471        "is_hidden": False,
472        "cc_biz_id": 0
473    },
474    {
475        "is_enabled": True,
476        "match_mode": 0,
477        "source_type": "ALERT",
478        "description": "磁盘写满",
479        "scenario": "主机监控",
480        "exclude": "",
481        "alarm_type": "base_alarm_6",
482        "pattern": "base_alarm_6",
483        "is_hidden": False,
484        "cc_biz_id": 0
485    },
486    {
487        "is_enabled": True,
488        "match_mode": 0,
489        "source_type": "ALERT",
490        "description": "Corefile产生",
491        "scenario": "主机监控",
492        "exclude": "",
493        "alarm_type": "base_alarm_7",
494        "pattern": "base_alarm_7",
495        "is_hidden": False,
496        "cc_biz_id": 0
497    },
498    {
499        "is_enabled": True,
500        "match_mode": 0,
501        "source_type": "ALERT",
502        "description": "PING不可达告警",
503        "scenario": "主机监控",
504        "exclude": "",
505        "alarm_type": "base_alarm_8",
506        "pattern": "base_alarm_8",
507        "is_hidden": False,
508        "cc_biz_id": 0
509    },
510    {
511        "is_enabled": True,
512        "match_mode": 0,
513        "source_type": "ALERT",
514        "description": "系统重新启动",
515        "scenario": "主机监控",
516        "exclude": "",
517        "alarm_type": "system_env_os_restart",
518        "pattern": "system_env_os_restart",
519        "is_hidden": False,
520        "cc_biz_id": 0
521    },
522    {
523        "is_enabled": True,
524        "match_mode": 0,
525        "source_type": "ALERT",
526        "description": "进程端口",
527        "scenario": "主机监控",
528        "exclude": "",
529        "alarm_type": "proc_port_proc_port",
530        "pattern": "proc_port_proc_port",
531        "is_hidden": False,
532        "cc_biz_id": 0
533    },
534    {
535        "is_enabled": True,
536        "match_mode": 0,
537        "source_type": "ALERT",
538        "description": "自定义字符型",
539        "scenario": "主机监控",
540        "exclude": "",
541        "alarm_type": "gse_custom_event_gse_custom_event",
542        "pattern": "gse_custom_event_gse_custom_event",
543        "is_hidden": False,
544        "cc_biz_id": 0
545    },
546    {
547        "is_enabled": True,
548        "match_mode": 0,
549        "source_type": "ALERT",
550        "description": "Apache",
551        "scenario": "组件",
552        "exclude": "",
553        "alarm_type": "apache",
554        "pattern": "apache",
555        "is_hidden": False,
556        "cc_biz_id": 0
557    },
558    {
559        "is_enabled": True,
560        "match_mode": 0,
561        "source_type": "ALERT",
562        "description": "MySQL",
563        "scenario": "组件",
564        "exclude": "",
565        "alarm_type": "mysql",
566        "pattern": "mysql",
567        "is_hidden": False,
568        "cc_biz_id": 0
569    },
570    {
571        "is_enabled": True,
572        "match_mode": 0,
573        "source_type": "ALERT",
574        "description": "NginX",
575        "scenario": "组件",
576        "exclude": "",
577        "alarm_type": "nginx",
578        "pattern": "nginx",
579        "is_hidden": False,
580        "cc_biz_id": 0
581    },
582    {
583        "is_enabled": True,
584        "match_mode": 0,
585        "source_type": "ALERT",
586        "description": "Redis",
587        "scenario": "组件",
588        "exclude": "",
589        "alarm_type": "redis",
590        "pattern": "redis",
591        "is_hidden": False,
592        "cc_biz_id": 0
593    },
594    {
595        "is_enabled": True,
596        "match_mode": 0,
597        "source_type": "ALERT",
598        "description": "Tomcat",
599        "scenario": "组件",
600        "exclude": "",
601        "alarm_type": "tomcat",
602        "pattern": "tomcat",
603        "is_hidden": False,
604        "cc_biz_id": 0
605    },
606    {
607        "is_enabled": True,
608        "match_mode": 0,
609        "source_type": "ALERT",
610        "description": "Active Directory",
611        "scenario": "组件",
612        "exclude": "",
613        "alarm_type": "ad",
614        "pattern": "ad",
615        "is_hidden": False,
616        "cc_biz_id": 0
617    },
618    {
619        "is_enabled": True,
620        "match_mode": 0,
621        "source_type": "ALERT",
622        "description": "Ceph",
623        "scenario": "组件",
624        "exclude": "",
625        "alarm_type": "ceph",
626        "pattern": "ceph",
627        "is_hidden": False,
628        "cc_biz_id": 0
629    },
630    {
631        "is_enabled": True,
632        "match_mode": 0,
633        "source_type": "ALERT",
634        "description": "Consul",
635        "scenario": "组件",
636        "exclude": "",
637        "alarm_type": "consul",
638        "pattern": "consul",
639        "is_hidden": False,
640        "cc_biz_id": 0
641    },
642    {
643        "is_enabled": True,
644        "match_mode": 0,
645        "source_type": "ALERT",
646        "description": "ElasticSearch",
647        "scenario": "组件",
648        "exclude": "",
649        "alarm_type": "elastic",
650        "pattern": "elastic",
651        "is_hidden": False,
652        "cc_biz_id": 0
653    },
654    {
655        "is_enabled": True,
656        "match_mode": 0,
657        "source_type": "ALERT",
658        "description": "Exchange 2010",
659        "scenario": "组件",
660        "exclude": "",
661        "alarm_type": "exchange2010",
662        "pattern": "exchange2010",
663        "is_hidden": False,
664        "cc_biz_id": 0
665    },
666    {
667        "is_enabled": True,
668        "match_mode": 0,
669        "source_type": "ALERT",
670        "description": "HAProxy",
671        "scenario": "组件",
672        "exclude": "",
673        "alarm_type": "haproxy",
674        "pattern": "haproxy",
675        "is_hidden": False,
676        "cc_biz_id": 0
677    },
678    {
679        "is_enabled": True,
680        "match_mode": 0,
681        "source_type": "ALERT",
682        "description": "IIS",
683        "scenario": "组件",
684        "exclude": "",
685        "alarm_type": "iis",
686        "pattern": "iis",
687        "is_hidden": False,
688        "cc_biz_id": 0
689    },
690    {
691        "is_enabled": True,
692        "match_mode": 0,
693        "source_type": "ALERT",
694        "description": "Kafka",
695        "scenario": "组件",
696        "exclude": "",
697        "alarm_type": "kafka",
698        "pattern": "kafka",
699        "is_hidden": False,
700        "cc_biz_id": 0
701    },
702    {
703        "is_enabled": True,
704        "match_mode": 0,
705        "source_type": "ALERT",
706        "description": "MemCache",
707        "scenario": "组件",
708        "exclude": "",
709        "alarm_type": "memcache",
710        "pattern": "memcache",
711        "is_hidden": False,
712        "cc_biz_id": 0
713    },
714    {
715        "is_enabled": True,
716        "match_mode": 0,
717        "source_type": "ALERT",
718        "description": "MongoDB",
719        "scenario": "组件",
720        "exclude": "",
721        "alarm_type": "mongodb",
722        "pattern": "mongodb",
723        "is_hidden": False,
724        "cc_biz_id": 0
725    },
726    {
727        "is_enabled": True,
728        "match_mode": 0,
729        "source_type": "ALERT",
730        "description": "SQLServer",
731        "scenario": "组件",
732        "exclude": "",
733        "alarm_type": "mssql",
734        "pattern": "mssql",
735        "is_hidden": False,
736        "cc_biz_id": 0
737    },
738    {
739        "is_enabled": True,
740        "match_mode": 0,
741        "source_type": "ALERT",
742        "description": "Oracle",
743        "scenario": "组件",
744        "exclude": "",
745        "alarm_type": "oracle",
746        "pattern": "oracle",
747        "is_hidden": False,
748        "cc_biz_id": 0
749    },
750    {
751        "is_enabled": True,
752        "match_mode": 0,
753        "source_type": "ALERT",
754        "description": "RabbitMQ",
755        "scenario": "组件",
756        "exclude": "",
757        "alarm_type": "rabbitmq",
758        "pattern": "rabbitmq",
759        "is_hidden": False,
760        "cc_biz_id": 0
761    },
762    {
763        "is_enabled": True,
764        "match_mode": 0,
765        "source_type": "ALERT",
766        "description": "WebLogic",
767        "scenario": "组件",
768        "exclude": "",
769        "alarm_type": "weblogic",
770        "pattern": "weblogic",
771        "is_hidden": False,
772        "cc_biz_id": 0
773    },
774    {
775        "is_enabled": True,
776        "match_mode": 0,
777        "source_type": "ALERT",
778        "description": "ZooKeeper",
779        "scenario": "组件",
780        "exclude": "",
781        "alarm_type": "zookeeper",
782        "pattern": "zookeeper",
783        "is_hidden": False,
784        "cc_biz_id": 0
785    },
786    {
787        "is_enabled": True,
788        "match_mode": 0,
789        "source_type": "ALERT",
790        "description": "物理机-CPU",
791        "scenario": "组件",
792        "exclude": "",
793        "alarm_type": "cpu",
794        "pattern": "cpu",
795        "is_hidden": False,
796        "cc_biz_id": 0
797    },
798    {
799        "is_enabled": True,
800        "match_mode": 0,
801        "source_type": "ALERT",
802        "description": "物理机-磁盘",
803        "scenario": "组件",
804        "exclude": "",
805        "alarm_type": "disk",
806        "pattern": "disk",
807        "is_hidden": False,
808        "cc_biz_id": 0
809    },
810    {
811        "is_enabled": True,
812        "match_mode": 0,
813        "source_type": "ALERT",
814        "description": "物理机-网卡",
815        "scenario": "组件",
816        "exclude": "",
817        "alarm_type": "net",
818        "pattern": "net",
819        "is_hidden": False,
820        "cc_biz_id": 0
821    },
822    {
823        "is_enabled": True,
824        "match_mode": 0,
825        "source_type": "ALERT",
826        "description": "物理机-内存",
827        "scenario": "组件",
828        "exclude": "",
829        "alarm_type": "mem",
830        "pattern": "mem",
831        "is_hidden": False,
832        "cc_biz_id": 0
833    },
834    {
835        "is_enabled": True,
836        "match_mode": 0,
837        "source_type": "ALERT",
838        "description": "物理机-system_env",
839        "scenario": "组件",
840        "exclude": "",
841        "alarm_type": "system_env",
842        "pattern": "system_env",
843        "is_hidden": False,
844        "cc_biz_id": 0
845    },
846    {
847        "is_enabled": True,
848        "match_mode": 0,
849        "source_type": "ALERT",
850        "description": "物理机-进程",
851        "scenario": "组件",
852        "exclude": "",
853        "alarm_type": "process",
854        "pattern": "process",
855        "is_hidden": False,
856        "cc_biz_id": 0
857    },
858    {
859        "is_enabled": True,
860        "match_mode": 0,
861        "source_type": "ALERT",
862        "description": "脚本采集",
863        "scenario": "脚本采集",
864        "exclude": "",
865        "alarm_type": "selfscript",
866        "pattern": "selfscript",
867        "is_hidden": False,
868        "cc_biz_id": 0
869    },
870    {
871        "is_enabled": True,
872        "match_mode": 0,
873        "source_type": "ALERT",
874        "description": "自定义监控",
875        "scenario": "自定义监控",
876        "exclude": "",
877        "alarm_type": "custom",
878        "pattern": "custom",
879        "is_hidden": False,
880        "cc_biz_id": 0
881    },
882    {
883        "is_enabled": True,
884        "match_mode": 0,
885        "source_type": "ALERT",
886        "description": "服务拨测",
887        "scenario": "服务拨测",
888        "exclude": "",
889        "alarm_type": "uptimecheck",
890        "pattern": "uptimecheck",
891        "is_hidden": False,
892        "cc_biz_id": 0
893    }
894]
895
Full Screen

init_alert_alarm_type_v4.py

Source: init_alert_alarm_type_v4.py Github

copy
1# -*- coding: utf-8 -*-
2"""
3Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
4Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
5Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
6http://opensource.org/licenses/MIT
7Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8""" # noqa
9"""更新蓝鲸监控告警类型
102018-09-10
11- 替换 False
12- 替换 True
13"""
14from fta_solutions_app.models import AlarmType
15
16MODEL = AlarmType
17
18
19def RUNNER(apps, schema_editor, module, silent):  # noqa
20    # 先删除所有的蓝鲸监控告警类型
21    module.MODEL.objects.filter(source_type='ALERT').delete()
22    for item in module.DATA:
23        try:
24            module.MODEL.objects.create(**item)
25        except Exception:
26            pass
27
28
29DATA = [
30    {
31        "is_enabled": True,
32        "match_mode": 0,
33        "source_type": "ALERT",
34        "description": "可用物理内存",
35        "scenario": "主机监控",
36        "exclude": "",
37        "alarm_type": "mem_60",
38        "pattern": "mem_60",
39        "is_hidden": False,
40        "cc_biz_id": 0
41    },
42    {
43        "is_enabled": True,
44        "match_mode": 0,
45        "source_type": "ALERT",
46        "description": "交换分区使用量",
47        "scenario": "主机监控",
48        "exclude": "",
49        "alarm_type": "mem_63",
50        "pattern": "mem_63",
51        "is_hidden": False,
52        "cc_biz_id": 0
53    },
54    {
55        "is_enabled": True,
56        "match_mode": 0,
57        "source_type": "ALERT",
58        "description": "物理内存使用率",
59        "scenario": "主机监控",
60        "exclude": "",
61        "alarm_type": "mem_64",
62        "pattern": "mem_64",
63        "is_hidden": False,
64        "cc_biz_id": 0
65    },
66    {
67        "is_enabled": True,
68        "match_mode": 0,
69        "source_type": "ALERT",
70        "description": "物理内存使用量",
71        "scenario": "主机监控",
72        "exclude": "",
73        "alarm_type": "mem_97",
74        "pattern": "mem_97",
75        "is_hidden": False,
76        "cc_biz_id": 0
77    },
78    {
79        "is_enabled": True,
80        "match_mode": 0,
81        "source_type": "ALERT",
82        "description": "应用内存使用量",
83        "scenario": "主机监控",
84        "exclude": "",
85        "alarm_type": "mem_98",
86        "pattern": "mem_98",
87        "is_hidden": False,
88        "cc_biz_id": 0
89    },
90    {
91        "is_enabled": True,
92        "match_mode": 0,
93        "source_type": "ALERT",
94        "description": "应用内存使用率",
95        "scenario": "主机监控",
96        "exclude": "",
97        "alarm_type": "mem_99",
98        "pattern": "mem_99",
99        "is_hidden": False,
100        "cc_biz_id": 0
101    },
102    {
103        "is_enabled": True,
104        "match_mode": 0,
105        "source_type": "ALERT",
106        "description": "CPU使用率",
107        "scenario": "主机监控",
108        "exclude": "",
109        "alarm_type": "process_122",
110        "pattern": "process_122",
111        "is_hidden": False,
112        "cc_biz_id": 0
113    },
114    {
115        "is_enabled": True,
116        "match_mode": 0,
117        "source_type": "ALERT",
118        "description": "内存使用率",
119        "scenario": "主机监控",
120        "exclude": "",
121        "alarm_type": "process_123",
122        "pattern": "process_123",
123        "is_hidden": False,
124        "cc_biz_id": 0
125    },
126    {
127        "is_enabled": True,
128        "match_mode": 0,
129        "source_type": "ALERT",
130        "description": "物理内存使用量",
131        "scenario": "主机监控",
132        "exclude": "",
133        "alarm_type": "process_124",
134        "pattern": "process_124",
135        "is_hidden": False,
136        "cc_biz_id": 0
137    },
138    {
139        "is_enabled": True,
140        "match_mode": 0,
141        "source_type": "ALERT",
142        "description": "虚拟内存使用量",
143        "scenario": "主机监控",
144        "exclude": "",
145        "alarm_type": "process_125",
146        "pattern": "process_125",
147        "is_hidden": False,
148        "cc_biz_id": 0
149    },
150    {
151        "is_enabled": True,
152        "match_mode": 0,
153        "source_type": "ALERT",
154        "description": "文件句柄数",
155        "scenario": "主机监控",
156        "exclude": "",
157        "alarm_type": "process_126",
158        "pattern": "process_126",
159        "is_hidden": False,
160        "cc_biz_id": 0
161    },
162    {
163        "is_enabled": True,
164        "match_mode": 0,
165        "source_type": "ALERT",
166        "description": "接收字节流量",
167        "scenario": "主机监控",
168        "exclude": "",
169        "alarm_type": "net_10",
170        "pattern": "net_10",
171        "is_hidden": False,
172        "cc_biz_id": 0
173    },
174    {
175        "is_enabled": True,
176        "match_mode": 0,
177        "source_type": "ALERT",
178        "description": "发送字节流量",
179        "scenario": "主机监控",
180        "exclude": "",
181        "alarm_type": "net_14",
182        "pattern": "net_14",
183        "is_hidden": False,
184        "cc_biz_id": 0
185    },
186    {
187        "is_enabled": True,
188        "match_mode": 0,
189        "source_type": "ALERT",
190        "description": "发送包速率",
191        "scenario": "主机监控",
192        "exclude": "",
193        "alarm_type": "net_16",
194        "pattern": "net_16",
195        "is_hidden": False,
196        "cc_biz_id": 0
197    },
198    {
199        "is_enabled": True,
200        "match_mode": 0,
201        "source_type": "ALERT",
202        "description": "接收包速率",
203        "scenario": "主机监控",
204        "exclude": "",
205        "alarm_type": "net_20",
206        "pattern": "net_20",
207        "is_hidden": False,
208        "cc_biz_id": 0
209    },
210    {
211        "is_enabled": True,
212        "match_mode": 0,
213        "source_type": "ALERT",
214        "description": "ESTABLISHED连接数",
215        "scenario": "主机监控",
216        "exclude": "",
217        "alarm_type": "net_110",
218        "pattern": "net_110",
219        "is_hidden": False,
220        "cc_biz_id": 0
221    },
222    {
223        "is_enabled": True,
224        "match_mode": 0,
225        "source_type": "ALERT",
226        "description": "TIME_WAIT连接数",
227        "scenario": "主机监控",
228        "exclude": "",
229        "alarm_type": "net_111",
230        "pattern": "net_111",
231        "is_hidden": False,
232        "cc_biz_id": 0
233    },
234    {
235        "is_enabled": True,
236        "match_mode": 0,
237        "source_type": "ALERT",
238        "description": "LISTEN连接数",
239        "scenario": "主机监控",
240        "exclude": "",
241        "alarm_type": "net_112",
242        "pattern": "net_112",
243        "is_hidden": False,
244        "cc_biz_id": 0
245    },
246    {
247        "is_enabled": True,
248        "match_mode": 0,
249        "source_type": "ALERT",
250        "description": "LAST_ACK连接数",
251        "scenario": "主机监控",
252        "exclude": "",
253        "alarm_type": "net_113",
254        "pattern": "net_113",
255        "is_hidden": False,
256        "cc_biz_id": 0
257    },
258    {
259        "is_enabled": True,
260        "match_mode": 0,
261        "source_type": "ALERT",
262        "description": "SYN_RECV连接数",
263        "scenario": "主机监控",
264        "exclude": "",
265        "alarm_type": "net_114",
266        "pattern": "net_114",
267        "is_hidden": False,
268        "cc_biz_id": 0
269    },
270    {
271        "is_enabled": True,
272        "match_mode": 0,
273        "source_type": "ALERT",
274        "description": "SYN_SENT连接数",
275        "scenario": "主机监控",
276        "exclude": "",
277        "alarm_type": "net_115",
278        "pattern": "net_115",
279        "is_hidden": False,
280        "cc_biz_id": 0
281    },
282    {
283        "is_enabled": True,
284        "match_mode": 0,
285        "source_type": "ALERT",
286        "description": "FIN_WAIT1连接数",
287        "scenario": "主机监控",
288        "exclude": "",
289        "alarm_type": "net_116",
290        "pattern": "net_116",
291        "is_hidden": False,
292        "cc_biz_id": 0
293    },
294    {
295        "is_enabled": True,
296        "match_mode": 0,
297        "source_type": "ALERT",
298        "description": "FIN_WAIT2连接数",
299        "scenario": "主机监控",
300        "exclude": "",
301        "alarm_type": "net_117",
302        "pattern": "net_117",
303        "is_hidden": False,
304        "cc_biz_id": 0
305    },
306    {
307        "is_enabled": True,
308        "match_mode": 0,
309        "source_type": "ALERT",
310        "description": "CLOSING连接数",
311        "scenario": "主机监控",
312        "exclude": "",
313        "alarm_type": "net_118",
314        "pattern": "net_118",
315        "is_hidden": False,
316        "cc_biz_id": 0
317    },
318    {
319        "is_enabled": True,
320        "match_mode": 0,
321        "source_type": "ALERT",
322        "description": "CLOSED状态连接数",
323        "scenario": "主机监控",
324        "exclude": "",
325        "alarm_type": "net_119",
326        "pattern": "net_119",
327        "is_hidden": False,
328        "cc_biz_id": 0
329    },
330    {
331        "is_enabled": True,
332        "match_mode": 0,
333        "source_type": "ALERT",
334        "description": "UDP接收包量",
335        "scenario": "主机监控",
336        "exclude": "",
337        "alarm_type": "net_120",
338        "pattern": "net_120",
339        "is_hidden": False,
340        "cc_biz_id": 0
341    },
342    {
343        "is_enabled": True,
344        "match_mode": 0,
345        "source_type": "ALERT",
346        "description": "UDP发送包量",
347        "scenario": "主机监控",
348        "exclude": "",
349        "alarm_type": "net_121",
350        "pattern": "net_121",
351        "is_hidden": False,
352        "cc_biz_id": 0
353    },
354    {
355        "is_enabled": True,
356        "match_mode": 0,
357        "source_type": "ALERT",
358        "description": "磁盘使用率",
359        "scenario": "主机监控",
360        "exclude": "",
361        "alarm_type": "disk_81",
362        "pattern": "disk_81",
363        "is_hidden": False,
364        "cc_biz_id": 0
365    },
366    {
367        "is_enabled": True,
368        "match_mode": 0,
369        "source_type": "ALERT",
370        "description": "读速率",
371        "scenario": "主机监控",
372        "exclude": "",
373        "alarm_type": "disk_86",
374        "pattern": "disk_86",
375        "is_hidden": False,
376        "cc_biz_id": 0
377    },
378    {
379        "is_enabled": True,
380        "match_mode": 0,
381        "source_type": "ALERT",
382        "description": "写速率",
383        "scenario": "主机监控",
384