func portOrPid() {
config := common.InitConfig("./config/test.txt")
port := config["ports"]
arr := strings.Split(port, ",")
for _, item := range arr {
if item !=""{
port, _ := strconv.Atoi(item)
if common.PortInUse(port) == -1 {
println("根据端口号未获取进程信息,端口号或进程号:%d", common.PortInUse(port))
} else {
tags, fields :=common.GetPidInfo(int32(common.PortInUse(port)))
tags ["ipv4"] = GetOutboundIP()
tags ["port"] = common.GetPortInfo(item).Port
tags ["bz"] = common.GetPortInfo(item).Bz
client := &http.Client{Timeout: 10 * time.Second}
tempJson := make(map[string]interface{})
tempJson["tag"]=tags
tempJson["fields"]=fields
tempJson["dbName"]="test_dbname"
jsonStr, _ :=json.Marshal(tempJson)
resp, _ := client.Post("http://10.102.110.93:8080/inserPortInfo", "application/json", bytes.NewBuffer(jsonStr))
resp.Body.Close()
fmt.Println("插入成功!")
}
}
}
}
go发送post请求
最新推荐文章于 2024-07-02 15:11:27 发布