return (0, 0);
}
+sub kernel_version {
+ my $line = PVE::Tools::file_read_firstline("/proc/version");
+
+ if ($line && $line =~ m|^Linux\sversion\s((\d+(?:\.\d+)+)-?(\S+)?)|) {
+ my ($fullversion, $version_numbers, $extra) = ($1, $2, $3);
+
+ # variable names are the one from the Linux kernel Makefile
+ my ($version, $patchlevel, $sublevel) = split(/\./, $version_numbers);
+
+ return wantarray
+ ? (int($version), int($patchlevel), int($sublevel), $extra, $fullversion)
+ : $fullversion;
+ }
+
+ return (0, 0, 0, '', '');
+}
+
sub read_loadavg {
my $line = PVE::Tools::file_read_firstline('/proc/loadavg');
if ($statstr && $statstr =~ m/^$pid \(.*\) (\S) (-?\d+) -?\d+ -?\d+ -?\d+ -?\d+ \d+ \d+ \d+ \d+ \d+ (\d+) (\d+) (-?\d+) (-?\d+) -?\d+ -?\d+ -?\d+ 0 (\d+) (\d+) (-?\d+) \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ -?\d+ -?\d+ \d+ \d+ \d+/) {
return {
status => $1,
+ ppid => $2,
utime => $3,
stime => $4,
starttime => $7,
# for processes spanned by other processes.
# kill(0, pid) return succes for zombies.
# So we read the status form /proc/$pid/stat instead
-
+
my $info = read_proc_pid_stat($pid);
-
+
return $info && (!$pstart || ($info->{starttime} eq $pstart)) && ($info->{status} ne 'Z') ? $info : undef;
}
while (my $line = <$fh>) {
if ($line =~ m/^(\S+):\s+(\d+)\s*kB/i) {
$d->{lc ($1)} = $2 * 1024;
- }
+ }
}
close($fh);