Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add show reboot-history #1154

Closed
wants to merge 82 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
e5e19ab
initial commit
sujinmkang Oct 9, 2020
60085a7
group the reboot cause show command
sujinmkang Oct 9, 2020
e1244a5
[setup.py] Pin external runtime dependencies at known working version…
jleveque Oct 9, 2020
c4b2b6c
group the reboot-cause history with reboot-cause
sujinmkang Oct 10, 2020
561d133
[README.md] Add instructions for setting up a build/test environment …
jleveque Oct 11, 2020
a71c72b
[show] Add 'show' CLI for system-health feature (#971)
shlomibitton Oct 12, 2020
b6af9f4
Fix expected neighbor when multiple ports connect to same neighbor (#…
lguohan Oct 13, 2020
3a7457c
[celestica] consutil to support customize tty device name (#1155)
sandycelestica Oct 13, 2020
d8977fe
read last reboot-cause from symlink file
sujinmkang Oct 13, 2020
9531e41
rename
sujinmkang Oct 13, 2020
fcd8647
lgtm
sujinmkang Oct 13, 2020
e66777b
fix test
sujinmkang Oct 13, 2020
29a7e78
fix ut
sujinmkang Oct 13, 2020
89b189c
ut
sujinmkang Oct 14, 2020
4659ee2
ut2
sujinmkang Oct 14, 2020
059cdca
Fix exception for ipaddress in python2 (#1164)
bingwang-ms Oct 14, 2020
a733df5
[watermarkstat] Add unit tests for watermarkstat show commands (#1157)
neethajohn Oct 14, 2020
e51d44f
[consutil] Fix issue where the show line command crash if no ttyUSB e…
Blueve Oct 15, 2020
c382d89
[config/console] Support update console configuration related command…
Blueve Oct 15, 2020
574726f
rename last reboot cause file and fix ut
sujinmkang Oct 15, 2020
28c23f0
review comments & fix ut
sujinmkang Oct 15, 2020
984ef40
ut fix
sujinmkang Oct 15, 2020
4220356
review comments
sujinmkang Oct 15, 2020
3b62af0
show/main.py
sujinmkang Oct 15, 2020
b96fb6b
remove redundant
sujinmkang Oct 16, 2020
c395e14
Modify fast-reboot script to use BGP service script to stop bgp servi…
vaibhavhd Oct 19, 2020
510d0ad
[consutil] Add brief option to show line command (#1176)
Blueve Oct 20, 2020
59a511d
[config/show] Add CLI support for proxy arp (#1168)
theasianpianist Oct 20, 2020
13bd06b
Fixes the issue with show interface counters and for pfc and queue co…
abdosi Oct 20, 2020
5c12ffd
review comments
sujinmkang Oct 21, 2020
ca92e36
[counterpoll] Disable Counter Poll When Entering Fast Reboot (#1174)
tahmed-dev Oct 21, 2020
f08d628
type
sujinmkang Oct 22, 2020
0c3a97f
Remove stdeb.cfg; no longer used now that we build as wheel (#1182)
jleveque Oct 23, 2020
5651b17
fix unit test
sujinmkang Oct 23, 2020
a060cf9
review comments
sujinmkang Oct 23, 2020
00a2570
fdbshow and nbrshow use SonicV2Connector with decode_responses=True, …
qiluo-msft Oct 24, 2020
f14bbe5
[CLI][show][platform] Added ASIC count in the output. (#1185)
smaheshm Oct 26, 2020
dfc73ac
review comments
sujinmkang Oct 26, 2020
e889212
[fwutil]: Set min log priority to INFO. (#1191)
nazariig Oct 26, 2020
987c433
^^
sujinmkang Oct 26, 2020
63c6733
Add license file, remove third-party licenses file (#1192)
jleveque Oct 27, 2020
1753f22
[show] remove 'device2interface_dict' in show interface neighbor expe…
lolyu Oct 27, 2020
f645a38
unit test coverage
sujinmkang Oct 27, 2020
d7e372b
fix expected_output
sujinmkang Oct 27, 2020
615c3b4
unit test
sujinmkang Oct 27, 2020
baeeed9
mock read file
sujinmkang Oct 28, 2020
2f33931
ut
sujinmkang Oct 28, 2020
2decd0c
ut
sujinmkang Oct 28, 2020
8af9aee
Show FG_NHG CLI Commands Added (#1056)
kktheballer Oct 29, 2020
ef5f212
[sfputil] Display 'N/A' for non-SFP ports (#1078)
PJHsieh Nov 2, 2020
b4a0ebe
fix unittest
sujinmkang Nov 2, 2020
9011750
Merge branch 'reboot-history' of https://github.com/sujinmkang/sonic-…
sujinmkang Nov 2, 2020
6d0452b
initial commit
sujinmkang Oct 9, 2020
b4075f6
group the reboot cause show command
sujinmkang Oct 9, 2020
8359c7b
group the reboot-cause history with reboot-cause
sujinmkang Oct 10, 2020
6f838c1
read last reboot-cause from symlink file
sujinmkang Oct 13, 2020
ac52429
rename
sujinmkang Oct 13, 2020
cc4f4e9
lgtm
sujinmkang Oct 13, 2020
b645c24
fix test
sujinmkang Oct 13, 2020
e9fb1fc
fix ut
sujinmkang Oct 13, 2020
c61191d
ut
sujinmkang Oct 14, 2020
b7a634c
ut2
sujinmkang Oct 14, 2020
6dce6ed
rename last reboot cause file and fix ut
sujinmkang Oct 15, 2020
c6f02ec
review comments & fix ut
sujinmkang Oct 15, 2020
17516c5
ut fix
sujinmkang Oct 15, 2020
81d0736
review comments
sujinmkang Oct 15, 2020
df9cfcf
show/main.py
sujinmkang Oct 15, 2020
cd282e9
remove redundant
sujinmkang Oct 16, 2020
e6b55ae
review comments
sujinmkang Oct 21, 2020
ac2eba5
type
sujinmkang Oct 22, 2020
b927ab7
fix unit test
sujinmkang Oct 23, 2020
212274d
review comments
sujinmkang Oct 23, 2020
f452276
review comments
sujinmkang Oct 26, 2020
2e8fad6
^^
sujinmkang Oct 26, 2020
fd2629f
unit test coverage
sujinmkang Oct 27, 2020
b59df08
fix expected_output
sujinmkang Oct 27, 2020
7d20f97
unit test
sujinmkang Oct 27, 2020
08817ad
mock read file
sujinmkang Oct 28, 2020
b18f0c4
ut
sujinmkang Oct 28, 2020
9489bb8
ut
sujinmkang Oct 28, 2020
517c2c5
fix unittest
sujinmkang Nov 2, 2020
02eb1c7
Merge branch 'reboot-history' of https://github.com/sujinmkang/sonic-…
sujinmkang Nov 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,26 @@ This command displays the cause of the previous reboot
User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019]
```

**show reboot-history**

This command displays the history of the previous reboots up to 10 entry

- Usage:
```
show reboot-history
```

- Example:
```
admin@sonic:~$ show reboot-history
name cause time user comment
jleveque marked this conversation as resolved.
Show resolved Hide resolved
------------------- ----------- ---------------------------- ------ ---------
2020_10_09_02_33_06 reboot Fri Oct 9 02:29:44 UTC 2020 admin
2020_10_09_01_56_59 reboot Fri Oct 9 01:53:49 UTC 2020 admin
2020_10_09_02_00_53 fast-reboot Fri Oct 9 01:58:04 UTC 2020 admin
2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin
```

**show uptime**

This command displays the current system uptime
Expand Down
53 changes: 53 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,59 @@ def reboot_cause():
click.echo(proc.stdout.read())


#
# 'reboot-history' command ("show reboot-history")
#
@cli.command('reboot-history')
def reboot_history():
"""Show reboot history"""
REBOOT_CAUSE_TABLE = "REBOOT_CAUSE"
TABLE_NAME_SEPARATOR = '|'

db = SonicV2Connector(host='127.0.0.1')
db.connect(db.STATE_DB, False) # Make one attempt only

prefix = REBOOT_CAUSE_TABLE + TABLE_NAME_SEPARATOR
_hash = '{}{}'.format(prefix, '*')
table_keys = db.keys(db.STATE_DB, _hash)
table_keys.sort(reverse=True)

def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text

table = []
for tk in table_keys:
entry = db.get_all(db.STATE_DB, tk)
r = []
r.append(remove_prefix(tk, prefix))
if 'cause' not in entry:
r.append("")
jleveque marked this conversation as resolved.
Show resolved Hide resolved
else:
r.append(entry['cause'])

if 'time' not in entry:
r.append("")
else:
r.append(entry['time'])

if 'user' not in entry:
r.append("")
else:
r.append(entry['user'])

if 'comment' not in entry:
r.append("")
else:
r.append(entry['comment'])

table.append(r)

header = ['name', 'cause', 'time', 'user', 'comment']
sujinmkang marked this conversation as resolved.
Show resolved Hide resolved
click.echo(tabulate(table, header))


#
# 'line' command ("show line")
#
Expand Down