diff options
Diffstat (limited to 'cmd/monfront')
| -rw-r--r-- | cmd/monfront/checks.go | 6 | ||||
| -rw-r--r-- | cmd/monfront/main.go | 14 | 
2 files changed, 9 insertions, 11 deletions
| diff --git a/cmd/monfront/checks.go b/cmd/monfront/checks.go index e6668fd..75af748 100644 --- a/cmd/monfront/checks.go +++ b/cmd/monfront/checks.go @@ -4,8 +4,6 @@ import (  	"database/sql"  	"net/http"  	"time" - -	"github.com/lib/pq"  )  type ( @@ -62,7 +60,7 @@ type (  		State        int  		Output       string  		Inserted     time.Time -		Sent         pq.NullTime +		Sent         sql.NullTime  		NotifierName string  		MappingId    int  	} @@ -91,7 +89,7 @@ func showCheck(con *Context) {  	err := DB.QueryRow(query, id[0]).Scan(&cd.Id, &cd.Name, &cd.Message, &cd.Enabled,  		&cd.Updated, &cd.LastRefresh, &cd.MappingId, &cd.MappingName, &cd.NodeId,  		&cd.NodeName, &cd.NodeMessage, &cd.CommandId, &cd.CommandName, &cd.CommandMessage, -		pq.Array(&cd.CommandLine), pq.Array(&cd.States), &cd.Notice, &cd.NextTime, +		&cd.CommandLine, &cd.States, &cd.Notice, &cd.NextTime,  		&cd.CheckerID, &cd.CheckerName, &cd.CheckerMsg)  	if err != nil && err == sql.ErrNoRows {  		con.w.Header()["Location"] = []string{"/"} diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index f8d8ee7..8943744 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -18,7 +18,7 @@ import (  	"time"  	"github.com/BurntSushi/toml" -	"github.com/lib/pq" +	_ "github.com/jackc/pgx/v5/stdlib"  	"golang.org/x/term"  ) @@ -107,7 +107,7 @@ func main() {  	logger := parseLogger(config) -	db, err := sql.Open("postgres", config.DB) +	db, err := sql.Open("pgx", config.DB)  	if err != nil {  		log.Fatalf("could not open database connection: %s", err)  	} @@ -278,7 +278,7 @@ func checkAction(con *Context) {  	case "disable":  		setClause = "enabled = false, updated = now()"  	case "delete_check": -		if _, err := DB.Exec(`delete from checks where id = any ($1::bigint[])`, pq.Array(checks)); err != nil { +		if _, err := DB.Exec(`delete from checks where id = any ($1::bigint[])`, checks); err != nil {  			con.log.Info("could not delete checks", "checks", checks, "error", err)  			con.Error = "could not delete checks"  			returnError(http.StatusInternalServerError, con, con.w) @@ -321,7 +321,7 @@ func checkAction(con *Context) {  			cn.notifier_id, $2  			from checks_notify cn  			join active_checks ac on cn.check_id = ac.check_id -			where cn.check_id = any ($1::bigint[])`, pq.Array(&checks), &hostname); err != nil { +			where cn.check_id = any ($1::bigint[])`, &checks, &hostname); err != nil {  			con.log.Info("could not acknowledge check", "error", err)  			con.Error = "could not acknowledge check"  			returnError(http.StatusInternalServerError, con, con.w) @@ -334,7 +334,7 @@ func checkAction(con *Context) {  		}  		_, err := DB.Exec(  			"update active_checks set notice = $2 where check_id = any ($1::bigint[]);", -			pq.Array(&checks), +			&checks,  			comment)  		if err != nil {  			con.w.WriteHeader(http.StatusInternalServerError) @@ -346,7 +346,7 @@ func checkAction(con *Context) {  		return  	case "uncomment":  		_, err := DB.Exec(`update active_checks set notice = null where check_id = any($1::bigint[]);`, -			pq.Array(&checks)) +			&checks)  		if err != nil {  			con.Error = "could not uncomment checks"  			returnError(http.StatusInternalServerError, con, con.w) @@ -366,7 +366,7 @@ func checkAction(con *Context) {  	}  	sql := "update " + setTable + " set " + setClause + " where " + whereColumn + " = any($1::bigint[])" -	whereVals = append([]any{pq.Array(&checks)}, whereVals...) +	whereVals = append([]any{&checks}, whereVals...)  	if len(whereFields) > 0 {  		for i, column := range whereFields {  			sql = sql + " and " + column + fmt.Sprintf(" = $%d", i+1) | 
