Merge "surveil-init: Added help text and more options"
This commit is contained in:
commit
8a09fc1a37
@ -51,5 +51,5 @@ ENV SURVEIL_OS_TENANT_NAME=admin
|
||||
|
||||
CMD cd /opt/surveil && \
|
||||
./setup.sh && \
|
||||
((sleep 40 && surveil-init) &) && \
|
||||
((sleep 40 && surveil-init --influxdb --packs --mongodb) &) && \
|
||||
surveil-api
|
||||
|
@ -40,9 +40,9 @@ Launch all surveil services with the following command: ::
|
||||
systemctl start surveil-full.target
|
||||
|
||||
|
||||
The surveil-init command will create a database in InfluxDB and initialize the MongoDB database: ::
|
||||
The surveil-init command will flush existing MongoDB Alignak config, create an InfluxDB database and upload configuration templates to Alignak: ::
|
||||
|
||||
surveil-init --influxdb
|
||||
surveil-init --mongodb --influxdb --packs
|
||||
|
||||
The surveil-webui-init command will pre-create data sources in Grafana: ::
|
||||
|
||||
|
@ -10,7 +10,7 @@ surveil:
|
||||
PBR_VERSION: "DEV"
|
||||
volumes:
|
||||
- ./surveil:/opt/surveil/surveil
|
||||
command: bash -c "cd /opt/surveil && ./setup.sh && /opt/surveil/env/bin/python setup.py develop && ((sleep 40 && surveil-init --demo) &) && sleep 20 && surveil-api --reload"
|
||||
command: bash -c "cd /opt/surveil && ./setup.sh && /opt/surveil/env/bin/python setup.py develop && ((sleep 40 && surveil-init --influxdb --packs --mongodb --demo) &) && sleep 20 && surveil-api --reload"
|
||||
# privileged: true # Fedora users might want to uncomment this if they face permission issues
|
||||
|
||||
alignak:
|
||||
|
@ -30,21 +30,35 @@ def main():
|
||||
parser.add_option('-d', '--demo',
|
||||
default=False,
|
||||
dest='demo',
|
||||
help="Create fake hosts in Alignak",
|
||||
action="store_true")
|
||||
parser.add_option('-i', '--influxdb',
|
||||
default=False,
|
||||
dest='influxdb',
|
||||
help="Pre-create the InfluxDB database",
|
||||
action='store_true')
|
||||
parser.add_option('-m', '--mongodb',
|
||||
default=False,
|
||||
dest='mongodb',
|
||||
help="Drop the existing Alignak MongoDB database",
|
||||
action='store_true')
|
||||
parser.add_option('-p', '--packs',
|
||||
default=False,
|
||||
dest='packs',
|
||||
help="Upload/Update configuration packs to MongoDB",
|
||||
action='store_true')
|
||||
opts, _ = parser.parse_args(sys.argv)
|
||||
|
||||
# Create a basic config in mongodb
|
||||
mongo = pymongo.MongoClient(config.surveil_api_config['mongodb_uri'])
|
||||
|
||||
if opts.demo is True:
|
||||
if opts.mongodb is True:
|
||||
# Drop the current shinken config
|
||||
print("Dropping existing Alignak MongoDB database...")
|
||||
mongo.drop_database('shinken')
|
||||
|
||||
if opts.influxdb is True:
|
||||
print("Pre-creating InfluxDB database...")
|
||||
# Create the InfluxDB database
|
||||
influx_client = influxdb.InfluxDBClient.from_DSN(
|
||||
config.surveil_api_config['influxdb_uri']
|
||||
@ -54,11 +68,8 @@ def main():
|
||||
if not any(db['name'] == influx_client._database for db in databases):
|
||||
influx_client.create_database(influx_client._database)
|
||||
|
||||
if mongo.surveil.init.count() == 0:
|
||||
# Mark packs as uploaded
|
||||
print("Uploading packs...")
|
||||
mongo.surveil.init.insert({"source": "surveil-init script"})
|
||||
|
||||
if opts.packs:
|
||||
print ("Uploading packs...")
|
||||
# Load the shinken packs
|
||||
subprocess.call(
|
||||
[
|
||||
@ -108,16 +119,13 @@ def main():
|
||||
]
|
||||
)
|
||||
|
||||
else:
|
||||
print("Skipping pack upload...")
|
||||
|
||||
cli_surveil = sc.Client('http://localhost:8080/v2',
|
||||
auth_url='http://localhost:8080/v2/auth',
|
||||
version='2_0')
|
||||
|
||||
# if --demo is specified, you get more hosts.
|
||||
if opts.demo is True:
|
||||
|
||||
print("Creating demo configuration...")
|
||||
# shinken's ws-arbiter
|
||||
cli_surveil.config.hosts.create(
|
||||
use="generic-host",
|
||||
|
Loading…
x
Reference in New Issue
Block a user