mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
prevent memprof file overwrites for small intervals
Previously, the timestamp was accurate only down to seconds. For smaller intervals, this would truncate the previous file(s). Now, for small intervals, the number of microseconds is appended to the file name. Added the possibility to disable timestamps in the memory profile file names and use increments of 1 instead. Updated the memory profiling integration tests.
This commit is contained in:
committed by
Dan Christian Bogos
parent
218ad92635
commit
63129feb4c
@@ -59,6 +59,7 @@ var (
|
||||
memProfDir = cgrEngineFlags.String(utils.MemProfDirCgr, utils.EmptyString, "Directory for memory profiles")
|
||||
memProfInterval = cgrEngineFlags.Duration(utils.MemProfIntervalCgr, 15*time.Second, "Interval between memory profile saves")
|
||||
memProfMaxFiles = cgrEngineFlags.Int(utils.MemProfMaxFilesCgr, 1, "Number of memory profiles to keep (most recent)")
|
||||
memProfTimestamp = cgrEngineFlags.Bool(utils.MemProfTimestampCgr, false, "Add timestamp to memory profile files")
|
||||
scheduledShutdown = cgrEngineFlags.Duration(utils.ScheduledShutdownCgr, 0, "Shutdown the engine after the specified duration")
|
||||
singleCPU = cgrEngineFlags.Bool(utils.SingleCpuCgr, false, "Run on a single CPU core")
|
||||
syslogger = cgrEngineFlags.String(utils.LoggerCfg, utils.EmptyString, "Logger type <*syslog|*stdout>")
|
||||
@@ -694,9 +695,10 @@ func main() {
|
||||
|
||||
if *memProfDir != utils.EmptyString {
|
||||
if err := cS.StartMemoryProfiling(cores.MemoryProfilingParams{
|
||||
DirPath: *memProfDir,
|
||||
Interval: *memProfInterval,
|
||||
MaxFiles: *memProfMaxFiles,
|
||||
DirPath: *memProfDir,
|
||||
Interval: *memProfInterval,
|
||||
MaxFiles: *memProfMaxFiles,
|
||||
UseTimestamp: *memProfTimestamp,
|
||||
}); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<%s> %v", utils.CoreS, err))
|
||||
return
|
||||
|
||||
@@ -98,6 +98,13 @@ func TestCgrEngineFlags(t *testing.T) {
|
||||
defaultVal: 1,
|
||||
want: 3,
|
||||
},
|
||||
{
|
||||
name: "memProfTimestamp",
|
||||
flags: []string{"-memprof_timestamp"},
|
||||
flagVar: memProfTimestamp,
|
||||
defaultVal: false,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "scheduledShutdown",
|
||||
flags: []string{"-scheduled_shutdown", "1h"},
|
||||
|
||||
Reference in New Issue
Block a user