Gl.ib.ly

(glibly); Just another techie blog.

Installing SNMPD (with remote access) on Debian 5/Lenny

Posted by Tariq • Wednesday, March 10. 2010 • Category: Tidbits
Today we're installing snmpd so that we can query our debian server from another remote server that will use snmp in alert scripts and pretty graphing software.

Snmpd installation is a little obtuse so here is how to do the installation on Debian Lenny.


  • Install snmpd with: sudo apt-get install snmpd

  • You should be using RCS/git/etc when editing system files at work. So use the appropriate techniques for checking in and out all config files. If you're a home user don't worry about this step; or, maybe you should. Muhahahaha! Eh, *cough*.

  • Open /etc/snmp/snmpd.conf and change to the following:
    # sec.name source community
    #com2sec paranoid default public
    #com2sec local localhost public
    com2sec local localhost mysecretcommunity
    com2sec readonly 192.168.XXX.XXX mysecretcommunity
    #com2sec readwrite default private


    Here mysecretcommunity is the uber secret name of your community. Change this to something other than public or mycommunity -- let common sense prevail. 192.168.XXX.XXX is the IP address of your remote server that will query snmpd.

  • Change /etc/default/snmpd so that it contains the following line:
    SNMPDOPTS=’-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid’ 

    Notice the lack of 127.0.0.1?

  • Save the file!

  • Restart snmpd with sudo /etc/init.d/snmpd restart.

  • Test snmpd locally:
    snmpwalk -Os -c mysecretcommunity -v 1 localhost system

  • Test snmpd remotely from 192.168.XXX.XXX:
    snmpwalk -Os -c mysecretcommunity -v 1 192.168.YYY.YYY system 


    Here 192.168.YYY.YYY is the IP address of the debian server hosting snmpd.

  • Verify test outputs look like:
    ...
    sysObjectID.0 = OID: netSnmpAgentOIDs.10
    sysUpTimeInstance = Timeticks: (1201) 0:00:12.01
    sysContact.0 = STRING: root
    sysName.0 = STRING: irsplsemos01
    sysLocation.0 = STRING: Unknown
    sysORLastChange.0 = Timeticks: (0) 0:00:00.00
    sysORID.1 = OID: snmpFrameworkMIBCompliance
    sysORID.2 = OID: snmpMPDCompliance
    sysORID.3 = OID: usmMIBCompliance
    sysORID.4 = OID: snmpMIB
    sysORID.5 = OID: tcpMIB
    sysORID.6 = OID: ip
    sysORID.7 = OID: udpMIB
    sysORID.8 = OID: vacmBasicGroup
    ...


  • Thats all folks!
    Defined tags for this entry: , , , , ,

iTunes could not connect to iPhone. An error occurred while reading from the device.

Posted by Tariq • Monday, January 18. 2010 • Category: Tidbits
After implementing tethering on my jailbroken iPhone 3Gs on 3.0 I got the following error from iTunes when I connected the iPhone to my PC with USB cable:


iTunes could not connect to iPhone. An error occurred while reading from the device.


I restarted iTunes but the error persisted. Then I followed the golden rule, if it isn't working then reset. So that is what I did. Hold the power button and home button until the white Apple logo appears. Once your phone reboots (may take a while) you should be able to connect it to iTunes again.
Defined tags for this entry: , , , , ,

Skype mute and unmute keyboard shortcuts in Mac OSX 10.5

Posted by Tariq • Friday, September 11. 2009 • Category: Tidbits
Ever do phone conferences? Ever put your microphone on mute only to be asked a question and then scramble your mouse to unmute your microphone? Well I do all of the above, well, until I came across a forum post at the Skype forums. I gave the guy's suggestion a go using ⌘M as the mute/unmute button but that only minimized the window. So, instead, I chose ⌘Z and it worked a charm; note, you will need to wait a little after call starts ringing before you can hit the keyboard shortcut. Plus, the keys are nice and close on the keyboard.

Defined tags for this entry: , , , , ,

Fixing binary merge conflicts in git

Posted by Tariq • Thursday, September 3. 2009 • Category: Tidbits
Git is an awesome tool for managing your code. However, it does take a while to get used to doing things in git. One question I get asked a bit too often is "how do I resolve binary merge conflicts"? Thankfully this is is pretty easy. I usually run the git mergetool command to allow me to resolve merge conflicts using a graphical interface and then manipulate the resultant files on the command line.

You can specify which editor to use in your ~/.gitconfig file. Favourites are kdiff3, vimdiff, xxdiff, and opendiff. If your on Mac OSX then you may be used to FileMerge, in which case you should be using opendiff in your .gitconfig; see below.

...
[merge]
tool = opendiff
...



So, when you are using mergetool option you will something like:
Normal merge conflict for 'lib/yui/assets/skins/sam/editor-sprite.gif':
{local}: created
{remote}: created
Hit return to start merge resolution tool (opendiff):


I just hit return so the editor opens, it will probably warn you the file is binary. In a separate terminal window navigate to the directory where the file is in and do an ls; you'll see something like what is below:
editor-sprite.gif
editor-sprite.gif.BACKUP.41930.gif
editor-sprite.gif.LOCAL.41930.gif
editor-sprite.gif.REMOTE.41930.gif


In this case editor-sprite.gif.REMOTE.41930.gif is the new file and editor-sprite.gif is the original file. To resolve the conflict just copy the REMOTE file over the original file. In my case it would be cp editor-sprite.gif.REMOTE.41930.gif editor-sprite.gif. However, I use the following one liner to resolve these conflicts more generically.


ls *.REMOTE.* | sed "s/\(\(.*\).REMOTE.*\)/cp \1 \2/g" | sh
 


I have it in shell script in my path so I just run it when I need to resolve these types of conflicts. It just finds files with REMOTE in them and then issues a cp command to copy that file over the original.

Hope this helps!

Outside of git mergetool you can just add the binary files using git add file1 file2 ....
Defined tags for this entry: , , , , , , , ,

Setting Google search language in Firefox 3.5 on the Mac

Posted by Tariq • Wednesday, July 29. 2009 • Category: Tidbits
While traveling around the place I have been highly annoyed at the Firefox search box's default behavior for Google search. While in the Middle East it shows me RTL pages in Arabic. Well you can easily fix this on the Mac!

Just open the file /Applications/Firefox.app/Contents/MacOS/searchplugins/google.xml in an editor. I normally use vim, so: vim /Applications/Firefox.app/Contents/MacOS/searchplugins/google.xml or you could let your OS decide open /Applications/Firefox.app/Contents/MacOS/searchplugins/google.xml at the terminal.

You should see something like:

...
<Url type="text/html" method="GET" template="http://www.google.com/search">
  <Param name="q" value="{searchTerms}"/>
  <Param name="ie" value="utf-8"/>
  <Param name="oe" value="utf-8"/>
  <Param name="aq" value="t"/>
  <!-- Dynamic parameters -->
  <Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
  <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
</Url>
...


We change this to:

...
<Url type="text/html" method="GET" template="http://www.google.com/search">
  <Param name="q" value="{searchTerms}"/>
  <Param name="ie" value="utf-8"/>
  <Param name="oe" value="utf-8"/>
  <Param name="aq" value="t"/>
  <!-- Stop Google from thinking we read anything but English -->
  <Param name="hl" value="en"/>
  <!-- Dynamic parameters -->
  <Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
  <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
</Url>
...


You can change this to any language (just change hl's value) or even country specific languages, like en_GB. When you finish editing save the file and restart Firefox (⌘Q). When using the search box you should now only see results in English.
Defined tags for this entry: , , , , , , ,

Doing OCR on linux/Mac

Posted by Tariq • Monday, July 27. 2009 • Category: Programming, Tidbits
Yesterday somebody gave me a USB key with ~1000 JPEGs on it. Each JPEG was a scanned page, ugh, and the task was to find some useful information about topic X. Now each JPEG was about 1-2mb and I needed to do something useful with these images quickly. So what follows is quick walk through of how to do Optical Character Recognition (OCR, that means taking silly image files and ripping out any text identified in them) on Linux or in my case a Mac.

Continue reading "Doing OCR on linux/Mac"

Encoding audio and removing file extensions from files

Posted by Tariq • Friday, July 24. 2009 • Category: One liners, Tidbits
Earlier today I got a massive SCORM object that contained lots of mp3 files. They were all high quality files, so I wanted to cut them down in size for web use. For this purpose I am using ffmpeg which you can easily get for Windows, Linux or Mac. I tried the following on a Mac, but it should also work on Linux (paths permitting) and on Windows if you are using something like cygwin.

I highly recommend you get familiar with ffmpeg as it is amazingly useful. Just check out the man pages; swf to avi, avi to something that works on ipods, all a breeze!

Continue reading "Encoding audio and removing file extensions from files"

Defined tags for this entry: , , , , , , , ,

Forwarding multiple mails in Google Mail

Posted by Tariq • Thursday, July 16. 2009 • Category: Tidbits
One gripe I have had for years is the inability in Google mail to forward more than one message at a time. I am not sure why it hasn't been implemented after all these years; scared of extra traffic, spam? Anyhows, this rant brings me to some new functionality Tasks. Now I could rant on about this a bit because IMHO it sucks ass right now, but hey, a move in the right direction. If it works well in six months I'd be happy.

But I'd be mucho mucho happier with the ability to forward multiple mails.

P.s. Anyone else notice the ultra crap quality of attached images when you click 'view' instead of 'download' lately?

P.s.s. This all doesn't negate the fact that Google Mail, overall, is awesome.
Defined tags for this entry: , , , , ,

Authentication usability gripes

Posted by Tariq • Wednesday, July 1. 2009 • Category: Tidbits
For the longest time I have been unhappy with password masking in GUIs. I never really saw the point and a whole host of functionality has been developed to help users out when dealing with passwords; browsers remember and auto-populate password fields for users. I use many passwords, even have my own encrypted password lists, however, I only use a handful of sites everyday and I know those passwords pretty well. This doesn't stop me from making errors while typing complicated 10-16 character passwords -- three in a row is not unheard of and then you have to deal with unreadable CAPTHAs. Seeing the password reinforces the context in which the password is used and helps users learn them off more quickly.

A much better option is to use a screen privacy filter to stop a wide audience from snooping over your shoulder.

This is just one of those gripes that was rekindled when I read The Problem with Password Masking.
Defined tags for this entry: , , , , ,

Auto corrupting your PDF files

Posted by Tariq • Tuesday, June 30. 2009 • Category: Tidbits
A few weeks ago I came across a blog post which showed you how to corrupt your own pdf files. That post was in response to the interweb ate my homework post from Bruce Schneier.

Anyhows, Didier's method is fairly simple -- there are many other ways todo this like truncating the file or inserting some randomness using dd and /dev/urandom. So lets automate it.

Continue reading "Auto corrupting your PDF files"

Defined tags for this entry: , , , ,

Searching compressed Apache logs

Posted by Tariq • Tuesday, June 23. 2009 • Category: One liners, Tidbits
From time to time things tend to go wrong and systems tend to go crazy. Sometimes these errors are more of nuisance than anything else, an intermittent annoyance you'd prefer not to investigate -- trawling through logs is a pain in the backside. Now you need to take a peak at those compressed Apache error log files, ugh! Well before you look for suitable places to hang some rope try running some expressions across a certain number of files. Normally you'd only want to look at logs for the last 7 days, so lets give that a go.

Continue reading "Searching compressed Apache logs"

Defined tags for this entry: , , , , , , , , ,

Downsides of using Tor

Posted by Tariq • Thursday, February 26. 2009 • Category: Tidbits
Shows Google being used over the Tor network, but Google thinks I no speaky the English.
Shows Google being used over the Tor network, but Google thinks I no speaky the English.

A small inconvenience I am sure! Well that and speed, which is horrendous.

Some interesting links: Nice overview of Onion and Garlic routing, Low-Cost Traffic Analysis of Tor, Low-Resource Routing Attacks Against Anonymous Systems, Shining Light in Dark Places:
Understanding the Tor Network
(are the authors in jail for wire tapping?) and Tor hack proposed to catch criminals (or anyone, don't expect all the kids to play fair). For some background check out Privacy on the Line: The Politics of Wiretapping and Encryption.

Edit: The researchers did not go to jail.
Defined tags for this entry: , , , , ,

Rubber hose attacks!

Posted by Tariq • Saturday, February 7. 2009 • Category: Tidbits


Awesome! Hot linked from xkcd. Also, checkout wikipedia for more details on what the Russians do and how public key crypto could get you killed or landed in jail (if you live in the uk).

Defined tags for this entry: , , , , , , ,

Scared of Sinn Fein?

Posted by Tariq • Thursday, January 29. 2009 • Category: Tidbits
You should be scared and not just of Sinn Fein -- Labour is pretty scary too! Take a look at the scandalous proposals of the opposition.

Fine Gael's looks promising and it would be nice to compare with Fianna Fáil's only they don't have a plan.

Defined tags for this entry: , , , , ,

What to expect

Posted by Tariq • Monday, December 1. 2008 • Category: Tidbits
Hello and welcome to my blog. I'll post on about pretty much everything, but mainly you can expect a raft of posts about Moodle, MySQL. Postgres, Debian, SLES 10 (probably rants), high performance stuff and a peppering of security related goodness. If you've just stumbled across this blog come back soon and I might have something worthwhile for you to read.
Defined tags for this entry: , , ,