Skip to content
Snippets Groups Projects
Unverified Commit cac436bb authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Added stats

parent 570f8ddc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,10 +2,12 @@ package main
 
import (
"fmt"
"github.com/Sirupsen/logrus"
"path/filepath"
"strings"
"sync"
"github.com/Sirupsen/logrus"
"github.com/dustin/go-humanize"
)
 
type blobData struct {
Loading
Loading
@@ -91,3 +93,23 @@ func (b blobsData) walk() error {
})
return err
}
func (b blobsData) info() {
var blobsUsed, blobsUnused int
var blobsUsedSize, blobsUnusedSize int64
for _, blob := range b {
if blob.references > 0 {
blobsUsed++
blobsUsedSize += blob.size
} else {
blobsUnused++
blobsUnusedSize += blob.size
}
}
logrus.Infoln("BLOBS INFO:",
"Objects/Unused:", blobsUsed, "/", blobsUnused,
"Data/Unused:", humanize.Bytes(uint64(blobsUsedSize)), "/", humanize.Bytes(uint64(blobsUnusedSize)),
)
}
Loading
Loading
@@ -5,6 +5,7 @@ import (
"sync"
 
"github.com/Sirupsen/logrus"
"github.com/dustin/go-humanize"
)
 
var (
Loading
Loading
@@ -35,9 +36,9 @@ func (d *deletesData) schedule(path string, size int64) {
}
 
func (d *deletesData) info() {
logrus.Warningln("Deleted:", deletedLinks, "links,",
logrus.Warningln("DELETEABLE INFO:", deletedLinks, "links,",
deletedBlobs, "blobs,",
deletedBlobSize/1024/1024, "in MB",
humanize.Bytes(uint64(deletedBlobSize)),
)
}
 
Loading
Loading
Loading
Loading
@@ -84,5 +84,7 @@ func main() {
deletes.run()
}
 
repositories.info(blobs)
blobs.info()
currentStorage.Info()
}
Loading
Loading
@@ -7,6 +7,7 @@ import (
"sync"
 
"github.com/Sirupsen/logrus"
"github.com/dustin/go-humanize"
)
 
type repositoryData struct {
Loading
Loading
@@ -228,6 +229,45 @@ func (r *repositoryData) addUpload(args []string, info fileInfo) error {
return nil
}
 
func (r *repositoryData) info(blobs blobsData) {
var layersUsed, layersUnused int
var manifestsUsed, manifestsUnused int
var tagsVersions int
var layersUsedSize, layersUnusedSize int64
for name, used := range r.layers {
blob := blobs[name]
if blob == nil {
continue
}
if used > 0 {
layersUsed++
layersUsedSize += blob.size
} else {
layersUnused++
layersUnusedSize += blob.size
}
}
for _, used := range r.manifests {
if used > 0 {
manifestsUsed++
} else {
manifestsUnused++
}
}
for _, tag := range r.tags {
tagsVersions += len(tag.versions)
}
logrus.Println("REPOSITORY INFO:", r.name, ":",
"Tags/Versions:", len(r.tags), "/", tagsVersions,
"Manifests/Unused:", manifestsUsed, "/", manifestsUnused,
"Layers/Unused:", layersUsed, "/", layersUnused,
"Data/Unused:", humanize.Bytes(uint64(layersUsedSize)), "/", humanize.Bytes(uint64(layersUnusedSize)))
}
func (r repositoriesData) process(segments []string, info fileInfo) error {
for idx := 0; idx < len(segments)-1; idx++ {
repository := segments[0:idx]
Loading
Loading
@@ -290,3 +330,9 @@ func (r repositoriesData) mark(blobs blobsData, deletes deletesData) error {
}
return nil
}
func (r repositoriesData) info(blobs blobsData) {
for _, repository := range r {
repository.info(blobs)
}
}
Loading
Loading
@@ -148,6 +148,6 @@ func (f *s3Storage) Delete(path string) error {
}
 
func (f *s3Storage) Info() {
logrus.Infoln("S3: API calls:", f.apiCalls,
logrus.Infoln("S3 INFO: API calls:", f.apiCalls,
"Cache (hit/miss/error):", f.cacheHits, f.cacheMiss, f.cacheError)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment