Blueprint lasterror
Add in a log report to nova-manage Usages: Get the last errors in the nova logs nova-manage logs errors Get the last x nova messages in the syslog. The default is 10 nova-manage logs syslog <x> Change-Id: Id5d3a546051e25175b6523711f437618d07c3f19
This commit is contained in:
parent
2d434e1389
commit
813794ed46
1
Authors
1
Authors
@ -44,6 +44,7 @@ Eric Day <eday@oddments.org>
|
|||||||
Eric Windisch <eric@cloudscaling.com>
|
Eric Windisch <eric@cloudscaling.com>
|
||||||
Ewan Mellor <ewan.mellor@citrix.com>
|
Ewan Mellor <ewan.mellor@citrix.com>
|
||||||
Gabe Westmaas <gabe.westmaas@rackspace.com>
|
Gabe Westmaas <gabe.westmaas@rackspace.com>
|
||||||
|
Gary Kotton <garyk@radware.com>
|
||||||
Hisaharu Ishii <ishii.hisaharu@lab.ntt.co.jp>
|
Hisaharu Ishii <ishii.hisaharu@lab.ntt.co.jp>
|
||||||
Hisaki Ohara <hisaki.ohara@intel.com>
|
Hisaki Ohara <hisaki.ohara@intel.com>
|
||||||
Ilya Alekseyev <ilyaalekseyev@acm.org>
|
Ilya Alekseyev <ilyaalekseyev@acm.org>
|
||||||
|
@ -2158,6 +2158,47 @@ class ConfigCommands(object):
|
|||||||
print FLAGS.FlagsIntoString()
|
print FLAGS.FlagsIntoString()
|
||||||
|
|
||||||
|
|
||||||
|
class GetLogCommands(object):
|
||||||
|
"""Get logging information"""
|
||||||
|
|
||||||
|
def errors(self):
|
||||||
|
"""Get all of the errors from the log files"""
|
||||||
|
if FLAGS.logdir:
|
||||||
|
error_found = 0
|
||||||
|
logs = [x for x in os.listdir(FLAGS.logdir) if x.endswith('.log')]
|
||||||
|
for file in logs:
|
||||||
|
log_file = os.path.join(FLAGS.logdir, file)
|
||||||
|
lines = [line.strip() for line in open(log_file, "r")]
|
||||||
|
lines.reverse()
|
||||||
|
print_name = 0
|
||||||
|
for index, line in enumerate(lines):
|
||||||
|
if line.find(" ERROR ") > 0:
|
||||||
|
error_found += 1
|
||||||
|
if print_name == 0:
|
||||||
|
print log_file + ":-"
|
||||||
|
print_name = 1
|
||||||
|
print "Line %d : %s" % (len(lines) - index, line)
|
||||||
|
if error_found == 0:
|
||||||
|
print "No errors in logfiles!"
|
||||||
|
|
||||||
|
def syslog(self, num_entries=10):
|
||||||
|
"""Get <num_entries> of the nova syslog events"""
|
||||||
|
entries = int(num_entries)
|
||||||
|
count = 0
|
||||||
|
lines = [line.strip() for line in open('/var/log/syslog', "r")]
|
||||||
|
lines.reverse()
|
||||||
|
print "Last %s nova syslog entries:-" % (entries)
|
||||||
|
for line in lines:
|
||||||
|
if line.find("nova") > 0:
|
||||||
|
count += 1
|
||||||
|
print "%s" % (line)
|
||||||
|
if count == entries:
|
||||||
|
break
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
print "No nova entries in syslog!"
|
||||||
|
|
||||||
|
|
||||||
CATEGORIES = [
|
CATEGORIES = [
|
||||||
('account', AccountCommands),
|
('account', AccountCommands),
|
||||||
('agent', AgentBuildCommands),
|
('agent', AgentBuildCommands),
|
||||||
@ -2181,7 +2222,8 @@ CATEGORIES = [
|
|||||||
('vm', VmCommands),
|
('vm', VmCommands),
|
||||||
('volume', VolumeCommands),
|
('volume', VolumeCommands),
|
||||||
('vpn', VpnCommands),
|
('vpn', VpnCommands),
|
||||||
('vsa', VsaCommands)]
|
('vsa', VsaCommands),
|
||||||
|
('logs', GetLogCommands)]
|
||||||
|
|
||||||
|
|
||||||
def lazy_match(name, key_value_tuples):
|
def lazy_match(name, key_value_tuples):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user