Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
41111bdc
Commit
41111bdc
authored
Oct 07, 2011
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add API for openvz user_beancounters
parent
c84fa8ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
OpenVZ.pm
PVE/API2/OpenVZ.pm
+40
-0
OpenVZ.pm
PVE/OpenVZ.pm
+26
-0
No files found.
PVE/API2/OpenVZ.pm
View file @
41111bdc
...
@@ -582,6 +582,7 @@ __PACKAGE__->register_method({
...
@@ -582,6 +582,7 @@ __PACKAGE__->register_method({
my
$res
=
[
my
$res
=
[
{
subdir
=>
'
current
'
},
{
subdir
=>
'
current
'
},
{
subdir
=>
'
ubc
'
},
{
subdir
=>
'
start
'
},
{
subdir
=>
'
start
'
},
{
subdir
=>
'
stop
'
},
{
subdir
=>
'
stop
'
},
];
];
...
@@ -615,6 +616,45 @@ __PACKAGE__->register_method({
...
@@ -615,6 +616,45 @@ __PACKAGE__->register_method({
return
$vmstatus
->
{
$param
->
{
vmid
}};
return
$vmstatus
->
{
$param
->
{
vmid
}};
}});
}});
__PACKAGE__
->
register_method
({
name
=>
'
vm_user_beancounters
',
path
=>
'
{vmid}/status/ubc
',
method
=>
'
GET
',
proxyto
=>
'
node
',
protected
=>
1
,
# openvz /proc entries are only readable by root
description
=>
"
Get container user_beancounters.
",
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
node
=>
get_standard_option
('
pve-node
'),
vmid
=>
get_standard_option
('
pve-vmid
'),
},
},
returns
=>
{
type
=>
'
array
',
items
=>
{
type
=>
"
object
",
properties
=>
{
id
=>
{
type
=>
'
string
'
},
held
=>
{
type
=>
'
number
'
},
maxheld
=>
{
type
=>
'
number
'
},
bar
=>
{
type
=>
'
number
'
},
lim
=>
{
type
=>
'
number
'
},
failcnt
=>
{
type
=>
'
number
'
},
},
},
},
code
=>
sub
{
my
(
$param
)
=
@_
;
# test if VM exists
my
$conf
=
PVE::OpenVZ::
load_config
(
$param
->
{
vmid
});
my
$ubc
=
PVE::OpenVZ::
read_container_beancounters
(
$param
->
{
vmid
});
return
PVE::RESTHandler::
hash_to_array
(
$ubc
,
'
id
');
}});
__PACKAGE__
->
register_method
({
__PACKAGE__
->
register_method
({
name
=>
'
vm_start
',
name
=>
'
vm_start
',
path
=>
'
{vmid}/status/start
',
path
=>
'
{vmid}/status/start
',
...
...
PVE/OpenVZ.pm
View file @
41111bdc
...
@@ -59,6 +59,32 @@ sub load_config {
...
@@ -59,6 +59,32 @@ sub load_config {
return
$conf
;
return
$conf
;
}
}
sub
read_container_beancounters
{
my
(
$vmid
)
=
@_
;
my
$ubc
=
{};
if
(
my
$fh
=
IO::
File
->
new
("
/proc/user_beancounters
",
"
r
"))
{
my
$cid
;
while
(
defined
(
my
$line
=
<
$fh
>
))
{
if
(
$line
=~
m|\s*((\d+):\s*)?([a-z]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$|
)
{
$cid
=
$2
if
defined
(
$2
);
next
if
!
$cid
||
$cid
!=
$vmid
;
my
(
$name
,
$held
,
$maxheld
,
$bar
,
$lim
,
$failcnt
)
=
(
lc
(
$3
),
$4
,
$5
,
$6
,
$7
,
$8
);
$ubc
->
{
$name
}
=
{
held
=>
$held
,
maxheld
=>
$maxheld
,
bar
=>
$bar
,
lim
=>
$lim
,
failcnt
=>
$failcnt
,
};
}
}
close
(
$fh
);
}
return
$ubc
;
}
sub
read_container_network_usage
{
sub
read_container_network_usage
{
my
(
$vmid
)
=
@_
;
my
(
$vmid
)
=
@_
;
...
...
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