DietPi icon indicating copy to clipboard operation
DietPi copied to clipboard

dietpi-cloudshell - Scene Selection - Network Usage, CPU, Storage, Network Details (only locales change)

Open k-plan opened this issue 10 years ago • 35 comments

Hi Fourdee, tested on Odroid C1+ (Jessie: v.109) (locales: en_GB.UTF-8) (root filesystem is on USB device) :

  • Install (apt-get install iperf) and start iperf (server) root@oDroide-C1:~# iperf -s -f m -i 10
  • Start dietpi-cloudshell (v4) on Odroid.
  • Start iperf (client) on a wired local network connected PC: admin@PC$ iperf -c 10.10.10.10 -f m -i 2 -d -t 360
  • Do same more iperf speed test and watch output on dietpi-cloudshell

Result, if more traffic when 9999 MB is generated: 160214-0004 Is dietpi-cloudshell not able to print traffic in GB?


  • While iperf is running, watch Scene : CPU and root@oDroide-C1:~# htop

Result: 160214-0006 160214-0005 How come margin?


  • Watch Scene : Storage / Memory:

Result: 160220-0002 160214-0003

root filesystem is on USB device (https://github.com/Fourdee/DietPi/issues/200)


  • Now change setting locales: en_GB.UTF-8 to locales: de_DE.UTF-8
  • Watch Scene : Network Details:

Result:

160214-0002


Be in doubt, if it is better to split this issue or post it in your forum. Thanks for your assistance.

cu k-plan

k-plan avatar Feb 20 '16 20:02 k-plan

Network Usage Scene

160214-0004

The values are pulled in directly from the network adapters stats:

NETWORK_USAGE_TOTAL_SENT=$(( $(cat /sys/class/net/$NETWORK_DETAILS_ADAPTER/statistics/tx_bytes) / 1000000 ))
NETWORK_USAGE_TOTAL_RECIEVED=$(( $(cat /sys/class/net/$NETWORK_DETAILS_ADAPTER/statistics/rx_bytes) / 1000000 ))

Yep, values are being reset by system. Some sort of cap?:

root@DietPi-XU4:~# echo -e "$(( $(cat /sys/class/net/eth0/statistics/tx_bytes) / 1000000 ))"
4283
root@DietPi-XU4:~# echo -e "$(( $(cat /sys/class/net/eth0/statistics/tx_bytes) / 1000000 ))"
98

Pull data from ifconfig instead?

root@DietPi-XU4:~# ifconfig eth0
eth0      Link encap:Ethernet  Hardware Adresse 00:1e:06:30:07:2b
          inet Adresse:192.168.0.111  Bcast:192.168.0.255  Maske:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:917 errors:0 dropped:0 overruns:0 frame:0
          TX packets:883 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000
          RX bytes:202364 (197.6 KiB)  TX bytes:143650 (140.2 KiB)

Ifconfigis being reset aswell. It must also be pulling the same values from /sys/class/net/eth0/statistics/tx_bytes

Fourdee avatar Feb 21 '16 14:02 Fourdee

CPU Scene

160214-0006 160214-0005

Looks like we are missing a few processes in the total calculations.

#Current code
root@DietPi-XU4:~# ps xo %cpu | sed '1d' | sed 's/ //' | wc -l
129

#New code
root@DietPi-XU4:~# ps axo %cpu | sed '1d' | sed 's/ //' | wc -l
134

untitled

Seems to be correct. 26~% of 8 cores = 2 cores at 100%. Will need to verify updated script on your C1.

Also, worth noting DietPi-Cloudshell is launched with nice +10. So there may be a delay before the scene update is processed during high system load.

Fourdee avatar Feb 21 '16 15:02 Fourdee

Storage Scene

160220-0002

Due to alternative rootFS mount.

The recent DietPi-Cleaner RootFS fix (https://github.com/Fourdee/DietPi/issues/200#issuecomment-185931543) has been rolled out to the dietpi-obtain_hw_model script https://github.com/Fourdee/DietPi/commit/a1b3d59a61eaf072aab7bafa090b3031e19e0358?diff=split. DietPi-Cloudshell + other DietPi scripts that use it, will now pull the correct RootFS (Flash storage), regardless of physical mount location.

Resolved for v110.

Fourdee avatar Feb 21 '16 15:02 Fourdee

Network Details Scene

160214-0002

Most likely due to NETWORK_DETAILS_IP_INT=$(cat "$FP_TEMP" | grep -m1 'inet addr:'| cut -d: -f2 | awk '{ print $1}') expected value inet addr changes when in de locale.

We can grab MAC with the following: cat /sys/class/net/eth0/address

We can find ip address using following ("inet " is same regardless of locale): ifconfig eth0 | grep -m1 'inet '| cut -d: -f2 | awk '{ print $1}'

Fourdee avatar Feb 21 '16 15:02 Fourdee

@k-plan Thanks for the reports. I've separated them into sections. I will update each section whilst working on them.

Fourdee avatar Feb 21 '16 15:02 Fourdee

@ Storage Scene

Due to no swap?

Use DietPi default swapfile:

root@oDroid-C1:~# dphys-swapfile setup
want /var/swap=100MByte, checking existing: keeping it

root@oDroid-C1:~# ls -la /var/swap
-rw------- 1 root root 104857600 Feb 14 23:04 /var/swap

k-plan avatar Feb 21 '16 16:02 k-plan

@k-plan

Use DietPi default swapfile:

free -m -o

#total swap size
free -m -o  | grep -m1 'Swap: ' | awk '{print $2}'

0 = disabled. Works regardless of swapfile or swap partition.

Fourdee avatar Feb 21 '16 16:02 Fourdee

@Fourdee

root@oDroid-C1:~# free -m -o
             total       used       free     shared    buffers     cached
Mem:           948        146        802          6          6         34
Swap:            0          0          0

root@oDroid-C1:~# free -m -o  | grep -m1 'Swap: ' | awk '{print $2}'
0

Hmm, generating a new swapfile via dietpi-config:

root@oDroid-C1:~# dietpi-config

DietPi: Deleting existing swapfile
 - /var/swap

DietPi: Generating new swapfile
 - 105 MB
 - /var/swap
please wait...

want /var/swap=105MByte, generating swapfile ...

root@oDroid-C1:~# free -m -o
             total       used       free     shared    buffers     cached
Mem:           948        255        693          6          6        140
Swap:          104          0        104

root@oDroid-C1:~# free -m -o  | grep -m1 'Swap: ' | awk '{print $2}'
104

Hmm, let's do a reboot ...

root@oDroid-C1:~#reboot

root@oDroid-C1:~# free -m -o  | grep -m1 'Swap: ' | awk '{print $2}'
104

160221-0001

:0) :+1:

  • Now change setting locales: en_GB.UTF-8 =>> locales: de_DE.UTF-8 and reboot

160221-0002

root@oDroid-C1:~# free -m -o
             total       used       free     shared    buffers     cached
Mem:           948        140        807          6          5         33
Swap:          104          0        104

Hmm, display Memory RAM [BAR] doesn't match any more.

k-plan avatar Feb 21 '16 16:02 k-plan

@k-plan

Hmm, display Memory RAM [BAR] doesn't match any more.

Can you please run this command whilst in de_DE:

MEMORY_USED=105;MEMORY_TOTAL=948;echo -e "$(echo | awk "{print $MEMORY_USED / $MEMORY_TOTAL * 100}")"

Should return 11.0759

Fourdee avatar Feb 21 '16 17:02 Fourdee

@Fourdee

Can you run this command whilst in de_DE:

root@oDroid-C1:~# MEMORY_USED=105;MEMORY_TOTAL=948;echo -e "$(echo | awk "{print $MEMORY_USED / $MEMORY_TOTAL * 100}")"
11.0759

k-plan avatar Feb 21 '16 17:02 k-plan

@Fourdee

Make sure the Memory usage scene is enabled, then run:

Done.

160221-0004

k-plan avatar Feb 21 '16 18:02 k-plan

Memory Usage Scene

160214-0003

Nan! swapfile:

DietPi-Cloudshell will now check for a active swap, before running calculations: https://github.com/Fourdee/DietPi/commit/2e8799066f8aaa0ef955cdbbea18ecb533853ed7

@k-plan

0% Ram graph is due to de_DE.UTF-8 breaking printf when using a float input:

#en_GB float
root@DietPi:~# MEMORY_PERCENT=11.12345;printf %0.f $MEMORY_PERCENT
11

#de_DE float
root@DietPi-XU4:~# MEMORY_PERCENT=11.12345;printf %0.f $MEMORY_PERCENT
-bash: printf: 11.0005352: Ungültige Zahl.

#de_DE int
root@DietPi-XU4:~# MEMORY_PERCENT=11;printf %0.f $MEMORY_PERCENT
11

Not sure how to resolve the above. Are printf command line options different in other locales?

Fourdee avatar Feb 21 '16 19:02 Fourdee

@Fourdee

Not sure how to resolve the above. Are printf command line options different in other locales?

No, not printf command line options cause the problem, it's the decimal delimiter symbol for numbers.

locales: en_GB.UTF-8 =>> " . "

locales: de_DE.UTF-8 =>> " , "

root@oDroid-C1:~# MEMORY_PERCENT=11.12345;printf %0.f $MEMORY_PERCENT
-bash: printf: 11.12345: Ungültige Zahl.
root@oDroid-C1:~# MEMORY_PERCENT=11,12345;printf %0.f $MEMORY_PERCENT
11

k-plan avatar Feb 21 '16 19:02 k-plan

Network Details Scene

160214-0002

@Fourdee

Most likely due to NETWORK_DETAILS_IP_INT=$(cat "$FP_TEMP" | grep -m1 'inet addr:'| cut -d: -f2 | awk '{ print $1}') expected value inet addr changes when in de locale.

We can grab MAC with the following: cat /sys/class/net/eth0/address

Odroid C1+ use eth1 instead of eth0:

root@oDroid-C1:~# cat /sys/class/net/eth1/address
00:1e:06:30:07:2b

We can find ip address using following ("inet " is same regardless of locale): ifconfig eth0 | grep -m1 'inet '| cut -d: -f2 | awk '{ print $1}'

root@oDroid-C1:~# ifconfig eth1 | grep -m1 'inet '| cut -d: -f2 | awk '{ print $1}'
192.168.0.111

If I can help you with another testing, let me know.

k-plan avatar Feb 21 '16 20:02 k-plan

@k-plan

No, not printf command line options cause the problem, it's the decimal delimiter symbol for numbers. locales: en_GB.UTF-8 =>> " . " locales: de_DE.UTF-8 =>> " , "

Interesting, but also really bizarre. I've never seen , being used as a decimal delimiter in any coding language. I suppose thats a bash and printf "thing".

Ok, so this will also affect all the Percent_To_Graph $(printf %.0f $MEMORY_SWAPERCENT) functions we use for the graphs. That is, if the input is a float.

I suppose we could try echoing the float and using cut to remove any values after and including the decimal place. This works on both en_GB and de_DE:

root@DietPi:~# TEST=123.456;echo $TEST | cut -d. -f1
123

Means I'll need to change all references to the function, but it will resolve the current language/printf issue.

Fourdee avatar Feb 21 '16 20:02 Fourdee

@Fourdee

Interesting, but also really bizarre. I've never seen ,being used as a decimal delimiter in any coding language.

Correct, nothing to do with coding language, its a problem of numeral system (Decimal mark).

https://en.wikipedia.org/wiki/Decimal_mark#Influence_of_calculators_and_computers

Didn't help, but it's not your fault. Sorry, because you now have a lot of work.

k-plan avatar Feb 21 '16 20:02 k-plan

@k-plan

Correct, nothing to do with coding language, its a problem of numeral system (Decimal mark). https://en.wikipedia.org/wiki/Decimal_mark#Influence_of_calculators_and_computers

Ah, thanks for the info. :+1:

Didn't help, but it's not your fault. Sorry, because you now have a lot of work.

Changing the function is a 5 minute job at most. Its just getting those 5 minutes to be available thats the issue lol.

I'll update you when the changes are completed. I will then provide you with the details to upgrade dietpi-cloudshell on your system. I would appreciate if you test and verify all the issues are fixed. I'll let you know when its ready.

Fourdee avatar Feb 21 '16 22:02 Fourdee

@k-plan I just need to resolve the network usage scene. Ifconfig RX/TX stats are also being reset, so that must pull data from /sys/class/net/$NETWORK_DETAILS_ADAPTER/statistics/tx_bytesalso.

I may need to use a 3rd party program that allows us to monitor network usage, without being reset.

Fourdee avatar Feb 22 '16 16:02 Fourdee

@Fourdee Hmm, is slurm something you are looking for? And yes, Decimal mark is a .(dot) in slurm. ;)

slurm_0 4 2

root@oDroid-C1:~# apt-get install slurm

Speed is measured in KB/s not in MBit/s, a thing that bother me in slurm. You also have a look at this collection of usefull stuff.

k-plan avatar Feb 22 '16 18:02 k-plan

@k-plan Tried slurm, nload and iftop.

None of these allow for single run, then exit. They must be run in the background, writing to a file that we would need to parse (not ideal).

netstat seems to be the best option, but we need to calculate MTU size (bytes) against total packets.

local mtu_size=$(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $2}')
NETWORK_USAGE_TOTAL_RECIEVED=$(( $(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $4}') * $mtu_size / 1024 / 1024 ))
NETWORK_USAGE_TOTAL_SENT=$(( $(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $8}') * $mtu_size / 1024 / 1024 ))

I've received over 20GB and the values have not reset :)

Note to self: apt-get install net-tools, check all DietPi systems.

Fourdee avatar Feb 22 '16 19:02 Fourdee