Skip to content

Commit

Permalink
fix proc stat status parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
aoliaoaoaojiao committed Feb 8, 2023
1 parent b31f11d commit f4b56b7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/perfmonUtil/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func getStatusOnPid(client *adb.Device, pid string) (status *entity.ProcessStatu
for scanner.Scan() {
line := scanner.Text()
fields := strings.Fields(line)
if len(fields) < 2 {
continue
}
var fieldName = strings.TrimRight(fields[0], ":")
var value = strings.Join(fields[1:], " ")
switch fieldName {
Expand Down Expand Up @@ -256,7 +259,7 @@ func newProcessStat(statStr string) (*entity.ProcessStat, error) {
if err1 != nil {
return nil, err1
}
processStat.Cmajflt = num
processStat.Majflt = num
case 13:
num, err1 := strconv.Atoi(value)
if err1 != nil {
Expand All @@ -280,43 +283,43 @@ func newProcessStat(statStr string) (*entity.ProcessStat, error) {
if err1 != nil {
return nil, err1
}
processStat.Priority = num
processStat.Cstime = num
case 17:
num, err1 := strconv.Atoi(value)
if err1 != nil {
return nil, err1
}
processStat.Nice = num
processStat.Priority = num
case 18:
num, err1 := strconv.Atoi(value)
if err1 != nil {
return nil, err1
}
processStat.Num_threads = num
processStat.Nice = num
case 19:
num, err1 := strconv.Atoi(value)
if err1 != nil {
return nil, err1
}
processStat.Itrealvalue = num
processStat.Num_threads = num
case 20:
num, err1 := strconv.Atoi(value)
if err1 != nil {
return nil, err1
}
processStat.Starttime = num
processStat.Itrealvalue = num
case 21:
num, err1 := strconv.Atoi(value)
if err1 != nil {
return nil, err1
}
processStat.Vsize = num
processStat.Starttime = num
case 22:
num, err1 := strconv.Atoi(value)
if err1 != nil {
return nil, err1
}
processStat.Rss = num
processStat.Vsize = num
case 23:
num, err1 := strconv.Atoi(value)
if err1 != nil {
Expand Down

0 comments on commit f4b56b7

Please sign in to comment.