43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
__author__ = 'vanzhiganov'
|
|
|
|
"""
|
|
This script collect information about each hosted containers and host-system
|
|
and send all data to root server
|
|
"""
|
|
|
|
# from optparse import OptionParser
|
|
|
|
# parser = OptionParser()
|
|
# parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE")
|
|
# parser.add_option("observer", "--quiet", action="store_false", dest="verbose", default=True, help="don't print status messages to stdout")
|
|
#
|
|
# (options, args) = parser.parse_args()
|
|
|
|
import logging
|
|
import os
|
|
import sys
|
|
|
|
import node
|
|
from SWSCloudNode.lxc import lxc
|
|
|
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
|
if os.geteuid() != 0:
|
|
print "This application must be running under user `root`"
|
|
sys.exit()
|
|
|
|
# connect to database
|
|
# for use this need to add timestamp into container data
|
|
# r = redis.StrictRedis(host=config.redis_conf['host'], port=config.redis_conf['port'], db=config.redis_conf['db'])
|
|
# r.set('foo', 'bar')
|
|
# r.delete('foo')
|
|
# print r.get('foo')
|
|
|
|
# localtime = time.localtime(time.time())
|
|
# print "Local current time :", localtime['']
|
|
#
|
|
|
|
# get current status each containers
|
|
for container in lxc().list():
|
|
data = lxc().info(container)
|
|
result = node.Report().container_info(data)
|