diff --git a/src/immich/data.go b/src/immich/data.go index 6c8cd41..dc4640f 100644 --- a/src/immich/data.go +++ b/src/immich/data.go @@ -38,7 +38,7 @@ func Analyze(r *prometheus.Registry) { if err != nil && err2 != nil { } else { - Sendbackmessagepreference(res2, res1, r) + SendBackMessagePreference(res2, res1, r) } close(serverinfo) close(allusers) @@ -103,7 +103,7 @@ func ServerVersion(r *prometheus.Registry) { log.Println("Can not unmarshal JSON") } - Sendbackmessageserverversion(&result, r) + SendBackMessageserverVersion(&result, r) } } diff --git a/src/immich/sendbackmessage.go b/src/immich/sendbackmessage.go index 9f26ead..82f641f 100644 --- a/src/immich/sendbackmessage.go +++ b/src/immich/sendbackmessage.go @@ -2,7 +2,6 @@ package immich import ( "immich-exporter/src/models" - "strconv" "github.com/prometheus/client_golang/prometheus" @@ -44,7 +43,6 @@ func Sendbackmessagepreference(result *models.StructServerInfo, result2 *models. }, []string{"uid", "firstname", "lastname"}) r.MustRegister(user_info) - r.MustRegister(total_usage) r.MustRegister(total_videos) r.MustRegister(total_photos) @@ -81,8 +79,8 @@ func Sendbackmessageserverversion(result *models.StructServerVersion, r *prometh } -func GetName(result string, result2 *models.StructAllUsers) models.CustomUser { - var myuser models.CustomUser +func GetName(result string, result2 *models.StructAllUsers) models.StructCustomUser { + var myuser models.StructCustomUser for i := 0; i < len(*result2); i++ { if (*result2)[i].ID == result { diff --git a/src/main.go b/src/main.go index 447df93..c4b1e94 100644 --- a/src/main.go +++ b/src/main.go @@ -18,16 +18,13 @@ func main() { log.Println("password :", models.Getpasswordmasked()) log.Println("Started") - http.HandleFunc("/metrics", test) + http.HandleFunc("/metrics", metrics) http.ListenAndServe(":8090", nil) } -func test(w http.ResponseWriter, r *http.Request) { +func metrics(w http.ResponseWriter, r *http.Request) { registry := prometheus.NewRegistry() - immich.Allrequests(registry) - - // Delegate http serving to Promethues client library, which will call collector.Collect. h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{}) h.ServeHTTP(w, r) diff --git a/src/models/api.go b/src/models/immich.go similarity index 98% rename from src/models/api.go rename to src/models/immich.go index db5367d..2b1a329 100644 --- a/src/models/api.go +++ b/src/models/immich.go @@ -55,7 +55,7 @@ type StructAllUsers []struct { OauthID string `json:"oauthId"` } -type CustomUser struct { +type StructCustomUser struct { Email string ID string FirstName string diff --git a/src/models/models.go b/src/models/models.go index 97e5567..3a5d47b 100644 --- a/src/models/models.go +++ b/src/models/models.go @@ -1,21 +1,13 @@ package models -type StructImmichUser struct { +type StructImmich struct { Username string Password string URL string - accessToken string + AccessToken string } -var myuser StructImmichUser - -func mask(input string) string { - hide := "" - for i := 0; i < len(input); i++ { - hide += "*" - } - return hide -} +var myuser StructImmich func Getuser() (string, string) { return myuser.Username, myuser.Password @@ -35,15 +27,19 @@ func Getpassword() string { return myuser.Password } func Getpasswordmasked() string { - return mask(myuser.Password) + hide := "" + for i := 0; i < len(myuser.Password); i++ { + hide += "*" + } + return hide } func SetAccessToken(accessToken string) { - myuser.accessToken = accessToken + myuser.AccessToken = accessToken } func GetAccessToken() string { - return myuser.accessToken + return myuser.AccessToken } func GetURL() string { diff --git a/src/models/test.go b/src/models/test.go deleted file mode 100644 index 2a51d60..0000000 --- a/src/models/test.go +++ /dev/null @@ -1,24 +0,0 @@ -package models - -import "github.com/prometheus/client_golang/prometheus" - -var ( - appVersion string - version = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "version", - Help: "Version information about this binary", - ConstLabels: map[string]string{ - "version": appVersion, - }, - }) - - pubhttpRequestsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ - Name: "http_requests_total", - Help: "Count of all HTTP requests", - }, []string{"code", "method"}) - - httpRequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ - Name: "http_request_duration_seconds", - Help: "Duration of all HTTP requests", - }, []string{"code", "handler", "method"}) -)