ing
This commit is contained in:
parent
c2dd51b071
commit
ca823a2e69
37
_build/_config/container/general/postgresql/989238744
Normal file
37
_build/_config/container/general/postgresql/989238744
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"configID" : "989238744",
|
||||||
|
"target" : {
|
||||||
|
"connection" : {
|
||||||
|
"ip" : "192.168.1.106",
|
||||||
|
"port" : "5432",
|
||||||
|
"ssl" : false,
|
||||||
|
"portType" : "tcp"
|
||||||
|
},
|
||||||
|
"auth" : {
|
||||||
|
"url":"jdbc:postgresql://192.168.1.50:5432/overflow",
|
||||||
|
"id":"overflow",
|
||||||
|
"pw":"qwer5795"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schedule" : {
|
||||||
|
"interval" : "3"
|
||||||
|
},
|
||||||
|
"crawler" : {
|
||||||
|
"name":"POSTGRESQL",
|
||||||
|
"container":"GENERAL"
|
||||||
|
},
|
||||||
|
"items" : [
|
||||||
|
{
|
||||||
|
"keys" : [
|
||||||
|
{
|
||||||
|
"metric":"net.pgsql.connection_count",
|
||||||
|
"key" : "connection_count"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"queryInfo":{
|
||||||
|
"query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle';"
|
||||||
|
},
|
||||||
|
"mappingInfo" : {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
23
_build/_config/container/network/postgresql/112103115113108
Normal file
23
_build/_config/container/network/postgresql/112103115113108
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"configID" : "112103115113108",
|
||||||
|
"target" : {
|
||||||
|
"connection" : {
|
||||||
|
"ip" : "192.168.1.50",
|
||||||
|
"port" : "5432",
|
||||||
|
"ssl" : false,
|
||||||
|
"portType" : "tcp"
|
||||||
|
},
|
||||||
|
"auth" : {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schedule" : {
|
||||||
|
"interval" : "3"
|
||||||
|
},
|
||||||
|
"crawler" : {
|
||||||
|
"name":"POSTGRESQL_HEALTH",
|
||||||
|
"container":"NETWORK"
|
||||||
|
},
|
||||||
|
"items" : [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
23
_build/_config/container/network/ssh/115115104
Normal file
23
_build/_config/container/network/ssh/115115104
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"configID" : "115115104",
|
||||||
|
"target" : {
|
||||||
|
"connection" : {
|
||||||
|
"ip" : "192.168.1.10",
|
||||||
|
"port" : "22",
|
||||||
|
"ssl" : false,
|
||||||
|
"portType" : "tcp"
|
||||||
|
},
|
||||||
|
"auth" : {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schedule" : {
|
||||||
|
"interval" : "7"
|
||||||
|
},
|
||||||
|
"crawler" : {
|
||||||
|
"name":"SSH_HEALTH",
|
||||||
|
"container":"NETWORK"
|
||||||
|
},
|
||||||
|
"items" : [
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
|
@ -20,4 +20,3 @@
|
||||||
"items" : [
|
"items" : [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,205 @@
|
||||||
2018-04-28T22:59:46.786+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:24.032+0900 [34minfo[0m RPC Client[NETWORK]: Started
|
||||||
2018-04-28T22:59:46.848+0900 [34minfo[0m Client[127.0.0.1:37772] has been connected
|
2018-05-03T20:02:24.032+0900 [34minfo[0m connected
|
||||||
2018-04-28T22:59:46.849+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:24.130+0900 [35mdebug[0m scheduler of config[112103115113108] has been added
|
||||||
2018-04-28T23:00:57.439+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:24.130+0900 [35mdebug[0m scheduler of config[115115104] has been added
|
||||||
2018-04-28T23:00:57.519+0900 [34minfo[0m Client[127.0.0.1:38544] has been connected
|
2018-05-03T20:02:24.130+0900 [35mdebug[0m Sensor configs[2] were added
|
||||||
2018-04-28T23:00:57.520+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:28.033+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
2018-04-28T23:01:36.808+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:28.033+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
2018-04-28T23:01:36.904+0900 [34minfo[0m Client[127.0.0.1:38978] has been connected
|
2018-05-03T20:02:28.034+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:02:28.034632013 +0900 KST m=+4.004447146 StartTime:2018-05-03 20:02:28.033144218 +0900 KST m=+4.002959297]]
|
||||||
2018-04-28T23:01:36.905+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:31.033+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
2018-04-28T23:02:41.382+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:31.033+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
2018-04-28T23:02:41.476+0900 [34minfo[0m Client[127.0.0.1:39668] has been connected
|
2018-05-03T20:02:31.034+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:02:31.034482669 +0900 KST m=+7.004297793 StartTime:2018-05-03 20:02:31.033146994 +0900 KST m=+7.002962070]]
|
||||||
2018-04-28T23:02:41.477+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:32.032+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
2018-04-28T23:03:50.918+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:32.033+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
2018-04-28T23:03:50.967+0900 [34minfo[0m Client[127.0.0.1:40418] has been connected
|
2018-05-03T20:02:32.040+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:02:32.033058998 +0900 KST m=+8.002874082 PacketType:Pre EndTime:2018-05-03 20:02:32.040726681 +0900 KST m=+8.010541833]]
|
||||||
2018-04-28T23:03:50.968+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:34.032+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
2018-04-28T23:07:02.032+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:34.033+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
2018-04-28T23:07:02.128+0900 [34minfo[0m Client[127.0.0.1:42406] has been connected
|
2018-05-03T20:02:34.034+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:02:34.03307974 +0900 KST m=+10.002894832 PacketType:Post EndTime:2018-05-03 20:02:34.034551119 +0900 KST m=+10.004366215]]
|
||||||
2018-04-28T23:07:02.128+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:37.032+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
2018-04-28T23:20:42.154+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:37.033+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
2018-04-28T23:20:42.236+0900 [34minfo[0m Client[127.0.0.1:50962] has been connected
|
2018-05-03T20:02:37.034+0900 [35mdebug[0m Get success config[map[EndTime:2018-05-03 20:02:37.034409562 +0900 KST m=+13.004224663 StartTime:2018-05-03 20:02:37.033070129 +0900 KST m=+13.002885212 PacketType:Post]]
|
||||||
2018-04-28T23:21:05.356+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:39.033+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
2018-04-28T23:23:32.464+0900 [34minfo[0m Server[Container Network]: Started
|
2018-05-03T20:02:39.033+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
2018-04-28T23:23:32.562+0900 [34minfo[0m Client[127.0.0.1:52710] has been connected
|
2018-05-03T20:02:39.040+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:02:39.033111775 +0900 KST m=+15.002926845 PacketType:Pre EndTime:2018-05-03 20:02:39.040281882 +0900 KST m=+15.010096992]]
|
||||||
2018-04-28T23:23:35.617+0900 [35mdebug[0m Sensor configs[2] were added
|
2018-05-03T20:02:40.033+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:02:40.033+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:02:40.034+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:02:40.033086634 +0900 KST m=+16.002901714 PacketType:Post EndTime:2018-05-03 20:02:40.034535981 +0900 KST m=+16.004351105]]
|
||||||
|
2018-05-03T20:03:07.055+0900 [34minfo[0m connected
|
||||||
|
2018-05-03T20:03:07.055+0900 [34minfo[0m RPC Client[NETWORK]: Started
|
||||||
|
2018-05-03T20:03:07.152+0900 [35mdebug[0m scheduler of config[112103115113108] has been added
|
||||||
|
2018-05-03T20:03:07.152+0900 [35mdebug[0m scheduler of config[115115104] has been added
|
||||||
|
2018-05-03T20:03:07.152+0900 [35mdebug[0m Sensor configs[2] were added
|
||||||
|
2018-05-03T20:03:11.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:03:11.055+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:03:11.057+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:11.0558387 +0900 KST m=+4.003590647 PacketType:Post EndTime:2018-05-03 20:03:11.057269837 +0900 KST m=+4.005021818]]
|
||||||
|
2018-05-03T20:03:14.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:03:14.055+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:03:14.057+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:14.055810196 +0900 KST m=+7.003562132 PacketType:Post EndTime:2018-05-03 20:03:14.057461713 +0900 KST m=+7.005213687]]
|
||||||
|
2018-05-03T20:03:15.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:03:15.055+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:03:15.063+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:15.055825297 +0900 KST m=+8.003577254 PacketType:Pre EndTime:2018-05-03 20:03:15.063149929 +0900 KST m=+8.010901931]]
|
||||||
|
2018-05-03T20:03:17.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:03:17.055+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:03:17.057+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:17.055824764 +0900 KST m=+10.003576707 PacketType:Post EndTime:2018-05-03 20:03:17.057124027 +0900 KST m=+10.004876011]]
|
||||||
|
2018-05-03T20:03:20.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:03:20.055+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:03:20.057+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:20.055777048 +0900 KST m=+13.003528978 PacketType:Post EndTime:2018-05-03 20:03:20.057090978 +0900 KST m=+13.004842922]]
|
||||||
|
2018-05-03T20:03:22.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:03:22.055+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:03:22.063+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:22.055800705 +0900 KST m=+15.003552642 PacketType:Pre EndTime:2018-05-03 20:03:22.063322443 +0900 KST m=+15.011074426]]
|
||||||
|
2018-05-03T20:03:23.055+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:03:23.055+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:03:23.057+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:03:23.055798516 +0900 KST m=+16.003550448 PacketType:Post EndTime:2018-05-03 20:03:23.057175323 +0900 KST m=+16.004927283]]
|
||||||
|
2018-05-03T20:05:28.701+0900 [34minfo[0m connected
|
||||||
|
2018-05-03T20:05:28.702+0900 [34minfo[0m RPC Client[NETWORK]: Started
|
||||||
|
2018-05-03T20:05:28.798+0900 [35mdebug[0m scheduler of config[112103115113108] has been added
|
||||||
|
2018-05-03T20:05:28.798+0900 [35mdebug[0m scheduler of config[115115104] has been added
|
||||||
|
2018-05-03T20:05:28.798+0900 [35mdebug[0m Sensor configs[2] were added
|
||||||
|
2018-05-03T20:05:32.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:32.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:32.703+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:32.702433589 +0900 KST m=+4.003514803 PacketType:Post EndTime:2018-05-03 20:05:32.703844072 +0900 KST m=+4.004925278]]
|
||||||
|
2018-05-03T20:05:35.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:35.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:35.703+0900 [35mdebug[0m Get success config[map[EndTime:2018-05-03 20:05:35.703313187 +0900 KST m=+7.004394409 StartTime:2018-05-03 20:05:35.70227483 +0900 KST m=+7.003355982 PacketType:Post]]
|
||||||
|
2018-05-03T20:05:36.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:05:36.702+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:05:36.711+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:36.702355565 +0900 KST m=+8.003436719 PacketType:Pre EndTime:2018-05-03 20:05:36.710979069 +0900 KST m=+8.012060276]]
|
||||||
|
2018-05-03T20:05:38.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:38.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:38.703+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:38.702296872 +0900 KST m=+10.003378038 PacketType:Post EndTime:2018-05-03 20:05:38.703567634 +0900 KST m=+10.004648836]]
|
||||||
|
2018-05-03T20:05:41.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:41.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:41.703+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:05:41.703619982 +0900 KST m=+13.004701143 StartTime:2018-05-03 20:05:41.702303914 +0900 KST m=+13.003385063]]
|
||||||
|
2018-05-03T20:05:43.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:05:43.702+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:05:43.710+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:43.702495507 +0900 KST m=+15.003576718 PacketType:Pre EndTime:2018-05-03 20:05:43.710224255 +0900 KST m=+15.011305463]]
|
||||||
|
2018-05-03T20:05:44.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:44.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:44.703+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:44.70226789 +0900 KST m=+16.003349067 PacketType:Post EndTime:2018-05-03 20:05:44.703568446 +0900 KST m=+16.004649630]]
|
||||||
|
2018-05-03T20:05:47.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:47.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:47.703+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:47.702281846 +0900 KST m=+19.003363009 PacketType:Post EndTime:2018-05-03 20:05:47.70374098 +0900 KST m=+19.004822200]]
|
||||||
|
2018-05-03T20:05:50.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:05:50.702+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:05:50.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:50.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:50.703+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:50.702452149 +0900 KST m=+22.003533301 PacketType:Post EndTime:2018-05-03 20:05:50.703837292 +0900 KST m=+22.004918495]]
|
||||||
|
2018-05-03T20:05:50.709+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:50.702349153 +0900 KST m=+22.003430309 PacketType:Pre EndTime:2018-05-03 20:05:50.709563575 +0900 KST m=+22.010644773]]
|
||||||
|
2018-05-03T20:05:53.702+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:05:53.702+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:05:53.703+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:05:53.702259275 +0900 KST m=+25.003340434 PacketType:Post EndTime:2018-05-03 20:05:53.703682478 +0900 KST m=+25.004763647]]
|
||||||
|
2018-05-03T20:22:11.175+0900 [34minfo[0m RPC Client[NETWORK]: Started
|
||||||
|
2018-05-03T20:22:11.175+0900 [34minfo[0m connected
|
||||||
|
2018-05-03T20:22:11.272+0900 [35mdebug[0m scheduler of config[112103115113108] has been added
|
||||||
|
2018-05-03T20:22:11.272+0900 [35mdebug[0m scheduler of config[115115104] has been added
|
||||||
|
2018-05-03T20:22:11.272+0900 [35mdebug[0m Sensor configs[2] were added
|
||||||
|
2018-05-03T20:22:11.372+0900 [35mdebug[0m scheduler of config[112103115113108] has been added
|
||||||
|
2018-05-03T20:22:11.373+0900 [35mdebug[0m scheduler of config[115115104] has been added
|
||||||
|
2018-05-03T20:22:11.373+0900 [35mdebug[0m Sensor configs[2] were added
|
||||||
|
2018-05-03T20:22:15.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:15.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:15.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:15.176+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:15.178+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:22:15.178150129 +0900 KST m=+4.005346803 StartTime:2018-05-03 20:22:15.176688702 +0900 KST m=+4.003885308]]
|
||||||
|
2018-05-03T20:22:15.178+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:15.176579046 +0900 KST m=+4.003775683 PacketType:Post EndTime:2018-05-03 20:22:15.178148499 +0900 KST m=+4.005345176]]
|
||||||
|
2018-05-03T20:22:18.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:18.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:18.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:18.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:18.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:18.175908731 +0900 KST m=+7.003105362 PacketType:Post EndTime:2018-05-03 20:22:18.177389605 +0900 KST m=+7.004586275]]
|
||||||
|
2018-05-03T20:22:18.177+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:22:18.17741306 +0900 KST m=+7.004609750 StartTime:2018-05-03 20:22:18.17586349 +0900 KST m=+7.003060105]]
|
||||||
|
2018-05-03T20:22:19.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:19.175+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:19.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:19.175+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:19.185+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:19.175972879 +0900 KST m=+8.003169489 PacketType:Pre EndTime:2018-05-03 20:22:19.185097825 +0900 KST m=+8.012294468]]
|
||||||
|
2018-05-03T20:22:19.189+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:19.175880309 +0900 KST m=+8.003076915 PacketType:Pre EndTime:2018-05-03 20:22:19.189029128 +0900 KST m=+8.016225760]]
|
||||||
|
2018-05-03T20:22:21.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:21.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:21.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:21.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:21.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:21.175920789 +0900 KST m=+10.003117404 PacketType:Post EndTime:2018-05-03 20:22:21.177427075 +0900 KST m=+10.004623760]]
|
||||||
|
2018-05-03T20:22:21.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:21.175932227 +0900 KST m=+10.003128832 PacketType:Post EndTime:2018-05-03 20:22:21.177442688 +0900 KST m=+10.004639357]]
|
||||||
|
2018-05-03T20:22:24.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:24.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:24.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:24.176+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:24.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:24.175963297 +0900 KST m=+13.003159907 PacketType:Post EndTime:2018-05-03 20:22:24.177368564 +0900 KST m=+13.004565219]]
|
||||||
|
2018-05-03T20:22:24.177+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:22:24.177556826 +0900 KST m=+13.004753473 StartTime:2018-05-03 20:22:24.176046182 +0900 KST m=+13.003242789]]
|
||||||
|
2018-05-03T20:22:26.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:26.175+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:26.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:26.176+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:26.185+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:26.176294412 +0900 KST m=+15.003491029 PacketType:Pre EndTime:2018-05-03 20:22:26.185708093 +0900 KST m=+15.012904745]]
|
||||||
|
2018-05-03T20:22:26.188+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:26.176184319 +0900 KST m=+15.003381012 PacketType:Pre EndTime:2018-05-03 20:22:26.188902479 +0900 KST m=+15.016099116]]
|
||||||
|
2018-05-03T20:22:27.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:27.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:27.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:27.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:27.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:27.175893993 +0900 KST m=+16.003090609 PacketType:Post EndTime:2018-05-03 20:22:27.177307408 +0900 KST m=+16.004504062]]
|
||||||
|
2018-05-03T20:22:27.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:27.175892983 +0900 KST m=+16.003089629 PacketType:Post EndTime:2018-05-03 20:22:27.177332012 +0900 KST m=+16.004528687]]
|
||||||
|
2018-05-03T20:22:30.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:30.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:30.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:30.176+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:30.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:30.176034784 +0900 KST m=+19.003231427 PacketType:Post EndTime:2018-05-03 20:22:30.177378039 +0900 KST m=+19.004574705]]
|
||||||
|
2018-05-03T20:22:30.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:30.175949905 +0900 KST m=+19.003146527 PacketType:Post EndTime:2018-05-03 20:22:30.177388547 +0900 KST m=+19.004585210]]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:33.175+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:33.177+0900 [35mdebug[0m Get success config[map[EndTime:2018-05-03 20:22:33.177246275 +0900 KST m=+22.004442924 StartTime:2018-05-03 20:22:33.176043133 +0900 KST m=+22.003239738 PacketType:Post]]
|
||||||
|
2018-05-03T20:22:33.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:33.175968233 +0900 KST m=+22.003164849 PacketType:Post EndTime:2018-05-03 20:22:33.177246417 +0900 KST m=+22.004443084]]
|
||||||
|
2018-05-03T20:22:33.185+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:33.176074164 +0900 KST m=+22.003270789 PacketType:Pre EndTime:2018-05-03 20:22:33.185113599 +0900 KST m=+22.012310236]]
|
||||||
|
2018-05-03T20:22:33.187+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:33.175965538 +0900 KST m=+22.003162188 PacketType:Pre EndTime:2018-05-03 20:22:33.187659559 +0900 KST m=+22.014856223]]
|
||||||
|
2018-05-03T20:22:36.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:36.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:36.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:36.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:36.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:36.175922189 +0900 KST m=+25.003118807 PacketType:Post EndTime:2018-05-03 20:22:36.177024449 +0900 KST m=+25.004221098]]
|
||||||
|
2018-05-03T20:22:36.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:36.175869538 +0900 KST m=+25.003066139 PacketType:Post EndTime:2018-05-03 20:22:36.177025275 +0900 KST m=+25.004221940]]
|
||||||
|
2018-05-03T20:22:39.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:39.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:39.175+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:39.175+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:39.177+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:39.175896312 +0900 KST m=+28.003092936 PacketType:Post EndTime:2018-05-03 20:22:39.177092949 +0900 KST m=+28.004289593]]
|
||||||
|
2018-05-03T20:22:39.177+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:22:39.177092735 +0900 KST m=+28.004289389 StartTime:2018-05-03 20:22:39.17586179 +0900 KST m=+28.003058411]]
|
||||||
|
2018-05-03T20:22:40.103+0900 [34minfo[0m connected
|
||||||
|
2018-05-03T20:22:40.104+0900 [34minfo[0m RPC Client[NETWORK]: Started
|
||||||
|
2018-05-03T20:22:40.204+0900 [35mdebug[0m scheduler of config[112103115113108] has been added
|
||||||
|
2018-05-03T20:22:40.204+0900 [35mdebug[0m scheduler of config[115115104] has been added
|
||||||
|
2018-05-03T20:22:40.204+0900 [35mdebug[0m Sensor configs[2] were added
|
||||||
|
2018-05-03T20:22:44.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:44.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:44.106+0900 [35mdebug[0m Get success config[map[EndTime:2018-05-03 20:22:44.10601816 +0900 KST m=+4.004949190 StartTime:2018-05-03 20:22:44.104719337 +0900 KST m=+4.003650362 PacketType:Post]]
|
||||||
|
2018-05-03T20:22:47.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:47.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:47.105+0900 [35mdebug[0m Get success config[map[PacketType:Post EndTime:2018-05-03 20:22:47.105836399 +0900 KST m=+7.004767429 StartTime:2018-05-03 20:22:47.104733443 +0900 KST m=+7.003664418]]
|
||||||
|
2018-05-03T20:22:48.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:48.104+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:48.113+0900 [35mdebug[0m Get success config[map[PacketType:Pre EndTime:2018-05-03 20:22:48.113102866 +0900 KST m=+8.012033882 StartTime:2018-05-03 20:22:48.104678857 +0900 KST m=+8.003609826]]
|
||||||
|
2018-05-03T20:22:50.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:50.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:50.105+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:50.104625951 +0900 KST m=+10.003556962 PacketType:Post EndTime:2018-05-03 20:22:50.105821606 +0900 KST m=+10.004752620]]
|
||||||
|
2018-05-03T20:22:53.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:53.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:53.106+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:53.104701401 +0900 KST m=+13.003632407 PacketType:Post EndTime:2018-05-03 20:22:53.10617632 +0900 KST m=+13.005107355]]
|
||||||
|
2018-05-03T20:22:55.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:22:55.104+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:22:55.112+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:55.10484313 +0900 KST m=+15.003774182 PacketType:Pre EndTime:2018-05-03 20:22:55.11205247 +0900 KST m=+15.010983496]]
|
||||||
|
2018-05-03T20:22:56.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:56.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:56.106+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:56.104655987 +0900 KST m=+16.003586980 PacketType:Post EndTime:2018-05-03 20:22:56.106167725 +0900 KST m=+16.005098762]]
|
||||||
|
2018-05-03T20:22:59.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:22:59.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:22:59.106+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:22:59.10473539 +0900 KST m=+19.003666383 PacketType:Post EndTime:2018-05-03 20:22:59.106177667 +0900 KST m=+19.005108690]]
|
||||||
|
2018-05-03T20:23:02.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[115115104] of crawler[SSH_HEALTH]
|
||||||
|
2018-05-03T20:23:02.104+0900 [35mdebug[0m Get invoked with sensor config[115115104]
|
||||||
|
2018-05-03T20:23:02.104+0900 [35mdebug[0m CollectorService.collectTask for sensor config id[112103115113108] of crawler[POSTGRESQL_HEALTH]
|
||||||
|
2018-05-03T20:23:02.104+0900 [35mdebug[0m Get invoked with sensor config[112103115113108]
|
||||||
|
2018-05-03T20:23:02.106+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:23:02.104742224 +0900 KST m=+22.003673199 PacketType:Post EndTime:2018-05-03 20:23:02.106043927 +0900 KST m=+22.004974956]]
|
||||||
|
2018-05-03T20:23:02.112+0900 [35mdebug[0m Get success config[map[StartTime:2018-05-03 20:23:02.104667962 +0900 KST m=+22.003598948 PacketType:Pre EndTime:2018-05-03 20:23:02.112020485 +0900 KST m=+22.010951474]]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
60000
|
|
|
@ -1 +0,0 @@
|
||||||
60000
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
crc "git.loafle.net/commons/rpc-go/client"
|
crc "git.loafle.net/commons/rpc-go/client"
|
||||||
occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
|
occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
|
||||||
"git.loafle.net/overflow/commons-go/core/util"
|
"git.loafle.net/overflow/commons-go/core/util"
|
||||||
"git.loafle.net/overflow/probe/client/central"
|
"git.loafle.net/overflow/probe/client/auth"
|
||||||
"git.loafle.net/overflow/probe/config"
|
"git.loafle.net/overflow/probe/config"
|
||||||
|
|
||||||
// For annotation
|
// For annotation
|
||||||
|
@ -35,7 +35,7 @@ type NoAuthProbeService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NoAuthProbeService) InitService() error {
|
func (s *NoAuthProbeService) InitService() error {
|
||||||
client, err := central.NewAuth(s.HandleTempKey, s)
|
client, err := auth.New(s.HandleTempKey, s)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package central
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -12,10 +12,11 @@ import (
|
||||||
cur "git.loafle.net/commons/util-go/reflect"
|
cur "git.loafle.net/commons/util-go/reflect"
|
||||||
occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
|
occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
|
||||||
"git.loafle.net/overflow/probe/auth/info"
|
"git.loafle.net/overflow/probe/auth/info"
|
||||||
|
"git.loafle.net/overflow/probe/client"
|
||||||
"git.loafle.net/overflow/probe/config"
|
"git.loafle.net/overflow/probe/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAuth(tempKeyHandler func(tempKey string), services ...interface{}) (*crc.Client, error) {
|
func New(tempKeyHandler func(tempKey string), services ...interface{}) (*crc.Client, error) {
|
||||||
config := config.GetConfig()
|
config := config.GetConfig()
|
||||||
if nil == config {
|
if nil == config {
|
||||||
return nil, fmt.Errorf("Config is not available")
|
return nil, fmt.Errorf("Config is not available")
|
||||||
|
@ -25,7 +26,7 @@ func NewAuth(tempKeyHandler func(tempKey string), services ...interface{}) (*crc
|
||||||
return nil, fmt.Errorf("AuthConfig is not available")
|
return nil, fmt.Errorf("AuthConfig is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
connector, err := newConnector("Auth", occn.HTTPEntry_Auth)
|
connector, err := client.NewConnector("Auth", occn.HTTPEntry_Auth)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,7 @@ func NewAuth(tempKeyHandler func(tempKey string), services ...interface{}) (*crc
|
||||||
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
||||||
}
|
}
|
||||||
|
|
||||||
return newClient("Auth", connector, services), nil
|
return client.New("Auth", connector, services), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAuthConfig() *occn.Auth {
|
func getAuthConfig() *occn.Auth {
|
|
@ -1,55 +0,0 @@
|
||||||
package central
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/url"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
crc "git.loafle.net/commons/rpc-go/client"
|
|
||||||
crpj "git.loafle.net/commons/rpc-go/protocol/json"
|
|
||||||
crr "git.loafle.net/commons/rpc-go/registry"
|
|
||||||
csc "git.loafle.net/commons/server-go/client"
|
|
||||||
csswc "git.loafle.net/commons/server-go/socket/web/client"
|
|
||||||
"git.loafle.net/overflow/probe/config"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newConnector(name string, entryPath string) (*csswc.Connectors, error) {
|
|
||||||
config := config.GetConfig()
|
|
||||||
if nil == config {
|
|
||||||
return nil, fmt.Errorf("Config is not available")
|
|
||||||
}
|
|
||||||
|
|
||||||
u := url.URL{
|
|
||||||
Scheme: "ws",
|
|
||||||
Host: config.Central.Address,
|
|
||||||
}
|
|
||||||
u.Path = path.Join(u.Path, entryPath)
|
|
||||||
|
|
||||||
_connector := config.Central.Connector.Clone()
|
|
||||||
connector, ok := _connector.(*csswc.Connectors)
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("Cannot convert to Connectors type")
|
|
||||||
}
|
|
||||||
|
|
||||||
connector.Name = name
|
|
||||||
connector.URL = u.String()
|
|
||||||
|
|
||||||
return connector, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func newClient(name string, connector csc.Connector, services []interface{}) *crc.Client {
|
|
||||||
codec := crpj.NewClientCodec()
|
|
||||||
|
|
||||||
var rpcRegistry crr.RPCRegistry
|
|
||||||
if nil != services && 0 < len(services) {
|
|
||||||
rpcRegistry = crr.NewRPCRegistry()
|
|
||||||
rpcRegistry.RegisterServices(services...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &crc.Client{
|
|
||||||
Connector: connector,
|
|
||||||
Codec: codec,
|
|
||||||
RPCInvoker: rpcRegistry,
|
|
||||||
Name: name,
|
|
||||||
}
|
|
||||||
}
|
|
56
client/client-handler.go
Normal file
56
client/client-handler.go
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
|
crc "git.loafle.net/commons/rpc-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ClientHandler interface {
|
||||||
|
crc.ClientHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientHandlers struct {
|
||||||
|
crc.ClientHandlers
|
||||||
|
|
||||||
|
validated atomic.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ch *ClientHandlers) Init(clientCtx crc.ClientCtx) error {
|
||||||
|
if err := ch.ClientHandlers.Init(clientCtx); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ch *ClientHandlers) OnStart(clientCtx crc.ClientCtx) error {
|
||||||
|
if err := ch.ClientHandlers.OnStart(clientCtx); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ch *ClientHandlers) OnStop(clientCtx crc.ClientCtx) {
|
||||||
|
|
||||||
|
ch.ClientHandlers.OnStop(clientCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ch *ClientHandlers) Destroy(clientCtx crc.ClientCtx) {
|
||||||
|
|
||||||
|
ch.ClientHandlers.Destroy(clientCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ch *ClientHandlers) Validate() error {
|
||||||
|
if nil != ch.validated.Load() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ch.validated.Store(true)
|
||||||
|
|
||||||
|
if err := ch.ClientHandlers.Validate(); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
28
client/client.go
Normal file
28
client/client.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
crc "git.loafle.net/commons/rpc-go/client"
|
||||||
|
crpj "git.loafle.net/commons/rpc-go/protocol/json"
|
||||||
|
crr "git.loafle.net/commons/rpc-go/registry"
|
||||||
|
csc "git.loafle.net/commons/server-go/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New(name string, connector csc.Connector, services []interface{}) *crc.Client {
|
||||||
|
codec := crpj.NewClientCodec()
|
||||||
|
|
||||||
|
var rpcRegistry crr.RPCRegistry
|
||||||
|
if nil != services && 0 < len(services) {
|
||||||
|
rpcRegistry = crr.NewRPCRegistry()
|
||||||
|
rpcRegistry.RegisterServices(services...)
|
||||||
|
}
|
||||||
|
|
||||||
|
ch := &ClientHandlers{}
|
||||||
|
ch.Name = name
|
||||||
|
ch.Connector = connector
|
||||||
|
ch.RPCCodec = codec
|
||||||
|
ch.RPCInvoker = rpcRegistry
|
||||||
|
|
||||||
|
return &crc.Client{
|
||||||
|
ClientHandler: ch,
|
||||||
|
}
|
||||||
|
}
|
34
client/connector.go
Normal file
34
client/connector.go
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
csswc "git.loafle.net/commons/server-go/socket/web/client"
|
||||||
|
"git.loafle.net/overflow/probe/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewConnector(name string, entryPath string) (*csswc.Connectors, error) {
|
||||||
|
config := config.GetConfig()
|
||||||
|
if nil == config {
|
||||||
|
return nil, fmt.Errorf("Config is not available")
|
||||||
|
}
|
||||||
|
|
||||||
|
u := url.URL{
|
||||||
|
Scheme: "ws",
|
||||||
|
Host: config.Central.Address,
|
||||||
|
}
|
||||||
|
u.Path = path.Join(u.Path, entryPath)
|
||||||
|
|
||||||
|
_connector := config.Central.Connector.Clone()
|
||||||
|
connector, ok := _connector.(*csswc.Connectors)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("Cannot convert to Connectors type")
|
||||||
|
}
|
||||||
|
|
||||||
|
connector.Name = name
|
||||||
|
connector.URL = u.String()
|
||||||
|
|
||||||
|
return connector, nil
|
||||||
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
logging "git.loafle.net/commons/logging-go"
|
|
||||||
crc "git.loafle.net/commons/rpc-go/client"
|
|
||||||
crpj "git.loafle.net/commons/rpc-go/protocol/json"
|
|
||||||
crr "git.loafle.net/commons/rpc-go/registry"
|
|
||||||
csc "git.loafle.net/commons/server-go/client"
|
|
||||||
cssnc "git.loafle.net/commons/server-go/socket/net/client"
|
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newConnector(name string, port int) (*cssnc.Connectors, error) {
|
|
||||||
connector := &cssnc.Connectors{
|
|
||||||
Network: "tcp4",
|
|
||||||
Address: fmt.Sprintf("127.0.0.1:%d", port),
|
|
||||||
}
|
|
||||||
connector.ReconnectInterval = 5
|
|
||||||
connector.ReconnectTryTime = 2
|
|
||||||
connector.MaxMessageSize = 4096
|
|
||||||
connector.ReadBufferSize = 4096
|
|
||||||
connector.WriteBufferSize = 4096
|
|
||||||
connector.PongTimeout = 60
|
|
||||||
connector.PingTimeout = 10
|
|
||||||
connector.PingPeriod = 9
|
|
||||||
connector.Name = name
|
|
||||||
|
|
||||||
connector.OnDisconnected = func(connector csc.Connector) {
|
|
||||||
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
|
||||||
}
|
|
||||||
|
|
||||||
return connector, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func newClient(name string, connector csc.Connector, services []interface{}) *crc.Client {
|
|
||||||
codec := crpj.NewClientCodec()
|
|
||||||
|
|
||||||
var rpcRegistry crr.RPCRegistry
|
|
||||||
if nil != services && 0 < len(services) {
|
|
||||||
rpcRegistry = crr.NewRPCRegistry()
|
|
||||||
rpcRegistry.RegisterServices(services...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &crc.Client{
|
|
||||||
Connector: connector,
|
|
||||||
Codec: codec,
|
|
||||||
RPCInvoker: rpcRegistry,
|
|
||||||
Name: name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewClient(containerType occp.ContainerType, port int, services []interface{}) (*crc.Client, error) {
|
|
||||||
connector, err := newConnector(containerType.String(), port)
|
|
||||||
if nil != err {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return newClient(containerType.String(), connector, services), nil
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package central
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -8,16 +8,17 @@ import (
|
||||||
crc "git.loafle.net/commons/rpc-go/client"
|
crc "git.loafle.net/commons/rpc-go/client"
|
||||||
csc "git.loafle.net/commons/server-go/client"
|
csc "git.loafle.net/commons/server-go/client"
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
|
"git.loafle.net/overflow/probe/client"
|
||||||
"git.loafle.net/overflow/probe/config"
|
"git.loafle.net/overflow/probe/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewData() (*crc.Client, error) {
|
func New() (*crc.Client, error) {
|
||||||
config := config.GetConfig()
|
config := config.GetConfig()
|
||||||
if nil == config {
|
if nil == config {
|
||||||
return nil, fmt.Errorf("Config is not available")
|
return nil, fmt.Errorf("Config is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
connector, err := newConnector("Data", occp.HTTPEntry_Data)
|
connector, err := client.NewConnector("Data", occp.HTTPEntry_Data)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -34,5 +35,5 @@ func NewData() (*crc.Client, error) {
|
||||||
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
||||||
}
|
}
|
||||||
|
|
||||||
return newClient("Data", connector, nil), nil
|
return client.New("Data", connector, nil), nil
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package central
|
package probe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -8,16 +8,17 @@ import (
|
||||||
crc "git.loafle.net/commons/rpc-go/client"
|
crc "git.loafle.net/commons/rpc-go/client"
|
||||||
csc "git.loafle.net/commons/server-go/client"
|
csc "git.loafle.net/commons/server-go/client"
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
|
"git.loafle.net/overflow/probe/client"
|
||||||
"git.loafle.net/overflow/probe/config"
|
"git.loafle.net/overflow/probe/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewProbe(encryptionKeyHandler func(encryptionKey string), services ...interface{}) (*crc.Client, error) {
|
func New(encryptionKeyHandler func(encryptionKey string), services ...interface{}) (*crc.Client, error) {
|
||||||
config := config.GetConfig()
|
config := config.GetConfig()
|
||||||
if nil == config {
|
if nil == config {
|
||||||
return nil, fmt.Errorf("Config is not available")
|
return nil, fmt.Errorf("Config is not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
connector, err := newConnector("Probe", occp.HTTPEntry_Probe)
|
connector, err := client.NewConnector("Probe", occp.HTTPEntry_Probe)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -37,5 +38,6 @@ func NewProbe(encryptionKeyHandler func(encryptionKey string), services ...inter
|
||||||
connector.OnDisconnected = func(connector csc.Connector) {
|
connector.OnDisconnected = func(connector csc.Connector) {
|
||||||
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
logging.Logger().Debugf("Client[%s] has been disconnected", connector.GetName())
|
||||||
}
|
}
|
||||||
return newClient("Probe", connector, services), nil
|
|
||||||
|
return client.New("Probe", connector, services), nil
|
||||||
}
|
}
|
|
@ -13,6 +13,10 @@ const (
|
||||||
ConfigKey = "Config"
|
ConfigKey = "Config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ProbePortNumber int64
|
||||||
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Account *occp.Account `required:"true" json:"account" yaml:"account" toml:"account"`
|
Account *occp.Account `required:"true" json:"account" yaml:"account" toml:"account"`
|
||||||
Central *occp.Central `required:"true" json:"central" yaml:"central" toml:"central"`
|
Central *occp.Central `required:"true" json:"central" yaml:"central" toml:"central"`
|
||||||
|
|
7
config/const.go
Normal file
7
config/const.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
const (
|
||||||
|
PROBE_RPC_SERVER_CODEC = "PROBE_RPC_SERVER_CODEC"
|
||||||
|
PROBE_ONCONNECT_CHAN = "PROBE_ONCONNECT_CHAN"
|
||||||
|
PROBE_ONDISCONNECT_CHAN = "PROBE_ONDISCONNECT_CHAN"
|
||||||
|
)
|
|
@ -1,17 +1,11 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
|
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ContainerPIDFilePath(containerType occp.ContainerType) string {
|
|
||||||
return path.Join(PIDDir(), fmt.Sprintf("%s.pid", strings.ToLower(containerType.String())))
|
|
||||||
}
|
|
||||||
|
|
||||||
func ContainerBinFilePath(containerType occp.ContainerType) string {
|
func ContainerBinFilePath(containerType occp.ContainerType) string {
|
||||||
return path.Join(BinDir(), occp.ContainerBinFileName[containerType])
|
return path.Join(BinDir(), occp.ContainerBinFileName[containerType])
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,6 @@ func LogsDir() string {
|
||||||
return path.Join(RootDir(), occp.PathLogs)
|
return path.Join(RootDir(), occp.PathLogs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PIDDir() string {
|
|
||||||
return path.Join(RootDir(), occp.PathPID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProbeConfigFilePath() string {
|
func ProbeConfigFilePath() string {
|
||||||
return path.Join(BinDir(), occp.ConfigFileName)
|
return path.Join(BinDir(), occp.ConfigFileName)
|
||||||
}
|
}
|
||||||
|
|
183
container/container-session.go
Normal file
183
container/container-session.go
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
package container
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
logging "git.loafle.net/commons/logging-go"
|
||||||
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
|
"git.loafle.net/overflow/probe/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OnConnectInfo struct {
|
||||||
|
ContainerType occp.ContainerType
|
||||||
|
WriteChan chan<- []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContainerSession(containerType occp.ContainerType) *ContainerSession {
|
||||||
|
|
||||||
|
cs := &ContainerSession{
|
||||||
|
containerType: containerType,
|
||||||
|
writeChan: make(chan []byte, 256),
|
||||||
|
}
|
||||||
|
|
||||||
|
return cs
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContainerSession struct {
|
||||||
|
containerType occp.ContainerType
|
||||||
|
cmd *exec.Cmd
|
||||||
|
writeChan chan []byte
|
||||||
|
containerWriteChan chan<- []byte
|
||||||
|
|
||||||
|
writeStopChan chan struct{}
|
||||||
|
stopWg sync.WaitGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) Start() error {
|
||||||
|
if err := cs.runContainer(); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cs.writeStopChan = make(chan struct{})
|
||||||
|
cs.stopWg.Add(1)
|
||||||
|
go cs.handleWrite()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) Stop() {
|
||||||
|
close(cs.writeStopChan)
|
||||||
|
|
||||||
|
if err := cs.killContainer(); nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cs.stopWg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) Connected(writeChan chan<- []byte) {
|
||||||
|
logging.Logger().Debugf("Container[%s] has been connected", cs.containerType.String())
|
||||||
|
cs.containerWriteChan = writeChan
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) Disconnected() {
|
||||||
|
logging.Logger().Debugf("Container[%s] has been disconnected", cs.containerType.String())
|
||||||
|
cs.refreshContainer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) Send(buff []byte) error {
|
||||||
|
select {
|
||||||
|
case cs.writeChan <- buff:
|
||||||
|
logging.Logger().Debugf("send buffer of Container[%s] has been queued %s", cs.containerType.String(), string(buff))
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Buffer of Container[%s] is full", cs.containerType.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) handleWrite() {
|
||||||
|
defer func() {
|
||||||
|
cs.stopWg.Done()
|
||||||
|
}()
|
||||||
|
var (
|
||||||
|
message []byte
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case message, ok = <-cs.writeChan:
|
||||||
|
if !ok {
|
||||||
|
logging.Logger().Debugf("WriteChan of Container[%s] has been closed", cs.containerType.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
LOOP_WRITE:
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case cs.containerWriteChan <- message:
|
||||||
|
logging.Logger().Debugf("message of Container[%s] has been sended %s", cs.containerType.String(), string(message))
|
||||||
|
break LOOP_WRITE
|
||||||
|
case <-cs.writeStopChan:
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
continue LOOP_WRITE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case <-cs.writeStopChan:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) runContainer() error {
|
||||||
|
cmd := cotainerCommand(cs.containerType)
|
||||||
|
|
||||||
|
if err := cmd.Start(); nil != err {
|
||||||
|
logging.Logger().Errorf("to run Container[%s] failed err %v", cs.containerType.String(), err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cs.cmd = cmd
|
||||||
|
logging.Logger().Debugf("Process of Container[%s] has been started", cs.containerType.String())
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) killContainer() error {
|
||||||
|
defer func() {
|
||||||
|
cs.cmd = nil
|
||||||
|
logging.Logger().Debugf("Process of Container[%s] has been stopped", cs.containerType.String())
|
||||||
|
}()
|
||||||
|
|
||||||
|
if nil == cs.cmd {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if nil == cs.cmd.ProcessState || !cs.cmd.ProcessState.Exited() {
|
||||||
|
if err := cs.cmd.Process.Kill(); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerSession) refreshContainer() {
|
||||||
|
if err := cs.killContainer(); nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
}
|
||||||
|
if err := cs.runContainer(); nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.Logger().Debugf("Process of Container[%s] has been refreshed", cs.containerType.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func cotainerCommand(containerType occp.ContainerType) (cmd *exec.Cmd) {
|
||||||
|
loggingConfigFilePath := config.ContainerLoggingConfigFilePath(containerType)
|
||||||
|
binFilePath := config.ContainerBinFilePath(containerType)
|
||||||
|
|
||||||
|
switch containerType {
|
||||||
|
case occp.ContainerDiscovery, occp.ContainerNetwork:
|
||||||
|
args := []string{
|
||||||
|
fmt.Sprintf("-%s=%s", occp.FlagProbePortName, strconv.FormatInt(config.ProbePortNumber, 10)),
|
||||||
|
fmt.Sprintf("-%s=%s", occp.FlagLoggingConfigFilePathName, loggingConfigFilePath),
|
||||||
|
}
|
||||||
|
cmd = exec.Command(binFilePath, args...)
|
||||||
|
case occp.ContainerGenernal:
|
||||||
|
args := []string{
|
||||||
|
"-jar",
|
||||||
|
binFilePath,
|
||||||
|
strconv.FormatInt(config.ProbePortNumber, 10),
|
||||||
|
loggingConfigFilePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = exec.Command(config.JavaBinPath(), args...)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
29
main.go
29
main.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.loafle.net/commons/configuration-go"
|
"git.loafle.net/commons/configuration-go"
|
||||||
cdr "git.loafle.net/commons/di-go/registry"
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
"git.loafle.net/commons/logging-go"
|
"git.loafle.net/commons/logging-go"
|
||||||
|
cssw "git.loafle.net/commons/server-go/socket/web"
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
occi "git.loafle.net/overflow/commons-go/core/interfaces"
|
occi "git.loafle.net/overflow/commons-go/core/interfaces"
|
||||||
"git.loafle.net/overflow/probe/auth"
|
"git.loafle.net/overflow/probe/auth"
|
||||||
|
@ -30,6 +31,7 @@ func main() {
|
||||||
cdr.RegisterResource(config.ConfigKey, _config)
|
cdr.RegisterResource(config.ConfigKey, _config)
|
||||||
|
|
||||||
var instance interface{}
|
var instance interface{}
|
||||||
|
var err error
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if occp.ProbeStateTypeNotAuthorized == _config.Probe.State() {
|
if occp.ProbeStateTypeNotAuthorized == _config.Probe.State() {
|
||||||
|
@ -53,22 +55,15 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = &probe.Probe{}
|
p := probe.New()
|
||||||
doneChan, err := instance.(occi.EndableStarter).EndableStart()
|
instance = p
|
||||||
|
err = p.ListenAndServe()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.Logger().Error(err)
|
logging.Logger().Error(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
var ok bool
|
|
||||||
err, ok = <-doneChan
|
if err := p.Shutdown(context.Background()); err != nil {
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if nil != err {
|
|
||||||
logging.Logger().Error(err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
if err := instance.(occi.Stopper).Stop(context.Background()); err != nil {
|
|
||||||
logging.Logger().Errorf("error: %v", err)
|
logging.Logger().Errorf("error: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -85,7 +80,15 @@ func main() {
|
||||||
<-interrupt
|
<-interrupt
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := instance.(occi.Stopper).Stop(ctx); err != nil {
|
|
||||||
|
switch v := instance.(type) {
|
||||||
|
case *auth.Authenticator:
|
||||||
|
err = v.Stop(ctx)
|
||||||
|
case *cssw.Server:
|
||||||
|
err = v.Shutdown(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
logging.Logger().Errorf("error: %v", err)
|
logging.Logger().Errorf("error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
185
probe/container-servlet.go
Normal file
185
probe/container-servlet.go
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
package probe
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
logging "git.loafle.net/commons/logging-go"
|
||||||
|
crp "git.loafle.net/commons/rpc-go/protocol"
|
||||||
|
crr "git.loafle.net/commons/rpc-go/registry"
|
||||||
|
"git.loafle.net/commons/server-go"
|
||||||
|
"git.loafle.net/commons/server-go/socket"
|
||||||
|
cssw "git.loafle.net/commons/server-go/socket/web"
|
||||||
|
cuc "git.loafle.net/commons/util-go/context"
|
||||||
|
occc "git.loafle.net/overflow/commons-go/config/container"
|
||||||
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
|
"git.loafle.net/overflow/probe/container"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ContainerTypeKey = cuc.ContextKey("ContainerType")
|
||||||
|
|
||||||
|
type ContainerServlet interface {
|
||||||
|
cssw.Servlet
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContainerServlets struct {
|
||||||
|
cssw.Servlets
|
||||||
|
|
||||||
|
RPCInvoker crr.RPCInvoker
|
||||||
|
RPCServerCodec crp.ServerCodec
|
||||||
|
|
||||||
|
OnConnectChan chan<- *container.OnConnectInfo
|
||||||
|
OnDisconnectChan chan<- occp.ContainerType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) Init(serverCtx server.ServerCtx) error {
|
||||||
|
if err := s.Servlets.Init(serverCtx); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) OnStart(serverCtx server.ServerCtx) error {
|
||||||
|
if err := s.Servlets.OnStart(serverCtx); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) OnStop(serverCtx server.ServerCtx) {
|
||||||
|
|
||||||
|
s.Servlets.OnStop(serverCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) Destroy(serverCtx server.ServerCtx) {
|
||||||
|
|
||||||
|
s.Servlets.Destroy(serverCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
||||||
|
bMethod := ctx.Request.Header.Peek(occc.HTTPRequestHeaderKey_Container_Method)
|
||||||
|
if nil == bMethod {
|
||||||
|
return nil, fmt.Errorf("Unexpected probe method: %v", bMethod)
|
||||||
|
}
|
||||||
|
|
||||||
|
method := string(bMethod)
|
||||||
|
|
||||||
|
switch method {
|
||||||
|
case occc.HTTPRequestHeaderValue_Container_Method_Connect:
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("Unexpected probe method: %s", method)
|
||||||
|
}
|
||||||
|
|
||||||
|
bContainerType := ctx.Request.Header.Peek(occc.HTTPRequestHeaderKey_Container_Type)
|
||||||
|
if nil == bContainerType {
|
||||||
|
return nil, fmt.Errorf("Unexpected Container type : %v", bContainerType)
|
||||||
|
}
|
||||||
|
|
||||||
|
containerType := string(bContainerType)
|
||||||
|
|
||||||
|
servletCtx.SetAttribute(ContainerTypeKey, containerType)
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) {
|
||||||
|
s.Servlets.OnConnect(servletCtx, conn)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) OnDisconnect(servletCtx server.ServletCtx) {
|
||||||
|
s.Servlets.OnDisconnect(servletCtx)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) Handle(servletCtx server.ServletCtx,
|
||||||
|
stopChan <-chan struct{}, doneChan chan<- struct{},
|
||||||
|
readChan <-chan []byte, writeChan chan<- []byte) {
|
||||||
|
|
||||||
|
_containerType := servletCtx.GetAttribute(ContainerTypeKey)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if nil != _containerType {
|
||||||
|
containerType := occp.ToContainerType(_containerType.(string))
|
||||||
|
s.OnDisconnectChan <- containerType
|
||||||
|
}
|
||||||
|
|
||||||
|
doneChan <- struct{}{}
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
src crp.ServerRequestCodec
|
||||||
|
result interface{}
|
||||||
|
replyBuff []byte
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if nil != _containerType {
|
||||||
|
containerType := occp.ToContainerType(_containerType.(string))
|
||||||
|
s.OnConnectChan <- &container.OnConnectInfo{
|
||||||
|
ContainerType: containerType,
|
||||||
|
WriteChan: writeChan,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case msg, ok := <-readChan:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// grpc exec method call
|
||||||
|
src, err = s.RPCServerCodec.NewRequest(msg)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if !s.RPCInvoker.HasMethod(src.Method()) {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
s.writeError(src, writeChan, crp.E_NO_METHOD, "", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = s.RPCInvoker.Invoke(src)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !src.HasResponse() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
replyBuff, err = src.NewResponse(result, err)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
s.writeError(src, writeChan, crp.E_INTERNAL, "", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
writeChan <- replyBuff
|
||||||
|
case <-stopChan:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ContainerServlets) writeError(src crp.ServerRequestCodec, writeChan chan<- []byte, code crp.ErrorCode, message string, data interface{}) {
|
||||||
|
if !src.HasResponse() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pErr := &crp.Error{
|
||||||
|
Code: code,
|
||||||
|
Message: message,
|
||||||
|
Data: data,
|
||||||
|
}
|
||||||
|
|
||||||
|
buf, err := src.NewResponse(nil, pErr)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeChan <- buf
|
||||||
|
}
|
|
@ -1,83 +0,0 @@
|
||||||
package probe
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"sync"
|
|
||||||
|
|
||||||
cdr "git.loafle.net/commons/di-go/registry"
|
|
||||||
occa "git.loafle.net/overflow/commons-go/core/annotation"
|
|
||||||
occi "git.loafle.net/overflow/commons-go/core/interfaces"
|
|
||||||
|
|
||||||
"git.loafle.net/overflow/probe/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Probe struct {
|
|
||||||
services []interface{}
|
|
||||||
|
|
||||||
endChan chan error
|
|
||||||
stopChan chan struct{}
|
|
||||||
stopWg sync.WaitGroup
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Probe) EndableStart() (<-chan error, error) {
|
|
||||||
if p.stopChan != nil {
|
|
||||||
return nil, fmt.Errorf("already running. Stop it before starting it again")
|
|
||||||
}
|
|
||||||
|
|
||||||
services, err := cdr.GetInstancesByAnnotationType(occa.RPCServiceAnnotationType)
|
|
||||||
if nil != err {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
p.services = services
|
|
||||||
|
|
||||||
if err := occi.ExecServices(p.services, occi.ServiceMethodInit, service.OrderedServices, false); nil != err {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
p.endChan = make(chan error)
|
|
||||||
p.stopChan = make(chan struct{})
|
|
||||||
|
|
||||||
p.stopWg.Add(1)
|
|
||||||
go p.handleProbe()
|
|
||||||
|
|
||||||
return p.endChan, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Probe) Stop(ctx context.Context) error {
|
|
||||||
if p.stopChan == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
close(p.stopChan)
|
|
||||||
p.stopWg.Wait()
|
|
||||||
|
|
||||||
occi.ExecServices(p.services, occi.ServiceMethodDestroy, service.OrderedServices, true)
|
|
||||||
|
|
||||||
p.stopChan = nil
|
|
||||||
close(p.endChan)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Probe) handleProbe() {
|
|
||||||
var err error
|
|
||||||
defer func() {
|
|
||||||
p.stopWg.Done()
|
|
||||||
p.endChan <- err
|
|
||||||
}()
|
|
||||||
|
|
||||||
err = occi.ExecServices(p.services, occi.ServiceMethodStart, service.OrderedServices, false)
|
|
||||||
if nil != err {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
LOOP:
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-p.stopChan:
|
|
||||||
break LOOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
occi.ExecServices(p.services, occi.ServiceMethodStop, service.OrderedServices, true)
|
|
||||||
}
|
|
92
probe/server-handler.go
Normal file
92
probe/server-handler.go
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
package probe
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"git.loafle.net/commons/logging-go"
|
||||||
|
"git.loafle.net/commons/server-go"
|
||||||
|
csgw "git.loafle.net/commons/server-go/socket/web"
|
||||||
|
occi "git.loafle.net/overflow/commons-go/core/interfaces"
|
||||||
|
"git.loafle.net/overflow/probe/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServerHandler interface {
|
||||||
|
csgw.ServerHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerHandlers struct {
|
||||||
|
csgw.ServerHandlers
|
||||||
|
|
||||||
|
Services []interface{}
|
||||||
|
OrderedServices []reflect.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *ServerHandlers) Init(serverCtx server.ServerCtx) error {
|
||||||
|
if err := sh.ServerHandlers.Init(serverCtx); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := occi.ExecServices(sh.Services, occi.ServiceMethodInit, sh.OrderedServices, false); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *ServerHandlers) OnStart(serverCtx server.ServerCtx) error {
|
||||||
|
if err := sh.ServerHandlers.OnStart(serverCtx); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := occi.ExecServices(sh.Services, occi.ServiceMethodStart, sh.OrderedServices, false); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *ServerHandlers) OnStop(serverCtx server.ServerCtx) {
|
||||||
|
if err := occi.ExecServices(sh.Services, occi.ServiceMethodStop, sh.OrderedServices, true); nil != err {
|
||||||
|
logging.Logger().Errorf("Service stop err %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sh.ServerHandlers.OnStop(serverCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *ServerHandlers) Destroy(serverCtx server.ServerCtx) {
|
||||||
|
if err := occi.ExecServices(sh.Services, occi.ServiceMethodDestroy, sh.OrderedServices, true); nil != err {
|
||||||
|
logging.Logger().Errorf("Service destroy err %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sh.ServerHandlers.Destroy(serverCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *ServerHandlers) Listener(serverCtx server.ServerCtx) (net.Listener, error) {
|
||||||
|
for i := 60000; i < 61000; i++ {
|
||||||
|
addr := fmt.Sprintf("localhost:%d", i)
|
||||||
|
l, err := net.Listen("tcp", addr)
|
||||||
|
if nil == err {
|
||||||
|
config.ProbePortNumber = int64(i)
|
||||||
|
return l, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("Cannot find availrable port")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sh *ServerHandlers) Validate() error {
|
||||||
|
if err := sh.ServerHandlers.Validate(); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if nil == sh.Services {
|
||||||
|
return fmt.Errorf("Services must be specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
if nil == sh.OrderedServices {
|
||||||
|
return fmt.Errorf("OrderedServices must be specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
52
probe/server.go
Normal file
52
probe/server.go
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
package probe
|
||||||
|
|
||||||
|
import (
|
||||||
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
|
logging "git.loafle.net/commons/logging-go"
|
||||||
|
crpj "git.loafle.net/commons/rpc-go/protocol/json"
|
||||||
|
crr "git.loafle.net/commons/rpc-go/registry"
|
||||||
|
cssw "git.loafle.net/commons/server-go/socket/web"
|
||||||
|
occc "git.loafle.net/overflow/commons-go/config/container"
|
||||||
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
|
occa "git.loafle.net/overflow/commons-go/core/annotation"
|
||||||
|
"git.loafle.net/overflow/probe/config"
|
||||||
|
"git.loafle.net/overflow/probe/container"
|
||||||
|
"git.loafle.net/overflow/probe/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New() *cssw.Server {
|
||||||
|
onConnectChan := make(chan *container.OnConnectInfo)
|
||||||
|
onDisconnectChan := make(chan occp.ContainerType)
|
||||||
|
rpcServerCodec := crpj.NewServerCodec()
|
||||||
|
|
||||||
|
cdr.RegisterResource(config.PROBE_RPC_SERVER_CODEC, rpcServerCodec)
|
||||||
|
cdr.RegisterResource(config.PROBE_ONCONNECT_CHAN, onConnectChan)
|
||||||
|
cdr.RegisterResource(config.PROBE_ONDISCONNECT_CHAN, onDisconnectChan)
|
||||||
|
|
||||||
|
services, err := cdr.GetInstancesByAnnotationType(occa.RPCServiceAnnotationType)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcRegistry := crr.NewRPCRegistry()
|
||||||
|
rpcRegistry.RegisterServices(services...)
|
||||||
|
|
||||||
|
cs := &ContainerServlets{}
|
||||||
|
cs.RPCInvoker = rpcRegistry
|
||||||
|
cs.RPCServerCodec = rpcServerCodec
|
||||||
|
cs.OnConnectChan = onConnectChan
|
||||||
|
cs.OnDisconnectChan = onDisconnectChan
|
||||||
|
|
||||||
|
sh := &ServerHandlers{}
|
||||||
|
sh.Name = "Probe"
|
||||||
|
sh.Services = services
|
||||||
|
sh.OrderedServices = service.OrderedServices
|
||||||
|
|
||||||
|
sh.RegisterServlet(occc.HTTPEntry_Container, cs)
|
||||||
|
|
||||||
|
s := &cssw.Server{
|
||||||
|
ServerHandler: sh,
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
|
@ -8,10 +8,8 @@ import (
|
||||||
|
|
||||||
cda "git.loafle.net/commons/di-go/annotation"
|
cda "git.loafle.net/commons/di-go/annotation"
|
||||||
cdr "git.loafle.net/commons/di-go/registry"
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
logging "git.loafle.net/commons/logging-go"
|
|
||||||
cuts "git.loafle.net/commons/util-go/time/scheduler"
|
cuts "git.loafle.net/commons/util-go/time/scheduler"
|
||||||
cutss "git.loafle.net/commons/util-go/time/scheduler/storage"
|
cutss "git.loafle.net/commons/util-go/time/scheduler/storage"
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
|
||||||
ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig"
|
ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig"
|
||||||
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
||||||
|
|
||||||
|
@ -45,7 +43,7 @@ func (s *CollectorService) InitService() error {
|
||||||
|
|
||||||
func (s *CollectorService) StartService() error {
|
func (s *CollectorService) StartService() error {
|
||||||
if err := s.scheduler.Start(); nil != err {
|
if err := s.scheduler.Start(); nil != err {
|
||||||
return err
|
return fmt.Errorf("CollectorService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.addScheduleAll(); nil != err {
|
if err := s.addScheduleAll(); nil != err {
|
||||||
|
@ -84,16 +82,16 @@ func (s *CollectorService) addSchedule(interval int64, sensorConfig *ocmsc.Senso
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CollectorService) collectTask(sensorConfig *ocmsc.SensorConfig) {
|
func (s *CollectorService) collectTask(sensorConfig *ocmsc.SensorConfig) {
|
||||||
go func(_sensorConfig *ocmsc.SensorConfig) {
|
// go func(_sensorConfig *ocmsc.SensorConfig) {
|
||||||
logging.Logger().Debugf("CollectorService.collectTask for sensor config id[%s] container[%s] crawler[%s]", _sensorConfig.ConfigID, _sensorConfig.Crawler.Container, _sensorConfig.Crawler.Name)
|
// logging.Logger().Debugf("CollectorService.collectTask for sensor config id[%s] container[%s] crawler[%s]", _sensorConfig.ConfigID, _sensorConfig.Crawler.Container, _sensorConfig.Crawler.Name)
|
||||||
var result map[string]string
|
// var result map[string]string
|
||||||
err := s.ContainerService.Call(occp.ToContainerType(_sensorConfig.Crawler.Container), &result, "CrawlerService.Get", _sensorConfig.ConfigID)
|
// err := s.ContainerService.Call(occp.ToContainerType(_sensorConfig.Crawler.Container), &result, "CrawlerService.Get", _sensorConfig.ConfigID)
|
||||||
if nil != err {
|
// if nil != err {
|
||||||
logging.Logger().Errorf("Cannot get data from crawler[%s] of container[%s] %v", _sensorConfig.Crawler.Name, _sensorConfig.Crawler.Container, err)
|
// logging.Logger().Errorf("Cannot get data from crawler[%s] of container[%s] %v", _sensorConfig.Crawler.Name, _sensorConfig.Crawler.Container, err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
logging.Logger().Debugf("Data[%v] received from crawler[%s] of container[%s]", result, _sensorConfig.Crawler.Name, _sensorConfig.Crawler.Container)
|
// logging.Logger().Debugf("Data[%v] received from crawler[%s] of container[%s]", result, _sensorConfig.Crawler.Name, _sensorConfig.Crawler.Container)
|
||||||
|
|
||||||
//cs.CentralService.Send(oocmp.HTTPEntry_Data, "CrawlerService.Data", result)
|
// //cs.CentralService.Send(oocmp.HTTPEntry_Data, "CrawlerService.Data", result)
|
||||||
}(sensorConfig)
|
// }(sensorConfig)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
cda "git.loafle.net/commons/di-go/annotation"
|
cda "git.loafle.net/commons/di-go/annotation"
|
||||||
cdr "git.loafle.net/commons/di-go/registry"
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
"git.loafle.net/commons/logging-go"
|
logging "git.loafle.net/commons/logging-go"
|
||||||
crc "git.loafle.net/commons/rpc-go/client"
|
crp "git.loafle.net/commons/rpc-go/protocol"
|
||||||
csc "git.loafle.net/commons/server-go/client"
|
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
||||||
"git.loafle.net/overflow/probe/client/container"
|
"git.loafle.net/overflow/probe/container"
|
||||||
"git.loafle.net/overflow/probe/config"
|
|
||||||
|
|
||||||
// For annotation
|
// For annotation
|
||||||
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
||||||
|
@ -35,319 +27,106 @@ type ContainerService struct {
|
||||||
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
||||||
|
|
||||||
DiscoveryService *DiscoveryService `annotation:"@Inject()"`
|
DiscoveryService *DiscoveryService `annotation:"@Inject()"`
|
||||||
|
SensorConfigService *SensorConfigService `annotation:"@Inject()"`
|
||||||
|
|
||||||
rpcServiceMap map[occp.ContainerType][]interface{}
|
OnConnectChan <-chan *container.OnConnectInfo `annotation:"@Resource(name='PROBE_ONCONNECT_CHAN')"`
|
||||||
containerStates map[occp.ContainerType]*containerState
|
OnDisconnectChan <-chan occp.ContainerType `annotation:"@Resource(name='PROBE_ONDISCONNECT_CHAN')"`
|
||||||
connectorMap map[csc.Connector]*containerState
|
RPCServerCodec crp.ServerCodec `annotation:"@Resource(name='PROBE_RPC_SERVER_CODEC')"`
|
||||||
|
|
||||||
|
containerSessions sync.Map
|
||||||
|
|
||||||
|
stopChan chan struct{}
|
||||||
|
stopWg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) InitService() error {
|
func (s *ContainerService) InitService() error {
|
||||||
s.containerStates = make(map[occp.ContainerType]*containerState)
|
|
||||||
s.rpcServiceMap = make(map[occp.ContainerType][]interface{})
|
|
||||||
s.connectorMap = make(map[csc.Connector]*containerState)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) StartService() error {
|
func (s *ContainerService) StartService() error {
|
||||||
s.rpcServiceMap[occp.ContainerDiscovery] = []interface{}{
|
s.stopChan = make(chan struct{})
|
||||||
s.DiscoveryService,
|
|
||||||
}
|
s.stopWg.Add(1)
|
||||||
s.rpcServiceMap[occp.ContainerNetwork] = []interface{}{}
|
go s.handleCotainerConnection()
|
||||||
s.rpcServiceMap[occp.ContainerGenernal] = []interface{}{}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) StopService() {
|
func (s *ContainerService) StopService() {
|
||||||
for containerType := range s.containerStates {
|
close(s.stopChan)
|
||||||
s.removeContainerState(containerType)
|
s.stopWg.Wait()
|
||||||
}
|
|
||||||
|
s.containerSessions.Range(func(_containerType, _containerSession interface{}) bool {
|
||||||
|
containerSession := _containerSession.(*container.ContainerSession)
|
||||||
|
containerSession.Stop()
|
||||||
|
|
||||||
|
return true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) DestroyService() {
|
func (s *ContainerService) DestroyService() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) Call(containerType occp.ContainerType, result interface{}, method string, params ...interface{}) error {
|
func (s *ContainerService) handleCotainerConnection() {
|
||||||
client, err := s.getClient(containerType)
|
for {
|
||||||
if nil != err {
|
select {
|
||||||
return err
|
case onConnectInfo := <-s.OnConnectChan:
|
||||||
|
_containerSession, ok := s.containerSessions.Load(onConnectInfo.ContainerType)
|
||||||
|
if !ok {
|
||||||
|
// var err error
|
||||||
|
// _containerSession, err = s.newContainerSession(onConnectInfo.ContainerType)
|
||||||
|
// if nil != err {
|
||||||
|
// logging.Logger().Errorf("ContainerSession is not exist for %s", onConnectInfo.ContainerType.String())
|
||||||
|
// }
|
||||||
|
logging.Logger().Errorf("ContainerSession is not exist for %s", onConnectInfo.ContainerType.String())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
containerSession := _containerSession.(*container.ContainerSession)
|
||||||
|
containerSession.Connected(onConnectInfo.WriteChan)
|
||||||
|
s.SensorConfigService.SendInitConfig(onConnectInfo.ContainerType)
|
||||||
|
|
||||||
|
case containerType := <-s.OnDisconnectChan:
|
||||||
|
_containerSession, ok := s.containerSessions.Load(containerType)
|
||||||
|
if ok {
|
||||||
|
containerSession := _containerSession.(*container.ContainerSession)
|
||||||
|
containerSession.Disconnected()
|
||||||
|
}
|
||||||
|
case <-s.stopChan:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return client.Call(result, method, params...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) Send(containerType occp.ContainerType, method string, params ...interface{}) error {
|
func (s *ContainerService) Send(containerType occp.ContainerType, method string, params ...interface{}) error {
|
||||||
client, err := s.getClient(containerType)
|
var err error
|
||||||
|
_containerSession, ok := s.containerSessions.Load(containerType)
|
||||||
|
if !ok {
|
||||||
|
_containerSession, err = s.newContainerSession(containerType)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return client.Send(method, params...)
|
}
|
||||||
}
|
containerSession := _containerSession.(*container.ContainerSession)
|
||||||
|
|
||||||
func (s *ContainerService) getClient(containerType occp.ContainerType) (*crc.Client, error) {
|
buff, err := s.RPCServerCodec.NewNotification(method, params)
|
||||||
cs := s.checkContainer(containerType)
|
|
||||||
if nil == cs {
|
|
||||||
// _cs, err := s.runContainer(containerType)
|
|
||||||
_cs, err := s.debugContainer(containerType)
|
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
cs = _cs
|
|
||||||
s.containerStates[containerType] = cs
|
|
||||||
}
|
|
||||||
|
|
||||||
if nil == cs.client {
|
|
||||||
client, err := container.NewClient(containerType, cs.port, s.rpcServiceMap[containerType])
|
|
||||||
if nil != err {
|
|
||||||
s.removeContainerState(containerType)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := client.Start(); nil != err {
|
|
||||||
s.removeContainerState(containerType)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
cs.client = client
|
|
||||||
cs.client.Connector.SetOnDisconnected(s.onDisconnected)
|
|
||||||
s.connectorMap[cs.client.Connector] = cs
|
|
||||||
}
|
|
||||||
|
|
||||||
return cs.client, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ContainerService) onDisconnected(connector csc.Connector) {
|
|
||||||
cs, ok := s.connectorMap[connector]
|
|
||||||
if !ok || nil == cs {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.refreshContainer(cs.containerType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ContainerService) runContainer(containerType occp.ContainerType) (*containerState, error) {
|
|
||||||
if cs := s.checkContainer(containerType); nil != cs {
|
|
||||||
return cs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd, pidFilePath := cotainerCommand(containerType)
|
|
||||||
removePidFile(pidFilePath)
|
|
||||||
|
|
||||||
if err := cmd.Start(); nil != err {
|
|
||||||
logging.Logger().Errorf("to run Container[%s] failed err %v", containerType.String(), err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
port, err := watchPidFileCreate(pidFilePath, time.Duration(time.Second*2))
|
|
||||||
if nil != err {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// go func(containerType occp.ContainerType, cmd *exec.Cmd) {
|
|
||||||
// if err := cmd.Wait(); nil != err {
|
|
||||||
// logging.Logger().Error(err)
|
|
||||||
// }
|
|
||||||
// logging.Logger().Infof("Container[%s] has been stopped", containerType.String())
|
|
||||||
// s.refreshContainer(containerType)
|
|
||||||
// }(containerType, cmd)
|
|
||||||
|
|
||||||
cs := &containerState{
|
|
||||||
containerType: containerType,
|
|
||||||
cmd: cmd,
|
|
||||||
port: port,
|
|
||||||
}
|
|
||||||
|
|
||||||
return cs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ContainerService) refreshContainer(containerType occp.ContainerType) {
|
|
||||||
cs := s.checkContainer(containerType)
|
|
||||||
if nil == cs {
|
|
||||||
if _, err := s.getClient(containerType); nil != err {
|
|
||||||
logging.Logger().Error(err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cs.cmd.Process.Kill()
|
|
||||||
cs.cmd = nil
|
|
||||||
|
|
||||||
delete(s.connectorMap, cs.client.Connector)
|
|
||||||
err := cs.client.Stop(context.Background())
|
|
||||||
if nil != err {
|
|
||||||
logging.Logger().Error(err)
|
|
||||||
}
|
|
||||||
cs.client = nil
|
|
||||||
delete(s.containerStates, containerType)
|
|
||||||
if _, err := s.getClient(containerType); nil != err {
|
|
||||||
logging.Logger().Error(err)
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//if cs, ok := s.checkContainer(containerType); nil == cs {
|
|
||||||
// cs, ok := s.containerStates[containerType]
|
|
||||||
// if !ok {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// delete(s.connectorMap, cs.client.Connector)
|
|
||||||
//
|
|
||||||
// logging.Logger().Debugf("Client[%s]11 has been disconnected", cs.containerType.String())
|
|
||||||
// err := cs.client.Stop(context.Background())
|
|
||||||
// if nil != err {
|
|
||||||
// logging.Logger().Error(err)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// client, err := container.NewClient(cs.containerType, cs.port, s.rpcServiceMap[cs.containerType])
|
|
||||||
// if nil != err {
|
|
||||||
// s.removeContainerState(cs.containerType)
|
|
||||||
// logging.Logger().Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if err := client.Start(); nil != err {
|
|
||||||
// s.removeContainerState(cs.containerType)
|
|
||||||
// logging.Logger().Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// cs.client = client
|
|
||||||
// cs.client.Connector.SetOnDisconnected(s.onDisconnected)
|
|
||||||
// s.connectorMap[cs.client.Connector] = cs
|
|
||||||
//} else {
|
|
||||||
// cs, ok := s.containerStates[containerType]
|
|
||||||
// if !ok {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// delete(s.connectorMap, cs.client.Connector)
|
|
||||||
// err := cs.client.Stop(context.Background())
|
|
||||||
// if nil != err {
|
|
||||||
// logging.Logger().Error(err)
|
|
||||||
// }
|
|
||||||
// delete(s.containerStates, containerType)
|
|
||||||
// _, err = s.getClient(containerType)
|
|
||||||
// if nil != err {
|
|
||||||
// logging.Logger().Error(err)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ContainerService) debugContainer(containerType occp.ContainerType) (*containerState, error) {
|
|
||||||
cs := &containerState{
|
|
||||||
containerType: containerType,
|
|
||||||
cmd: nil,
|
|
||||||
port: 60000,
|
|
||||||
}
|
|
||||||
|
|
||||||
return cs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ContainerService) checkContainer(containerType occp.ContainerType) *containerState {
|
|
||||||
cs, ok := s.containerStates[containerType]
|
|
||||||
if !ok || nil == cs {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// p, err := os.FindProcess(cs.cmd.Process.Pid)
|
|
||||||
// if nil != err {
|
|
||||||
// s.removeContainerState(containerType)
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
// if nil == p {
|
|
||||||
// s.removeContainerState(containerType)
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if nil != cs.cmd.ProcessState && cs.cmd.ProcessState.Exited() {
|
|
||||||
// s.removeContainerState(containerType)
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
return cs
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ContainerService) killContainer(containerType occp.ContainerType) error {
|
|
||||||
cs, ok := s.containerStates[containerType]
|
|
||||||
if !ok || nil == cs {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if nil == cs.cmd.ProcessState || !cs.cmd.ProcessState.Exited() {
|
|
||||||
if err := cs.cmd.Process.Kill(); nil != err {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return containerSession.Send(buff)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContainerService) removeContainerState(containerType occp.ContainerType) {
|
func (s *ContainerService) newContainerSession(containerType occp.ContainerType) (*container.ContainerSession, error) {
|
||||||
cs, ok := s.containerStates[containerType]
|
_containerSession, ok := s.containerSessions.Load(containerType)
|
||||||
if !ok || nil == cs {
|
if !ok {
|
||||||
return
|
_containerSession = container.NewContainerSession(containerType)
|
||||||
|
s.containerSessions.Store(containerType, _containerSession)
|
||||||
|
if err := _containerSession.(*container.ContainerSession).Start(); nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != cs.client {
|
return _containerSession.(*container.ContainerSession), nil
|
||||||
delete(s.connectorMap, cs.client.Connector)
|
|
||||||
cs.client.Stop(context.Background())
|
|
||||||
}
|
|
||||||
s.killContainer(containerType)
|
|
||||||
delete(s.containerStates, containerType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func cotainerCommand(containerType occp.ContainerType) (cmd *exec.Cmd, pidFilePath string) {
|
|
||||||
pidFilePath = config.ContainerPIDFilePath(containerType)
|
|
||||||
loggingConfigFilePath := config.ContainerLoggingConfigFilePath(containerType)
|
|
||||||
binFilePath := config.ContainerBinFilePath(containerType)
|
|
||||||
|
|
||||||
switch containerType {
|
|
||||||
case occp.ContainerDiscovery, occp.ContainerNetwork:
|
|
||||||
args := []string{
|
|
||||||
fmt.Sprintf("-%s=%s", occp.FlagPidFilePathName, pidFilePath),
|
|
||||||
fmt.Sprintf("-%s=%s", occp.FlagLoggingConfigFilePathName, loggingConfigFilePath),
|
|
||||||
}
|
|
||||||
cmd = exec.Command(binFilePath, args...)
|
|
||||||
case occp.ContainerGenernal:
|
|
||||||
args := []string{
|
|
||||||
"-jar",
|
|
||||||
binFilePath,
|
|
||||||
pidFilePath,
|
|
||||||
loggingConfigFilePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd = exec.Command(config.JavaBinPath(), args...)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func removePidFile(pidFilePath string) {
|
|
||||||
if _, err := os.Stat(pidFilePath); err == nil {
|
|
||||||
if err := os.Remove(pidFilePath); nil != err {
|
|
||||||
logging.Logger().Errorf("removing pid file has been failed [%v]", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func watchPidFileCreate(pidFilePath string, waitTime time.Duration) (int, error) {
|
|
||||||
startTime := time.Now()
|
|
||||||
|
|
||||||
for {
|
|
||||||
if _, err := os.Stat(pidFilePath); err == nil {
|
|
||||||
buf, err := ioutil.ReadFile(pidFilePath)
|
|
||||||
if nil != err {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
portNumber, err := strconv.ParseInt(string(buf), 10, 32)
|
|
||||||
if nil != err {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return int(portNumber), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if time.Since(startTime) > waitTime {
|
|
||||||
return 0, fmt.Errorf("pid file not exist")
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(time.Duration(time.Millisecond * 100))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type containerState struct {
|
|
||||||
containerType occp.ContainerType
|
|
||||||
cmd *exec.Cmd
|
|
||||||
port int
|
|
||||||
client *crc.Client
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
cda "git.loafle.net/commons/di-go/annotation"
|
cda "git.loafle.net/commons/di-go/annotation"
|
||||||
cdr "git.loafle.net/commons/di-go/registry"
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
||||||
"git.loafle.net/overflow/probe/client/central"
|
"git.loafle.net/overflow/probe/client/data"
|
||||||
|
|
||||||
// For annotation
|
// For annotation
|
||||||
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
||||||
|
@ -27,7 +28,7 @@ type DataClientService struct {
|
||||||
|
|
||||||
func (s *DataClientService) InitService() error {
|
func (s *DataClientService) InitService() error {
|
||||||
if err := s.RPCClientService.InitService(); nil != err {
|
if err := s.RPCClientService.InitService(); nil != err {
|
||||||
return err
|
return fmt.Errorf("DataClientService: InitService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -35,17 +36,17 @@ func (s *DataClientService) InitService() error {
|
||||||
|
|
||||||
func (s *DataClientService) StartService() error {
|
func (s *DataClientService) StartService() error {
|
||||||
if err := s.RPCClientService.StartService(); nil != err {
|
if err := s.RPCClientService.StartService(); nil != err {
|
||||||
return err
|
return fmt.Errorf("DataClientService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := central.NewData()
|
client, err := data.New()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return fmt.Errorf("ProbeClientService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
s.client = client
|
s.client = client
|
||||||
|
|
||||||
if err := s.client.Start(); nil != err {
|
if err := s.client.Start(); nil != err {
|
||||||
return err
|
return fmt.Errorf("DataClientService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
48
service/DataService.go
Normal file
48
service/DataService.go
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
cda "git.loafle.net/commons/di-go/annotation"
|
||||||
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
|
logging "git.loafle.net/commons/logging-go"
|
||||||
|
|
||||||
|
// For annotation
|
||||||
|
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
||||||
|
)
|
||||||
|
|
||||||
|
var DataServiceType = reflect.TypeOf((*DataService)(nil))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cdr.RegisterType(DataServiceType)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataService struct {
|
||||||
|
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
||||||
|
|
||||||
|
DataClientService *DataClientService `annotation:"@Inject()"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DataService) InitService() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DataService) StartService() error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DataService) StopService() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DataService) DestroyService() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DataService) Metric(metric map[string]string) error {
|
||||||
|
|
||||||
|
logging.Logger().Debugf("Metric: %v", metric)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
cda "git.loafle.net/commons/di-go/annotation"
|
cda "git.loafle.net/commons/di-go/annotation"
|
||||||
|
@ -8,7 +9,7 @@ import (
|
||||||
|
|
||||||
// For annotation
|
// For annotation
|
||||||
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
||||||
"git.loafle.net/overflow/probe/client/central"
|
"git.loafle.net/overflow/probe/client/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ProbeClientServiceType = reflect.TypeOf((*ProbeClientService)(nil))
|
var ProbeClientServiceType = reflect.TypeOf((*ProbeClientService)(nil))
|
||||||
|
@ -29,7 +30,7 @@ type ProbeClientService struct {
|
||||||
|
|
||||||
func (s *ProbeClientService) InitService() error {
|
func (s *ProbeClientService) InitService() error {
|
||||||
if err := s.RPCClientService.InitService(); nil != err {
|
if err := s.RPCClientService.InitService(); nil != err {
|
||||||
return err
|
return fmt.Errorf("ProbeClientService: InitService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -37,17 +38,17 @@ func (s *ProbeClientService) InitService() error {
|
||||||
|
|
||||||
func (s *ProbeClientService) StartService() error {
|
func (s *ProbeClientService) StartService() error {
|
||||||
if err := s.RPCClientService.StartService(); nil != err {
|
if err := s.RPCClientService.StartService(); nil != err {
|
||||||
return err
|
return fmt.Errorf("ProbeClientService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := central.NewProbe(s.HandleEncryptionKey, s.DiscoveryService)
|
client, err := probe.New(s.HandleEncryptionKey, s.DiscoveryService)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return fmt.Errorf("ProbeClientService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
s.client = client
|
s.client = client
|
||||||
|
|
||||||
if err := s.client.Start(); nil != err {
|
if err := s.client.Start(); nil != err {
|
||||||
return err
|
return fmt.Errorf("ProbeClientService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
cda "git.loafle.net/commons/di-go/annotation"
|
cda "git.loafle.net/commons/di-go/annotation"
|
||||||
cdr "git.loafle.net/commons/di-go/registry"
|
cdr "git.loafle.net/commons/di-go/registry"
|
||||||
|
logging "git.loafle.net/commons/logging-go"
|
||||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig"
|
ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig"
|
||||||
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
ocsp "git.loafle.net/overflow/commons-go/service/probe"
|
||||||
|
@ -32,6 +33,7 @@ type SensorConfigService struct {
|
||||||
ContainerService *ContainerService `annotation:"@Inject()"`
|
ContainerService *ContainerService `annotation:"@Inject()"`
|
||||||
|
|
||||||
sensorConfigs map[string]*ocmsc.SensorConfig
|
sensorConfigs map[string]*ocmsc.SensorConfig
|
||||||
|
sensorConfigsPerContainer map[occp.ContainerType][]*ocmsc.SensorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SensorConfigService) InitService() error {
|
func (s *SensorConfigService) InitService() error {
|
||||||
|
@ -42,15 +44,14 @@ func (s *SensorConfigService) InitService() error {
|
||||||
|
|
||||||
func (s *SensorConfigService) StartService() error {
|
func (s *SensorConfigService) StartService() error {
|
||||||
if err := s.loadConfigAll(); nil != err {
|
if err := s.loadConfigAll(); nil != err {
|
||||||
return err
|
return fmt.Errorf("SensorConfigService: StartService failed %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != s.sensorConfigs || 0 < len(s.sensorConfigs) {
|
if nil != s.sensorConfigs || 0 < len(s.sensorConfigs) {
|
||||||
sortedMap := sortSensorConfigPerContainer(s.sensorConfigs)
|
s.sortSensorConfigPerContainer()
|
||||||
for containerName, configs := range sortedMap {
|
|
||||||
if err := s.ContainerService.Send(occp.ToContainerType(containerName), "SensorConfigService.InitConfig", configs); nil != err {
|
for containerType := range s.sensorConfigsPerContainer {
|
||||||
return err
|
s.SendInitConfig(containerType)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +66,19 @@ func (s *SensorConfigService) DestroyService() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SensorConfigService) SendInitConfig(containerType occp.ContainerType) error {
|
||||||
|
configs, ok := s.sensorConfigsPerContainer[containerType]
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.ContainerService.Send(containerType, "SensorConfigService.InitConfig", configs); nil != err {
|
||||||
|
return fmt.Errorf("SensorConfigService: StartService failed %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SensorConfigService) AddConfig(tempFilePath string) error {
|
func (s *SensorConfigService) AddConfig(tempFilePath string) error {
|
||||||
sc, buf, err := s.loadConfigFile(tempFilePath)
|
sc, buf, err := s.loadConfigFile(tempFilePath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
@ -81,6 +95,37 @@ func (s *SensorConfigService) AddConfig(tempFilePath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
s.sensorConfigs[sc.ID.String()] = sc
|
s.sensorConfigs[sc.ID.String()] = sc
|
||||||
|
s.sortSensorConfigPerContainer()
|
||||||
|
|
||||||
|
if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.Container), "SensorConfigService.AddConfig", sc); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SensorConfigService) UpdateConfig(tempFilePath string) error {
|
||||||
|
sc, buf, err := s.loadConfigFile(tempFilePath)
|
||||||
|
if nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPath := config.SensorConfigFilePath(sc)
|
||||||
|
ioutil.WriteFile(targetPath, buf, 0644)
|
||||||
|
|
||||||
|
// tempfile remove
|
||||||
|
err = os.Remove(tempFilePath)
|
||||||
|
if nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(s.sensorConfigs, sc.ConfigID)
|
||||||
|
s.sensorConfigs[sc.ID.String()] = sc
|
||||||
|
s.sortSensorConfigPerContainer()
|
||||||
|
|
||||||
|
if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.Container), "SensorConfigService.UpdateConfig", sc); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -98,6 +143,11 @@ func (s *SensorConfigService) RemoveConfig(sensorConfigID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(s.sensorConfigs, sensorConfigID)
|
delete(s.sensorConfigs, sensorConfigID)
|
||||||
|
s.sortSensorConfigPerContainer()
|
||||||
|
|
||||||
|
if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.Container), "SensorConfigService.RemoveConfig", sensorConfigID); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -146,6 +196,7 @@ func (s *SensorConfigService) loadConfigDir(dirPath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SensorConfigService) loadConfigFile(filePath string) (*ocmsc.SensorConfig, []byte, error) {
|
func (s *SensorConfigService) loadConfigFile(filePath string) (*ocmsc.SensorConfig, []byte, error) {
|
||||||
|
logging.Logger().Debugf("filePath: %s", filePath)
|
||||||
buf, err := ioutil.ReadFile(filePath)
|
buf, err := ioutil.ReadFile(filePath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
@ -159,17 +210,16 @@ func (s *SensorConfigService) loadConfigFile(filePath string) (*ocmsc.SensorConf
|
||||||
return m, buf, nil
|
return m, buf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortSensorConfigPerContainer(sensorConfigMap map[string]*ocmsc.SensorConfig) map[string][]*ocmsc.SensorConfig {
|
func (s *SensorConfigService) sortSensorConfigPerContainer() {
|
||||||
if nil == sensorConfigMap || 0 == len(sensorConfigMap) {
|
if nil == s.sensorConfigs || 0 == len(s.sensorConfigs) {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m := make(map[string][]*ocmsc.SensorConfig)
|
s.sensorConfigsPerContainer = nil
|
||||||
|
s.sensorConfigsPerContainer = make(map[occp.ContainerType][]*ocmsc.SensorConfig)
|
||||||
|
|
||||||
for _, sensorConfig := range sensorConfigMap {
|
for _, sensorConfig := range s.sensorConfigs {
|
||||||
containerName := sensorConfig.Crawler.Container
|
containerType := occp.ToContainerType(sensorConfig.Crawler.Container)
|
||||||
m[containerName] = append(m[containerName], sensorConfig)
|
s.sensorConfigsPerContainer[containerType] = append(s.sensorConfigsPerContainer[containerType], sensorConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user