github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/syz-manager/stats.go (about) 1 // Copyright 2018 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package main 5 6 import ( 7 "fmt" 8 "runtime" 9 "time" 10 11 "github.com/google/syzkaller/pkg/image" 12 "github.com/google/syzkaller/pkg/stat" 13 ) 14 15 type Stats struct { 16 statCrashes *stat.Val 17 statCrashTypes *stat.Val 18 statSuppressed *stat.Val 19 statUptime *stat.Val 20 statFuzzingTime *stat.Val 21 statAvgBootTime *stat.Val 22 statCoverFiltered *stat.Val 23 } 24 25 func (mgr *Manager) initStats() { 26 mgr.statCrashes = stat.New("crashes", "Total number of VM crashes", 27 stat.Simple, stat.Prometheus("syz_crash_total")) 28 mgr.statCrashTypes = stat.New("crash types", "Number of unique crashes types", 29 stat.Simple, stat.NoGraph) 30 mgr.statSuppressed = stat.New("suppressed", "Total number of suppressed VM crashes", 31 stat.Simple, stat.Graph("crashes")) 32 mgr.statFuzzingTime = stat.New("fuzzing", "Total fuzzing time in all VMs (seconds)", 33 stat.NoGraph, func(v int, period time.Duration) string { return fmt.Sprintf("%v sec", v/1e9) }) 34 mgr.statUptime = stat.New("uptime", "Total uptime (seconds)", stat.Simple, stat.NoGraph, 35 func() int { 36 firstConnect := mgr.firstConnect.Load() 37 if firstConnect == 0 { 38 return 0 39 } 40 return int(time.Now().Unix() - firstConnect) 41 }, func(v int, period time.Duration) string { 42 return fmt.Sprintf("%v sec", v) 43 }) 44 mgr.statAvgBootTime = stat.New("instance restart", "Average VM restart time (sec)", 45 stat.NoGraph, 46 func() int { 47 return int(mgr.pool.BootTime.Value().Seconds()) 48 }, 49 func(v int, _ time.Duration) string { 50 return fmt.Sprintf("%v sec", v) 51 }) 52 53 stat.New("heap", "Process heap size (bytes)", stat.Graph("memory"), 54 func() int { 55 var ms runtime.MemStats 56 runtime.ReadMemStats(&ms) 57 return int(ms.Alloc) 58 }, func(v int, period time.Duration) string { 59 return fmt.Sprintf("%v MB", v>>20) 60 }) 61 stat.New("VM", "Process VM size (bytes)", stat.Graph("memory"), 62 func() int { 63 var ms runtime.MemStats 64 runtime.ReadMemStats(&ms) 65 return int(ms.Sys - ms.HeapReleased) 66 }, func(v int, period time.Duration) string { 67 return fmt.Sprintf("%v MB", v>>20) 68 }) 69 stat.New("images memory", "Uncompressed images memory (bytes)", stat.Graph("memory"), 70 func() int { 71 return int(image.StatMemory.Load()) 72 }, func(v int, period time.Duration) string { 73 return fmt.Sprintf("%v MB", v>>20) 74 }) 75 stat.New("uncompressed images", "Total number of uncompressed images in memory", 76 func() int { 77 return int(image.StatImages.Load()) 78 }) 79 mgr.statCoverFiltered = stat.New("filtered coverage", "", stat.NoGraph) 80 }