blob: 26c1c0a34a65539090348117aae9b1e883621b4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/*
backend code for Samba4 management
Copyright Andrew Tridgell 2005
Released under the GNU GPL v2 or later
*/
/*
return a list of current sessions
*/
function smbsrv_sessions()
{
var irpc = irpc_init();
status = irpc.connect("smb_server");
if (status.is_ok != true) {
return undefined;
}
var io = irpcObj();
io.input.level = irpc.SMBSRV_INFO_SESSIONS;
status = irpc.smbsrv_information(io);
if (status.is_ok != true) {
return undefined;
}
/* gather the results into a single array */
var i, count=0, ret = new Object();
for (i=0;i<io.results.length;i++) {
var sessions = io.results[i].info.sessions.sessions;
var j;
for (j=0;j<sessions.length;j++) {
ret[count] = sessions[j];
count++;
}
}
ret.length = count;
return ret;
}
/*
return a list of current tree connects
*/
function smbsrv_trees()
{
var irpc = irpc_init();
status = irpc.connect("smb_server");
if (status.is_ok != true) {
return undefined;
}
var io = irpcObj();
io.input.level = irpc.SMBSRV_INFO_TREES;
status = irpc.smbsrv_information(io);
if (status.is_ok != true) {
return undefined;
}
/* gather the results into a single array */
var i, count=0, ret = new Object();
for (i=0;i<io.results.length;i++) {
var trees = io.results[i].info.trees.trees;
var j;
for (j=0;j<trees.length;j++) {
ret[count] = trees[j];
count++;
}
}
ret.length = count;
return ret;
}
/*
return nbtd statistics
*/
function nbtd_statistics()
{
var irpc = irpc_init();
status = irpc.connect("nbt_server");
if (status.is_ok != true) {
return undefined;
}
var io = irpcObj();
io.input.level = irpc.NBTD_INFO_STATISTICS;
status = irpc.nbtd_information(io);
if (status.is_ok != true) {
return undefined;
}
return io.results[0].info.stats;
}
/*
see if a service is enabled
*/
function service_enabled(name)
{
var lp = loadparm_init();
var services = lp.get("server services");
var i;
for (i=0;i<services.length;i++) {
if (services[i] == name) {
return true;
}
}
return false;
}
/*
show status of a server
*/
function server_status(name)
{
var i;
var io;
var irpc = irpc_init();
if (!service_enabled(name)) {
return "DISABLED";
}
status = irpc.connect(name + "_server");
if (status.is_ok != true) {
return "DOWN";
}
var io = irpcObj();
status = irpc.irpc_uptime(io);
if (status.is_ok != true) {
return "NOT RESPONDING";
}
return "RUNNING";
}
/*
show status of a stream server
*/
function stream_server_status(name)
{
var irpc = irpc_init();
if (!service_enabled(name)) {
return "DISABLED";
}
status = irpc.connect(name + "_server");
if (status.is_ok != true) {
return "0 connections";
}
var io = irpcObj();
status = irpc.irpc_uptime(io);
if (status.is_ok != true) {
return "NOT RESPONDING";
}
var n = io.results.length;
return sprintf("%u connection%s", n, plural(n));
}
|