Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement for bind points #628

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/libs/dbHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func UpsertSystemSummary(cfg types.ConfigDB, summaryMap map[types.SystemSummary]
func upsertSysSummarySQL(db *sql.DB, summary types.SystemSummary, timeCount types.SysSummaryTimeCount) error {
queryString := `cluster_name = ? and cluster_id = ? and workspace_id = ? and namespace_name = ? and namespace_id = ? and container_name = ? and container_image = ?
and container_id = ? and podname = ? and operation = ? and labels = ? and deployment_name = ? and source = ? and destination = ?
and destination_namespace = ? and destination_labels = ? and type = ? and ip = ? and port = ? and protocol = ? and action = ? and bind_port = ? and bind_address = ?`
and destination_namespace = ? and destination_labels = ? and type = ? and ip = ? and port = ? and protocol = ? and action = ? and bindport = ? and bindaddr = ?`

query := "UPDATE " + TableSystemSummarySQLite + " SET count=count+?, updated_time=? WHERE " + queryString + " "

Expand Down Expand Up @@ -453,7 +453,7 @@ func upsertSysSummarySQL(db *sql.DB, summary types.SystemSummary, timeCount type
if err == nil && rowsAffected == 0 {

insertQueryString := `(cluster_name,cluster_id,workspace_id,namespace_name,namespace_id,container_name,container_image,container_id,podname,operation,labels,deployment_name,
source,destination,destination_namespace,destination_labels,type,ip,port,protocol,action,count,updated_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
source,destination,destination_namespace,destination_labels,type,ip,port,protocol,action,count,updated_time,bindport,bindaddr) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`

insertQuery := "INSERT INTO " + TableSystemSummarySQLite + insertQueryString

Expand Down Expand Up @@ -486,7 +486,9 @@ func upsertSysSummarySQL(db *sql.DB, summary types.SystemSummary, timeCount type
summary.Protocol,
summary.Action,
timeCount.Count,
timeCount.UpdatedTime)
timeCount.UpdatedTime,
summary.BindPort,
summary.BindAddress)
if err != nil {
log.Error().Msg(err.Error())
return err
Expand Down Expand Up @@ -517,7 +519,7 @@ func getSysSummarySQL(db *sql.DB, dbName string, filterOptions types.SystemSumma

query := `SELECT cluster_name,cluster_id,workspace_id,namespace_name,namespace_id,container_name,
container_image,container_id,podname,operation,labels,deployment_name,source,destination,destination_namespace,
destination_labels,type,ip,port,protocol,action,count,updated_time FROM ` + dbName
destination_labels,type,ip,port,protocol,action,count,updated_time,bindport,bindaddr FROM ` + dbName

var whereClause string
var args []interface{}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/sqliteHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,11 @@ func CreateSystemSummaryTableSQLite(cfg types.ConfigDB) error {
" `ip` int DEFAULT NULL," +
" `port` varchar(10) DEFAULT NULL," +
" `protocol` varchar(10) DEFAULT NULL," +
" `bindport` varchar(10) DEFAULT NULL," +
" `bindaddr` varchar(10) DEFAULT NULL," +
" `action` varchar(10) DEFAULT NULL," +
" `count` int NOT NULL," +
" `updated_time` bigint NOT NULL," +
" `bind_port` varchar(10) DEFAULT NULL," +
" `bind_address` varchar(10) DEFAULT NULL," +
" PRIMARY KEY (`id`)" +
" );"

Expand Down
8 changes: 7 additions & 1 deletion src/observability/summarizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ func extractNetworkInfoFromSystemLog(netLog pb.Log) (string, string, string, str
}
}
}
} else if strings.Contains(netLog.Data, "SYS_BIND") {
}

if strings.Contains(netLog.Data, "SYS_BIND") {
bindAddress = ip
resslice := strings.Split(netLog.Resource, " ")
for _, locres := range resslice {
if strings.Contains(locres, "sin_port") {
Expand All @@ -60,6 +63,9 @@ func extractNetworkInfoFromSystemLog(netLog pb.Log) (string, string, string, str
if strings.Contains(locres, "sin_addr") {
bindAddress = strings.Split(locres, "=")[1]
}
if strings.Contains(locres, "sa_family") {
protocol = strings.Split(locres, "=")[1]
}
}

} else {
Expand Down