This function olny works properly if you apply correct setting to your nanny/deploy project In nanny - Runtime -> Instance spec -> Advanced settings -> Cgroupfs settings: Mount mode = Read only In deploy - Stage - Edit stage - Box - Cgroupfs settings: Mount mode = Read only */
| 53 | In deploy - Stage - Edit stage - Box - Cgroupfs settings: Mount mode = Read only |
| 54 | */ |
| 55 | static inline double CgroupV1Cpus(const TString& cpuCfsQuotaUsPath, const TString& cfsPeriodUsPath) { |
| 56 | try { |
| 57 | double q = FromString<int32_t>(StripString(TFileInput(cpuCfsQuotaUsPath).ReadAll())); |
| 58 | |
| 59 | if (q <= 0) { |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | double p = FromString<int32_t>(StripString(TFileInput(cfsPeriodUsPath).ReadAll())); |
| 64 | |
| 65 | if (p <= 0) { |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | return q / p; |
| 70 | } catch (...) { |
| 71 | return 0; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | In cgroups v2 there isn't a dedicated "cpu" directory under /sys/fs/cgroup, |
no test coverage detected