Monitoring RPi Temp and CPU with Thingspeak

I made the following python script to update CPU Temperature and 5 minute average CPU load of my RPi to Thingspeak:

#!/usr/bin/env python
import subprocess
import httplib, urllib

GetTempCommand = "cat /sys/class/thermal/thermal_zone0/temp"
GetCPUCommand = "cat /proc/loadavg"

GetTempProcess = subprocess.Popen(GetTempCommand.split(), stdout=subprocess.PIPE)
GetTempOutput = GetTempProcess.communicate()[0]
Temp = float(GetTempOutput) / 1000
#print Temp
GetCPUProcess = subprocess.Popen(GetCPUCommand.split(), stdout=subprocess.PIPE)
GetCPUOutput = GetCPUProcess.communicate()[0]
CPU = GetCPUOutput.split()
#print CPU[1]

params = urllib.urlencode({'field1': CPU[1],'field2': Temp, 'key':'######'})     # use your API key generated in the thingspeak channels for the value of 'key'
# temp is the data you will be sending to the thingspeak channel for plotting the graph. You can add more than one channel and plot more graphs
headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")                
try:
    conn.request("POST", "/update", params, headers)
    response = conn.getresponse()
    data = response.read()
    conn.close()
except:
    print "connection failed"

The script is run every 5 mins using cron ($ crontab -e):

*/5 * * * * python "/home/ubuntu/logging/TempCPUtoThingspeak.py"

I borrowed some script from here and here.

LinkyMcLinkFace Part 2

So my initially Nanobridge factory reset itself, before resetting itself every minute or so. I assumed it was due to my crappy wiring initially. First thing I did was get a Ubiquiti ETH-SP Ethernet Surge Protector, this really is more related to the safety of the LAN than anything else, except that now I have the Ethernet port for the NanoBridge accessible from my ceiling. When I went to install the ETH-SP I found one pair of the network cable wasn’t connected properly.

Continue reading “LinkyMcLinkFace Part 2”

Raspbian on RPi3 for NAS

Note: I have swapped the RPi3 for a RPi2 due to Ubuntu compatibility. Even the supported RPi2 with Ubuntu is proving problematic, I want to move to something more reliable.

20161025_134850
Using a Western Digital PiDrive Cable to power the setup.
  • Raspbian comes with default user:pass = pi:raspbian so this needs to be changed
  • I confirmed SSH was installed and working.
  • Following these instructions;
    • I installed ufw
      sudo apt-get install ufw
      sudo ufw allow ssh
      etc..
    • I confirmed NTP configuration.
  • Installed autoupdates, similar to this with different config.
  • Installed postfix, kind of like this.
  • the rest of the steps are basically the same that I used for Ubuntu – except that there isn’t a proper Ubuntu release for RPI3 yet.

LinkyMcLinkFace

Monday a wifi stumble returned some surprisingly decent numbers, initially my idea was to have a mast up by Tuesday. I repaired my hammer drill and got to constructing. This effort resulted in a total of half a hole drilled once I’d gotten up to the roof.

I’ve been looking at the lovely new Makita hammer drill I bought and feeling a bit guilty. Oh well I bought it now, lets hope Makita doesn’t pull any planned obsolescence schemes on the batteries any time soon.

It’s now Thursday, I was able to run a cable to my LAN and stumble a connection. Initially I was getting signal around 80dBm, I went to google earth so I knew at least which direction to aim and zing we’re online!

Using SSL (https) on RouterOS WebFig

So when I googled this I got links to setting up a hot spot and other assorted irrelevant stuff, so I did this. I created a certificate in winbox using System/Certificates. Then, here’s the best part, went to IP/Services and gained access to to all the current services, making routerOS look like an actual OS for me, rather than a complicated WebUI for this router thing. So now I set all the services to a /16 Mask (leaving room for my old subnet if I need it) on my LAN IP range, and I shouldn’t be getting a crazy amount of login attempts now – after selecting my cert and ticking the box for www-ssl, thats all, ticking the freaking box. cranking out the command line not required 😀

Reminded me of this inspiring video, which linked to a new dam video. snackpot!

rsync on a GoFlex Home NAS

So the GoFlex home UI is pretty crap, it sure as hell doesn’t have a rsync deamon. Until now. This summer…. etc

So I want to send Synology backups to the old GoFlex NAS.

Here’s how I did it:

Take Drive plastic off, replace 2TB drive with 3TB drive.

Reformat. (and gain SSH root).

Install  and config rsync .
      • Install package manager.
      • Add rsync:
        sudo ipkg install rsync
      • Config rsync daemon. In mine I set the path to a symlink for a users private shared folder, and added settings for that user.
        I started the daemon with
        sudo /opt/etc/init.d/S57rsyncd start
        and played with this until it was reachable from my Synology (some celebrations may have been had)
      • I made a symlink for the rsync opt init script in the system init folder:
        sudo ln -s /home/opt/etc/init.d/S57rsyncd /etc/rc.d/init.d/rsyncd
      • Then symlinked that with a startup link in runlevel 3.
        sudo ln -s /etc/rc.d/init.d/rsyncd /etc/rc.d/rc3.d/S57rsyncd
    • Holy Macrol, it appears to work!