Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F117520545
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/op-mode-definitions/show-system.xml.in b/op-mode-definitions/show-system.xml.in
index 18a28868d..059cd813b 100644
--- a/op-mode-definitions/show-system.xml.in
+++ b/op-mode-definitions/show-system.xml.in
@@ -1,177 +1,177 @@
<?xml version="1.0"?>
<interfaceDefinition>
<node name="show">
<children>
<node name="system">
<properties>
<help>Show system information</help>
</properties>
<children>
<node name="connections">
<properties>
<help>Show active network connections on the system</help>
</properties>
<command>netstat -an</command>
<children>
<node name="tcp">
<properties>
<help>Show TCP connection information</help>
</properties>
<command>ss -t -r</command>
<children>
<leafNode name="all">
<properties>
<help>Show all TCP connections</help>
</properties>
<command>ss -t -a</command>
</leafNode>
<leafNode name="numeric">
<properties>
<help>Show TCP connection without resolving names</help>
</properties>
<command>ss -t -n</command>
</leafNode>
</children>
</node>
<node name="udp">
<properties>
<help>Show UDP socket information</help>
</properties>
<command>ss -u -a -r</command>
<children>
<leafNode name="numeric">
<properties>
<help>Show UDP socket information without resolving names</help>
</properties>
<command>ss -u -a -n</command>
</leafNode>
</children>
</node>
</children>
</node>
<leafNode name="cpu">
<properties>
<help>Show CPU information</help>
</properties>
<command>${vyos_op_scripts_dir}/show_cpu.py</command>
</leafNode>
<leafNode name="kernel-messages">
<properties>
<help>Show messages in kernel ring buffer</help>
</properties>
<command>sudo dmesg</command>
</leafNode>
<node name="login">
<properties>
<help>Show user accounts</help>
</properties>
<children>
<node name="users">
<properties>
<help>Show user account information</help>
</properties>
<command>${vyos_libexec_dir}/vyos-sudo.py ${vyos_op_scripts_dir}/show_users.py</command>
<children>
<leafNode name="all">
<properties>
<help>Show information about all accounts</help>
</properties>
<command>${vyos_libexec_dir}/vyos-sudo.py ${vyos_op_scripts_dir}/show_users.py all</command>
</leafNode>
<leafNode name="locked">
<properties>
<help>Show information about locked accounts</help>
</properties>
<command>${vyos_libexec_dir}/vyos-sudo.py ${vyos_op_scripts_dir}/show_users.py locked</command>
</leafNode>
<leafNode name="other">
<properties>
<help>Show information about non VyOS user accounts</help>
</properties>
<command>${vyos_libexec_dir}/vyos-sudo.py ${vyos_op_scripts_dir}/show_users.py other</command>
</leafNode>
<leafNode name="vyos">
<properties>
<help>Show information about VyOS user accounts</help>
</properties>
<command>${vyos_libexec_dir}/vyos-sudo.py ${vyos_op_scripts_dir}/show_users.py vyos</command>
</leafNode>
</children>
</node>
</children>
</node>
<node name="memory">
<properties>
<help>Show system memory usage</help>
</properties>
<command>${vyos_op_scripts_dir}/show_ram.sh</command>
<children>
<leafNode name="cache">
<properties>
<help>Show kernel cache information</help>
</properties>
<command>sudo slabtop -o</command>
</leafNode>
<leafNode name="detail">
<properties>
<help>Show detailed system memory usage</help>
</properties>
<command>cat /proc/meminfo</command>
</leafNode>
<leafNode name="routing-daemons">
<properties>
<help>Show memory usage of all routing protocols</help>
</properties>
<command>vtysh -c "show memory"</command>
</leafNode>
</children>
</node>
<node name="processes">
<properties>
<help>Show system processes</help>
</properties>
<command>ps ax</command>
<children>
<leafNode name="extensive">
<properties>
<help>Show extensive process info</help>
</properties>
<command>top -b -n1</command>
</leafNode>
<leafNode name="summary">
<properties>
<help>Show summary of system processes</help>
</properties>
- <command>uptime</command>
+ <command>${vyos_op_scripts_dir}/show_uptime.py</command>
</leafNode>
<leafNode name="tree">
<properties>
<help>Show process tree</help>
</properties>
<command>ps -ejH</command>
</leafNode>
</children>
</node>
<leafNode name="routing-daemons">
<properties>
<help>Show Quagga routing daemons</help>
</properties>
<command>vtysh -c "show daemons"</command>
</leafNode>
<leafNode name="storage">
<properties>
<help>Show filesystem usage</help>
</properties>
<command>df -h -x squashfs</command>
</leafNode>
<leafNode name="uptime">
<properties>
<help>Show how long the system has been up</help>
</properties>
<command>uptime</command>
</leafNode>
</children>
</node>
</children>
</node>
</interfaceDefinition>
diff --git a/src/op_mode/show_uptime.py b/src/op_mode/show_uptime.py
new file mode 100755
index 000000000..c3dea52e6
--- /dev/null
+++ b/src/op_mode/show_uptime.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2021 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+def get_uptime_seconds():
+ from re import search
+ from vyos.util import read_file
+
+ data = read_file("/proc/uptime")
+ seconds = search("([0-9\.]+)\s", data).group(1)
+
+ return int(float(seconds))
+
+def get_load_averages():
+ from re import search
+ from vyos.util import cmd
+
+ data = cmd("uptime")
+ matches = search(r"load average:\s*(?P<one>[0-9\.]+)\s*,\s*(?P<five>[0-9\.]+)\s*,\s*(?P<fifteen>[0-9\.]+)\s*", data)
+
+ res = {}
+ res[1] = float(matches["one"])
+ res[5] = float(matches["five"])
+ res[15] = float(matches["fifteen"])
+
+ return res
+
+if __name__ == '__main__':
+ from vyos.util import seconds_to_human
+
+ print("Uptime: {}\n".format(seconds_to_human(get_uptime_seconds())))
+
+ avgs = get_load_averages()
+
+ print("Load averages:")
+ print("1 minute: {:.02f}%".format(avgs[1]*100))
+ print("5 minutes: {:.02f}%".format(avgs[5]*100))
+ print("15 minutes: {:.02f}%".format(avgs[15]*100))
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Sep 26, 11:06 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4284988
Default Alt Text
(8 KB)
Attached To
Mode
rVYOSONEX vyos-1x
Attached
Detach File
Event Timeline
Log In to Comment