-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhealth_check.c
More file actions
71 lines (59 loc) · 1.06 KB
/
health_check.c
File metadata and controls
71 lines (59 loc) · 1.06 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
// 2016152037 Á¶Çö±Ù ´ã´ç ¿µ¿ªÀÔ´Ï´Ù.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i;
char cmd[40];
int arr[9];
int cnt=7;
int ret;
for(i=0;i<9;i++)
arr[i]=-1;
for(i=1;i<9;i++)
printf("%d ",arr[i]);
printf("\n\n");
while(1)
{
for(i=1;i<=cnt+1;i++)
{
sprintf(cmd,"ping -c 1 10.0.42.%d | grep from",i);
ret=system(cmd);
if(WEXITSTATUS(ret)==0) // ping-ack o
{
arr[i]=0;
}
else if(WEXITSTATUS(ret)==1) // ping-ack x
{
arr[i]=1;
}
}
for(i=1;i<=cnt+1;i++)
printf("%d ",arr[i]);
for(i=1;i<=cnt+1;i++)
{
if(arr[i]==1)
{
if(i==2)
system("docker start home");
else if(i==3)
system("docker start user");
else if(i==4)
system("docker start list");
else if(i==5)
system("docker start evaluation");
else if(i==6)
system("docker start community");
else if(i==7)
system("docker start grade");
else if(i==8)
system("docker start ct_mysql");
}
}
printf("\n\n");
sleep(1);
}
printf("\nfinish\n");
return 0;
}