Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62327243
hpc_lsusers
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 12, 11:02
Size
2 KB
Mime Type
text/x-perl
Expires
Tue, May 14, 11:02 (2 d)
Engine
blob
Format
Raw Data
Handle
17633416
Attached To
rSLURMACCOUNTS slurm-accounts
hpc_lsusers
View Options
#!/usr/bin/perl -w
# lshpcusers - list hpc users in format:
# username, login group, sciper, email, slurm accountsi, scratch dirs
#
# Author : EPFL-SCITAS
# Date : January 2016
#
use
strict
;
use
FindBin
;
use
lib
"$FindBin::RealBin/../lib/blib"
;
use
HPCUsers
;
use
Scratch
;
# -----------------------------------------------------------------------------
# Command line options
#
my
%opt
;
my
$print_scratch
=
0
;
# print scratch usage, or not
sub
print_usage
()
{
print
STDERR
<<
"EOF"
;
List
users
on
Scitas
hpc
clusters
.
usage:
$0
[
-
s
]
[
-
h
]
OPTIONS
-
s
:
show
scratch
usage
-
h
:
this
(
help
)
message
example:
$0
EOF
exit
;
}
sub
init
()
{
use
Getopt::
Std
;
my
$opt_string
=
'hs'
;
getopts
(
"$opt_string"
,
\
%opt
)
or
print_usage
();
print_usage
()
if
$opt
{
h
};
$print_scratch
=
1
if
$opt
{
s
};
print_usage
()
if
(
scalar
@ARGV
>
1
);
}
sub
print_users
()
{
if
(
$print_scratch
==
1
)
{
printf
(
"%-12s%-20s%-8s%-12s%-26s%-30s%-20s %s\n"
,
"User"
,
"Group:gid"
,
"Sciper"
,
"Employee"
,
"Title"
,
"Email"
,
"Slurm Accounts"
,
"Scratch dirs"
);
printf
(
"%-12s%-20s%-8s%-12s%-26s%-30s%-20s %s\n"
,
"----"
,
"---------"
,
"------"
,
"--------"
,
"-----"
,
"-----"
,
"--------------"
,
"------------"
);
}
else
{
printf
(
"%-12s%-20s%-8s%-12s%-26s%-30s%-20s\n"
,
"User"
,
"Group:gid"
,
"Sciper"
,
"Employee"
,
"Title"
,
"Email"
,
"Slurm Accounts"
);
printf
(
"%-12s%-20s%-8s%-12s%-26s%-30s%-20s\n"
,
"----"
,
"---------"
,
"------"
,
"--------"
,
"-----"
,
"-----"
,
"--------------"
);
}
foreach
my
$username
(
HPCUsers::
all_users
())
{
my
$user
=
$username
;
if
(
$
HPCUsers::
users
{
$username
}{
"in_hpc_group"
}
==
0
)
{
$user
=
"*"
.
$username
;
}
my
$group
=
$
HPCUsers::
users
{
$username
}{
"group"
};
my
$gid
=
$
HPCUsers::
users
{
$username
}{
"gid"
};
if
(
$gid
==
-
1
)
{
$group
=
"-1"
;
}
else
{
$group
.=
":"
.
$gid
;
}
my
$accounts
=
HPCUsers::
accounts_to_string
(
$username
);
$accounts
=
"NOASSOC"
if
(
$accounts
eq
""
);
# All scratch directories belonging to user
my
$scratch_dirs
=
Scratch::
scratch_dirs_to_string
(
HPCUsers::
uid
(
$username
));
if
(
$print_scratch
==
1
)
{
printf
(
"%-12s%-20s%-8s%-12s%-26s%-30s%-20s %s\n"
,
$user
,
$group
,
$
HPCUsers::
users
{
$username
}{
"sciper"
},
$
HPCUsers::
users
{
$username
}{
"type"
},
substr
(
$
HPCUsers::
users
{
$username
}{
"title"
},
0
,
24
),
substr
(
$
HPCUsers::
users
{
$username
}{
"email"
},
0
,
28
),
$accounts
,
$scratch_dirs
);
}
else
{
printf
(
"%-12s%-20s%-8s%-12s%-26s%-30s%-20s\n"
,
$user
,
$group
,
$
HPCUsers::
users
{
$username
}{
"sciper"
},
$
HPCUsers::
users
{
$username
}{
"type"
},
substr
(
$
HPCUsers::
users
{
$username
}{
"title"
},
0
,
24
),
substr
(
$
HPCUsers::
users
{
$username
}{
"email"
},
0
,
28
),
$accounts
);
}
}
}
# -----------------------------------------------------------------------------
&
init
();
&
HPCUsers::
init
();
&
Scratch::
init
()
if
(
$print_scratch
==
1
);
&
print_users
();
Event Timeline
Log In to Comment