Changeset 46c20c8 in mainline for uspace/app/stats/stats.c
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/app/stats/stats.c (moved) (moved from uspace/lib/libc/include/sys/typefmt.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/stats/stats.c
rfb150d78 r46c20c8 1 1 /* 2 * Copyright (c) 2010 Jiri Svoboda2 * Copyright (c) 2010 Stanislav Kozina 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc 29 /** @addtogroup stats 30 * @brief Print system statistics. 30 31 * @{ 31 32 */ 32 /** @file Formatting macros for types from sys/types.h and some other33 * system types.33 /** 34 * @file 34 35 */ 35 36 36 #ifndef LIBC_SYS_TYPEFMT_H_ 37 #define LIBC_SYS_TYPEFMT_H_ 37 #include <stdio.h> 38 #include <stats.h> 39 #include <sys/time.h> 40 #include <inttypes.h> 41 #include <malloc.h> 38 42 39 # include <inttypes.h>43 #define NAME "sysstat" 40 44 41 /* off_t */ 42 #define PRIdOFF "ld" 43 #define PRIuOFF "lu" 44 #define PRIxOFF "lx" 45 #define PRIXOFF "lX" 45 #define DAY 86400 46 #define HOUR 3600 47 #define MINUTE 60 46 48 47 /* bn_t */ 48 #define PRIdBN PRId64 49 #define PRIuBN PRIu64 50 #define PRIxBN PRIx64 51 #define PRIXBN PRIX64 52 53 /* (s)size_t */ 54 #define PRIdSIZE PRIdPTR 55 #define PRIuSIZE PRIuPTR 56 #define PRIxSIZE PRIxPTR 57 #define PRIXSIZE PRIXPTR 58 59 /* sysarg_t */ 60 #define PRIdSYSARG PRIdPTR 61 #define PRIuSYSARG PRIuPTR 62 #define PRIxSYSARG PRIxPTR 63 #define PRIXSYSARG PRIxPTR 64 65 /* ipcarg_t */ 66 #define PRIdIPCARG PRIdPTR 67 #define PRIuIPCARG PRIuPTR 68 #define PRIxIPCARG PRIxPTR 69 #define PRIXIPCARG PRIXPTR 70 71 /* taskid_t */ 72 #define PRIdTASKID PRId64 73 #define PRIuTASKID PRIu64 74 #define PRIxTASKID PRIx64 75 #define PRIXTASKID PRIx64 76 77 #endif 49 int main(int argc, char *argv[]) 50 { 51 struct timeval time; 52 if (gettimeofday(&time, NULL) != 0) { 53 fprintf(stderr, "%s: Cannot get time of day\n", NAME); 54 return -1; 55 } 56 57 uint64_t sec = time.tv_sec; 58 printf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64, 59 (sec % DAY) / HOUR, (sec % HOUR) / MINUTE, sec % MINUTE); 60 61 sysarg_t uptime = stats_get_uptime(); 62 printf(", up %" PRIun " days, %" PRIun " hours, " 63 "%" PRIun " minutes, %" PRIun " seconds", 64 uptime / DAY, (uptime % DAY) / HOUR, 65 (uptime % HOUR) / MINUTE, uptime % MINUTE); 66 67 size_t count; 68 load_t *load = stats_get_load(&count); 69 if (load != NULL) { 70 printf(", load average: "); 71 72 size_t i; 73 for (i = 0; i < count; i++) { 74 if (i > 0) 75 printf(" "); 76 77 stats_print_load_fragment(load[i], 2); 78 } 79 80 free(load); 81 } 82 83 printf("\n"); 84 return 0; 85 } 78 86 79 87 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.
