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
04a567a6
Commit
04a567a6
authored
Apr 18, 2015
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pvestatd: update status of LXC containers
parent
e7adbb77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
18 deletions
+44
-18
pvestatd
bin/pvestatd
+44
-18
No files found.
bin/pvestatd
View file @
04a567a6
...
@@ -13,6 +13,7 @@ use PVE::INotify;
...
@@ -13,6 +13,7 @@ use PVE::INotify;
use
PVE::
Cluster
qw(cfs_read_file)
;
use
PVE::
Cluster
qw(cfs_read_file)
;
use
PVE::
Storage
;
use
PVE::
Storage
;
use
PVE::
QemuServer
;
use
PVE::
QemuServer
;
use
PVE::
LXC
;
use
PVE::
RPCEnvironment
;
use
PVE::
RPCEnvironment
;
use
PVE::API2::
Subscription
;
use
PVE::API2::
Subscription
;
use
PVE::
AutoBalloon
;
use
PVE::
AutoBalloon
;
...
@@ -175,30 +176,43 @@ sub update_qemu_status {
...
@@ -175,30 +176,43 @@ sub update_qemu_status {
}
}
}
}
sub
find_vzctl_console_pid
s
{
sub
remove_stale_lxc_console
s
{
my
$res
=
{};
my
$vmstatus
=
PVE::LXC::
vmstatus
();
my
$pidhash
=
PVE::LXC::
find_lxc_console_pids
();
dir_glob_foreach
('
/proc
',
'
\
d+
',
sub
{
foreach
my
$vmid
(
keys
%
$pidhash
)
{
my
(
$pid
)
=
@_
;
next
if
defined
(
$vmstatus
->
{
$vmid
});
syslog
('
info
',
"
remove stale lxc-console for CT
$vmid
");
foreach
my
$pid
(
@
{
$pidhash
->
{
$vmid
}})
{
kill
(
9
,
$pid
);
}
}
}
my
$cmdline
=
file_read_firstline
("
/proc/
$pid
/cmdline
");
sub
update_lxc_status
{
return
if
!
$cmdline
;
my
@args
=
split
(
/\0/
,
$cmdline
);
my
$ctime
=
time
(
);
# serach for vzctl console <vmid>
my
$vmstatus
=
PVE::LXC::
vmstatus
();
return
if
scalar
(
@args
)
!=
3
;
return
if
$args
[
1
]
ne
'
console
';
return
if
$args
[
2
]
!~
m/^\d+$/
;
return
if
$args
[
0
]
!~
m|^(/usr/sbin/)?vzctl$|
;
my
$vmid
=
$args
[
2
];
push
@
{
$res
->
{
$vmid
}},
$pid
;
});
return
$res
;
foreach
my
$vmid
(
keys
%
$vmstatus
)
{
my
$d
=
$vmstatus
->
{
$vmid
};
my
$data
;
if
(
$d
->
{
status
}
eq
'
running
')
{
# running
$data
=
"
$d
->{uptime}:
$d
->{name}:
$d
->{status}:0:
$ctime
:
$d
->{cpus}:
$d
->{cpu}:
"
.
"
$d
->{maxmem}:
$d
->{mem}:
"
.
"
$d
->{maxdisk}:
$d
->{disk}:
"
.
"
$d
->{netin}:
$d
->{netout}:
"
.
"
$d
->{diskread}:
$d
->{diskwrite}
";
}
else
{
$data
=
"
0:
$d
->{name}:
$d
->{status}:0:
$ctime
:
$d
->{cpus}::
"
.
"
$d
->{maxmem}::
"
.
"
$d
->{maxdisk}:
$d
->{disk}:
"
.
"
:::
";
}
PVE::Cluster::
broadcast_rrd
("
pve2.3-vm/
$vmid
",
$data
);
}
}
}
sub
update_storage_status
{
sub
update_storage_status
{
...
@@ -247,11 +261,23 @@ sub update_status {
...
@@ -247,11 +261,23 @@ sub update_status {
$err
=
$@
;
$err
=
$@
;
syslog
('
err
',
"
qemu status update error:
$err
")
if
$err
;
syslog
('
err
',
"
qemu status update error:
$err
")
if
$err
;
eval
{
update_lxc_status
();
};
$err
=
$@
;
syslog
('
err
',
"
lxc status update error:
$err
")
if
$err
;
eval
{
eval
{
update_storage_status
();
update_storage_status
();
};
};
$err
=
$@
;
$err
=
$@
;
syslog
('
err
',
"
storage status update error:
$err
")
if
$err
;
syslog
('
err
',
"
storage status update error:
$err
")
if
$err
;
eval
{
remove_stale_lxc_consoles
();
};
$err
=
$@
;
syslog
('
err
',
"
lxc console cleanup error:
$err
")
if
$err
;
}
}
my
$next_update
=
0
;
my
$next_update
=
0
;
...
...
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