Posts: 249
Joined: Thu Nov 22, 2012 9:38 pm

Raspberry Pi Spy (Application and Agent)

Thu Dec 13, 2012 4:37 am

Well, a few people have asked about a small application I wrote to monitor my Raspberry Pi devices, since most of my Raspberry Pi devices as always-on devices. I wanted and needed an interactive and automation friendly way to monitor such things as Pi temperature, SD card space free space, processor load, memory use, etc. The result is what I have coined as 'RPI Spy' or 'Raspberry Pi Spy' if you will. However, this solution is more of a remote command execution tool, than a monitoring tool, it all depends on how you choose to leverage it. Overtime, as I am able, I expect to enhance this solution to incorporate features that a true monitoring solution would have.

RPI-Spy 1.0 includes 3 components...

1) A python script that runs on each Pi, that listens to a simple TCP port socket. Mind, now, there is no security protocol to this solution, so I would suggest not running the python script under root! And realize any transported requests or responses is in the clear. Also, given this solution is Linux distribution agnostic, I did not provide any details on setting up the script as a daemon or serivce, but I am sure others will do this. I developed the python script, or agent, on Fedora 17 on Pi, in fact.

2) a .NET C# interactive (GUI) application that allows sending of shell commands to any Pi device running the python script as already noted.

3) To assist with automation of shell command execution and results capture, a .NET C# console application is also provided. The .NET C# source was created in Visual Studio 2012 Express, and leverages .NET 4.5.

The Raspberry Pi Spy solution was tested on Windows 7 Ultimate and 256MB and 512MB Model B Pi devices.

This is all provided GPL, freeware, for personal use. If this inspires more development in this area, so much the better. All that I asked is that I am credited as appropriate in the documentation and/or code comments. And by all means, improve on the idea! Anyone that wants to use this solution for educational or commercial use may do so, provided they have written approval from me, this will be always be freeware, and provided strictly as is. This solution is designed and offered as a foundation for learning, education, and encourage innovation, nothing more, nothing less.

For those that wish to be critical? I am sure my coding style and design is a shadow of what a professional could or would do. Feedback is always welcome, of course, but be considerate and professional. Moreover, I have spent considerable time, effort and resources developing this solution, but I will seriously consider all rationale and considerate suggestions and comments, no doubt the solution should be enhanced and improved over time, if not by me, than others. That said, enjoy! I am looking forward to all the ideas, comments, and suggestions that may result.

Below is an example of the agent script running and the basic reporting the agent does, and the console application. I have redacted some of the environment information, but I trust this will not confuse anyone overtly...

Raspberry Pi Spy Agent...

# ./
Raspberry Pi Spy Agent
Raspberry Pi Inspection Agent * 12/12/2012

Initialize (Host: <Pi Device>, Port: 50001)...
Connect (Client: <Windows Desktop>, Addres:, Port: 57232)...
Request: uname -a
Response: Linux <Pi Device> 3.2.27+ #307 PREEMPT Mon Nov 26 23:22:29 GMT 2012 armv6l armv6l armv6l GNU/Linux,
...Disconnect (Client: <Windows Desktop>, Address:
^C...Deinitialize (Host: <Pi Device>, Port: 50001, Result: 0)

Windows (Console)...

>RaspberryPiSpyConsole /H:<Pi Device> /P:50001 /R:"uname -a"
Raspberry Pi Spy Console
Raspberry Pi Remote Inspection Console Application * 12/12/2012

Request: 'uname -a'
Port: 50001
Length: 4096
Host: <Pi Device>
Standard Output Pipe: Linux 3.2.27+ #307 PREEMPT Mon Nov 26 23:22:29 GMT 2012 armv6l armv6l armv6l GNU/Linux
Standard Error Pipe:

Windows (Console), same as above but notice the addition of the /S option, thus only response information is returned...

Linux 3.2.27+ #307 PREEMPT Mon Nov 26 23:22:29 GMT 2012 armv6l armv6l armv6l GNU/Linux,

Also, notice, stdout and stderr are delimited by a comma, in the above example, no results returned in stderr pipe. :D

Link to Raspberry Pi Spy Source Files...

Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Raspberry Pi Spy (Application and Agent)

Thu Dec 13, 2012 9:10 am

Thanks for posting this.
Already bookmarked.

• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere

Return to “Other projects”