Exim Mail Queue Alert Script in Python
If you run a mail server using Exim then you’ll want to know when there is an above average amount of emails in the mail queue. This could be caused by a legitimate user using the server improperly (e.g. sending a newsletter or other mass email without any throttling or with a poor recipient list) or, more seriously, a jeopardized (i.e. hacked) account being used for sending spam.
I’ve created a simple script that retrieves the current number of emails in the mail queue and, if that number is greater than a certain threshold, emails an alert to the admin.
Here is the script:
Set the To and From email addresses and you also may need to change the path to Exim.
Instead of ['/usr/sbin/exim','-bpc'], you may be able to use ['exim','-bpc']. If neither of those work, locate where the exim executable is on your server and use the appropriate path.
Change the threshold number to be higher than the normal amount of queued messages that will be in the system at any given time so you don’t receive alerts that are false positives.
Once you have the script in on your server, make sure it’s executable:
chmod +x /path/to/exim_alerts.py
Then add a cron entry. I set mine to run the script every five minutes:
*/5 * * * * python /root/exim_alerts.py
I’m working on a new iteration of the OpenExo project. The problem is is that the microcontroller and project box is going to be located underneath the device. Running wires to a control is going to be cumbersome and also get in the way of the operation of the device so I thought that communicating wirelessly with the Arduino would be the best approach. And I can use my Android phone (or any Android phone) running an App to as the remote!
I’m using the Seeed Bluetooth Shield available here on Amazon. You can also find it sometimes at RadioShack.
The nice thing about using the shield as opposed to something like the Bluesmirf bluetooth module is that you don’t have to bother with lashing it to the Arduino and then working it into a proto board. The shield just sits nicely and securely on the Arduino.
SoftwareSerial vs. Hardware Serial
The Seeed shield has jumpers that join any of digital pins 0-7 to the RX and TX serial lines that the Bluetooth module uses for communication to and from the Arduino.
If you choose to use pins 2-7 then you’ll be need to use the SoftwareSerial (or NewSoftSerial if you’re in the Arduino environment < version 1) Arduino library to talk to the shield. If you use pins 0 and 1 then you can just use the Serial commands (the same as you’d use w/ the Serial monitor) to communicate with the shield.
The downside of using the hardware serial pins (0 and 1) is that, since the Bluetooth shield is basically hijacking the same line of communication that the Arduino uses to communicate to and from the computer then you can no longer use the serial monitor and also you’ll need to remove the shield each time you want to upload new code to the Arduino.
The upside of using the hardware serial pins is that a lot of libraries that you may want to use with Bluetooth are setup to work over the default Serial implementation. So in using SoftwareSerial, you may need to tweak these libraries like I had to in order to use Amarino with SoftwareSerial.
One curious issue I found was that I simply could not get the shield and code to work when I was using the default jumper positions that the shield came with (pins 6 and 7). I’m not sure if it’s a problem with my Arduino in particular or a broader issue pertaining to all Unos but everything worked correctly once I changed the jumpers to pins 2 and 3.
Initializing Bluetooth Shield, Making it Pairable
In order to allow the Bluetooth shield to connect with other devices (making it pairable), it’s necessary to send initialization code every time the Bluetooth shield is powered up. Unlike setting the baud rate, the pairable configuration is reset to the default of not being pairable each time the board is reset.
This initialization code is available in the Seeed Bluetooth Library. Once you install the library in the libraries directory of your Arduino installation (/Applications/Arduino.app/Contents/Resources/Java/libraries/ for me on OSX), you’ll be able to open the “Slave” demo in the examples dropdown in your Arduino environment.
Here is the Slave sketch code:
/* BluetoothShield Demo Code Slave.pde. This sketch could be used with Master.pde to establish connection between two Arduino. It can also be used for one slave bluetooth connected by the device(PC/Smart Phone) with bluetooth function. 2011 Copyright (c) Seeed Technology Inc. All right reserved. Author: Steve Chang This demo code is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA For more details about the product please check http://www.seeedstudio.com/depot/ */ /* Upload this sketch into Seeeduino and press reset*/ #include <SoftwareSerial.h> //Software Serial Port #define RxD 6 #define TxD 7 #define DEBUG_ENABLED 1 NewSoftSerial blueToothSerial(RxD,TxD); void setup() { Serial.begin(9600); pinMode(RxD, INPUT); pinMode(TxD, OUTPUT); setupBlueToothConnection(); } void loop() { char recvChar; while(1){ if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield recvChar = blueToothSerial.read(); Serial.print(recvChar); } if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here recvChar = Serial.read(); blueToothSerial.print(recvChar); } } } void setupBlueToothConnection() { blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400 blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave" blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here delay(2000); // This delay is required. blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable Serial.println("The slave bluetooth is inquirable!"); delay(2000); // This delay is required. blueToothSerial.flush(); } |
The first few lines need to be changed:
#include <SoftwareSerial.h> //Software Serial Port #define RxD 6 #define TxD 7 |
If you’re in the Arduino environment greater than version 1, then you can use this SoftwareSerial library inclusion:
#include <SoftwareSerial.h> |
For versions less than 1, you need to get the NewSoftSerial library and put it in your Arduino libraries directory and include it like this:
#include <NewSoftSerial.h> |
The other thing that needs changing is the Rx and Tx pin configuration. The default in the Slave sketch should work with the default of the shield but, like I mentioned, I needed to change the jumpers and the config to pins 2 and 3 like this:
#include <SoftwareSerial.h> //Software Serial Port #define RxD 3 #define TxD 2 |
Then you can run the Slave code and you should see the board LEDs go to blinking between red and green instead of just the green LED blinking in two pulses. This means that the Bluetooth module is initialized and it is able to be paired with a device.
Changing the Baud Rate
Another thing you might need to do is change the Baud rate of the Bluetooth shield which basically determines how fast it communicates with the paired device. There are different recommended Baud rates for different applications. For using Amarino and Android, one of the recommended Baud rates is 57600.
So to change the Baud rate, you can insert this line into the Slave sketch:
blueToothSerial.print("\r\n+STBD=57600\r\n"); |
Changing the Baud rate on the shield is permanent so you’ll need to connect to it using that Baud rate once the change is made. You can of course change it again using the command above but it will keep the latest Baud rate even if you power down the board.
Connecting Android and Arduino using Bluetooth
You can follow these installation instructions to get Amarino setup both on your Android device as well as for the Arduino development:
http://www.amarino-toolkit.net/index.php/download.html
Next, you can test that you can get communication going between the Android and Arduino by using the SoftwareSerialExample sketch included with Arduino. You’ll need to edit that though in order to the initialization routine for the Bluetooth shield.
Here’s what mine looks like after adding it in:
/* Software serial multple serial test Receives from the hardware serial, sends to software serial. Receives from software serial, sends to hardware serial. The circuit: * RX is digital pin 10 (connect to TX of other device) * TX is digital pin 11 (connect to RX of other device) Note: Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 Not all pins on the Leonardo support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). created back in the mists of time modified 25 May 2012 by Tom Igoe based on Mikal Hart's example This example code is in the public domain. */ #include <SoftwareSerial.h> SoftwareSerial blueToothSerial(3,2); // RX, TX void setup() { // Open serial communications and wait for port to open: Serial.begin(38400); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } Serial.println("Goodnight moon!"); blueToothSerial.begin(57600); blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave" blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here delay(2000); // This delay is required. blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable Serial.println("The slave bluetooth is inquirable!"); delay(2000); // This delay is required. blueToothSerial.flush(); } void loop() // run over and over { if (blueToothSerial.available()) Serial.write(blueToothSerial.read()); if (Serial.available()) blueToothSerial.write(Serial.read()); } |
Now, you can open the Amarino app in Android, connect to the device listed (should be there as “SeeedBTSlave”) and go to the monitoring tool inside the Amarino app. Then you should be able to send commands from the Amarino app to the Arduino serial monitor like I did in the video above.
Using SoftwareSerial with the Amarino bridge and MeetAndroid Library
One other hangup when you actually start making your Android app and have it talk with Arduino is that the MeetAndroid Amarino libraries that use with Amarino are setup with the assumption that you’ll be using the hardware Serial, pins 0 and 1 for Bluetooth communication. So if you are using pins 0 and 1 with the shield, you are all set. But if you’re not, you’ll need to get a modified version of the MeetAndroid library.
Thankfully someone ran into this problem already and was kind enough to modify the libraries and put them up for download here:
http://www.double-oops.org/mini-blog/amarinowithsoftwareserial
So this is excellent. Except there is one other problem. When using the shield, you need to run that initialization code first. I tried doing this first by putting the initialization code right in the sketch after created the modified MeetAndroid connection like we’ve been doing in the sketches above. However, there was a conflict in that the MeetAndroid library takes control of the Bluetooth serial lines once it’s initialized and therefore trying to initialize the module inside the sketch doesn’t work.
So I modified the the library again, adding a new “send_plain” method which can be used to send Bluetooth configuration commands. This was necessary since the “send” command built into the library modifies the input string in order to communicate appropriately with the Amarino API on the Android side.
I put it up at Github:
MeetAndroid SoftwareSerial Library With Bluetooth Configuration Command
Scooter Standing Mechanism Progress

The scooter standing frame project is coming along.
This week so far I’ve:
* tested the new seat mechanism on the scooter
* repositioned the linear actuator so that when the stroke is fully extended while standing the angle of the seat base to the floor is more of a right angle
* begun to shape the seat base out of plywood I harvested from a discarded massage table
* begun to work out the angle of the linkage for the back rest so that it morphs from a 90 degree angle with the seat base when sitting to a 180 degree angle when it goes to standing
* bought some female quarter inch wire connectors to hook up the dpdt switch to the battery and linear actuator
Scooter Standing Frame Project
I’ve started building a device that can be added to a mobility scooter (used by people with disabilities) to bring the user to a standing position.
Here’s a video I shot of my latest progress:
In the video is the add-on frame made with 80/20 aluminum extrusion and a linear actuator that sits on top of the original seat base of a mobility scooter. In this case it is an Amiga seat base.
The electric linear actuator lifts the top rails to a 90 degree angle at which point the person sitting on it would be in a standing position.
The original seat from the scooter would be bolted on to the top rails and then I’m going to work out how the back rest will be positioned to the top rails along with a linkage that would keep it at the correct angle while the position changes from seated to standing.
I plan on using the scooter batteries for the power to the linear actuator and also incorporating a DPDT momentary rocker-style switch inline to allow the user to control the actuator.
Also, knee locks will be incorporated into the stander as well as perhaps a frame and tray for the user to access when she’s in the standing position.
Custom Back Harness for Exo Project Post
I just posted a new blog entry at openexo.com about making a new customer back harness for affixing the device to the body.

Project Refocusing
It’s tough picking back up projects after being away for some time.
When a project is new, it’s exciting. The mind easily focuses in on it. Getting lost in the mechanics, the how to and the end vision. And the body follows suit, making working on it easy and rhythmic. Flow-like.
Jaimie Mantzell just started back in on his giant robot project. He’s a cool guy. You should follow him on Youtube.
Here’s a video where he’s getting back to work on the giant robot project:
“It’s kind of weird coming back into a project after not working on it for a while. It’s like coming into someone else’s project, ‘I have a no idea what’s going on here!’”
It’s tough.
Recently I’ve done my own refocusing on the exo project as well as the trike project. I’d really like to wrap those up or at least get them to a much more finished state. Just have to put one foot in front of the other.
With the exo project, I’m making the leap to using window lift motors that I’ll convert into big servos that I can use for the joint actuation in place of the wiper motor servos.These will be lighter and stronger and also, because they have worm gears, they’ll be able to maintain a fixed position without the need for battery-draining powered locking. I’m psyched to get started integrating these into the design and I just ordered a seemingly hackable one from AME Equipment.
With the trike project, I got some metal work and welding done on the head rest. And I also have new foam cut out for the seat cushioning and seat cover material on the way to wrap them up.
Powering up!
It’s kind of daunting getting back into projects after a hiatus but once you’re stepping through the motions again the mind starts wrapping around the mechanics and the flow can flow.
Learning to Fly
Over the last few weeks I’ve had the good fortune of tossing a frisbee with my friend Raph.
He’s a frisbee master. It’s estimated that he has reached the Malcolm Gladwell denoted 10,000-hour-expert-level of playing frisbee.
He’s also a masterful teacher.
When we first went out I had never thrown a forehand pass. I mean I may have a few times. But I had only ever really used my backhand. I always marveled at good frisbee throwers and their forehand throws. So elegant and effortless!
Our first time out, Raph showed me the finger position for the forehand. Middle finger on the inside rim of the disc and the forefinger extended further inside on the flat of the disc for leveling.
“Use just your wrist to start. Get that motion down first.”
So at short distances I flicked my wrist, letting the frisbee roll off my middle finger to get it to spin.
Wobble, wobble, wobble. Back and forth, back and forth.
“Use just your wrist,” he reminded me when I would put my arm into it.
Back and forth, back and forth.
Soon I was getting the disc leveled out and enough spin on it to get it to him fairly consistently.
We started to move further away from each other.
I would watch him and his throws. So effortless. The action all in his wrist and arm. The rest of his body still and sure.
“It should feel like air hockey.” The disc just floating on air. That’s what makes it work. Not injecting strength into the propulsion of the disc like a backhand but finding the right action and finesse to harness the disc’s natural capacity to float on air.
Back and forth, back and forth.
“Don’t step into it.”
“Keep your body facing me.”
I watched his body and listened to his sage advice. And I slowly adjusted my actions to match his. Learning frisbee like this is exciting in that I have this mirror-like ideal every-time Raph would throw to me.
He’s letting his arm drop out of the way, that’s right, I think I’ve been forgetting about that.
Back and forth, back and forth.
Make sure the disc is leveled out by your forefinger before releasing to avoid that angle.
Back and forth, back and forth.
We’ve started to move further away and my throws are getting more accurate, more controlled.
And the other day, it happened. Back and forth, back and forth. I wasn’t thinking about specific mechanics and something magical emerged. I wasn’t working the disc. I only encouraged the disc to work the air. It sailed. It felt so good. It was air hockey.
A new website I’ve been working on (hasthat.com) is built using Django and hosted on Heroku. Because Heroku doesn’t have persistent file storage, I’m using django-storages with the s3boto storage backend to seamlessly use Amazon S3 for the image upload functionality of the site.
When I first put up the site and watched it get indexed by Google, I noticed that these uploaded images weren’t displayed in the cached previews of pages. Okay, I thought, it’s probably because Google takes longer to index images with new sites.
A couple weeks passed. Still no images showing in preview. It turns out that Google wasn’t indexing the images because they were being served through django-storages and s3boto over https. As an aside, it’s sort of interesting that Google takes the approach of not indexing secure-served images. Or maybe it’s just https with S3. Oh well. It’s also interesting that the s3boto backend defaults to returning secure s3 objects.
But anyway, in order to force s3boto to return s3 objects over http, you need to add this to your settings.py:
AWS_S3_SECURE_URLS = False
Almost immediately after making this change, the Google cached previews changed to showing the non-secured images.
Good to go!
Tiny House, Simpler Life?
Want.
But why do I want it? And why is a tiny house attractive to a lot of other people too?
I don’t think it’s about the hardware, actually owning the house. It’s about the constraint the hardware puts on the software. What can go in the house and what the house can handle. The simpler (and better) living that might develop when we are weighed down less by the stuff we have. Burdened less mentally by the overhead of being responsible for and to a great deal of atoms in physical space.
I think that’s why a tiny house is cool.
But is it really such a simple relationship that the more stuff you have = more psychological complexity? And in turn, stress?
Maybe there are other ways of simplifying our relationship to physical things for the better without having to move into a tiny house. Things aren’t inherently bad of course. We can do amazing things with things. Our things can act as signals to other people to help facilitate connections. We can use things to help us dream and build.
These are some of the ideas and questions I’ve been thinking about in building hasthat.com, a web-based storage unit for the things we own. The idea really struck me when I was anguishing over all of the things that surfaced when we had to move apartments recently. It was tough to process. All of those things were only loosely organized in my head. By offloading them to hasthat.com, maybe I’ll be able to harness more of a tiny house mentality.
Audio QR Codes
Here’s a thought: Audio QR codes. Short snippets of audio that when “scanned” (recorded and processed) by a device like a smartphone would translate into data like a website URL. They could be used to transmit additional data related to any sort of audio output including radio, television or even music.
I caught the tail end of an NPR program the other day that sounded really interesting. I didn’t have too much to go by to look it up later on the web. Also, later might never happen. So it’d be sweet if there was an audio QR code that I could record on my phone and provide me with the proper links and related information.
The actual code being transmitted could be encoded in a form not unlike early telephone-based modems although ideally with more pleasant tones
I think it would be really interesting to play with this idea in music as the code could both be musical but also a way of transmitting information reminiscent of the the African talking drums. Perhaps too when musicians play live music, if there was a simple enough language, data could even be created and relayed on the fly. I’ve heard that Phish has a language of notes and chords that the band members use it to “talk” to each other while they’re jamming. Maybe though trying to incorporate an additional layer of information would be distracting to the base language of music.
–
Hat tip to Kawan for the debut of this new category on my blog called “Ideabox”



