2 backend code for Samba4 management
3 Copyright Andrew Tridgell 2005
4 Released under the GNU GPL v2 or later
9 return a list of current sessions
11 function smbsrv_sessions()
13 var irpc = irpc_init();
14 status = irpc.connect("smb_server");
15 if (status.is_ok != true) {
20 io.input.level = irpc.SMBSRV_INFO_SESSIONS;
21 status = irpc.smbsrv_information(io);
22 if (status.is_ok != true) {
26 /* gather the results into a single array */
27 var i, count=0, ret = new Object();
28 for (i=0;i<io.results.length;i++) {
29 var sessions = io.results[i].info.sessions.sessions;
31 for (j=0;j<sessions.length;j++) {
32 ret[count] = sessions[j];
41 return a list of current tree connects
43 function smbsrv_trees()
45 var irpc = irpc_init();
46 status = irpc.connect("smb_server");
47 if (status.is_ok != true) {
52 io.input.level = irpc.SMBSRV_INFO_TREES;
53 status = irpc.smbsrv_information(io);
54 if (status.is_ok != true) {
58 /* gather the results into a single array */
59 var i, count=0, ret = new Object();
60 for (i=0;i<io.results.length;i++) {
61 var trees = io.results[i].info.trees.trees;
63 for (j=0;j<trees.length;j++) {
64 ret[count] = trees[j];
73 return nbtd statistics
75 function nbtd_statistics()
77 var irpc = irpc_init();
78 status = irpc.connect("nbt_server");
79 if (status.is_ok != true) {
84 io.input.level = irpc.NBTD_INFO_STATISTICS;
85 status = irpc.nbtd_information(io);
86 if (status.is_ok != true) {
89 return io.results[0].info.stats;
93 see if a service is enabled
95 function service_enabled(name)
97 var lp = loadparm_init();
98 var services = lp.get("server services");
100 for (i=0;i<services.length;i++) {
101 if (services[i] == name) {
109 show status of a server
111 function server_status(name)
115 var irpc = irpc_init();
117 if (!service_enabled(name)) {
121 status = irpc.connect(name + "_server");
122 if (status.is_ok != true) {
127 status = irpc.irpc_uptime(io);
128 if (status.is_ok != true) {
129 return "NOT RESPONDING";
136 show status of a stream server
138 function stream_server_status(name)
140 var irpc = irpc_init();
142 if (!service_enabled(name)) {
145 status = irpc.connect(name + "_server");
146 if (status.is_ok != true) {
147 return "0 connections";
151 status = irpc.irpc_uptime(io);
152 if (status.is_ok != true) {
153 return "NOT RESPONDING";
156 var n = io.results.length;
157 return sprintf("%u connection%s", n, plural(n));