Log Aging
The profiling log aging service implemented with the shell script is periodically executed using the crondtab service supported by the Linux OS, and is integrated into the runfile for the Ascend 910 AI Processor.
The profiling log aging policy determined by the profiling_aging.conf file is stored in the /var/log/npu/conf/profiling directory on the host by default.
The profiling_aging.conf file is as follows:
# crontab time set: # mode 0:minute period in hour(integer range 0-59) # mode 1:hour period in day(integer range 0-23) # mode 2:day period in month(integer range 1-31) # mode 3:month period in year(integer range 1-12) # mode 4:day period in week(integer range 0-6) CRONTAB_MODE=0 CRONTAB_TIME=1 #aging threshold that begin to aging, unit: %, range:[1, 99] AGING_THRESHOLD=90 #aging amount that need to aging, unit: %, range:[0, 50] AGING_AMOUNT=10
The preceding configuration options are described as follows:
- CRONTAB_MODE and CRONTAB_TIME: sets the crontab running mode and period. The two configuration options are used in pair.
The value range of CRONTAB_MODE is from 0 to 4.
- Mode0: performs execution every few minutes in the period of an hour. In this mode, CRONTAB_TIME ∈ [1, 59].
- Mode1: performs execution every few hours in the period of a day. In this mode, CRONTAB_TIME ∈ [1, 23].
- Mode2: performs execution every few days in the period of a month. In this mode, CRONTAB_TIME ∈ [1, 31].
- Mode3: performs execution every few months in the period of a year. In this mode, CRONTAB_TIME ∈ [1, 12].
- Mode4: performs execution every few days in the period of a week. In this mode, CRONTAB_TIME ∈ [1, 7].
The value of CRONTAB_MODE must be in the range [0, 4]. No additional verification logic for CRONTAB_TIME is performed. If the value is not a number or a negative value, an error is reported and the system exits.
- AGING_THRESHOLD: sets the log aging threshold. When the disk usage reaches the threshold, log aging starts. The default value is recommended.
- AGING_AMOUNT: specifies the percentage of logs to be aged when the disk usage reaches the threshold. The default value is recommended.
You are advised to use the default values of parameters of the log aging policy.
- The settings of CRONTAB_MODE and CRONTAB_TIME do not take effect until the HwHiAiUser user manually runs the profiling_periodic_aging_start.sh --restart command.
- The log aging service may take a long time, so lock is used to prevent the log aging service from being executed repeatedly. In other words, each time the log aging service is started, the system checks whether a non-block exclusive lock is added to /var/log/npu/conf/profiling/profiling_aging.lock. If yes, the log aging service is not executed. In this way, repeat execution is avoided when the run time of the log aging service is longer than the period interval configured for the crontab service.
- If you manually run the kill command to stop executing the profiling_periodic_aging.sh script, the non-blocking exclusive lock of profiling_aging.lock cannot be released. As a result, the log aging crontab service becomes an invalid operation. In this case, run profiling_periodic_aging_start.sh -restart again.
- The Profiling log aging service and log compression service are independent but affect each other. Therefore, if AGING_THRESHOLD of both services is set to a small value, the aging service may be started during the execution of the compression service. As a result, a file to be aged may have been compressed, causing a file aging failure.
- The /var/log/npu/conf/profiling/aging directory must not be deleted. If deleted by mistake, the log aging function is unavailable.
In this case, create an aging directory and a prof_aging_old_record file in the directory as the HwHiAiUser user, and write the minimum index of the slices for recording the aged files (that is, the value of the asterisk (*) of the prof_aging_file_record.slice_*.DONE file in the aging directory).
Tips:
Run the crontab -l command to view all crontab services of the current user. Run the crontab -u command to view the crontab service of a specified user. Run the crontab -r to delete all crontab services of the current user.
To start the aging service, run profiling_periodic_aging_start.sh --start. To stop the aging service, run profiling_periodic_aging_start.sh --stop.