/* * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Flora License, Version 1.1 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _SYS_STATS_H_ #define _SYS_STATS_H_ /** * @brief System's statistics snapshot */ struct sys_stats { unsigned long long busy_ticks; unsigned long long busy_ticks_delta; unsigned long long total_ticks; unsigned long long total_ticks_delta; unsigned long long memory_used; unsigned long long total_memory; }; /** * @brief Calculates average cpu usage between two stats snapshots. * * @param[in] stats the stats snapshots * * @return usage the cpu usage as percent. */ float sys_stats_get_cpu_usage_percentage(struct sys_stats *stats); /** * @brief Takes system statistics snapshot. * * @param[out] stats System's statistics snapshot. * * @return: 0 on success, other value on error */ int sys_stats_update(struct sys_stats *stats); /** * @brief Calculates system memory usage. * * @param[in] stats the stats snapshots * * @return usage the system memory usage as percent. */ float sys_stats_get_memory_usage_percentage(struct sys_stats *stats); /** * @brief Gets system load averages stats. * * @param[out] a1 one minute average. * @param[out] a5 five minute average. * @param[out] a15 fifteen minute average. * * @return: 0 on success, other value on error */ int sys_stats_get_load_averages(float *a1, float *a5, float *a15); #endif