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
7a10f3e6
Commit
7a10f3e6
authored
Nov 18, 2011
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix cpu usage display
parent
6658a0b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
19 deletions
+15
-19
OpenVZ.pm
PVE/OpenVZ.pm
+6
-10
Utils.js
www/manager/Utils.js
+6
-6
StatusView.js
www/manager/openvz/StatusView.js
+2
-2
StatusView.js
www/manager/qemu/StatusView.js
+1
-1
No files found.
PVE/OpenVZ.pm
View file @
7a10f3e6
...
...
@@ -180,6 +180,8 @@ sub vmstatus {
my
$list
=
$opt_vmid
?
{
$opt_vmid
=>
{
type
=>
'
openvz
'
}}
:
config_list
();
my
$cpucount
=
$cpuinfo
->
{
cpus
}
||
1
;
foreach
my
$vmid
(
keys
%
$list
)
{
next
if
$opt_vmid
&&
(
$vmid
ne
$opt_vmid
);
...
...
@@ -192,6 +194,7 @@ sub vmstatus {
$d
->
{
name
}
=~
s/[\s]//g
;
$d
->
{
cpus
}
=
$conf
->
{
cpus
}
->
{
value
}
||
1
;
$d
->
{
cpus
}
=
$cpucount
if
$d
->
{
cpus
}
>
$cpucount
;
$d
->
{
disk
}
=
0
;
$d
->
{
maxdisk
}
=
int
(
$conf
->
{
diskspace
}
->
{
bar
}
*
1024
);
...
...
@@ -206,7 +209,6 @@ sub vmstatus {
$d
->
{
uptime
}
=
0
;
$d
->
{
cpu
}
=
0
;
$d
->
{
relcpu
}
=
0
;
$d
->
{
netout
}
=
0
;
$d
->
{
netin
}
=
0
;
...
...
@@ -264,7 +266,6 @@ sub vmstatus {
close
(
$fh
);
}
my
$cpus
=
$cpuinfo
->
{
cpus
}
||
1
;
# Note: OpenVZ does not use POSIX::_SC_CLK_TCK
my
$hz
=
1000
;
...
...
@@ -277,7 +278,7 @@ sub vmstatus {
my
$nice
=
$3
;
my
$system
=
$4
;
my
$ut
=
$5
;
my
$sum
=
$8
*
$cpu
s
;
# uptime in jiffies * cpus = available jiffies
my
$sum
=
$8
*
$cpu
count
;
# uptime in jiffies * cpus = available jiffies
my
$used
=
$9
;
# used time in jiffies
my
$uptime
=
int
(
$ut
/
$hz
);
...
...
@@ -290,24 +291,19 @@ sub vmstatus {
if
(
!
defined
(
$last_proc_vestat
->
{
$vmid
})
||
(
$last_proc_vestat
->
{
$vmid
}
->
{
sum
}
>
$sum
))
{
$last_proc_vestat
->
{
$vmid
}
=
{
used
=>
0
,
sum
=>
0
,
cpu
=>
0
,
relcpu
=>
0
};
$last_proc_vestat
->
{
$vmid
}
=
{
used
=>
0
,
sum
=>
0
,
cpu
=>
0
};
}
my
$diff
=
$sum
-
$last_proc_vestat
->
{
$vmid
}
->
{
sum
};
if
(
$diff
>
1000
)
{
# don't update too often
my
$useddiff
=
$used
-
$last_proc_vestat
->
{
$vmid
}
->
{
used
};
my
$cpu
=
int
(
$useddiff
*
100
/
$diff
)
;
my
$cpu
=
((
$useddiff
/$diff) * $cpucount) /
$d
->
{
cpus
}
;
$last_proc_vestat
->
{
$vmid
}
->
{
sum
}
=
$sum
;
$last_proc_vestat
->
{
$vmid
}
->
{
used
}
=
$used
;
$last_proc_vestat
->
{
$vmid
}
->
{
cpu
}
=
$d
->
{
cpu
}
=
$cpu
;
my
$relcpu
=
$cpu
;
$last_proc_vestat
->
{
$vmid
}
->
{
relcpu
}
=
$d
->
{
relcpu
}
=
$relcpu
;
}
else
{
$d
->
{
cpu
}
=
$last_proc_vestat
->
{
$vmid
}
->
{
cpu
};
$d
->
{
relcpu
}
=
$last_proc_vestat
->
{
$vmid
}
->
{
relcpu
};
}
}
}
...
...
www/manager/Utils.js
View file @
7a10f3e6
...
...
@@ -593,17 +593,17 @@ Ext.define('PVE.Utils', { statics: {
render_cpu
:
function
(
value
,
metaData
,
record
,
rowIndex
,
colIndex
,
store
)
{
var
maxcpu
=
record
.
data
.
maxcpu
;
if
(
!
record
.
data
.
uptime
)
{
if
(
!
(
record
.
data
.
uptime
&&
Ext
.
isNumeric
(
value
)))
{
return
''
;
}
if
(
!
(
Ext
.
isNumeric
(
value
)
&&
Ext
.
isNumeric
(
maxcpu
)
&&
(
maxcpu
>=
1
)))
{
var
maxcpu
=
record
.
data
.
maxcpu
||
1
;
if
(
!
Ext
.
isNumeric
(
maxcpu
)
&&
(
maxcpu
>=
1
))
{
return
''
;
}
var
per
=
(
value
*
100
)
/
maxcpu
;
var
per
=
value
*
100
;
return
per
.
toFixed
(
1
)
+
'
% of
'
+
maxcpu
.
toString
()
+
(
maxcpu
>
1
?
'
CPUs
'
:
'
CPU
'
);
},
...
...
www/manager/openvz/StatusView.js
View file @
7a10f3e6
...
...
@@ -25,9 +25,9 @@ Ext.define('PVE.openvz.StatusView', {
return
'
-
'
;
}
var
per
=
(
value
*
100
)
/
maxcpu
;
var
cpu
=
value
*
100
;
return
cpu
.
toFixed
(
1
)
+
'
% of
'
+
maxcpu
.
toString
()
+
(
maxcpu
>
1
?
'
CPUs
'
:
'
CPU
'
);
return
per
.
toFixed
(
1
)
+
'
% of
'
+
maxcpu
.
toString
()
+
(
maxcpu
>
1
?
'
CPUs
'
:
'
CPU
'
);
};
var
render_mem
=
function
(
value
,
metaData
,
record
,
rowIndex
,
colIndex
,
store
)
{
...
...
www/manager/qemu/StatusView.js
View file @
7a10f3e6
...
...
@@ -26,7 +26,7 @@ Ext.define('PVE.qemu.StatusView', {
return
'
-
'
;
}
var
per
=
(
value
*
100
)
/
maxcpu
;
var
per
=
(
value
*
100
);
return
per
.
toFixed
(
1
)
+
'
% of
'
+
maxcpu
.
toString
()
+
(
maxcpu
>
1
?
'
CPUs
'
:
'
CPU
'
);
};
...
...
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