forked from trumae/ec8top
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infomemoria.c
29 lines (19 loc) · 811 Bytes
/
infomemoria.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <string.h>
#include <sys/sysinfo.h> //biblioteca que permite obter info dos sistema
#include "infomemoria.h"
int infomemoria(char *b, size_t s) {//Função que que mostra status da memoria Ram do sistema
/* Conversoes para uso de medidas */
const double megabyte = 1024 * 1024;
/* Obtendo informacoes do sistema */
struct sysinfo si;
sysinfo (&si);
char buffer[500];
buffer[0] = '\x0';
/*impressao das informacoes*/
snprintf(buffer,500, "<p><b>Total RAM:</b> %5.1f MB<br><b>Total RAM in Use:</b> %5.1f MB<br><b>Total RAM Free:</b> %5.1f MB</p>",
si.totalram / megabyte , (si.totalram - si.freeram) / megabyte , si.freeram / megabyte);
//acrescenta ao buffer do projeto os dados contidos no buffer da função
strncat(b, buffer, s);
return 1;
}