Show client IP and Server address in issue report and offline report
This commit is contained in:
parent
a380c5c41e
commit
cb37ca5077
40
ews/ews.go
40
ews/ews.go
@ -38,6 +38,8 @@ type ReportInfo struct {
|
||||
MfgMO string
|
||||
Line string
|
||||
Location string
|
||||
IPAddr string
|
||||
Relay string
|
||||
Item string
|
||||
Status string
|
||||
Message string
|
||||
@ -694,7 +696,7 @@ func (e *EWS) GetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri
|
||||
}
|
||||
|
||||
if loc == "" {
|
||||
loc = `<span style="color: red;">Unknown</span>`
|
||||
loc = `<span style="color: red;">N/A</span>`
|
||||
} else {
|
||||
loc = fmt.Sprintf(`<span>%s</span>`, loc)
|
||||
}
|
||||
@ -764,9 +766,8 @@ func (e *EWS) GetIssueReport(cfg cnf.Cfg, logger *log.Logger, host string, addr
|
||||
ri := new(ReportInfo)
|
||||
defect := ""
|
||||
rows, err := dbo.Query(fmt.Sprintf(
|
||||
`SELECT usn,partno,sku,mo,line,location,item,status,message,first_ack,last_ack,last_change,diffmins
|
||||
FROM %s
|
||||
ORDER BY diffmins ASC;`, cfg.MySQL.IssuesView))
|
||||
`SELECT usn,partno,sku,mo,line,location,ipaddr,relay,item,status,message,first_ack,last_ack,last_change,diffmins
|
||||
FROM %s;`, cfg.MySQL.IssuesView))
|
||||
if err != nil {
|
||||
logger.Printf("[ERR] %s; %s; %#v; %s\r\n", addr, uri, params, err.Error())
|
||||
rst["RESULT"] = "NG"
|
||||
@ -784,11 +785,11 @@ func (e *EWS) GetIssueReport(cfg cnf.Cfg, logger *log.Logger, host string, addr
|
||||
&ri.MfgMO,
|
||||
&ri.Line,
|
||||
&ri.Location,
|
||||
&ri.IPAddr,
|
||||
&ri.Relay,
|
||||
&ri.Item,
|
||||
&ri.Status,
|
||||
&ri.Message,
|
||||
&ri.FirstAck,
|
||||
&ri.LastAck,
|
||||
&ri.LastChg,
|
||||
&ri.DiffMins,
|
||||
)
|
||||
@ -796,13 +797,13 @@ func (e *EWS) GetIssueReport(cfg cnf.Cfg, logger *log.Logger, host string, addr
|
||||
break
|
||||
}
|
||||
temp := fmt.Sprintf(`<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>%s`,
|
||||
num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.Item, ri.Status, ri.Message, ri.FirstAck, ri.LastAck, ri.LastChg, ri.DiffMins, "\r\n")
|
||||
num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.IPAddr, ri.Relay, ri.Item, ri.Status, ri.Message, ri.LastChg, ri.DiffMins, "\r\n")
|
||||
defect = defect + temp
|
||||
num += 1
|
||||
}
|
||||
|
||||
rst["RESULT"] = "OK"
|
||||
rst["ErrMsg"] = e.TemplateDefectInfo(defect)
|
||||
rst["ErrMsg"] = e.TemplateReportInfo(defect)
|
||||
return rst
|
||||
}
|
||||
|
||||
@ -835,9 +836,8 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add
|
||||
ri := new(ReportInfo)
|
||||
offline := ""
|
||||
rows, err := dbo.Query(fmt.Sprintf(
|
||||
`SELECT usn,partno,sku,mo,line,location,item,status,message,first_ack,last_ack,last_change,diffmins
|
||||
FROM %s
|
||||
ORDER BY diffmins DESC;`, cfg.MySQL.OfflineView))
|
||||
`SELECT usn,partno,sku,mo,line,location,ipaddr,relay,item,status,message,last_change,diffmins
|
||||
FROM %s;`, cfg.MySQL.OfflineView))
|
||||
if err != nil {
|
||||
logger.Printf("[ERR] %s; %s; %#v; %s\r\n", addr, uri, params, err.Error())
|
||||
rst["RESULT"] = "NG"
|
||||
@ -855,11 +855,11 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add
|
||||
&ri.MfgMO,
|
||||
&ri.Line,
|
||||
&ri.Location,
|
||||
&ri.IPAddr,
|
||||
&ri.Relay,
|
||||
&ri.Item,
|
||||
&ri.Status,
|
||||
&ri.Message,
|
||||
&ri.FirstAck,
|
||||
&ri.LastAck,
|
||||
&ri.LastChg,
|
||||
&ri.DiffMins,
|
||||
)
|
||||
@ -867,13 +867,13 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add
|
||||
break
|
||||
}
|
||||
temp := fmt.Sprintf(`<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>%s`,
|
||||
num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.Item, ri.Status, ri.Message, ri.FirstAck, ri.LastAck, ri.LastChg, ri.DiffMins, "\r\n")
|
||||
num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.IPAddr, ri.Relay, ri.Item, ri.Status, ri.Message, ri.LastChg, ri.DiffMins, "\r\n")
|
||||
offline = offline + temp
|
||||
num += 1
|
||||
}
|
||||
|
||||
rst["RESULT"] = "OK"
|
||||
rst["ErrMsg"] = e.TemplateDefectInfo(offline)
|
||||
rst["ErrMsg"] = e.TemplateReportInfo(offline)
|
||||
return rst
|
||||
}
|
||||
|
||||
@ -972,7 +972,7 @@ func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string {
|
||||
<th>MAC</th>
|
||||
<th>IP Address</th>
|
||||
<th>Server</th>
|
||||
<th>Test Item</th>
|
||||
<th>Item</th>
|
||||
<th>Status</th>
|
||||
<th>Message</th>
|
||||
<th>Last Change</th>
|
||||
@ -985,7 +985,7 @@ func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string {
|
||||
return resp
|
||||
}
|
||||
|
||||
func (e *EWS) TemplateDefectInfo(src string) string {
|
||||
func (e *EWS) TemplateReportInfo(src string) string {
|
||||
now := time.Now().Format("2006-01-02 15:04:05")
|
||||
if src == "" {
|
||||
src = fmt.Sprintf(`<span style="color: red;">[%s] NO Records !</span><br/>`, now)
|
||||
@ -1035,13 +1035,13 @@ func (e *EWS) TemplateDefectInfo(src string) string {
|
||||
<th>MO</th>
|
||||
<th>Line</th>
|
||||
<th>Location</th>
|
||||
<th>IP Address</th>
|
||||
<th>Server</th>
|
||||
<th>Item</th>
|
||||
<th>Status</th>
|
||||
<th>Message</th>
|
||||
<th>First Ack</th>
|
||||
<th>Last Ack</th>
|
||||
<th>Last Change</th>
|
||||
<th>Differ Time (Min)</th>
|
||||
<th>Differ Mins</th>
|
||||
</tr>
|
||||
%s
|
||||
</table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user