Closed chip-and-dail closed 10 years ago
Any comment?
sorry, update comment
Can you run this in IRB?
df = `df --total`
df.split(" ").last.to_f.round(2)
1.9.3-p545 :001 > df = df --total
=> "Файловая система 1K-блоков Использовано Доступно Использовано% Cмонтировано в\n/dev/ploop34820p1 15479792 3323852 11369612 23% /\nnone 2097152 4 2097148 1% /dev\nnone 419432 1100 418332 1% /run\nnone 5120 0 5120 0% /run/lock\nnone 1677720 0 1677720 0% /run/shm\nnone 102400 0 102400 0% /run/user\ntotal 19781616 3324956 15670332 18%\n"
1.9.3-p545 :002 > df.split(" ").last.to_f.round(2)
=> 18.0
1.9.3-p545 :003 >
It run in the server?, because this is the code that returns the uw_diskused_perc, Probably the lang config is generating the error
yes, it's in the server
please, run in the terminal
$ env
wich lang is have you ?, in my case LANG=en_US.UTF-8
LANG=ru_RU.KOI8-R
what i must do?
complete
df = `df --total`.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
df.split(" ").last.to_f.round(2)
by http://robots.thoughtbot.com/fight-back-utf-8-invalid-byte-sequences
Hey @chip-and-dail excuse me for the delay, looks like your shell lang is not compatible with sub by default, if we replace all no utf-8 characters, probably some info will be lost. Even though, almost all linux methods are inherited from https://github.com/nethacker/usagewatch, so we have two options,
Yes, I'm overwrited. Thanks!
work: <%= @usw.uw_cpuused %> not work: <%= @usw.uw_diskused_perc %>
why?
P.S.
Distributor ID: Debian Release: 7.4 Codename: wheezy