Signed-off-by: martin <martin.labat92@gmail.com>
This commit is contained in:
martin 2023-02-15 20:45:26 +01:00
parent 4022be77ae
commit be9d6fa0dc
No known key found for this signature in database
GPG key ID: 4544CC55835A3B9E
6 changed files with 17 additions and 50 deletions

View file

@ -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)
}
}

View file

@ -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 {

View file

@ -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)

View file

@ -55,7 +55,7 @@ type StructAllUsers []struct {
OauthID string `json:"oauthId"`
}
type CustomUser struct {
type StructCustomUser struct {
Email string
ID string
FirstName string

View file

@ -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 {

View file

@ -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"})
)