code: def init(self):
          
          if not self.export_enable:
              return None
  
          self.index='{}-{}'.format(self.index, datetime.utcnow().strftime("%Y.%m.%d"))
          template_body =  {
            "mappings": {
              "glances": {
                "dynamic_templates": [
                  {
                    "integers": {
                      "match_mapping_type": "long",
                      "mapping": {
                        "type": "integer"
                      }
                    }
                  },
                  {
                    "strings": {
                      "match_mapping_type": "string",
                      "mapping": {
                        "type": "text",
                        "fields": {
                          "raw": {
                            "type":  "keyword",
                            "ignore_above": 256
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
  
          try:
              es = Elasticsearch(hosts=['{}:{}'.format(self.host, self.port)])
          except Exception as e:
              logger.critical("Cannot connect to ElasticSearch server %s:%s (%s)" % (self.host, self.port, e))
              sys.exit(2)
          else:
              logger.info("Connected to the ElasticSearch server %s:%s" % (self.host, self.port))
  
          try:
              index_count = es.count(index=self.index)['count']
          except Exception as e:
              # Index did not exist, it will be created at the first write
              # Create it...
              es.indices.create(index=self.index,body=template_body)
          else:
              logger.info("The index %s exists and holds %s entries." % (self.index, index_count))
  
          return es
docs: Init the connection to the ES server.