summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-19 09:30:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:42 -0500
commit82f1a9474d85f75291d0af0e51d55fa904d42055 (patch)
treee7875ca9d28e260d4b30cd5cb5ff7a88024c952f /source4
parent0e7b9f84ce2dcd5363409acc99a7b887a29be595 (diff)
downloadsamba-82f1a9474d85f75291d0af0e51d55fa904d42055.tar.gz
samba-82f1a9474d85f75291d0af0e51d55fa904d42055.tar.bz2
samba-82f1a9474d85f75291d0af0e51d55fa904d42055.zip
r8590: added server status utility functions for checking on the status of a task via irpc
- for stream tasks, returns the number of connections - for non-stream tasks, returns "RUNNING" For both, return "DISABLED" or "NOT RESPONDING" appropriately (This used to be commit 78d6303814382f7835212f5045f12180e396b540)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/libjs/base.js11
-rw-r--r--source4/scripting/libjs/management.js69
2 files changed, 80 insertions, 0 deletions
diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js
index 181b3ca959..39b62b133e 100644
--- a/source4/scripting/libjs/base.js
+++ b/source4/scripting/libjs/base.js
@@ -87,3 +87,14 @@ function substitute_var(str, subobj)
}
return join("", list);
}
+
+/*
+ return "s" if a number should be shown as plural
+*/
+function plural(n)
+{
+ if (n == 1) {
+ return "";
+ }
+ return "s";
+}
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
index 8b04247248..7130cdc5dd 100644
--- a/source4/scripting/libjs/management.js
+++ b/source4/scripting/libjs/management.js
@@ -91,3 +91,72 @@ function nbtd_statistics()
}
return io.results[0].info.stats;
}
+
+/*
+ see if a service is enabled
+*/
+function service_enabled(name)
+{
+ var services = lpGet("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 conn = new Object();
+ var i;
+ var io;
+ var irpc = irpc_init();
+
+ if (!service_enabled(name)) {
+ return "DISABLED";
+ }
+
+ status = irpc_connect(conn, name + "_server");
+ if (status.is_ok != true) {
+ return "DOWN";
+ }
+
+ var io = irpcObj();
+ status = irpc.irpc_uptime(conn, io);
+ if (status.is_ok != true) {
+ return "NOT RESPONDING";
+ }
+
+ return "RUNNING";
+}
+
+/*
+ show status of a stream server
+*/
+function stream_server_status(name)
+{
+ var conn = new Object();
+ var irpc = irpc_init();
+
+ if (!service_enabled(name)) {
+ return "DISABLED";
+ }
+ status = irpc_connect(conn, name + "_server");
+ if (status.is_ok != true) {
+ return "0 connections";
+ }
+
+ var io = irpcObj();
+ status = irpc.irpc_uptime(conn, io);
+ if (status.is_ok != true) {
+ return "NOT RESPONDING";
+ }
+
+ var n = io.results.length;
+ return sprintf("%u connection%s", n, plural(n));
+}