added status information to status command in lish
This commit is contained in:
parent
c1a7982557
commit
f4080ffffc
3 changed files with 11 additions and 71 deletions
|
|
@ -155,4 +155,8 @@ class LinspectorInterface(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_enabled_layouts(self):
|
def get_enabled_layouts(self):
|
||||||
self._config.get_enabled_layouts()
|
self._config.get_enabled_layouts()
|
||||||
|
|
||||||
|
def get_thread_count(self):
|
||||||
|
return {"Num Threads": str(self._scheduler._threadpool.num_threads),
|
||||||
|
"Max Threads": str(self._scheduler._threadpool.max_threads)}
|
||||||
|
|
@ -244,7 +244,12 @@ class LishCommander(Exit):
|
||||||
print('''Manage logging''')
|
print('''Manage logging''')
|
||||||
|
|
||||||
def do_status(self, text):
|
def do_status(self, text):
|
||||||
print('''executed %s''' % text)
|
# print instance name from core config
|
||||||
|
print GREEN + "Hostname" + END + ":\t" + socket.gethostname()
|
||||||
|
# print instance uptime
|
||||||
|
print GREEN + "Job Count" + END + ":\t" + str(self.interface.get_job_count())
|
||||||
|
thread_info = self.interface.get_thread_count()
|
||||||
|
print GREEN + "Threads" + END + ":\t" + str(thread_info["Num Threads"]) + "/" + str(thread_info["Max Threads"])
|
||||||
|
|
||||||
def help_status(self):
|
def help_status(self):
|
||||||
print('''Show status information about the Linspector instance''')
|
print('''Show status information about the Linspector instance''')
|
||||||
|
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
"""
|
|
||||||
The Linspector main thread. Here all scheduling is done so backends and
|
|
||||||
frontends can start before all jobs are scheduled.
|
|
||||||
|
|
||||||
Copyright (c) 2011-2013 by Johannes Findeisen and Rafael Timmerberg
|
|
||||||
|
|
||||||
This file is part of Linspector (http://linspector.org).
|
|
||||||
|
|
||||||
Linspector is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import threading
|
|
||||||
|
|
||||||
from logging import getLogger
|
|
||||||
|
|
||||||
from core.job import Job
|
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_job(jobInfo):
|
|
||||||
jobInfo.handle_call()
|
|
||||||
|
|
||||||
|
|
||||||
class Linspector(threading.Thread):
|
|
||||||
def __init__(self, linConf, core, scheduler, q):
|
|
||||||
self.linConf = linConf
|
|
||||||
self.core = core
|
|
||||||
self.scheduler = scheduler
|
|
||||||
self.q = q
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
|
|
||||||
def handle_job(self, jobInfo):
|
|
||||||
jobInfo.handle_call()
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
start_date = datetime.datetime.now()
|
|
||||||
time_delta = 0
|
|
||||||
jobs = []
|
|
||||||
for layout in self.linConf.get_enabled_layouts():
|
|
||||||
for hostgroup in layout.get_hostgroups():
|
|
||||||
for service in hostgroup.get_services():
|
|
||||||
for host in hostgroup.get_hosts():
|
|
||||||
for period in service.get_periods():
|
|
||||||
time_delta += 2.315379
|
|
||||||
new_start_date = start_date + datetime.timedelta(seconds=time_delta)
|
|
||||||
job = Job(service,
|
|
||||||
host,
|
|
||||||
hostgroup.get_members(),
|
|
||||||
hostgroup.get_processors(),
|
|
||||||
self.core,
|
|
||||||
hostgroup)
|
|
||||||
schedulerJob = period.createJob(self.scheduler, job, handle_job, start_date=new_start_date)
|
|
||||||
if schedulerJob is not None:
|
|
||||||
job.set_job(schedulerJob)
|
|
||||||
jobs.append(job)
|
|
||||||
self.q.put(jobs)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue