2005-07-19 07:59:25 +04:00
#!/bin/sh
exec smbscript "$0" ${1+"$@"}
/*
provide information on connected users and open files
Copyright Andrew Tridgell 2005
2008-03-28 09:08:49 +03:00
Released under the GNU GPL version 3 or later
2005-07-19 07:59:25 +04:00
*/
libinclude("base.js");
libinclude("management.js");
var options = new Object();
2005-08-22 18:32:58 +04:00
options = GetOptions(ARGV,
2005-07-19 07:59:25 +04:00
"POPT_AUTOHELP",
2005-07-19 10:18:48 +04:00
"POPT_COMMON_SAMBA",
2005-07-19 13:29:30 +04:00
"POPT_COMMON_VERSION",
2005-07-19 10:18:48 +04:00
"nbt");
2005-08-22 18:32:58 +04:00
if (options == undefined) {
2005-07-19 10:08:06 +04:00
println("Failed to parse options: " + options.ERROR);
return -1;
2005-07-19 07:59:25 +04:00
}
2005-07-19 10:08:06 +04:00
/*
show open sessions
*/
function show_sessions()
{
var sessions = smbsrv_sessions();
var i;
var sys = sys_init();
if (sessions == undefined) {
println("No sessions open");
return;
}
printf("User Client Connected at\n");
printf("-------------------------------------------------------------------------------\n");
for (i=0;i<sessions.length;i++) {
var info = sessions[i];
var fulluser = sprintf("%s/%s", info.account_name, info.domain_name);
printf("%-30s %16s %s\n",
fulluser, info.client_ip, sys.httptime(info.connect_time));
}
printf("\n");
2005-07-19 08:26:58 +04:00
}
2005-07-19 07:59:25 +04:00
2005-07-19 10:08:06 +04:00
/*
show open tree connects
*/
2005-12-02 10:02:38 +03:00
function show_tcons()
2005-07-19 10:08:06 +04:00
{
2005-12-02 10:02:38 +03:00
var tcons = smbsrv_tcons();
2005-07-19 10:08:06 +04:00
var sys = sys_init();
2005-12-02 10:02:38 +03:00
if (tcons == undefined) {
2005-07-19 10:08:06 +04:00
println("No tree connects");
return;
}
printf("Share Client Connected at\n");
printf("-------------------------------------------------------------------------------\n");
2005-12-02 10:02:38 +03:00
for (i=0;i<tcons.length;i++) {
var info = tcons[i];
2005-07-19 10:08:06 +04:00
printf("%-30s %16s %s\n",
info.share_name, info.client_ip, sys.httptime(info.connect_time));
}
2005-07-19 08:26:58 +04:00
}
2005-07-19 10:08:06 +04:00
2005-07-19 10:18:48 +04:00
/*
show nbtd information
*/
function show_nbt()
{
var stats = nbtd_statistics();
if (stats == undefined) {
println("nbt server not running");
return;
}
var r;
println("NBT server statistics:");
for (r in stats) {
print("\t" + r + ":\t" + stats[r] + "\n");
}
println("");
}
2005-07-19 10:08:06 +04:00
2005-07-20 11:20:03 +04:00
var lp = loadparm_init();
printf("%s\n\n", lp.get("server string"));
2005-07-19 10:18:48 +04:00
if (options['nbt'] != undefined) {
show_nbt();
} else {
show_sessions();
2005-12-02 10:02:38 +03:00
show_tcons();
2005-07-19 10:18:48 +04:00
}
2005-07-19 08:26:58 +04:00
2005-07-19 07:59:25 +04:00
return 0;