Skip to content

Instantly share code, notes, and snippets.

@mconcas
Created April 26, 2016 15:15
Show Gist options
  • Save mconcas/81634e524ee79165a53763ad78c4ddce to your computer and use it in GitHub Desktop.
Save mconcas/81634e524ee79165a53763ad78c4ddce to your computer and use it in GitHub Desktop.
#!/bin/env python
import json
import time
from datetime import datetime
from elasticsearch import Elasticsearch
ncpus = 8
dummy_string = {'host': { 'ip': '193.205.66.55',
'hostname': 'ali55xl.to.infn.it',
'hardware': { 'tot_cores': 8,
'tot_ram': 8,
'tot_storage': 500
},
'system': { 'distro': 'Centos07',
'kernel_version': '3.10.0-327.13.1.el7.x86_64'
},
'docker': { 'version': '1.10.3',
'build': '20f81dd',
'api_version': '1.22'
},
'plancton': { 'version': '0.3.2',
'status': 'running',
'has_pid': True,
'config': { 'cpus_per_docks': 0.5,
'max_docks': ncpus - 1,
'rigidity': 'soft',
'morbidity': 'hard',
'cputhresh': 75
},
},
'volatile': { 'timestamp': datetime.utcnow().isoformat(),
'cpu_efficiency': 56,
'nodes': [ { 'id': '1e9c4ce1d767',
'name': 'plancton-slave-Bs2noN',
'image': 'mconcas/centos6-autobuild-container:latest',
'status': 'active',
'pid': '742176'
},
{ 'id': 'f68083a1bf5d',
'name': 'plancton-slave-YBa6WN',
'image': 'mconcas/centos6-autobuild-container:latest',
 'status': 'inactive',
'pid': ' --- '
}
]
}
}
}
es = Elasticsearch([ '193.205.66.55:9200' ])
for i in range(10):
print es.index(index="plancton", doc_type="host", body={ "timestamp": datetime.utcnow().isoformat(), "host_data": dummy_string })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment