| 1742 | |
| 1743 | |
| 1744 | Try<hashmap<string, uint64_t>> stat( |
| 1745 | const string& hierarchy, |
| 1746 | const string& cgroup, |
| 1747 | const string& file) |
| 1748 | { |
| 1749 | Try<string> contents = cgroups::read(hierarchy, cgroup, file); |
| 1750 | |
| 1751 | if (contents.isError()) { |
| 1752 | return Error(contents.error()); |
| 1753 | } |
| 1754 | |
| 1755 | hashmap<string, uint64_t> result; |
| 1756 | |
| 1757 | foreach (const string& line, strings::split(contents.get(), "\n")) { |
| 1758 | // Skip empty lines. |
| 1759 | if (strings::trim(line).empty()) { |
| 1760 | continue; |
| 1761 | } |
| 1762 | |
| 1763 | string name; |
| 1764 | uint64_t value; |
| 1765 | |
| 1766 | // Expected line format: "%s %llu". |
| 1767 | istringstream stream(line); |
| 1768 | stream >> name >> value; |
| 1769 | |
| 1770 | if (stream.fail()) { |
| 1771 | return Error("Unexpected line format in " + file + ": " + line); |
| 1772 | } |
| 1773 | |
| 1774 | result[name] = value; |
| 1775 | } |
| 1776 | |
| 1777 | return result; |
| 1778 | } |
| 1779 | |
| 1780 | |
| 1781 | namespace internal { |
nothing calls this directly
no test coverage detected