# Update Progress from mender client

**URL:** <https://hub.mender.io/t/update-progress-from-mender-client/5260>\
**Category:** General Discussions\
**Tags:** yocto, raspberry-pi-3, sumo, mender-client, dunfell\
**Created:** [September 19, 2022, 9:31am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260 "2022-09-19T09:31:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tactmaster](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/tactmaster/32/1709_2.png) [@tactmaster](https://hub.mender.io/u/tactmaster)\
**Post date:** [September 19, 2022, 9:31am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/1 "2022-09-19T09:31:10Z")

</div>

## Description

So we report our progress in % to our UI. We do this by getting the progress from “mender” i.e. mender client. We piped the output from mender indirectly to the UI

we did use mender client 1.x (in sumo) the output went to stout.  
I think since the upgrade to mender client 2.x (dunfell) the progress is not going to sdout.  
It display it on the terminal but it doesn’t seemed to get piped anymore.

I have tired various logging options. No joy  
What is the correct way of getting the progress from mender client.

Example use-cases:  
sudo mender -rootfs image.mender (worked)  
sudo mender install image.mender (doesn’t)

---

<div class="post-metadata">

**Author:** ![lluiscampos](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lluiscampos/32/112_2.png) [@lluiscampos](https://hub.mender.io/u/lluiscampos)\
**Post date:** [September 21, 2022, 8:59am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/2 "2022-09-21T08:59:13Z")

</div>

Hi @tactmaster,

In modern versions of mender, the progress for standalone install is written interactively to stdout. I think it might be hard to parse and update your GUI from that, though.

You’ll get something like:

```auto
INFO[0003] Opening device "/dev/hda3" for writing       
INFO[0003] Native sector size of block device /dev/hda3 is 512 bytes. Mender will write in chunks of 1048576 bytes 
............. - 21 %

```

and eventually:

```auto
......................................................................
time="2022-09-21T08:56:14Z" level=info msg="All bytes were successfully written to the new partition"

```

---

<div class="post-metadata">

**Author:** ![marcus](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marcus/32/1714_2.png) [@marcus](https://hub.mender.io/u/marcus)\
**Post date:** [September 21, 2022, 9:19am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/3 "2022-09-21T09:19:32Z")

</div>

Ed, if the percentage is written we should be able to capture that via a regex or something.

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [September 21, 2022, 9:34am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/4 "2022-09-21T09:34:16Z")

</div>

I have successfully parsed numeric output for projects, however, something to be aware of, early versions had an incrementing percentage numeric in the output, then at some point it was removed, this required me to create a custom patch for progress.go on my Yocto mender recipe to replace the new progress renderer with the old one. I had been meaning to create a ticket for this, as there should really be an option to change the type of progress renderer rather than replace it, as this was a breaking change for me.

> <https://github.com/mendersoftware/progressbar/blob/master/progress.go>

If it helps or serves as a starting point, the patch for my projects is below and may or may not apply cleanly depending on your version being used.

```auto
From 83cc8154732da938a63c2fe87198685b71abed5b Mon Sep 17 00:00:00 2001
From: Dell Green <dell.green@ideaworks.co.uk>
Date: Thu, 25 Feb 2021 14:29:35 +0000
Subject: [PATCH] add our own custom notty progress writer

---
 .../mendersoftware/progressbar/progress.go | 40 ++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/vendor/github.com/mendersoftware/progressbar/progress.go b/vendor/github.com/mendersoftware/progressbar/progress.go
index 8c1841a..6baf9ef 100644
--- a/vendor/github.com/mendersoftware/progressbar/progress.go
+++ b/vendor/github.com/mendersoftware/progressbar/progress.go
@@ -48,7 +48,7 @@ func New(size int64) *Bar {
 		}
 	} else {
 		return &Bar{
- Renderer: &NoTTYRenderer{
+ Renderer: &IwNoTTYRenderer{
 				Out: os.Stderr,
 				ProgressMarker: ".",
 				terminalWidth: 80,
@@ -134,3 +134,41 @@ func (p *NoTTYRenderer) Render(percentage int) {
 		fmt.Fprintf(p.Out, str)
 	}
 }
+
+type IwNoTTYRenderer struct {
+	Out io.Writer // Output device
+	ProgressMarker string
+	lastPercentage int
+	terminalWidth int
+}
+
+func (p *IwNoTTYRenderer) Render(percentage int) {
+	if percentage <= p.lastPercentage {
+ return
+	}
+	suffix := fmt.Sprintf(" %3d%%", percentage)
+	widthAvailable := p.terminalWidth - len(suffix)
+	number_of_dots := int((float64(widthAvailable) * float64(percentage)) / 100)
+	number_of_fillers := widthAvailable - number_of_dots
+	if percentage > 100 {
+ number_of_dots = widthAvailable
+ number_of_fillers = 0
+	}
+	if percentage < 0 {
+ return
+	}
+	if number_of_dots < 0 {
+ return
+	}
+	if number_of_fillers < 0 {
+ return
+	}
+	p.lastPercentage = percentage
+	fmt.Fprintf(p.Out, "%s%s%s\n",
+ strings.Repeat(p.ProgressMarker, number_of_dots),
+ strings.Repeat(" ", number_of_fillers),
+ suffix)
+	if percentage == 100 {
+ fmt.Fprintln(p.Out)
+	}
+}
-- 
2.25.1

```

---

<div class="post-metadata">

**Author:** ![tactmaster](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/tactmaster/32/1709_2.png) [@tactmaster](https://hub.mender.io/u/tactmaster)\
**Post date:** [December 5, 2022, 11:35am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/5 "2022-12-05T11:35:52Z")

</div>

Sorry for the late reply. Yes thank very much this worked. We updated mender client to match yours in dunfell but all is fine.

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [February 15, 2023, 10:31am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/6 "2023-02-15T10:31:02Z")

</div>

I have finally got around to putting up a ticket for this, will probably need discussion.

[https://tracker.mender.io/browse/MEN-6318](https://tracker.mender.io/browse/MEN-6318)

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [March 1, 2023, 9:28am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/7 "2023-03-01T09:28:42Z")

</div>

Issue has now been migrated to: [[MEN-6318] - Mender and CFEngine (by Northern.tech) Jira](https://northerntech.atlassian.net/browse/MEN-6318)

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [August 9, 2023, 9:06am UTC](https://hub.mender.io/t/update-progress-from-mender-client/5260/8 "2023-08-09T09:06:11Z")

</div>

Percentage based progress is scheduled to be added into the new C++ implementation of the client, and not the GO implementation.

[https://northerntech.atlassian.net/browse/MEN-6318](https://northerntech.atlassian.net/browse/MEN-6318)

[https://northerntech.atlassian.net/browse/MEN-6670](https://northerntech.atlassian.net/browse/MEN-6670)
