Announcement

Collapse
No announcement yet.

Trying to send the hs3 memory usage to a mqtt ( only hs3 process)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to send the hs3 memory usage to a mqtt ( only hs3 process)

    So I created this file

    Code:
    #!/bin/sh
    #
    
    pids=$(pidof /usr/bin/mono /HomeSeer/HSConsole.exe); for p in ${pids[@]}; do cat /proc/$p/status | grep -i vmrss | awk '{print $2}'; done | while read m; do let t=$t+$m; echo $t; done | mosquitto_pub -h 127.0.0.1 -t Hs3/memory -m "$(tail -n 1)"

    the problem is that i get all the process run by mono ( all hs3). So it give me 1gb of memory used.

    when i replace the pidof with this :

    Code:
    #!/bin/sh
    #
    
    pids=$(pidof /usr/bin/mono /HomeSeer/HSConsole.exe --log); for p in ${pids[@]}; do cat /proc/$p/status | grep -i vmrss | awk '{print $2}'; done | while read m; do let t=$t+$m; echo $t; done | mosquitto_pub -h 127.0.0.1 -t Hs3/memory -m "$(tail -n 1)"
    I got an error that pidof do not recognise --log function.

    Maybe i have some error in the systaxe i posted here, but that is not important. the improtant thing is how to make '' /usr/bin/mono /HomeSeer/HSConsole.exe --log '' be recognized by pidoff ?

    thanks!!





  • #2
    ok... i am getting near of the goal with this :

    Code:
    #!/bin/sh
    #
    
    while true
    do
    
    t=$( ps axo rss,cmd | grep '/usr/bin/mono /HomeSeer/HSConsole.exe --log' | grep -v grep)
    
    mosquitto_pub -h 127.0.0.1 -t HS3/MemUSED -m "$t"
     sleep 30
    done

    But not able to remove the ''cmd'' for only using :

    ps axo rss | grep '/usr/bin/mono /HomeSeer/HSConsole.exe --log' | grep -v grep

    Comment


    • #3
      To be more explicit here is a picture of output i get when I send the command with or without ''cmd'' to the terminal ( and without of course getting anything via mqtt).


      With
      Code:
      ps axo rss,cmd | grep '/usr/bin/mono /HomeSeer/HSConsole.exe --log' | grep -v grep
      I get : 187252 /usr/bin/mono /HomeSeer/HSConsole.exe --log

      With
      Code:
      ps axo rss | grep '/usr/bin/mono /HomeSeer/HSConsole.exe --log' | grep -v grep
      I get : Nothing
      Attached Files

      Comment


      • #4
        ha.. i think Grep use the cmd attribute in a reverse manner to find the memory usage associated to it. So it is a little hard to remove ''cmd''

        Comment

        Working...
        X