luci-app-statistics: add users plugin support
authorJoel Johnson <mrjoel@lixil.net>
Fri, 31 Jul 2020 03:42:53 +0000 (21:42 -0600)
committerPaul Donald <itsascambutmailmeanyway@gmail.com>
Wed, 13 Mar 2024 15:44:44 +0000 (16:44 +0100)
The users plugin is functional and useful, but requires usage of custom
built packages of busybox, dropbear, openssh, or other console/shell
access mechanisms.

Signed-off-by: Joel Johnson <mrjoel@lixil.net>
applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js [new file with mode: 0644]
applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js [new file with mode: 0644]

diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js
new file mode 100644 (file)
index 0000000..06921a3
--- /dev/null
@@ -0,0 +1,23 @@
+/* Licensed to the public under the Apache License 2.0. */
+
+'use strict';
+'require baseclass';
+
+return baseclass.extend({
+       title: _('Users'),
+
+       rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
+               return {
+                       title: "%H: Users (console logins)",
+                       vlabel: "count",
+                       data: {
+                               types: [ "users" ],
+                               options: {
+                                       users: {
+                                               title: "Users %di",
+                                       }
+                               }
+                       }
+               };
+       }
+});
diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js
new file mode 100644 (file)
index 0000000..05b5eb8
--- /dev/null
@@ -0,0 +1,16 @@
+'use strict';
+'require baseclass';
+'require form';
+
+return baseclass.extend({
+       title: _('Users Plugin Configuration'),
+       description: _('The users plugin collects statistics about users logged in locally via shell. NOTE: Local shell (wtmp) tracking is NOT enabled in default builds. Additional setup is required to get non-zero counts.'),
+
+       addFormOptions: function(s) {
+               var o = s.option(form.Flag, 'enable', _('Enable this plugin'));
+       },
+
+       configSummary: function(section) {
+               return _('Monitoring shell users count');
+       }
+});