Monday, April 27, 2015

Reverse the scroll on your Dell laptop touchpad

When messing around with my laptop that I normally have attached to a dock, I noticed that it wasn't acting like my other main laptop. The scrolling on the touchpad was going in the opposite direction of the way that I am used to. I like to scroll on the touchpad in the same direction as the page scrolls. Some call that way opposite but it comes naturally to me so.... I needed to change it!

After doing some research on the web, I found the best solution was to not think of it as a Dell product, think of it as an Alps product, which it is. It uses software called Apoint to render what is done in the physical world to the digital world through the touchpad.

Using this new found knowledge, it pointed me to a location in the Registry:


Find the key that says InvertScrollFlag and change the 3 to a 0 and reboot. Simple!

I have an E6540 but I would imagine that any dell laptop that uses the Dell Touchpad control software this would work on:

Happy Scrolling!

Friday, May 31, 2013

Using Secure copy to bring all the log files together raspberry pi

So now that I have two RPis doing environmental monitoring, I have these log files on each machine being dumped locally. Some of our clients would like to see the logs so they know that we are keeping the proper temperature outlined in their contracts. I need a repository to dump them to and a way to copy them.

Across the network, we have other devices monitoring temperature, humidity, light, air, etc. I set up a Ubuntu box a long time ago for internal device monitoring before I went to Nagios. During that time, I used "wget" to go across the network and grab the log files from these devices and put them in a shared location on that Ubuntu box every so often which was fine. The log files were always the same name so it was easy.

Now that I have these RPis, it has become apparent that I would like the logs from these devices to go to the same place; this Ubuntu box with the other log files. So... how to get them there.

Using SCP, I set a cron job to copy them securely from one linux distro to another. Ill be referencing the Ubuntu box as well as the RPi but you can use RPis for the whole thing. It is not inclusive to just Ubuntu.

***If this gets technical, that is what we have the Google machine for. I knew nothing about secure copy before embarking on this but after about an hour or so, I was copying files back and forth with success.***

First you need to set up SSH to accept the copy. I found that while trying to copy using SCP, it always wanted a password after running SCP blahblahblah. So I needed to set up Password-less login with SSH.

Following these instructions at:

I ran (on the local machine, machine where the logs originate)


hitting enter all the way through. Then running:

ssh-copy-id -i ~/.ssh/ remote-host

I was able to find out that I couldnt because the username on the Ubuntu box was not the same and the RPi. Nor the port... ugh. so I had to run this:

ssh-copy-id -P port -i ~/.ssh/ user@remotehost

Which then worked and I was able to start an ssh session with the remote host without a password. I put this line:

scp -P remote_machine_port local_directory_where_logs_are user@remote_host:remote_directory

and saved it as a executable file that I am calling with THAT USERS CRON. I was trying to call it with roots cron but the keys I made wouldn't allow for a password-less login.

So typing on the local machine where the logs are originating from:

crontab -e

and putting this line in:

0 0 1 * * /home/pi/logcopy

it is successfully copying the contents of the log folder on the FIRST of each month to the remote machines log repository.

Wednesday, April 24, 2013

Raspberry Pi and snmp polling using am2302 (wired dht22) temp sensor

Yipes. This sensor has been interesting. First off, because of the fast polling of data off the sensor, a C program was written because python seems to be too slow. Ugh. I don't know C at all but managed to get through it with a little help from a bunch of ppl to whom I will credit as the post continues.

What is this post concerning? Well, it is written on the heels of another one of my posts, SNMP polling using a DS18B20 sensor. Many assumptions will be made during this post but those assumptions all come from the know-how that is in that article, for example, I assume you have a working SNMP server/client set up and configured. If not, cruise over to the other article and scroll down a bit and it shows you how. So, on that note, lets go.

What is needed (again with the assumptions):

Let me get this out of the way. I didn't create any of this from scratch. What I've done is harvest all the information into one spot from me jumping all over the internet trying to find a way to get this done. So I take no credit in any of these pieces as pieces. I will take credit for bringing this all together in a very readable, easy to understand tutorial that anyone can follow and have a working sensor giving data to any program that uses SNMP.

Wiring the AM2302 to the Pi:

This is pretty much it. Nothing to it. Because we have used the Prototyping Pi Plate, we just need to find pins for GROUND, 3.3 VOLTS and PIN #25 (ill explain later why 25 and not 4) and screw the leads into the screw down terminals. That's it. Because this is the AM2302 and NOT the DHT22, we do NOT need a  pull-up resistor anywhere in the wiring. The resistor is INSIDE the casing of the AM2302. Sweet.

Once its wired, we gotta look at the software side. Ugh.

I followed the directions on THIS LINK to the "t" and everything worked exactly how it should with Pin 4 and everything exactly how they stated it there (there's no need to copy and paste everything since it is on that page pretty well formatted so cruise on over and then jump back when you have it working).

This was just to test that the wiring and software compiling was working on your end. Now we have to edit everything to get it to do what we need it to do, so here goes.

What I didn't know is that you need to compile each time you make a change. yeah, i remember saying I didn't know C right? Anyway, after figuring that out, I was able to come up with some pretty quick changes to the main C program and then compiled it.

First change to the file Adafruit_DHT.c I made was commenting out this line:

printf("Using pin #%d\n", dhtpin);

This messes up the SNMP output. So does this line so comment it out as well:

printf("Data (%d): 0x%x 0x%x 0x%x 0x%x 0x%x\n", j, data[0], data[1], data[2], data[3], data[4]);

After commenting both those lines out, i got into the nitty gritty of the actual output. I commented out this line at the end of the file:

printf("Temp =  %.1f *C, Hum = %.1f \%\n", f, h);

and added these lines:

printf("%.0f\n", f*1.8+32);
printf("%.0f\n", h);

What this will do is change the output from that one line to two separate lines with just the temp and humidity in it. Then I compiled it using the compiler line in the link above on adafruits website:

gcc Adafruit_DHT.c -l bcm2835 -std=gnu99 -o Adafruit_DHT

This makes an executable file called Adafruit_DHT that has our code in it. This is where the pin move comes into effect. I had something on pin 4 that couldn't be moved for one reason or another so I had to use pin 25. So from now on, I will be referencing pin 25 instead of pin 4 but there is NO code that forces it on pin 25 or pin 4, only the executable when you run it. So running this:

sudo ./Adafruit_DHT 2302 4

will set the pin to 4 and running this:

sudo ./Adafruit_DHT 2302 25

will set the pin to 25. Easy. The 2302 part is calling the code to reference that you are using a 2302 sensor.

Here comes the tricky part. Getting it to run with SNMP and dump this data. Because the sensor fails to dump data every time its polled (I found this somewhere that if you run that executable too quickly, it wont show data both times - you have to wait 3 seconds until you poll it again), you must grab both the temp and humidity at the same time even tho you might want to grab the temp separately and the humidity separately through your SNMP program.

This is where we trick it. By calling that executable OUTSIDE of SNMP altogether through cron, we can then poll against a SED output to two separate files. Oh Snap! This is what I did:

I made a bash script called "getboth" and put it in /var/scripts made up of this code:



sudo /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver/Adafruit_DHT_both 2302 25 > /home/pi/both.txt

while [ ! -s "/home/pi/both.txt" ]
        sleep 5
        sudo /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver/Adafruit_DHT_both 2302 25 > /home/pi/both.txt


sed '1d' /home/pi/both.txt > /home/pi/humid.txt
sed '2d' /home/pi/both.txt > /home/pi/temp.txt


The code between the lines is what you want to copy and paste. Blogger doesn't have a decent code box to paste special code into.... Anyway, to explain what I did, 

  • the first line runs the Adafruit exe (which i renamed to Adafruit_DHT_both) with the syntax 2302 for the sensor type and 25 for the pin i used then dumps the output to a local file called "both.txt" in my home dir. Remember knowing this, you can put the files anywhere but Im only adding it here so this could be a direct copy and paste and everything works.
  • Next is the WHILE loop that looks at "both.txt" and if it is 0 bytes, it sleeps for 5 seconds and runs it again. This is because sometimes the sensor doesn't give back info the first time you poll it. This is all documented on other pages. Feel free to search for it but since I found a workaround, I didn't feel the need to go into detail about the inner worksings of the sensor, only that it has this "issue".
  • the second to last line looks inside "both.txt" and uses SED to dump the FIRST line and read only the SECOND line and it dumps it to a file called "humid.txt"
  • the last line does what the previous line does but backwards; it dumps the SECOND line and reads only the first line then dumps that output to a file called "temp.txt"
If you remember, when we added and changed all those lines in the original C program code, we added those lines at the end that stated printf blah blah blah but there were two lines, one for the temp and the other for the humidity. That output from that original C program is being outputted into our "both.txt" file so SED can look through it easily and grab what it needs.

Now that that script is done, we gotta call it using cron. By typing this:

sudo crontab -e

I was able to edit the cron in order to run that script as root every minute by copying that Adafruit_DHT_both file to /var/scripts and putting this line at the end of my cron file:

*/1 * * * * /var/scripts/getboth

This will run the "getboth" script every 1 minute which will poll the sensor only ONCE per minute but more than 3 seconds apart due to our constraints (what i explained above with the polling once every 3 seconds at least).

The last part of this equation is making sure SNMP likes us. What I did was make two more bash scripts and put them with the others in /usr/local/bin. One to parse out the humidity and the other to parse out the temp.

Temp script:

echo .
echo gauge
cat /home/pi/humid.txt

Humidity script:

echo .
echo gauge
cat /home/pi/temp.txt


sudo chmod +x scriptname

These two files will be run by your snmpd.conf to post the correct OID, gauge and output to the proper SNMP output that is liked by SNMP. They are called something different because they do different things. They each will be called separately to grab what was originally polled by cron from the two txt files in your home dir.

I had to do this because of the restriction against polling the device too quickly. Also had to do it this way because of an issue I ran into trying to run sudo from inside the snmpd.conf file. I could have written this all in the original C program but i was unable to run sudo from snmpd.conf so I could call the adafruit exe correctly. Looking back, i dont think that would have been feasible because of the polling issue with getting data too fast from the sensor...

Of course this is open to a LOT of assistance. For one, I did run into some trouble with sometimes the polling doesnt happen and I would like to put an if then else in the "getboth" script somewhere that would poll the sensor again until it got results. Why this is needed is because, as the code sits now, sometimes when the sensor is polled, it gives blank results. It will then save the "both.txt" as blank. That means when the "humid.txt" and "temp.txt" are created, they are created blank as well. When that happens and SNMP rolls through, it grabs no data and throws an error inside my Nagios setup until the next time it comes through and data has been successfully retrieved from the sensor and those three text files are populated with data. If anyone has any code to do that, I would appreciate it! :) What I do know is that the way it is describe above, it is working quite well so I imagine I am on the right track!!  Code is in as of 04-25-13.

Some of this might not have made sense. I explained everything in much more detail in my previous post so if there is something that is confusing, cruise over to the other article and it will most likely be explained there!

Update 05-31-13
I have 2 50 foot remote sensors and a local sensor attached to the Pi. After seeing some strange power issues after the first weekend of testing, I opted to switch out the 1 amp power supply I was using and put a 2 amp power supply in. One came with my cell phone (Note 2) so on a whim I tried it and haven't had problems since.

Wednesday, March 20, 2013

Raspberry Pi and snmp polling using ds18b20 temp sensors

Finally, after visiting the end of the internet and talking with countless people about hacking code up, I think I have put together a decent little system for polling temp readings off of a digital DS18B20 probe. Ill attempt to map out everything I have done from start to finish. Here goes:

Current Setup:

I got the Wheezy build from here and followed their instructions on how to put it on the SD card in the paragraphs above the download section. Depending on what OS you are using, there are obviously different programs to use.

I hooked the Pi up to a screen, keyboard, mouse and network, stuck the SD card in and, after a little initial setup, i was off and running. I gave it a static by adding these lines to the /etc/network/interfaces file:

iface eth0 inet static
        address IP ADDRESS
        netmask NETMASK
        gateway GW
        dns-nameservers DNS

I commented out the line that said "iface eth0 inet dhcp" because we don't need it for a static. Either one or the other. Now, either restart the Pi or restart the daemon for the network settings to take effect. I've had more luck rebooting....

Following directions from here

Step One: Updating the Kernel
  • The first step is to change where our Pi updates from, by editing a text file. We need to open up the file /etc/apt/sources.list.d/raspi.list as root, so type:
    sudo leafpad /etc/apt/sources.list.d/raspi.list
  • Now change the line in this file so that it reads "deb wheezy main untested", then save and close the file.
  • Next, do the following commands:
    apt-get update
    apt-get upgrade
Next comes wiring the probe and connecting it to the Pi. Using the directions here, I wired it to look similar to this pic:

Obviously, it can be set up any way but it must be connected correctly. I'm talking about using different pins on the breadboard and placement and such.

After that is done and the ribbon cable is connected, I powered the device on. You should feel the probe during this initial power-up. If it gets hot, which it will within seconds, turn it off and check your wiring. 

Running these two commands:

Sudo modprobe w1-gpio
sudo modprobe w1-therm

will fire up the probe. These will need to be put in a start-up file upon boot if ever the device is restarted. After those two commands complete, it will be dumping data into a file located at 

/sys/bus/w1/devices/SERIAL OF PROBE/w1_slave

The serial of the probe can be found by doing an "ls" inside the /sys/bus/w1/devices folder. In the pic at the top, I found what that number was and made a yellow label for it since that serial will never change. Easier to label them rather than trying to remember! :)

Running "cat w1_slave" inside that serial folder will produce two lines of output. the very last few digits will be the temperature in Celsius. Its at the thousands place so the python code further down that links page will tell us how to divide by 1k.

The following code is taken from that page with a little tweak at the end to convert it to Fahrenheit:

# Open the file that we viewed earlier so that python can see what is in it. Replace the serial number as before.

tfile = open("/sys/bus/w1/devices/28-00000474e0b1/w1_slave")

# Read all of the text in the file.

text =

# Close the file now that the text has been read.


# Split the text with new lines (\n) and select the second line.

secondline = text.split("\n")[1]

# Split the line into words, referring to the spaces, and select the 10th word (counting from 0).

temperaturedata = secondline.split(" ")[9]

# The first two characters are "t=", so get rid of those and convert the temperature from a string to a number.

temperature = float(temperaturedata[2:])

# Put the decimal point in the right place and display it.

temperature = temperature / 1000

# Convert Temperature to Fahrenheit

temperature = (temperature * 9) / 5 + 32

# Print Temperature

print int(temperature)

The 28-00000474e0b1 part in that first line is the serial of MY probe. That will be different for you, of course. Copy and paste that, using your serial number, into a file called and place it wherever. to run it, type:


and it should return a rounded-like (because of the int() statement) integer that is the Celsius degrees converted to Fahrenheit. The probe works and the temp is being converted. That step is done.

Once we have all that done, we can install SMNPD and get it to respond to queries from a remote machine. This proved to be the most difficult for me because, up until this point, I always piggybacked on an existing SNMP install with the OIDs already there. Building this from scratch was definitely tricky for an SNMP nub like me.

So, taking directions from a lot of places, Ill post links to the most helpful places here.

Following directions from here, I installed SNMPD by running:

sudo apt-get update
sudo apt-get install snmpd
sudo apt-get install snmp

Im not 100% sure if i needed the client portion, but I installed it anyway during troubleshooting steps. 

Please be aware that this is for a totally internal setup with no outward facing access therefore its pretty wide open. You'll want to check up on securing your SNMP install if you choose to have it facing the internet. 

You'll need to edit your snmpd.conf file by typing:

sudo nano /etc/snmp/snmpd.conf

Here is where it got tricky. I had a line in there that read:

agentAddress  udp:

which i commented out and added this line below it:

agentAddress udp:161

which I'm assuming from what I read allows for any machine with explicit access to get queries. Then, further down in that config, I found the rocommunity lines. I added these lines:

rocommunity public IP OF REMOTE MACHINE
rocommunity public localhost

not sure if that last one was there or not to begin with. Then commented out:

rocommunity public  default    -V systemonly

just for good measure! :) it looked like it might have caused a problem. Not sure if it was needed but, again, SNMP newb here. Make sure you restart the daemon to make your changes stick:

sudo /etc/init.d/snmpd restart

once those are done, from the local machine, you should be able to type:

snmpwalk -v 1 -c public localhost

and it will throw a ton of stuff at you from the console. you can also try that same command from a remote machine instead putting in the IP of the Pi rather than localhost and it should do the same thing.

From this moment on it gets a touch more tricky. Getting an OID to match to the temp probe output. remember the temp probe? yeah its been a while....

Continuing to follow the instructions here, you must do a few things which I will list:
  • make a script to call the python file we created in the first steps above
  • config a new OID inside the snmpd.conf to point to this new script
Easy. Kinda. If you originally knew what you were doing....

I grabbed the executable from that link above and changed it a bit:

if [ "$1" = "-g" ]
echo .
echo gauge
python /usr/local/bin/
exit 0

copy and paste that above into a file called snmp-temp. Then run this:

sudo chmod 755 snmp-temp

which will make it executable and try running it:

./snmp-temp -g

Please notice that I changed the directories where these files are located which you will need to do as well for this to work. If they are all in the same place calling the same files, you should be ok. SNMP likes them to be in that /usr/local/bin directory. i was NOT able to run them out of my home directory where i was originally building these files. i moved both the python scripts and the shell scripts to that location and everything is working fine.

once you run that file, you should get output in three lines:

Now that that is working, we need to add a line to our snmpd.conf file to join that script with that OID. So... Edit the snmpd.conf:

sudo nano /etc/snmp/snmpd.conf

and add this line down where the other "PASS" lines are:

pass .      /bin/sh         /usr/local/bin/snmp-temp -g

Again, please remember that I moved files around to that /usr/local/bin directory.

So.... Now if we run this (either locally or from the remote machine - ill use localhost for this example):

snmpget -v 1 -c public localhost .

it should return:


So for understanding, this is what happens:
  1. snmpget goes out via version 1 looking for the public community on localhost for the OID labeled .
  2. Once it finds that OID in the snmpd.conf, it runs the associated script called snmp-temp inside /usr/local/bin
  3. That script calls the python script that actually does all the work; grabbing the output of the probe, parsing all the gibberish and converting it to Fahrenheit.
  4. snmp-get returns the results of the into a nicely formatted snmp query that can then be put into any program.
I use nagios to poll a ton of other devices so this was an easy setup inside nagios once the output was generated and the ability to query against it was done.

Friday, March 1, 2013

SNMP polling temp as Celsius and changing it to Fahrenheit nagios/opsview

A little while ago, I created a Opsview install that monitors all aspects of the network from temp/humidty/air flow readings off our WeatherGeese devices to APC loads and charges to server uptime and service states. This turned out quite nicely. I used a tutorial over at to get it started and been hacking it ever since.

My latest issue with it is that some of our environmental devices are either too old, coded wrong or have the wrong temp sensors in them to report Fahrenheit temps. they are only in Celsius. Now, even tho nagios does a good job at reporting red/yellow/green indicators (using the rawNumbers gadget), it is still in Celsius.

I sent a few pings out to my nerd community and they answered. Here is the entire post of what followed at this link:

Long story short, here is the complete code that you can use and adjust to your liking. It took quite a bit of hacking apart and I appreciate George1421's assistance. I do not know how to code. I'm only VERY dangerous using multiple languages. I think we got through it! :)

This will allow you to poll the device using the syntax that is allowable (its defined in the help or at the bottom of the code). I added the functionality of the OID in the parameters so its not hard coded in anymore.

Tuesday, July 10, 2012

Barracuda Web Filter 310 New enhancements?

Apparently, and I'm not sure when this went into effect, but there is an area under Block/Exempt-Applications that allows/disallows certain programs and/or protocols.

Well, a few months ago, email started to not flow in so in troubleshooting, I found that the web filter was causing this issue so I took it out of the chain and everything seemed to flow again. I left it out for a few weeks and tried to put it back in, thinking it was a cache issue or something bogging the filter down and with a couple weeks out of commission, we would be ok. Negative.

I had a chance to turn it on this past weekend and call barracuda if everything wasnt ok, so I did. And I called. Well the tech said he has seen this before so.....

By selecting the UnAuthenticated dropdown in the top right, I was able to see that all protocols were being blocked when they were unauthenticated, which email and all my SNMP traps were. I allowed all protocols while being UnAuthenticated and we are back in business.

Yeah. Wow.

Monday, January 23, 2012

AppleTV 2 and XBMC

I recently upgraded to an AppleTV from my Western Digital Live HD device to serve my movies. Granted i had no intention of doing anything with iTunes. I only wanted the device because it is practically a turn-key solution to a newer streaming device. XBMC allows for better movie info and just a much better user interface than the Western Digital device. Dont get me wrong, the WD device kicks butt. Its just that its not pretty! :) (note: i have never had a problem with this device. It plays everything that I need it to.)

So for $99 at Best Buy (yeah i know. I had a gift card so its ok), I bought one and jailbroke it to get XBMC on it. Here are the steps:

1. Jailbreak it:

2. Put XBMC on it:

3. ????

4. Profit

I also used these two programs before even turning on the ATV2:

Media Companion:

TheRenamer is an EXCELLENT tool that will take all your movies, move them into their own folders, check them with and post a year at the end of that folder name and get them ready for a VERY quick scraping of all movie content.

Media Companion will import all those movies into its own database and then go out to and parse the movies page (that was correctly identified using TheRenamer) and bring down that movies info; actors names, plot, posters, fan art, etc.

After doing both of those, launch into XBMC and add a folder and make the scraper IMDB. It will then go through your local share for info that you have just downloaded with Media Companion.

Granted, this took me the better part of last week and the weekend only because my library wasnt ready for this drastic move but I can assure you that my work was not lost. This device is doing exactly what I want it to do.