summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-12-27 21:22:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:30:16 -0500
commit2d132edbab902c59ca6ca39b0bb42ab12693cee5 (patch)
tree5f772da013e701926684b3c91499710b889381a9 /services
parentb5aa81635d8eaf200d88fd37ee11c31dc9042659 (diff)
downloadsamba-2d132edbab902c59ca6ca39b0bb42ab12693cee5.tar.gz
samba-2d132edbab902c59ca6ca39b0bb42ab12693cee5.tar.bz2
samba-2d132edbab902c59ca6ca39b0bb42ab12693cee5.zip
r20364: SWAT updates, part 1
These next few check-ins will add a working Statistics module to SWAT, and add an API Documentation module as well. Next step will be to modify the LDB browser to work with this new module and fsm structure. Derrell (This used to be commit 29db71587f1332a9c44d5993a2be389f3a392ce4)
Diffstat (limited to 'services')
-rw-r--r--services/samba/adm.esp6
-rw-r--r--services/samba/management.esp184
2 files changed, 190 insertions, 0 deletions
diff --git a/services/samba/adm.esp b/services/samba/adm.esp
index 2fd0ec2f97..8843a068eb 100644
--- a/services/samba/adm.esp
+++ b/services/samba/adm.esp
@@ -19,4 +19,10 @@ function _nbt_packet_stats(params, error) {
}
jsonrpc.method.NBTPacketStats = _nbt_packet_stats;
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
%>
diff --git a/services/samba/management.esp b/services/samba/management.esp
new file mode 100644
index 0000000000..1efd8f6777
--- /dev/null
+++ b/services/samba/management.esp
@@ -0,0 +1,184 @@
+<%
+/*
+ * Copyright:
+ * (C) 2006 by Derrell Lipman
+ * All rights reserved
+ *
+ * License:
+ * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
+ */
+
+/*
+ * JSON-RPC mappings to management functions
+ */
+
+libinclude("base.js");
+libinclude("management.js");
+
+/**
+ * Get statistics from each of the servers
+ *
+ * @param params[0]
+ * Optional enum_smb_sessions flag, default false
+ *
+ * @param params[1]
+ * Optional enum_smb_tcons flag, default false
+ *
+ * @param error
+ * An object of class JsonRpcError.
+ *
+ * @return
+ * Success: Object containing all of the statistics
+ * Failure: error event
+ */
+function _get_statistics(params, error)
+{
+ var enum_smb_sessions = false;
+ var enum_smb_tcons = false;
+
+ if (params.length >= 1)
+ {
+ enum_smb_sessions = params[0];
+ }
+ if (params.length >= 2)
+ {
+ enum_smb_tcons = params[1];
+ }
+
+ var info = new Object();
+
+ info["nbt"] = new Object();
+ info["wins"] = new Object();
+ info["cldap"] = new Object();
+ info["kdc"] = new Object();
+ info["smb"] = new Object();
+ info["ldap"] = new Object();
+ info["rpc"] = new Object();
+
+ for (var service in info)
+ {
+ var irpc = irpc_init();
+ var status;
+ var obj = info[service];
+ obj.status = null;
+
+ if (!service_enabled(service))
+ {
+ obj.status = "DISABLED";
+ }
+ else
+ {
+ status = irpc.connect(service + "_server");
+ if (status.is_ok != true)
+ {
+ obj.status = "INACTIVE";
+ }
+ else
+ {
+ var io = irpcObj();
+ status = irpc.irpc_uptime(io);
+ if (status.is_ok != true)
+ {
+ obj.status = "NOT RESPONDING";
+ }
+ else
+ {
+ obj.status = "RUNNING";
+
+ if (service == "smb" ||
+ service == "ldap" ||
+ service == "rpc")
+ {
+ obj.connections = io.results.length;
+ }
+
+ if (service == "smb")
+ {
+ if (enum_smb_sessions)
+ {
+ var io = irpcObj();
+ io.input.level = irpc.SMBSRV_INFO_SESSIONS;
+ status = irpc.smbsrv_information(io);
+ obj.sessions = new Array(0);
+ if (status.is_ok == true)
+ {
+ /* gather the results into a single array */
+ var count = 0;
+ for (var i = 0; i < io.results.length; i++)
+ {
+ var sessions =
+ io.results[i].info.sessions.sessions;
+ for (var j = 0; j < sessions.length; j++)
+ {
+ obj.sessions[count] = sessions[j];
+
+ // convert NT times to unix epoch
+ obj.sessions[count].auth_time =
+ nttime2unix(obj.sessions[count].auth_time);
+ obj.sessions[count].last_use_time =
+ nttime2unix(obj.sessions[count].last_use_time);
+ obj.sessions[count].connect_time =
+ nttime2unix(obj.sessions[count].connect_time);
+
+ count++;
+ }
+ }
+ }
+ }
+
+ if (enum_smb_tcons)
+ {
+ var io = irpcObj();
+ io.input.level = irpc.SMBSRV_INFO_TCONS;
+ status = irpc.smbsrv_information(io);
+ obj.tcons = new Array(0);
+
+ if (status.is_ok == true)
+ {
+ /* gather the results into a single array */
+ var count=0;
+ for (var i = 0; i < io.results.length; i++)
+ {
+ var tcons = io.results[i].info.tcons.tcons;
+ for (var j = 0; j < tcons.length; j++)
+ {
+ obj.tcons[count] = tcons[j];
+
+
+ // convert NT times to unix epoch
+ obj.tcons[count].last_use_time =
+ nttime2unix(obj.tcons[count].last_use_time);
+ obj.tcons[count].connect_time =
+ nttime2unix(obj.tcons[count].connect_time);
+
+ count++;
+ }
+ }
+ }
+ }
+ }
+ else if (service == "nbt")
+ {
+ var io = irpcObj();
+ io.input.level = irpc.NBTD_INFO_STATISTICS;
+ status = irpc.nbtd_information(io);
+ if (status.is_ok == true)
+ {
+ obj.statistics = io.results[0].info.stats;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return info;
+}
+jsonrpc.method.get_statistics = _get_statistics;
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
+%>