Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux dash widgets aren't loading [Ubuntu + Python] #453

Closed
mhellmeier opened this issue Dec 27, 2017 · 17 comments
Closed

linux dash widgets aren't loading [Ubuntu + Python] #453

mhellmeier opened this issue Dec 27, 2017 · 17 comments

Comments

@mhellmeier
Copy link
Contributor

The Problem

I tried to install linux dash but it isn't working: The widgets loading the hole time:
linux-dash-problem

The widgets "CPU Avg Load" and "CPU Utilization" seem to work:
linux-dash-problem2

Steps to reproduce

Cloning the git repository and starting linux dash using python:

git clone --depth 1 https://github.com/afaqurk/linux-dash.git
cd linux-dash/app/server
python index.py --port 8500

I also tried running python with sudo or download the master.zip file using curl, but I run into the same problem

After starting the Server with sudo python index.ph --port 8500 I got: Starting server, use <Ctrl-C> to stop

If a open Linux Dash in my Chrome browser, I get the following console output on my server:

127.0.0.1 - - [27/Dec/2017 17:29:48] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [27/Dec/2017 17:29:48] "GET /linuxDash.min.css HTTP/1.1" 200 -
127.0.0.1 - - [27/Dec/2017 17:29:48] "GET /linuxDash.min.js HTTP/1.1" 200 -
127.0.0.1 - - [27/Dec/2017 17:29:49] code 404, message File Not Found: /websocket
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /websocket HTTP/1.1" 404 -
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=current_ram HTTP/1.1" 200 -
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=swap HTTP/1.1" 200 -
top: Invalid user
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=disk_partitions HTTP/1.1" 200 -
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=cpu_intensive_processes HTTP/1.1" 200 -
top: bad pid 'ython'
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=ram_intensive_processes HTTP/1.1" 200 -
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=load_avg HTTP/1.1" 200 -
top: bad pid 's'
top: unknown option 'a'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: bad delay interval 'f'
top: unknown option 'a'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
127.0.0.1 - - [27/Dec/2017 17:29:49] "GET /server/?module=docker_processes HTTP/1.1" 200 -
127.0.0.1 - - [27/Dec/2017 17:29:52] "GET /server/?module=cpu_utilization HTTP/1.1" 200 -

The Chrome console also shows some errors:

Failed to load resource: the server responded with a status of 404 (File Not Found: /websocket)
linuxDash.min.js:101 SyntaxError: Unexpected token \ in JSON at position 2
    at JSON.parse (<anonymous>)
    at oc (linuxDash.min.js:14)
    at Yb (linuxDash.min.js:76)
    at linuxDash.min.js:77
    at r (linuxDash.min.js:7)
    at Vc (linuxDash.min.js:77)
    at c (linuxDash.min.js:78)
    at linuxDash.min.js:111
    at k.$eval (linuxDash.min.js:125)
    at k.$digest (linuxDash.min.js:122)
(anonymous) @ linuxDash.min.js:101
linuxDash.min.js:101 SyntaxError: Unexpected token \ in JSON at position 3
    at JSON.parse (<anonymous>)
    at oc (linuxDash.min.js:14)
    at Yb (linuxDash.min.js:76)
    at linuxDash.min.js:77
    at r (linuxDash.min.js:7)
    at Vc (linuxDash.min.js:77)
    at c (linuxDash.min.js:78)
    at linuxDash.min.js:111
    at k.$eval (linuxDash.min.js:125)
    at k.$digest (linuxDash.min.js:122)
(anonymous) @ linuxDash.min.js:101
2linuxDash.min.js:101 SyntaxError: Unexpected token \ in JSON at position 4
    at JSON.parse (<anonymous>)
    at oc (linuxDash.min.js:14)
    at Yb (linuxDash.min.js:76)
    at linuxDash.min.js:77
    at r (linuxDash.min.js:7)
    at Vc (linuxDash.min.js:77)
    at c (linuxDash.min.js:78)
    at linuxDash.min.js:111
    at k.$eval (linuxDash.min.js:125)
    at k.$digest (linuxDash.min.js:122)
(anonymous) @ linuxDash.min.js:101
linuxDash.min.js:101 SyntaxError: Unexpected token \ in JSON at position 2
    at JSON.parse (<anonymous>)
    at oc (linuxDash.min.js:14)
    at Yb (linuxDash.min.js:76)
    at linuxDash.min.js:77
    at r (linuxDash.min.js:7)
    at Vc (linuxDash.min.js:77)
    at c (linuxDash.min.js:78)
    at linuxDash.min.js:111
    at k.$eval (linuxDash.min.js:125)
    at k.$digest (linuxDash.min.js:122)
(anonymous) @ linuxDash.min.js:101
linuxDash.min.js:101 SyntaxError: Unexpected token \ in JSON at position 4
    at JSON.parse (<anonymous>)
    at oc (linuxDash.min.js:14)
    at Yb (linuxDash.min.js:76)
    at linuxDash.min.js:77
    at r (linuxDash.min.js:7)
    at Vc (linuxDash.min.js:77)
    at c (linuxDash.min.js:78)
    at linuxDash.min.js:111
    at k.$eval (linuxDash.min.js:125)
    at k.$digest (linuxDash.min.js:122)
(anonymous) @ linuxDash.min.js:101
linuxDash.min.js:1984 Uncaught TypeError: Cannot set property 'width' of undefined
    at linuxDash.min.js:1984
    at c (linuxDash.min.js:32)

My System

> lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial
> python --version
Python 2.7.12
@duckzito
Copy link

duckzito commented Jan 1, 2018

Try this: edit linux_json_api.sh and replace "s/\"/\\\\\"/g" with 's/\\//g' on _parseAndPrint function.
The line should look like this: $ECHO -n "$data" | $SED -r 's/\\//g' | $TR -d "\n";

I tried it in go version and it's working.

@mhellmeier
Copy link
Contributor Author

Thanks @duckzito , it solved my problem!
I think this is a Linux Dash bug, isn't it!? I will create a pull request.

@carnivorouz
Copy link

Thanks @duckzito, also worked for me on korora running it with python.

@davidawad
Copy link

davidawad commented Mar 5, 2018

just confirming that this is still an issue with the latest release of this repo. I encountered it today and the above suggested fix solved the problem for me.

@vsxen
Copy link

vsxen commented Mar 18, 2018

you can replace | _parseAndPrint with #| _parseAndPrint or delete | _parseAndPrint

@TwanoO67
Copy link

TwanoO67 commented Jun 12, 2018

Hello,

I have the same problem here, on Ubuntu + PHP

top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: bad pid 's'
top: unknown option 'a'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'l'
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
top: unknown option 'a'

But the solution of @duckzito didn't work

@alozovskoy
Copy link
Contributor

@TwanoO67 , this error is because linux-dash try to get docker information, and if you dont have docker ("type -P docker" return nothing) arguments pass to top command, not for "docker top". Solution of @duckzito is for fixing json formatter, it's another issue.

Do you have errors in browser developer console?

@TwanoO67
Copy link

Hi @alozovskoy ,
I had to remove linux-dash as it was flooding my server with errors twice by second.
Is there no test to know which module (like docker) is installed or not on the server, before trying to get its state ?

@alozovskoy
Copy link
Contributor

Hi @TwanoO67 ,
At now - no test. I maked simple check for a docker (#466), so now i dont get any errors like this, but i didn't do a full rewiev of all functions so you may get an another errors about some uncorrect call of another function.

@SuperSpe
Copy link

this solved my problem too!
what about cpu temp?

ppp225 added a commit to ppp225/linux-dash that referenced this issue Aug 30, 2019
srogovtsev added a commit to srogovtsev/linux-dash that referenced this issue Dec 21, 2019
tariqbuilds added a commit that referenced this issue Mar 22, 2020
Fix #453 - Linux Dash Python widget loading problem
@mildmojo
Copy link

mildmojo commented Mar 23, 2020

FWIW, I just cloned the repo today to try it out, and none of the boxes were loading for me (Ubuntu 19.10, running using the NodeJS ./bin/linux-dash). I did the reverse of duckzito's first advice. This fixed it for me:

  1. Edit app/server/linux_json_api.sh
  2. In _parseAndPrint, change 's/\\//g' to "s/\"/\\\\\"/g"

Here's the patch:

diff --git a/app/server/linux_json_api.sh b/app/server/linux_json_api.sh
index 16f573e..1bbea30 100755
--- a/app/server/linux_json_api.sh
+++ b/app/server/linux_json_api.sh
@@ -12,7 +12,7 @@ PS=$(type -P ps)
 
 _parseAndPrint() {
   while read data; do
-    $ECHO -n "$data" | $SED -r 's/\\//g' | $TR -d "\n";
+    $ECHO -n "$data" | $SED -r "s/\"/\\\\\"/g" | $TR -d "\n";
   done;
 }

@AnotherDaniel
Copy link

FWIW, I just cloned the repo today to try it out, and none of the boxes were loading for me (running using the NodeJS ./bin/linux-dash). I did the reverse of duckzito's first advice. This fixed it for me:

1. Edit `app/server/linux_json_api.sh`

2. In `_parseAndPrint`, change `'s/\\//g'` to `"s/\"/\\\\\"/g"`

Here's the patch:

diff --git a/app/server/linux_json_api.sh b/app/server/linux_json_api.sh
index 16f573e..1bbea30 100755
--- a/app/server/linux_json_api.sh
+++ b/app/server/linux_json_api.sh
@@ -12,7 +12,7 @@ PS=$(type -P ps)
 
 _parseAndPrint() {
   while read data; do
-    $ECHO -n "$data" | $SED -r 's/\\//g' | $TR -d "\n";
+    $ECHO -n "$data" | $SED -r "s/\"/\\\\\"/g" | $TR -d "\n";
   done;
 }

Same here - in my case, I just migrated a bunch of stuff from a Raspi 3 to a 4, linux-dash one of them.
On the 3, the short regex worked ('s/\//g'). On the 4, I get the issue reported by OP. But when reverting to the long regex ("s/"/\\"/g"), things are fine again on the 4.

On the 3 I was running Raspian strech, while the 4 is running buster...

@PrzemekSkw
Copy link

@AnotherDaniel Hi, I have the same bug in Debian 10 and Your solution help me. Thank You.
Regards.

@fitzroymckay
Copy link

FWIW, I just cloned the repo today to try it out, and none of the boxes were loading for me (Ubuntu 19.10, running using the NodeJS ./bin/linux-dash). I did the reverse of duckzito's first advice. This fixed it for me:

  1. Edit app/server/linux_json_api.sh
  2. In _parseAndPrint, change 's/\\//g' to "s/\"/\\\\\"/g"

Here's the patch:

diff --git a/app/server/linux_json_api.sh b/app/server/linux_json_api.sh
index 16f573e..1bbea30 100755
--- a/app/server/linux_json_api.sh
+++ b/app/server/linux_json_api.sh
@@ -12,7 +12,7 @@ PS=$(type -P ps)
 
 _parseAndPrint() {
   while read data; do
-    $ECHO -n "$data" | $SED -r 's/\\//g' | $TR -d "\n";
+    $ECHO -n "$data" | $SED -r "s/\"/\\\\\"/g" | $TR -d "\n";
   done;
 }

Thank you! Tried it on ElementaryOS 5.1.7, worked like a charm

@ecdeveloper
Copy link

How come this issue is closed given that the bug is still there? I had the same exact problem and had to manually update the linux_json_api making the change from the suggested snippet to fix it.

@dylanjamesdev
Copy link

Agreed

@ugur1yildiz
Copy link

FWIW, I just cloned the repo today to try it out, and none of the boxes were loading for me (Ubuntu 19.10, running using the NodeJS ./bin/linux-dash). I did the reverse of duckzito's first advice. This fixed it for me:

  1. Edit app/server/linux_json_api.sh
  2. In _parseAndPrint, change 's/\\//g' to "s/\"/\\\\\"/g"

Here's the patch:

diff --git a/app/server/linux_json_api.sh b/app/server/linux_json_api.sh
index 16f573e..1bbea30 100755
--- a/app/server/linux_json_api.sh
+++ b/app/server/linux_json_api.sh
@@ -12,7 +12,7 @@ PS=$(type -P ps)
 
 _parseAndPrint() {
   while read data; do
-    $ECHO -n "$data" | $SED -r 's/\\//g' | $TR -d "\n";
+    $ECHO -n "$data" | $SED -r "s/\"/\\\\\"/g" | $TR -d "\n";
   done;
 }

FYI. This change fails for node.js, If you intend to use node.js, don't apply this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests