Exemplo n.º 1
0
   def help_cluster_hosts_dbscan():
       """Print help for cluster_hosts_dbscan command"""
       colorize_log(
           'usage', """cluster_hosts_dbscan [min_samples] [max_dist] [metric]
tmin_samples : minimum number of hosts to form a cluster
tmax_dist : maximum distance between two hosts to form a cluster
tmetric : can be "cityblock", "euclidean", "l1", "l2" or "manhattan" """)
Exemplo n.º 2
0
 def preloop(self):
     context = Context()
     colorize_log('info', 'Initialization')
     self._build_filter(raw_input('Filter > '))
     colorize_log('info', 'Reading database..')
     context.dfilter = self._dfilter
     context.init_hosts()
     self.push(context)
Exemplo n.º 3
0
 def preloop(self):
     context = Context()
     colorize_log('info', 'Initialization')
     self._build_filter(raw_input('Filter > '))
     colorize_log('info', 'Reading database..')
     context.dfilter = self._dfilter
     context.init_hosts()
     self.push(context)
Exemplo n.º 4
0
 def do_remove_clusters(self, line):
     """Remove provided clusters"""
     try:
         cluster_labels = [int(idx) for idx in line.split()]
         if not cluster_labels:
             raise ValueError()
     except ValueError:
         self.help_select_clusters()
         return
     try:
         self.push(self.get_context().remove_clusters(cluster_labels))
     except (RuntimeError, AttributeError):
         colorize_log('warning', 'Cluster hosts first.')
Exemplo n.º 5
0
 def do_remove_clusters(self, line):
     """Remove provided clusters"""
     try:
         cluster_labels = [int(idx) for idx in line.split()]
         if not cluster_labels:
             raise ValueError()
     except ValueError:
         self.help_select_clusters()
         return
     try:
         self.push(self.get_context().remove_clusters(cluster_labels))
     except (RuntimeError, AttributeError):
         colorize_log('warning', 'Cluster hosts first.')
Exemplo n.º 6
0
 def postloop(self):
     colorize_log('info', 'Leaving..')
Exemplo n.º 7
0
 def help_plot3d():
     """Print help for do_plot3d command"""
     colorize_log('usage', 'plot3d\n\tPlot hosts in three dimensions')
Exemplo n.º 8
0
   def help_search_anomalies():
       """Print help for search_anomalies command"""
       colorize_log(
           'usage', """search_anomalies [N|N%]
tSearch N (or N%) most abnormal hosts""")
Exemplo n.º 9
0
 def help_select_centers():
     """Print help for do_select_centers command"""
     colorize_log('usage', 'select_centers\n\tSelect cluster centers')
Exemplo n.º 10
0
   def help_remove_anomalies():
       """Print help for do_remove_anomalies command"""
       colorize_log('usage', """remove_anomalies
tRemove anomalies from context""")
Exemplo n.º 11
0
 def help_count():
     """Help for do_count command"""
     colorize_log('usage', 'count\n\tPrint host count to sdout')
Exemplo n.º 12
0
   def help_cluster_hosts_kmeans():
       """Print help for cluster_hosts_kmeans command"""
       colorize_log('usage', """cluster_hosts_kmeans [nb_clusters]
tCluster hosts in [nb_clusters] groups using KMeans algorithm""")
Exemplo n.º 13
0
   def help_search_anomalies():
       """Print help for search_anomalies command"""
       colorize_log('usage', """search_anomalies [N|N%]
tSearch N (or N%) most abnormal hosts""")
Exemplo n.º 14
0
   def help_display_hosts():
       """Print help for do_display_hosts command"""
       colorize_log('usage', """display_hosts
tReturn current context host(s) ObjectID(s)""")
Exemplo n.º 15
0
 def help_select_centers():
     """Print help for do_select_centers command"""
     colorize_log('usage', 'select_centers\n\tSelect cluster centers')
Exemplo n.º 16
0
   def help_select_anomalies():
       """Print help for do_select_anomalies command"""
       colorize_log('usage', """select_anomalies
tRemove NON-anomalies from context""")
Exemplo n.º 17
0
   def help_remove_anomalies():
       """Print help for do_remove_anomalies command"""
       colorize_log('usage', """remove_anomalies
tRemove anomalies from context""")
Exemplo n.º 18
0
   def help_cluster_hosts_dbscan():
       """Print help for cluster_hosts_dbscan command"""
       colorize_log('usage', """cluster_hosts_dbscan [min_samples] [max_dist] [metric]
tmin_samples : minimum number of hosts to form a cluster
tmax_dist : maximum distance between two hosts to form a cluster
tmetric : can be "cityblock", "euclidean", "l1", "l2" or "manhattan" """)
Exemplo n.º 19
0
 def do_select_centers(self, _):
     """Select cluster centers"""
     try:
         self.push(self.get_context().select_cluster_centers())
     except (RuntimeError, AttributeError):
         colorize_log('warning', 'Cluster hosts first.')
Exemplo n.º 20
0
   def help_select_clusters():
       """Print help for select_clusters command"""
       colorize_log('usage', """select_clusters c1 [c2 [c3..]]
tSelect clusters c1, c2, c3.. for further analysis
tEnter -1 for noise if DBSCAN clusterring""")
Exemplo n.º 21
0
 def help_plot3d():
     """Print help for do_plot3d command"""
     colorize_log('usage', 'plot3d\n\tPlot hosts in three dimensions')
Exemplo n.º 22
0
   def help_remove_clusters():
       """Print help for remove_clusters command"""
       colorize_log('usage', """remove_clusters c1 [c2 [c3..]]
tRemove clusters c1, c2, c3.. from current context
tEnter -1 for noise if DBSCAN clusterring""")
Exemplo n.º 23
0
   def help_select_anomalies():
       """Print help for do_select_anomalies command"""
       colorize_log(
           'usage', """select_anomalies
tRemove NON-anomalies from context""")
Exemplo n.º 24
0
 def do_select_centers(self, _):
     """Select cluster centers"""
     try:
         self.push(self.get_context().select_cluster_centers())
     except (RuntimeError, AttributeError):
         colorize_log('warning', 'Cluster hosts first.')
Exemplo n.º 25
0
   def help_display_hosts():
       """Print help for do_display_hosts command"""
       colorize_log(
           'usage', """display_hosts
tReturn current context host(s) ObjectID(s)""")
Exemplo n.º 26
0
   def help_remove_clusters():
       """Print help for remove_clusters command"""
       colorize_log(
           'usage', """remove_clusters c1 [c2 [c3..]]
tRemove clusters c1, c2, c3.. from current context
tEnter -1 for noise if DBSCAN clusterring""")
Exemplo n.º 27
0
   def help_cluster_hosts_kmeans():
       """Print help for cluster_hosts_kmeans command"""
       colorize_log(
           'usage', """cluster_hosts_kmeans [nb_clusters]
tCluster hosts in [nb_clusters] groups using KMeans algorithm""")
Exemplo n.º 28
0
 def help_count():
     """Help for do_count command"""
     colorize_log('usage', 'count\n\tPrint host count to sdout')
Exemplo n.º 29
0
   def help_select_clusters():
       """Print help for select_clusters command"""
       colorize_log(
           'usage', """select_clusters c1 [c2 [c3..]]
tSelect clusters c1, c2, c3.. for further analysis
tEnter -1 for noise if DBSCAN clusterring""")
Exemplo n.º 30
0
 def postloop(self):
     colorize_log('info', 'Leaving..')
Exemplo n.º 31
0
 def do_count(self, _):
     """Print host count to stdout"""
     colorize_log('info', "Number of hosts:\n\t%s" % '\n\t'.join(
         '%s:\t%s' % (key, value)
         for key, value in self.get_context().count().iteritems()
     ))
Exemplo n.º 32
0
 def do_select_anomalies(self, _):
     """Select anomalies from hosts"""
     try:
         self.push(self.get_context().select_anomalies())
     except (RuntimeError, AttributeError):
         colorize_log('warning', 'Search anomalies first.')
Exemplo n.º 33
0
 def do_count(self, _):
     """Print host count to stdout"""
     colorize_log(
         'info', "Number of hosts:\n\t%s" % '\n\t'.join(
             '%s:\t%s' % (key, value)
             for key, value in self.get_context().count().iteritems()))
Exemplo n.º 34
0
 def do_select_anomalies(self, _):
     """Select anomalies from hosts"""
     try:
         self.push(self.get_context().select_anomalies())
     except (RuntimeError, AttributeError):
         colorize_log('warning', 'Search anomalies first.')