一、zabbix2.4.7python
二、zabbix3.0express
好處就是能夠批量處理,好比我說我有1000機器都要監控cpu、內存、IO的監控函數
一、優勢:orm
能夠批量引用,不用重複建立相同的模板,好比我說我有1000機器都要監控cpu、內存、IO的監控建立相同的觸發器,blog
二、缺點:內存
模板1更改觸發器的閥值會影響全部的模板ci
三、生產不建議使用多對多的關係,這樣靈活性就會不好,並且修改模板1會影響別的模板,這樣會出現不少坑get
一、觸發器表it
class Trigger(models.Model): name = models.CharField(u'觸發器名稱',max_length=64) severity_choices = ( (1,'Information'), (2,'Warning'), (3,'Average'), (4,'High'), (5,'Diaster'), ) #expressions = models.ManyToManyField(TriggerExpression,verbose_name=u"條件表達式") severity = models.IntegerField(u'告警級別',choices=severity_choices) enabled = models.BooleanField(default=True) memo = models.TextField(u"備註",blank=True,null=True) def __str__(self): return "<serice:%s, severity:%s>" %(self.name,self.get_severity_display())
二、觸發器表達式表io
class TriggerExpression(models.Model): trigger = models.ForeignKey('Trigger',verbose_name=u"所屬觸發器") service = models.ForeignKey(Service,verbose_name=u"關聯服務") service_index = models.ForeignKey(ServiceIndex,verbose_name=u"關聯服務指標") specified_index_key = models.CharField(verbose_name=u"只監控專門指定的指標key",max_length=64,blank=True,null=True) operator_type_choices = (('eq','='),('lt','<'),('gt','>')) operator_type = models.CharField(u"運算符",choices=operator_type_choices,max_length=32) data_calc_type_choices = ( ('avg','Average'), ('max','Max'), ('hit','Hit'), ('last','Last'), ) data_calc_func= models.CharField(u"數據處理方式",choices=data_calc_type_choices,max_length=64) data_calc_args = models.CharField(u"函數傳入參數",help_text=u"如果多個參數,則用,號分開,第一個值是時間",max_length=64) threshold = models.IntegerField(u"閾值") logic_type_choices = (('or','OR'),('and','AND')) logic_type = models.CharField(u"與一個條件的邏輯關係",choices=logic_type_choices,max_length=32,blank=True,null=True) def __str__(self): return "%s %s(%s(%s))" %(self.service_index,self.operator_type,self.data_calc_func,self.data_calc_args)