-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxentest.c
More file actions
92 lines (79 loc) · 1.45 KB
/
xentest.c
File metadata and controls
92 lines (79 loc) · 1.45 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
int main (int argc, char *argv[])
{
FILE *fxm;
char buf[512];
char *c;
char *cc;
char curvps[16];
int curcpu = 0;
int curmem = 0;
int curiops = 0;
time_t now;
int tdiff;
int i;
//now = time (NULL);
//tdiff = now - VPS->lastround;
if (tdiff<0) tdiff = 1;
//VPS->lastround = now;
curvps[0] = 0;
inf->nxenvps = 0;
fxm = fopen ("/var/run/zero1-guestinfo.xml", "r");
if (! fxm) return 1;
while (! feof (fxm))
{
buf[0] = 0;
fgets (buf, 512, fxm);
buf[511] = 0;
if (strlen (buf))
{
if ((! strncmp (buf, "\t</dict>", 8)) && (*curvps))
{
if (strlen (curvps))
{
printf ("setvps %s %i %i %i\n", curvps,curcpu,curmem,curiops);
}
curvps[0] = 0;
curmem = curcpu = 0;
curcpu = 0;
curiops = 0;
continue;
}
c = buf;
while (isspace (*c)) c++;
if (! strncmp (c, "<dict id=\"", 10))
{
c += 10;
cc = strchr (c, '\"');
if (cc)
{
*cc = 0;
strncpy (curvps, c, 16);
curvps[15] = 0;
continue;
}
}
if (! strncmp (c, "<integer id=\"cpu\">", 18))
{
curcpu = atoi (c+18);
continue;
}
if (! strncmp (c, "<integer id=\"memory\">", 21))
{
curmem = atoi (c+21);
continue;
}
if (! strncmp (c, "<integer id=\"ioblkps\">", 22))
{
curiops = atoi (c+22);
}
}
}
fclose (fxm);
return 0;
}