2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "err-check.h"
23 #define LOADAVG_FILEPATH "/proc/loadavg"
25 int procfs_read_system_load_average(struct procfs_load_average_info *info)
29 ON_NULL_RETURN_VAL(info, -1);
31 FILE *loadavg_fp = fopen(LOADAVG_FILEPATH, "r");
33 ERR("failed to open " LOADAVG_FILEPATH);
37 if (fscanf(loadavg_fp, "%f %f %f", &a1, &a5, &a15) != 3) {
38 ERR("failed to read " LOADAVG_FILEPATH);
43 info->one_min_avg = a1;
44 info->five_min_avg = a5;
45 info->fifteen_min_avg = a15;
52 int profcs_read_system_cpu_usage(struct procfs_system_cpu_usage_info *usage)
57 int profcs_read_system_percpu_usage(struct procfs_system_percpu_usage_info **usage)
62 int procfs_read_system_memory_usage(struct procfs_system_memory_usage_info *usage)
67 int procfs_read_process_memory_usage(int pid, struct procfs_process_memory_usage_info *usage)
72 int procfs_read_process_cpu_usage(int pid, struct procfs_process_cpu_usage_info *usage)
77 int procfs_read_uptime(int *uptime)
82 int procfs_read_cpu_count(int *cpu_count)