From 66def933731de59e2c9ee8ec5fda76602a45cfca Mon Sep 17 00:00:00 2001 From: Hekmon Date: Mon, 5 Oct 2020 12:31:01 +0200 Subject: [PATCH] mount cmd: update systemd status with cache stats --- vfs/vfscache/cache.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vfs/vfscache/cache.go b/vfs/vfscache/cache.go index 11958138b..3670e7058 100644 --- a/vfs/vfscache/cache.go +++ b/vfs/vfscache/cache.go @@ -13,6 +13,7 @@ import ( "sync" "time" + sysdnotify "github.com/iguanesolutions/go-systemd/v5/notify" "github.com/pkg/errors" "github.com/rclone/rclone/fs" fscache "github.com/rclone/rclone/fs/cache" @@ -652,7 +653,12 @@ func (c *Cache) clean(removeCleanFiles bool) { c.mu.Unlock() uploadsInProgress, uploadsQueued := c.writeback.Stats() - fs.Infof(nil, "vfs cache: cleaned: objects %d (was %d) in use %d, to upload %d, uploading %d, total size %v (was %v)", newItems, oldItems, totalInUse, uploadsQueued, uploadsInProgress, newUsed, oldUsed) + stats := fmt.Sprintf("objects %d (was %d) in use %d, to upload %d, uploading %d, total size %v (was %v)", + newItems, oldItems, totalInUse, uploadsQueued, uploadsInProgress, newUsed, oldUsed) + fs.Infof(nil, "vfs cache: cleaned: %s", stats) + if err = sysdnotify.Status(fmt.Sprintf("[%s] vfs cache: %s", time.Now().Format("15:04"), stats)); err != nil { + fs.Errorf(nil, "vfs cache: updating systemd status with current stats failed: %s", err) + } } // cleaner calls clean at regular intervals and upon being kicked for out-of-space condition