Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
liming6
dcu-process-montor
Commits
a500d35c
Commit
a500d35c
authored
Jan 19, 2026
by
liming6
Browse files
fix pid_of_docker适应public_user
parent
4ff719ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
cmd/pid_of_docker/main.go
cmd/pid_of_docker/main.go
+10
-2
utils/utils_test.go
utils/utils_test.go
+4
-4
No files found.
cmd/pid_of_docker/main.go
View file @
a500d35c
...
@@ -54,7 +54,10 @@ func (c *Cinfo) Format() ([5]string, [5]int) {
...
@@ -54,7 +54,10 @@ func (c *Cinfo) Format() ([5]string, [5]int) {
return
rs
,
rl
return
rs
,
rl
}
}
var
RegUser
=
regexp
.
MustCompile
(
`^(?i)/public[0-9]*/home/([0-9a-z_]+)(?:|/.*)$`
)
var
(
RegUser
=
regexp
.
MustCompile
(
`^(?i)/public[0-9]*/home/([0-9a-z_]+)(?:|/.*)$`
)
RegUserPublic
=
regexp
.
MustCompile
(
`^(?i)/public[0-9]*/home/(?:public_user|locauser|localuser)/([0-9a-z_]+)(?:|/.*)$`
)
)
func
main
()
{
func
main
()
{
cli
,
err
:=
docker
.
GetDockerClient
()
cli
,
err
:=
docker
.
GetDockerClient
()
...
@@ -83,7 +86,12 @@ func main() {
...
@@ -83,7 +86,12 @@ func main() {
}
else
{
}
else
{
c
.
User
=
make
([]
string
,
0
,
4
)
c
.
User
=
make
([]
string
,
0
,
4
)
for
_
,
v
:=
range
i
.
Mounts
{
for
_
,
v
:=
range
i
.
Mounts
{
if
RegUser
.
MatchString
(
v
.
Source
)
{
if
RegUserPublic
.
MatchString
(
v
.
Source
)
{
f
:=
RegUserPublic
.
FindStringSubmatch
(
v
.
Source
)
if
len
(
f
)
>=
2
{
c
.
User
=
append
(
c
.
User
,
f
[
1
])
}
}
else
if
RegUser
.
MatchString
(
v
.
Source
)
{
f
:=
RegUser
.
FindStringSubmatch
(
v
.
Source
)
f
:=
RegUser
.
FindStringSubmatch
(
v
.
Source
)
if
len
(
f
)
>=
2
{
if
len
(
f
)
>=
2
{
c
.
User
=
append
(
c
.
User
,
f
[
1
])
c
.
User
=
append
(
c
.
User
,
f
[
1
])
...
...
utils/utils_test.go
View file @
a500d35c
...
@@ -220,11 +220,11 @@ func TestSplitN(t *testing.T) {
...
@@ -220,11 +220,11 @@ func TestSplitN(t *testing.T) {
}
}
func
TestReg
(
t
*
testing
.
T
)
{
func
TestReg
(
t
*
testing
.
T
)
{
var
RegUser
=
regexp
.
MustCompile
(
`^(?i)/public[0-9]*/([0-9a-z]+)(?:|/.*)$`
)
var
RegUser
Public
=
regexp
.
MustCompile
(
`^(?i)/public[0-9]*/
home/(?:public_user|locauser|localuser)/
([0-9a-z
_
]+)(?:|/.*)$`
)
test
:=
[]
string
{
"/public
2/liming6
"
,
"/Public/Liming6/hello"
}
test
:=
[]
string
{
"/public
/home/public_user/chenxi/WAN
"
,
"/Public/Liming6/hello"
}
for
_
,
v
:=
range
test
{
for
_
,
v
:=
range
test
{
if
RegUser
.
MatchString
(
v
)
{
if
RegUser
Public
.
MatchString
(
v
)
{
f
:=
RegUser
.
FindStringSubmatch
(
v
)
f
:=
RegUser
Public
.
FindStringSubmatch
(
v
)
t
.
Logf
(
"match %s, %v"
,
v
,
f
)
t
.
Logf
(
"match %s, %v"
,
v
,
f
)
}
else
{
}
else
{
t
.
Logf
(
"not match %s"
,
v
)
t
.
Logf
(
"not match %s"
,
v
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment