diff options
Diffstat (limited to 'src/sys-stats.h')
-rw-r--r-- | src/sys-stats.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/sys-stats.h b/src/sys-stats.h new file mode 100644 index 0000000..8c2d784 --- /dev/null +++ b/src/sys-stats.h @@ -0,0 +1,72 @@ +/* + * 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 + * @param[out] usage the cpu usage as percent. + * + * @return: 0 on success, other value on error + */ +int sys_stats_get_cpu_usage_percentage(struct sys_stats *stats, float *usage); + +/** + * @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[out] usage the memory usage as percent. + * + * @return: 0 on success, other value on error + */ +int sys_stats_get_memory_usage_percentage(struct sys_stats *stats, float *usage); + +/** + * @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 |