Python road, Day20-distributed monitoring system development

Source: Internet
Author: User
Tags snmp

The content of this section

Why do we need to monitor?

Discussion on the design of common monitoring system

Monitoring System Architecture Design

Structure Design of monitoring table

Why do we need to monitor? – Familiar with the design principle of it monitoring system – developing a simple version of the class Zabbix monitoring system – Mastering the program design ideas of the automation development project and the architecture of the common Monitoring system design discussion on Zabbixnagios Monitoring system requirements Discussion 1. Can monitor common system services, applications, Network equipment, etc. 2. A host can monitor a number of different services, different service monitoring interval can be different 3. The same service on different host monitoring interval, alarm threshold value can be different 4. You can add, delete, and modify the services to be monitored by a batch of hosts 5. Alarm level:
    • Different services because of the degree of business importance different, if there is a problem can be set different alarm level
    • You can specify a specific service or alert level event notification to a specific user
    • Alarm Upgrade Settings

6. Storage and optimization of historical data
    • Achieve the most efficient data storage with the least amount of space consumed
    • How do I get 5 years of monitoring data from all the services on a single host within 1s?

7. Data visualization, how to make a simple and beautiful user interface?

8. How can I support 5000+ machine monitoring requirements for standalone machines? 9. What mode of communication is adopted? Active, passive?  10. How can I achieve horizontal scaling of the monitoring server? What architecture is used?? Mysql? Active communication? Snmp,wget ...? Passive communication? Agent---How do I communicate with the monitor server? Socket server–> sockect Client? Can I use a ready-made C/s architecture? Rabbit MQ, Redis subscription publishing, HTTP? Using HTTP Benefits

1. Simple interface Design

2. Easy horizontal scaling to do distributed

3.Socket stable and mature, eliminating the more communication maintenance energy

HTTP Features:

1. Short connection

2. No status

3. Safety Certification

4. Passive communication

Monitoring System Architecture Design

Table structure Design
  1 #!_*_coding:utf8_*_ 2 from django.db import models 3 4 # Create your models here. 5 6 7 8 9 class Host (models. Model): Ten name = models. Charfield (max_length=64,unique=true) ip_addr = models. Genericipaddressfield (unique=true) host_groups = models. Manytomanyfield (' HostGroup ', blank=true) # A B C templates = models. Manytomanyfield ("Template", blank=true) # A D E monitored_by_choices = (' Agent ', ' Agent '), 16 (' SNMP ', ' SNMP '), (' wget ', ' wget '), + monitored_by = models.         Charfield (U ' monitoring mode ', max_length=64,choices=monitored_by_choices) status_choices= (1, ' Online '), 22 (2, ' Down '), (3, ' unreachable '), (4, ' Offline '), [+]-Status = models. Integerfield (U ' state ', choices=status_choices,default=1) is Memo = models. TextField (U "remarks", Blank=true,null=true) def __unicode__ (self): return Self.name to Class HostGroup (Models.    Model): 33 Name = models. Charfield (max_length=64,unique=true) templates = models. Manytomanyfield ("Template", blank=true) Memo = models. TextField (U "remarks", Blank=true,null=true)-def __unicode__ (self): Notoginseng return Self.name-Class Serviceindex ( Models. Model): + name = models. Charfield (max_length=64), key =models. Charfield (max_length=64) data_type_choices = (' int ', ' int '), (' float ', "float"), 45 ( ' Str ', "string") Data_type = models. Charfield (U ' indicator data type ', max_length=32,choices=data_type_choices,default= ' int ') = Memo = models. Charfield (U "remarks", Max_length=128,blank=true,null=true)-def __unicode__ (self): return "%s.%s"% (self.name,s Elf.key) The class Service (models. Model): The Models name =. Charfield (U ' service name ', max_length=64,unique=true) interval = models. Integerfield (U ' monitoring interval ', default=60) Plugin_name = models. Charfield (U ' plugin name ', max_length=64,default= ' n/a '). MansYtomanyfield (' Serviceindex ', verbose_name=u "indicator list", blank=true), Memo = models.     Charfield (U "remarks", Max_length=128,blank=true,null=true) __unicode__ def (self): return Self.name 61 #def get_service_items (obj): "# return", ". Join" ([I.name for I in Obj.items.all ()]) and the class Template (MODELS.M Odel): + + name = models. Charfield (U ' template name ', max_length=64,unique=true) * * Services = models. Manytomanyfield (' service ', verbose_name=u "Services list") triggers = models. Manytomanyfield (' Trigger ', verbose_name=u "trigger list", Blank=true)--def __unicode__ (self): return self.name 70 ' "Triggerexpression Class (models. Model): The Models name =. Charfield (U "trigger expression name", max_length=64,blank=true,null=true) service = models. ForeignKey (service,verbose_name=u "affiliate service") Service_index = models. ForeignKey (serviceindex,verbose_name=u "Related Service indicator") Logic_type_choices = ((' or ', ' or '), (' and ', ' and '), Logic_type = Models. Charfield (U "logical relationship", choices=logic_type_choices,max_length=32,blank=true,null=true) left_sibling = models. ForeignKey (' self ', verbose_name=u "left condition", blank=true,null=true,related_name= ' left_sibling_condition ') operator_ type_choices = (' eq ', ' = '), (' Lt ', ' < '), (' GT ', ' > ') ') Operator_type = models. Charfield (U "operator", choices=operator_type_choices,max_length=32) data_calc_type_choices = (Bayi (' avg ', ' Average '), the (' Max ', ' Max '), (' Hit ', ' hits '), (' Last ', ' last '), data_calc_func= models . Charfield (U "Data processing method", choices=data_calc_type_choices,max_length=64) Data_calc_args = models. Charfield (U "function passed in parameter", Help_text=u "if more than one parameter, then with, the number is separated, the first value is the time", max_length=64) threshold = models. Integerfield (U "threshold") __unicode__ def: "%s%s (%s)"% (self.service_index,self.operator _type,self.data_calc_func,self.data_calc_args) "94" Triggerexpression (models. Model): #name = models. Charfield (U "trigger expression name", max_length=64,blank=true,null=true) Trigger = models. ForeignKey (' Trigger ', verbose_name=u "belongs to trigger") 98 service = models. ForeignKey (service,verbose_name=u "affiliate service") Service_index = models. ForeignKey (serviceindex,verbose_name=u "Related Service indicator") Specified_index_key = models. Charfield (verbose_name=u "only monitors specifically specified indicator key", max_length=64,blank=true,null=true) 101 operator_type_choices = (' eq ', ' = ' ), (' Lt ', ' < '), (' GT ', ' > ') 102 Operator_type = models. Charfield (U "operator", choices=operator_type_choices,max_length=32) 103 data_calc_type_choices = (104 (' avg ', ' Average '), (' Max ', ' Max '), 106 (' hit ', ' hits '), 107 (' Last ', ' last '), 108) 109 data_calc_func= Models . Charfield (U "Data processing method", choices=data_calc_type_choices,max_length=64) Data_calc_args = models. Charfield (U "function passed parameter", Help_text=u "if more than one parameter, then with, the number is separated, the first value is the time", max_length=64) 111 threshold = models. Integerfield (U "threshold") 113 logic_type_choices = ((' or ', ' or '), (' and ', ' and '), Logic_type = models. CHarfield (U "logical relationship with a condition", choices=logic_type_choices,max_length=32,blank=true,null=true) #next_condition = Models . ForeignKey (' self ', verbose_name=u "right condition", blank=true,null=true,related_name= ' Right_sibling_condition ') 117 def __ Unicode__ (self): 118 return "%s%s (%s)"% (Self.service_index,self.operator_type,self.data_calc_func,self.data_c Alc_args) 119 Class meta:120 Pass #unique_together = (' trigger_id ', ' service ') 121 122 class trigger (models. Model): 123 name = models. Charfield (U ' trigger name ', max_length=64) 124 #expressions = models. TextField (u "expression") Severity_choices = (126 (1, ' information '), 127 (2, ' Warning '), + (3, ' Avera GE '), 129 (4, ' High '), Diaster (5, ' '), 131) #expressions = models. Manytomanyfield (triggerexpression,verbose_name=u "conditional expression") 133 severity = models. Integerfield (U ' alarm level ', choices=severity_choices) 134 enabled = models. Booleanfield (default=true) 135 memo = models. TextField (U "Remarks", blank=True,null=true) 136 137 def __unicode__ (self): 138 return "<serice:%s, severity:%s>"% (self.name,self.get_ Severity_display ()) 139 141 142 class Action (models. Model): 143 name = models. Charfield (max_length=64,unique=true) 144 host_groups = models. Manytomanyfield (' HostGroup ', blank=true) 145 hosts = models. Manytomanyfield (' Host ', blank=true) 146 147 conditions = models. TextField (U ' alarm condition ') 148 interval = models. Integerfield (U ' alarm interval (s) ', default=300) 149 operations = models. Manytomanyfield (' actionoperation ') 151 Recover_notice = models. Booleanfield (send notification message after recovery (U ') (default=true) Recover_subject = models. Charfield (max_length=128,blank=true,null=true) 153 recover_message = models. TextField (blank=true,null=true) 154 155 enabled = models. Booleanfield (default=true) 156 157 def __unicode__ (self): 158 return self.name159 class Actionoperation (mode Ls. Model): 161 name = models. Charfield (max_length=64) 162 step = models. SmallIntEgerfield (U "nth Time alarm", default=1) 163 action_type_choices = (164 (' email ', ' email '), 165 (' SMS ', ' SMS '), 166 (' script ', ' RunScript '), 167) 168 Action_type = models. Charfield (U "action type", choices=action_type_choices,default= ' email ', max_length=64) 169 #notifiers = models. Manytomanyfield (host_models. USERPROFILE,VERBOSE_NAME=U "Notification Object", Blank=true) __unicode__ def (self): 171 return self.name172 173 174 class Ma Intenance (models. Model): 175 name = models. Charfield (max_length=64,unique=true) 176 hosts = models. Manytomanyfield (' Host ', blank=true) 177 host_groups = models. Manytomanyfield (' HostGroup ', blank=true) 178 content = models. TextField (U "Maintenance content") 179 start_time = models. Datetimefield () End_time = models. Datetimefield () 181 182 def __unicode__ (self): 183 return self.name184 185 "' 186 CPU187 idle 80188 USA GE 90189 system 30190 user191 iowait 50192 193 memory:194 usage195 free196 swap197 Cache198 buffer199 load:201 load1202 load 5203 load 15204 " 

Category: Python Automation Development The way to the top of my collection This article King corner King
Follow-0
Fans-639 + plus attention00? Previous post: Python Select parsing posted @2016-05-01 17:18 Golden Horn King Reading (901) Comment (0) Edit Collection

Refresh Comments Refresh page back to top

Python road, Day20-distributed monitoring system development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.