Giter Club home page Giter Club logo

Comments (10)

gazay avatar gazay commented on June 20, 2024

Sorry for delay, I will check it soon and write to you results :)

from gon.

wari avatar wari commented on June 20, 2024

top -b -n 1 should work.

On my side though, no matter what I use, ps, top, df, I don't get output with the top example. Heck, even if I use gon.watch.top = "Some String" does not work. I could only get it to work if I set gon.watch.top = Time.now in the controller. In the source, I do see `gon.top=" PID TTY TIME CMD\n 8<..snipped..8<", but nothing is seen in the html.

from gon.

fermuch avatar fermuch commented on June 20, 2024

@wari I solved the same problem using to_json. For example:

gon.watch.top = `top -b -n 1`.to_json

from gon.

gazay avatar gazay commented on June 20, 2024

Great @fermuch! I think I missed here to_json call on value https://github.com/gazay/gon/blob/master/lib/gon/watch.rb#L50. I have to check it

from gon.

wari avatar wari commented on June 20, 2024

Thanks @fermuch btw, @gazay I wanted to re-report this issue (as promised in rdrc), but hey, had a long holiday in Bali, and the internet is bad there. ;)

Still does not explain why Time.now works without converting to JSON

from gon.

hak8or avatar hak8or commented on June 20, 2024

Not sure if this is the right place for this, but I am also seeing the issue that gon.watch does not seem to work when passing in a string.

For example, gon.watch.var1 = "foo" does not work, but putting the string in an array like gon.watch.var1 = ["foo"] does work.

from gon.

fermuch avatar fermuch commented on June 20, 2024

There are some problems while using watch. Maybe the best to do is to call a to_json on every object, and then use base64 to pass the variable, so we avoid unexpected calls. So, the client has to first transform base64 into JSON, and then parse the JSON.

What do you think about this?

from gon.

tonydm avatar tonydm commented on June 20, 2024

I'm looking at a push solution and this seemed like the lightweight solution to fit my needs. So I tried the gon.watch.top example. Like to the others I ran into the issue with ubuntu 12x. Solved with suggestions posted. However, if I use the controller variable top (gon.watch.top), gon.watch.top or gon.all_variables returns nil (logged debug). If I change it to something else as in btop voila, values. The next issue is the data will not update the dom element. I get a continuous reload of the top.html.erb view but no data. It's a copy paste example and hard to screw up. The only change I made to example source was "top" to "btop". A view source shows the data getting picked up by gon.watch.btop but never makes it to the DOM. What might I be missing here?

TIA!

<!DOCTYPE html>
<html>
<head>
  <title>Testgon</title>
    <script type="text/javascript">
//<![CDATA[
window.gon={};gon.btop="\"top - 11:49:31 up 71 days, 20:19,  2 users,  load average: 0.06, 0.25, 0.22\\nTasks: 104 total,   1 running, 103 sleeping,   0 stopped,   0 zombie\\nCpu(s):  0.3%us,  0.1%sy,  0.0%ni, 99.1%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st\\nMem:   2051284k total,  1822624k used,   228660k free,   276680k buffers\\nSwap:   524284k total,    22856k used,   501428k free,   778912k cached\\n\\n  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            \\n    1 root      20   0 24336 1712  928 S  0.0  0.1   0:01.12 init               \\n    2 root      20   0     0    0    0 S  0.0  0.0   0:00.04 kthreadd           \\n    3 root      20   0     0    0    0 S  0.0  0.0  80:44.44 ksoftirqd/0        \\n    5 root      20   0     0    0    0 S  0.0  0.0   0:00.22 kworker/u:0        \\n    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0        \\n    7 root      RT   0     0    0    0 S  0.0  0.0   7:38.37 watchdog/0         \\n    8 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 cpuset             \\n    9 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 khelper            \\n   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kdevtmpfs          \\n   11 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 netns              \\n   12 root      20   0     0    0    0 S  0.0  0.0   1:12.21 sync_supers        \\n   13 root      20   0     0    0    0 S  0.0  0.0   0:01.93 bdi-default        \\n   14 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kintegrityd        \\n   15 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kblockd            \\n   16 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 ata_sff            \\n   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khubd              \\n   18 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 md                 \\n   21 root      20   0     0    0    0 S  0.0  0.0   0:05.81 khungtaskd         \\n   22 root      20   0     0    0    0 S  0.0  0.0   0:04.52 kswapd0            \\n   23 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd               \\n   24 root      39  19     0    0    0 S  0.0  0.0   0:00.00 khugepaged         \\n   25 root      20   0     0    0    0 S  0.0  0.0   0:00.01 fsnotify_mark      \\n   26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ecryptfs-kthrea    \\n   27 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 crypto             \\n   36 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kthrotld           \\n   37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_0          \\n   38 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_1          \\n   39 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kworker/u:2        \\n   41 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 binder             \\n   60 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 deferwq            \\n   61 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 charger_manager    \\n   62 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 devfreq_wq         \\n  178 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_2          \\n  201 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kdmflush           \\n  210 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kdmflush           \\n  222 root      20   0     0    0    0 S  0.0  0.0   4:09.01 jbd2/dm-0-8        \\n  223 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit    \\n  425 messageb  20   0 23948  992  716 S  0.0  0.0   0:00.10 dbus-daemon        \\n  440 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kpsmoused          \\n  609 root      20   0 15188  376  356 S  0.0  0.0   0:00.00 upstart-socket-    \\n  759 root      20   0  7264  684  548 S  0.0  0.0   0:16.55 dhclient3          \\n  859 root      20   0 14504  408  404 S  0.0  0.0   0:00.00 getty              \\n  864 root      20   0 14504  408  404 S  0.0  0.0   0:00.00 getty              \\n  874 root      20   0 14504  408  404 S  0.0  0.0   0:00.00 getty              \\n  875 root      20   0 14504  408  404 S  0.0  0.0   0:00.00 getty              \\n  879 root      20   0 14504  408  404 S  0.0  0.0   0:00.00 getty              \\n  897 root      20   0  4328  344  340 S  0.0  0.0   0:00.00 acpid              \\n  899 root      20   0 19112  664  508 S  0.0  0.0   0:34.38 cron               \\n  900 daemon    20   0 16908  116  104 S  0.0  0.0   0:00.46 atd                \\n  964 root      20   0  189m 7440 2668 S  0.0  0.4  26:59.45 apache2            \\n 1103 root      20   0 14508  740  736 S  0.0  0.0   0:00.00 getty              \\n 1257 root      20   0 73584 3680 2860 S  0.0  0.2   0:02.51 sshd               \\n 1440 root      20   0 12780  924  752 S  0.0  0.0   0:00.43 sftp-server        \\n 1641 root      20   0 50036 1292 1168 S  0.0  0.1   0:00.02 sshd               \\n 3327 root      20   0 25112 1488 1372 S  0.0  0.1   0:45.21 master             \\n 3331 postfix   20   0 27336 1604 1432 S  0.0  0.1   0:08.84 qmgr               \\n 5281 www-data  20   0  190m 5900 1080 S  0.0  0.3   0:00.00 apache2            \\n 6925 www-data  20   0  190m 5908  916 S  0.0  0.3   0:00.00 apache2            \\n 9240 root      20   0 73584 1716 1548 S  0.0  0.1   1:02.01 sshd               \\n 9431 root      20   0 12896 1088  796 S  0.0  0.1   0:13.11 sftp-server        \\n 9511 root      20   0 73440 2240 1492 S  0.0  0.1   0:00.01 sshd               \\n 9653 tonyd     20   0 74776 2260  632 S  0.0  0.1   1:56.10 sshd               \\n 9654 tonyd     20   0 28080 2504 1620 S  0.0  0.1   0:00.32 bash               \\n 9845 root      20   0 37888 1108 1104 S  0.0  0.1   0:00.01 sudo               \\n 9846 root      20   0 39528  980  980 S  0.0  0.0   0:00.00 su                 \\n 9847 root      20   0 24320 3940 1780 S  0.0  0.2   3:27.52 bash               \\n15625 syslog    20   0  243m 1812  932 S  0.0  0.1   3:57.66 rsyslogd           \\n16620 www-data  20   0  190m 5940  948 S  0.0  0.3   0:00.00 apache2            \\n16621 www-data  20   0  190m 5972  948 S  0.0  0.3   0:00.01 apache2            \\n16622 www-data  20   0  190m 5908  916 S  0.0  0.3   0:00.00 apache2            \\n16623 www-data  20   0  190m 5900  928 S  0.0  0.3   0:00.00 apache2            \\n16624 www-data  20   0  190m 5908  916 S  0.0  0.3   0:00.01 apache2            \\n16899 www-data  20   0  190m 5988  984 S  0.0  0.3   0:00.01 apache2            \\n16900 www-data  20   0  190m 5900  920 S  0.0  0.3   0:00.01 apache2            \\n18986 whoopsie  20   0  183m 1788 1444 S  0.0  0.1   0:00.31 whoopsie           \\n19004 root      20   0  103m  24m 3728 S  0.0  1.2  18:32.29 ruby               \\n20860 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 xfsalloc           \\n20861 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 xfs_mru_cache      \\n20862 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 xfslogd            \\n20865 root      20   0     0    0    0 S  0.0  0.0   0:00.00 jfsIO              \\n20866 root      20   0     0    0    0 S  0.0  0.0   0:00.00 jfsCommit          \\n20867 root      20   0     0    0    0 S  0.0  0.0   0:00.00 jfsSync            \\n21308 root      20   0 17236  400  400 S  0.0  0.0   0:00.00 upstart-udev-br    \\n21310 root      20   0 21456  804  772 S  0.0  0.0   0:00.00 udevd              \\n24913 mysql     20   0  865m  99m 7872 S  0.0  5.0   4:49.37 mysqld             \\n25240 root      20   0 21452  456  408 S  0.0  0.0   0:00.00 udevd              \\n25340 root      20   0  652m  65m 3252 S  0.0  3.3   1:18.46 ruby               \\n25347 ossecm    20   0 17176  640  460 S  0.0  0.0   2:17.14 ossec-maild        \\n25351 root      20   0 12808  392  368 S  0.0  0.0   0:06.52 ossec-execd        \\n25355 ossec     20   0 15164 2604  756 S  0.0  0.1   0:09.14 ossec-analysisd    \\n25359 root      20   0  4540  560  468 S  0.0  0.0   6:35.79 ossec-logcollec    \\n25371 root      20   0  5372 1800  744 S  0.0  0.1   6:55.21 ossec-syscheckd    \\n25374 ossec     20   0 13076  736  592 S  0.0  0.0   0:07.93 ossec-monitord     \\n27784 root      20   0 84524  20m 4504 S  0.0  1.0   9:52.30 ruby               \\n27861 root      20   0     0    0    0 S  0.0  0.0   0:00.58 kworker/0:1        \\n27958 root      20   0  768m 117m 5584 S  0.0  5.9   4:27.66 ruby               \\n28121 root      20   0  5920  608  512 S  0.0  0.0   0:00.09 tail               \\n28154 root      20   0     0    0    0 S  0.0  0.0   0:00.57 kworker/0:0        \\n28207 postfix   20   0 27176 1516 1244 S  0.0  0.1   0:00.00 pickup             \\n28332 root      20   0     0    0    0 S  0.0  0.0   0:00.27 kworker/0:2        \\n28654 root      20   0 17336 1244  932 R  0.0  0.1   0:00.00 top                \\n29078 root      20   0     0    0    0 S  0.0  0.0   1:42.28 flush-252:0        \\n30283 root      20   0  740m 162m 5672 S  0.0  8.1   6:08.10 ruby               \\n32461 www-data  20   0  190m 5932  952 S  0.0  0.3   0:00.00 apache2            \\n\\n\"";gon._timers = {};

gon.watch = function(name, possibleOptions, possibleCallback) {
  var callback, key, options, performAjax, timer, value, _base, _ref, _ref1;
  if (typeof $ === 'undefined' || $ === null) {
    return;
  }

...

from gon.

fermuch avatar fermuch commented on June 20, 2024

I cannot replicate your error. You can try by encoding to base64 and decoding in your function before using the data.

from gon.

tonydm avatar tonydm commented on June 20, 2024

No joe. I deleted and recreated the example project. Interestingly, when <%= include_gon :watch => true %> is included in the application.html layout file, the value of gon.watch.top = nil when logging the result out to log each time the top method is called. If I remove the include tag and call the top method then gon.watch.top has the result of the top -n1 -b call. Would there be a version conflict?

me@smi1:/www/testgon# rails -v
Rails 3.2.14
me@smi1:/www/testgon# 

from gon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.