MyController agent for Raspberry PI



  • You asked for suggestions so here's a couple for now....

    1. Monitor and report network lan traffic bandwidth used (maybe with options to see different types of traffic eg tcp/http/udp etc....).

    2. Get data for the number of packets sent/received by the nrf24l01+ attached to the pi.

    Still, it's working well now and very useful to see this info!



  • @Tag said:

    @jkandasa

    Thx!,
    Will keep an eye open for a new release!

    Just in the mean time, how to fill a variable from a file?, i have tried to get this using jscript however i am not a java programmer...

    i.e, ont the OrangePI in armbianthe cpu temp is stored here:

    /sys/class/thermal/thermal_zone0/temp
    and here is the cpu frequency

    /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
    Another nice one would be the memory usage:

    /sys/fs/cgroup/memory/memory.usage_in_bytes
    would it be possible to read these in a script and add them to the database?

    Thx!

    Hi @Tag
    Here is the javascript to read and update RPI-internal values to MyController DB.

    var myImports = new JavaImporter(java.io, java.lang, java.util, java.text, org.apache.commons.io.FileUtils);
    
    with(myImports) {
      //get Sensors with UID tag
      var temperatureSensor = mcApi.uidTag().getByUid("rpi-temperature").getResource();
      var memorySensor = mcApi.uidTag().getByUid("rpi-memory").getResource();
      //var cpuFreqSensor = mcApi.uidTag().getByUid("rpi-cpu-freq").getResource();
    
      var temperature = FileUtils.readFileToString(FileUtils.getFile("/sys/class/thermal/thermal_zone0/temp"));
      var memory = FileUtils.readFileToString(FileUtils.getFile("/sys/fs/cgroup/memory/memory.usage_in_bytes"));
      //var cpuFrequency = FileUtils.readFileToString(FileUtils.getFile("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq "));
    
      //Change values
      temperatureSensor.value = parseInt(temperature) / 1000;
      memorySensor.value = parseInt(memory);
      //cpuFreqSensor.value = parseInt(cpuFrequency);
    
      //Update to db
      mcApi.sensor().sendPayload(temperatureSensor);
      mcApi.sensor().sendPayload(memorySensor);
      //mcApi.sensor().sendPayload(cpuFreqSensor);
    }
    

    I have commented out CPU frequency read. It needs root privilage. If you want cpuFreqSensor to be executed, you need to run MyController as root user. For me cpuFreqSensor is useless value. It never change. It is up to you.

    To run this script you have to create dummy node(ex:rpi-internals-dummy) and dummy sensors for temperature, memory and cpuFrequency. And map all these sensors with UID tags to refer to the script.

    You can configure this script on timer to update temperature value for N minutes once.


  • MOD

    @jkandasa

    Got it working for the CPU temp!!
    Only problem is the CPU frequency and memory usage, for both i am not able to add a variable type when adding the sensor... this makes it impossible to add a uuid tag since the fake sensors memory and cpu simply do not show up when adding the uuid tag

    On the CPU frequency... the H2+ CPU is able to scale the frequency automagically between i.e 240mhz and 1.2Ghz... this saves power and therefore makes the CPU run cooler... my OPI zero is using 500mah max these days (only peeking to 1-1.2Ghz several times per minute)... so for me it interesting to see the cpu frequency, if it is high all the time, i might have a cpu hog somewhere...
    No need to run mysensors as root, i will create a root cronjob dumping the value into a file which is readable for the world, and read that file from your script;)

    Thanks for helping to get this work, i can imagine this script is very usefull for the MyController community!!!

    MyController just got even better!!
    (hard to imagine but it seems possible!)



  • @Tag said:

    Only problem is the CPU frequency and memory usage, for both i am not able to add a variable type when adding the sensor... this makes it impossible to add a uuid tag since the fake sensors memory and cpu simply do not show up when adding the uuid tag

    If you use the SNAPSHOT version of MyController you can see CPU/Memory. I hope it will work only for MyController type gateway.

    Another way, You can map CPU and Memory with >> Custom type and Variable 1 and Variable 2. Edit both variables and set Metric type as Double. Now all set.


  • MOD

    @jkandasa

    Did some testing, got the memory usage setup as you pointed out.
    Mapped memory to type custom and variable1. Now it shows the memory usage! (i divided it by 1024 to see the Kb's in use, since that gives me a more usable number)

    CPU is still work in progress, will keep you posted!, many thanks for the help!!



  • @jkandasa
    I have followed your instructions to setup the MCAgent, and its up and running.
    I need only rpi-internal node hence I commented the following line in mcagent.properties file.
    mcac.node.name.gpio=rpi-gpio

    But I still see a node being created EUI as rpi-gpio whenever I restart the mcagent.
    Can you please help me with this?

    In devices.yaml file is it possible for me to change the ids i.e. can id: cpu_temperature be changed to id: CPU_TEMP?



  • @naguraob Do not comment mcac.node.name.gpio=rpi-gpio on mcagent.properties. Just delete or disable[enabled: false] gpio_devices devices on devices.yaml.

    In devices.yaml file is it possible for me to change the ids i.e. can id: cpu_temperature be changed to id: CPU_TEMP?

    Yes you can change to any name.

    Do restart mcagent when you change anything on mcagent.properties or on devices.yaml



  • @Tag Now McAgent supports for Orange PI. with some known issues. Kindly use SNAPSHOT version

    My OrangePiZero (512MB) gets super heat when I use MyController on this. Do you use any heatsink?


  • MOD

    @jkandasa

    Appologies for the delay......Took some time, but mcagent is installed on my OPI-0, 🙂
    setup with the manual you provided, works.

    I can see 4 sensors, however it seems that:

    • cpu voltage is not updated.
    • the CPU temp is shown as 0.049c instead of 49c

    0_1509460086590_Screenshot 2017-10-31 at 15.26.50.png

    rest is perfect!.

    When you mention "hot" on the orangepi, what kind of values do you see?
    I have got 2 OPI-zero boards, one that shows me approx 36 degrees, and one that shows 49 degrees, with the same SD card.... but... both are the same temp, it seems that there are allwinner chips or opi-zero boards(rev 1.4) that have a temp measuring error. At this moment installing mcagent does not increase the cputemp as far as i can see...

    This is how i keep my system "cool"

    • OPI-0 has a heatsink installed (no fan required)
    • The cpu frequency to 912mhz max, this setting also limits the voltage used.
    h3consumption -m 912mhz
    
    • cpufequency govenor = interactive
      check with:
    cpufreq-info
    

    Which image do you use (in my opinion armbian jesse is still the best..)
    and what is "hot" 🙂 can you keep your finger on the cpu for a minute?



  • @tag Thank you for the feedback.

    the CPU temp is shown as 0.049c instead of 49c

    I have filed an issue with pi4j. Seems it's fixed. Let me check with recent version and update.
    https://github.com/Pi4J/pi4j/issues/356

    Which image do you use (in my opinion armbian jesse is still the best..)

    Yes, I too use armbian. Which is super cool image for Orange PI

    and what is "hot" 🙂 can you keep your finger on the cpu for a minute?

    Sure, Will update you 🙂


 

Suggested Topics

11
Online

407
Users

371
Topics

2.3k
Posts