People who have used Zabbix know that a variety of monitoring projects are based on the template, and then they also imitate to do a monitoring system
Draw a diagram first, is the template diagram of the future design monitoring system
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7C/A4/wKioL1bU7MKwx7aiAABFiFf9gak452.png "title=" QQ picture 20160301091124.png "alt=" Wkiol1bu7mkwx7aiaabfiff9gak452.png "/>
The design of a parent template class, followed by a variety of specific templates, such as Linux monitoring templates, Windows monitoring templates or custom templates, and then take the Linux template, Linuxtemplate is sure to monitor the CPU, memory, Hard disk and other information, these monitoring services are referred to as a service list, and then the CPU is the real monitoring items, such as CPU iowait, usage, idle and so on
Models Design
Class Templates (models. Model): #monitor template name = models. Charfield (max_length=50, unique=true) Service_list = models. Manytomanyfield (' servicelist ') def __unicode__ (self): return self.name
Defines a template class that has the name of the templates, the servicelist of the two classes: many-to-many, meaning that a template can correspond to multiple sets of services, a set of services can also correspond to multiple templates, Just like linuxtemplate will contain CPU, mem and so on, CPU can belong to Linuxtemplate and wintemplate as well.
Class Servicelist (models. Model): name = models. Charfield (max_length=50,unique=true) service = models. ForeignKey (' Services ') Check_interval = models. Integerfield (default=300) conditons = models. Manytomanyfield (' Conditions ', verbose_name=u ' monitoring threshold ', null=true,blank=true) Description = models. TextField () def __unicode__ (self): return self.name
The above is the Servicelist class, as mentioned earlier, Servicelist contains services, so the service is a serviceslist foreign key, and servicelist and conditions are many-to-many relationships, Each service collection has a method for monitoring the calculation of thresholds, which can also be used by multiple service collections
And look at the conditions (Monitoring alarm threshold calculation) This class
Class Conditions (models. Model): name = models. Charfield (max_length=100,unique=true) item = models. ForeignKey (' Items ', verbose_name=u ' monitor value ') formula = models. ForeignKey (' formulas ', verbose_name=u ' op function ', null=true,blank=true) operator = models. ForeignKey (operators,verbose_name=u ' operator ', null=true,blank=true) Data_type = models. Charfield (default= ' char ', max_length=32, verbose_name=u ' data type ') threshold = models. Charfield (max_length=64, verbose_name=u ' threshold ') def __unicode__ (self): return self.name
Similarly, there is a name column, and the foreign key item ' monitor value ', Formula ' Operation function ', operator ' operator ', data_type ' data type ', threshold ' threshold '
Similarly, look at some of the class tables associated with the conditions class
Items Category:
Class Items (models. Model): # Monitor Item name = models. Charfield (max_length=50, unique=true) key = models. Charfield (max_length=100,unique=true) data_type_option = (' float ', ' float '), (' String ', ' string '), (' Integer ', ' Integer ')) Data_type = models. Charfield (max_length=50, choices=data_type_option) unit = models. Charfield (max_length=30,default= '% ') enabled = models. Booleanfield (default=true) def __unicode__ (self): return self.name
Formulas class
Class formulas (models. Model): name = models. Charfield (max_length=64,unique=true) key = models. Charfield (max_length=64,unique=true) memo = models. TextField () def __unicode__ (self): return self.name
Operators class
Class Operators (models. Model): name = models. Charfield (max_length=32,unique=true) key = models. Charfield (max_length=32) memo = models. TextField () def __unicode__ (self): return self.name
Basically, the structure of the Monitoring Template table is finished.
This article is from the "write-free" blog, please be sure to keep this source http://fangniu.blog.51cto.com/8773628/1746239
Template design for monitoring of CMDB project