02 March 2014

Unite. A hobby project

Unite, is a project I began working on, when I wanted to re-learn web app programming. The project is designed to have a highly customizable front-end, a robust back-end and either a relational or a graph database. The project is hosted on GitHub under GPL v3. This is also meant to serve as a project that will give me a deeper understanding of using Git, continuous integration (Jenkins), Issue tracking (Trac), automated testing, automated code coverage checking, build scripting (Gradle), automated bug finding and deployment (Phew! Big target to achieve with the limited time I get everyday). This page captures the progress of the project.

Setting up the basics

Setting up a new project on GitHub was a breeze. Once done, I cloned the repository onto my local machine and using SmartGit, created an authentication token, the folder structures, spent an awful lot of time learning Gradle by myself and decided to use Gradle with Netbeans (which has Gradle support built-in) because the Eclipse plugin ended up giving me some errors during build. Setting up a continuous integration build right from the start was a practice I wanted to follow, so after installing Jenkins (tried Hudson too. It's good, but I liked Jenkins' interface better), it's plugins and successfully figuring out how to trigger a build on Git commit (this is a better approach than making Jenkins poll to check for code changes), the project was ready for some real coding.

D3.js as a general purpose data visualization library on the web

What would one do when one wants to use JavaScript to graphically display some data or statistics on a web-page? Use a library of course. I saw a lot of libraries, but was shocked at what d3.js had to offer. Just have a look at these:



Amazing! The initiators are Michael Bostock, Jeffrey Heer, Vadim Ogievetsky, who created d3.js (BSD license) based on the experience they had from the stepping stones of other similar projects that didn't work out very well.

It takes a while to figure out how to use d3. If you have a good understanding of JavaScript, you can start off right away. If not, the concepts of anonymous functions and closures will help you learn. Most of the impressive functionality can be implemented with just the d3.js file (319kB). A more compressed version of the file d3.min.js (144kB) is also available. More advanced functions are available in the supporting script files of d3.

A novice would find it surprising, the way d3.js works. By selecting elements of the DOM before they're even created. By passing variables like "d" and "i" internally, which don't seem to be declared anywhere.

But that's the challenge that makes it worth learning! D3 is a tool with which you can use on any area of the DOM. You can create any kind of visualization you want.

To make d3.js simpler, there are encapsulating libraries like nvd3, c3, cubism and rickshaw.

Went through the source code of d3 as usual, and was completely taken aback when I saw they've used the actual pi, phi and lambda symbols as variable names! Decided to ask my community, and here's what they had to say about it. Although it looks fancy, it's better to stick to variable names rather than symbols. Psst...if you want to generate pi on your screen, make sure the num lock on your keyboard is on; then keep the alt key pressed and type 227 on the num pad and you'll get the pi symbol like this ( π ). I pasted it in notepad, and it didn't turn into a junk character. Cool, isn't it?!
Jeff Atwood had an article on the use of unicode too (the 'entity' word is to be replaced by a heart symbol).

After dabbling with d3.js for about a week, I created an ajax program to query a servlet for data and display the retrieved data on a d3 graph. Worked like a charm!

A nice source for learning are the tutorials from the main website, practically trying it out a little, a free book and if that isn't enough, more than a thousand examples with sources, for you to refer. Definitely a work of art!

01 March 2014

Keeping those wires all neatly wrapped up (and a point on wireless electricity)

Well, as software people, we also have to deal with hardware issues :)
One of them, is getting wires in place. While there are various clever ways to do it, the one that solves the problem of keeping earphones nicely and inexpensively wrapped up, is this one.

This could have been a time and age where we would not have had to deal with wires. It'd have been a reality if Tesla's Tower of Power wasn't pulled down by economic problems and a short-cut, cost-effective solution to communication by Marconi.
More on the Wardenclyffe Tower here: http://en.wikipedia.org/wiki/Wardenclyffe_Tower
Same story told in a damn-interesting way :-)  http://www.damninteresting.com/teslas-tower-of-power/

It intrigues me, the way some people develop an intuitive understanding of a subject. Tesla understanding the working of electricity, in this case. Einstein, understanding the concept of relativity. Newton and gravity.

What also intrigues me is the way commerce isn't designed to produce the best possible outcome. Corporates always go for the short-term approach which makes money (and hence sustains life), rather than the long-term approach which could have sustained life in a much better way. A concept called Hyperbolic Discounting.

Looking forward to a truly wireless future.

08 February 2014

How to trigger a Jenkins build on git commit

I spent quite some time figuring this out, but was happy when it worked. This is for Windows. In Linux, the process is the same, but it's far easier.

First, you have to know that if you've installed Git in Windows, it comes with curl pre-installed. So just open the Git bash prompt and start typing your commands.


Let's say you have a Jenkins job setup on localhost, named "someJob". To initiate a build, just type the following command in the Git Bash prompt:

curl http://localhost:8080/job/someJob/build?delay=0sec

That's it. Once you've typed the command, just have a look at your Jenkins dashboard and you'll see your project building. (you might also want to know about this)

Now to make a Git commit trigger the build, you have to navigate to the hidden ".git" directory in your git repository. Enter the "hooks" directory and you'll see there, a "post-commit.sample" file. You can open it with Notepad++ to see the contents of it.

Make a copy of the file and name it "post-commit". It does not need an extension. This is the file that Git will invoke whenever you do a commit to this particular Git repository. Don't worry about the fact that it looks like a Linux bash script. When Git triggers it, it will run even in Windows. If the file has a line ": Nothing", you can remove that line and insert this new line:

curl http://localhost:8080/job/someJob/build?delay=0sec

Now save the file, make some changes to your git repository and commit the changes. The moment you commit, you'll see the build being triggered in Jenkins! Awesome! :)


-----------------------------------------------------------------

Additional note: Many people reach this page via a StackOverflow answer. One such person (see comment below answer) mentioned being confused about what "someJob" was and also had faced an issue with his project name having a space in between, so he had to substitute "%20" in place of a space "codecept%20tests". Hope his response would be of help to anyone else who faces a similar situation. Thank you Paul.


07 February 2014

Access GitHub with an authentication token instead of your Github password

I'm currently using the SmartGit client, as it's good and crossplatform. When I wanted to connect to my GitHub repository for a hobby project I was working on, I was a bit uncomfortable sharing my Github password with the application. Good thing is, Github allows you to also create a token which SmartGit can use to authenticate.

Click on settings on the top of the page:
Select "Applications" and "Create a new token". Use the hash value that gets generated (and treat this token like you would treat a password)


05 February 2014

Contributing to the open source community

How many developers actually help out in the open source community? The numerous software we get to use for free are a result of people willingly putting in effort to create good quality software. I believe that if we are using such software, we can also help the community by contributing back.

Some ways you can contribute:

1. Be a part of the forums / mailing-lists and answer queries of people struggling with learning / implementing the software. I've been a member of some forums and mailing lists under various usernames (Actionscript, Intel TBB, Processing, OSG, OGRE, Stackoverflow and it's sister sites, linuxforums, ffmpeg, netsnmp, SDL and many others).
2. Join the development of the software and contribute patches. Websites like OpenHatch can help you get up to speed with the process.
3. Allow the software to report back crashes and anonymous usage statistics. The latter helps the dev's to improve the UI and interactivity by having authentic user journeys. I've allowed these for Fedora, Netbeans and a few other software.
4. When you find a bug, report it on their issue tracking system. I filed an issue today.
5. Sponsor them. Jenkins allows you to sponsor a particular issue. Other projects allow you to donate to the overall development effort. These people really do deserve sponsorship for the great work they're doing.
6. Add to the Wiki. Most projects have a Wiki page which you can add useful information to.
7. Create tutorials. Many users have a tough time learning how to use a software. You can create video tutorials and post them on youtube or post tutorials on your blog. I used to create tutorials on Stackoverflow too: my Mutex tutorial becoming the highest ranked in Google searches.

Doing all this not just makes you a good contributor to the community, it also expands your skills. It makes you a better developer, as you get exposure to international best-practices, standards, technologies. It improves your communication and hones your technical skills. I'd encourage every software developer to participate. All the best!

Say thank you or donate

04 February 2014

How to install plugins for Jenkins?

I wanted to install the plugin for Gradle and was perplexed that there was no download button on this page: https://wiki.jenkins-ci.org/display/JENKINS/Gradle+Plugin

A bit more searching led me to: https://wiki.jenkins-ci.org/display/JENKINS/Plugins#Plugins-Howtoinstallplugins

Start Jenkins on your browser, go to "Manage Jenkins" and you'll see the option for "Plugin manager".

Select which plugins you want, and install them. It'll take a while for it to download and install. As the how-to page says, you can also install the plugins manually.

I chose the following, as there was quite a bit of experimentation I wanted to do with a lot of tools. A pity there wasn't any ready plugin for graph databases:

  • Git Client Plugin
  • SCM API Plugin   
  • Git Plugin   
  • Git Server Plugin   
  • Git userContent plugin   
  • Git Chooser Alternative Plugin   
  • ruby-runtime   
  • git-notes Plugin   
  • Static Code Analysis Plug-ins   
  • Task Scanner Plugin   
  • Database Plugin   
  • PostgreSQL Database Plugin   
  • LDAP Email Plugin   
  • MSBuild Plugin   
  • Cobertura Plugin   
  • EasyAnt Plugin   
  • GitBucket Plugin   
  • SSH Agent Plugin   
  • The Continuous Integration Game plugin   
  • jQuery Plugin   
  • jQuery UI Plugin   
  • Terminal Plugin   
  • ClearCase Plugin   
  • ClearCase Release Plugin   
  • Gitlab Merge Request Builder Plugin   
  • Gitlab Hook Plugin   
  • JUnit Attachments Plugin   
  • xUnit Plugin   
  • JSUnit plugin   
  • GitHub API Plugin   
  • AnsiColor Plugin   
  • JSGames Plugin   
  • Mercurial Plugin   
  • Git Parameter Plugin   
  • Github OAuth Plugin   
  • Build Monitor Plugin   
  • CodeCover Plugin   
  • NUnit Plugin   
  • ClearCase UCM Plugin   
  • jQuery UI Plugin   
  • Valgrind Plugin   
  • MySQL Database Plugin   
  • Eclipse Update Site Plugin   
  • jQuery Plugin   
  • Parameterized Trigger Plugin   
  • Build Pipeline Plugin   
  • HTML5 Notifier Plugin   
  • Gitorious Plugin   
  • Git Plugin   
  • Trac Plugin   
  • ClearCase UCM Baseline Plugin   
  • Python Plugin   
  • Checkstyle Plugin   
  • Gradle Plugin   
  • JDK Parameter Plugin   
  • cmakebuilder Plugin   
  • ClearCase Plugin   
  • Active Directory plugin   
  • Signal killer   
  • MySQL Authentication Plugin   
  • Metadata plugin   
  • Git Client Plugin   
  • Git Server Plugin 
  •  Parallel Test Executor Plugin

Did you notice that there's a The Continuous Integration Game plugin? I felt it was pretty cool of them to have brought in Gamification into CI.

03 February 2014

Getting Gradle integrated into Eclipse

It was nice learning Gradle, but I felt it'd be a bit more convenient to have Gradle inside the Eclipse IDE. Gradle is already present in the Netbeans IDE, but for Eclipse you have to install it like so:

This project at Github is what you need: https://github.com/spring-projects/eclipse-integration-gradle

From the documentation on the website, just follow the same steps:
  • Open the Eclipse IDE
  • Select Help > Install new software
  • Paste a Gradle update site link (http://dist.springsource.com/release/TOOLS/gradle) into the "Work with" text box. 
  • Ensure that the option "Group Items by Category" is enabled.
  • Select the top-level node 'Extensions / Gradle Integration'.
  • Click "Next".
  • Review the list of software that will be installed. Click "Next" again.
  • Review and accept licence agreements and Click "Finish".
It'll take a while to install:


Now in Project Explorer, right click on your project, go to Run As > 2. Gradle... to run the project under whichever tasks you want to select.


You don't always have to return to this dialog box. The next time, you can simply run the selected tasks using Run As > 1. Gradle.
If you add any tasks externally, click the refresh button to view that task.

It's that simple. Happy building! :)

01 February 2014

How to add the path of the JDK to JAVA_HOME in Linux?


If you've already installed the JDK, it's as simple as this:
type locate jdk and search for the path.

Mine was in /usr/local/jdk1.7.0_45/

So I opened up bash_profile with
vim ~/.bash_profile

and added the following line into it.
JAVA_HOME=/usr/local/jdk1.7.0_45
export JAVA_HOME


Also add :
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/gradle-1.10/bin:/usr/local/jdk1.7.0_45/bin
 

So that when you execute commands like jar -xf somejar.jar, the executables will be recognized.


Then type source ~/.bash_profile to activate the changes you made (basically the whole of bash_profile will be executed again).

That's it! all programs will recognize JAVA_HOME. I had to do this for Gradle to recognize the path. Without the path, it didn't compile Java programs.

26 January 2014

Gradle installation and example / tutorial for Linux (Fedora 20)

When I wanted to re-learn Ant, I found Maven. When I found Maven, I found out about Gradle being better than Maven. And indeed it did seem to be so.
The Gradle build script appeared a lot shorter and more powerful than Maven. There is also a more feature-rich C++ version for Gradle coming up and a demo and cpp plugin already available.

This is intended to be a simple tutorial for Gradle. Recording my path in learning the what and why of Gradle.

To give it a shot, download the Gradle binaries, extract them into /usr/local/ with sudo unzip gradle-1.10-bin.zip.

To run Gradle, you have to add the path of the Gradle bin folder to PATH. So do this:

sudo vim ~/.bash_profile

Add the path this way in .bash_profile

 PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/gradle-1.10/bin

Save, exit and type source ~/.bash_profile to incorporate the changes immediately.

Type gradle -v and you'll see the Gradle version, build time, build number etc. Congratulations.

To try out Gradle, create a file named build.gradle file in any directory you like and as the Gradle documentation says, paste the following content in it:

task hello {
    doLast {
        println 'Hello world!'
    }
}

Save, exit and then type gradle hello for the script to execute (gradle.build isn't exactly a build script. It's a build configuration script; which means that it's a script we write, which internally creates the necessary build script automatically. Saves us a lot of trouble, really!)

Now that you know Gradle works, you have to understand that Gradle thinks in terms of high-level tasks. You have to learn the syntax of writing tasks.

Type gradle tasks at the terminal (in some other directory which does not have a build.gradle file in it) to see the list of tasks that gradle supports by default. You'll see something like this:

All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
dependencies - Displays all dependencies declared in root project 'nav'.
dependencyInsight - Displays the insight into a specific dependency in root project 'nav'.
help - Displays a help message
projects - Displays the sub-projects of root project 'nav'.
properties - Displays the properties of root project 'nav'.
tasks - Displays the tasks runnable from root project 'nav'.

To see all tasks and more detail, run with --all.

BUILD SUCCESSFUL

Total time: 3.327 secs
This means that similar to how you had defined a "hello" task above, Gradle already has such tasks named dependencies, help, properties etc., already defined somewhere. To see proof of it, type gradle help and see the result. These tasks are already part of Gradle by default. That's why you didn't need a build.gradle file.

Now go back to the directory where you created the build.gradle file. Now type gradle tasks and you'll see a similar output as above, with the additional display of "hello" as a task. Which means that in this directory if you type gradle hello, the hello task will be executed.

Gradle encourages convention over configuration, so it'll be easier for us to create a new project with the following directory structure:

src/main/java  for production Java source
src/main/resources for production resources
src/test/java for test Java source
src/test/resources for test resources
src/sourceSet/java for java source for the given source set
src/sourceSet/resources for resources for the given source set

Create a simple java class inside src/main/java, named Main.java with the following contents.
public class Main
{
    public static void main(String[] args)
    {
        System.out.println("in main");
    }//main
 }//Main class

Go back to the folder where your build.gradle file is. Now to be able to build a Java project, you haven't created any tasks. Thankfully, Gradle comes with a plugin which has the necessary tasks for building a Java project, predefined. Open your build.gradle file and add this line as the fist line of the file: 

apply plugin: 'java'


Save and exit and type gradle tasks. Now you'll see a lot more tasks listed. Running the gradle build command will automatically find your Main.java file, create a build directory for it, place the ".class" file there and will also create a jar file for you in build/libs.

Now if you try to run the jar file with java -jar jarname.jar, it won't execute because you didn't specify the application entry point in manifest.mf.

So now open your build.gradle file and add the following info to it:


apply plugin: 'java'

jar {
    manifest {
        attributes(
            "Implementation-Title": "Tutorial",
            "Implementation-Version": 1.0,
            "Main-Class": "Main"
            )
    }
}
Now executing the gradle build command will create the manifest file and you'll be able to execute the jar. Similar to make files in C and C++, you can run a clean command with gradle clean and the build directory will get cleared.


Gradle can  automatically create Eclipse project files for you. Just add to your build.gradle, the following line 
apply plugin: 'eclipse'
Type gradle tasks and see a new set of tasks you've got.

Now type gradle eclipse and when you type ls -altr you'll see the Eclipse project files have been generated. Open Eclipse, go to File > Import > General > Existing projects into workspace and you'll be able to use this newly created Eclipse project.













Learn to use a mouse with your other hand

If you're working a lot on the computer, wrist discomfort is a sign that you should be taking rest more often. If you still have to work, and you're sure the discomfort is because of using the mouse, then do consider this:

Learn to use the mouse with your other hand. Switching hands this way gives your overworked wrist the rest it needs. I started doing it and it really helped. It'll take a couple of weeks of practice to get used to it, but it'll help a lot. Do give it a shot!

Installing Jenkins on Fedora 20

Typing sudo yum install jenkins strangely didn't work (even though it was on the Jenkins website). It's then I realized that what they showed on the website was a three step process and not options to choose from. The first two steps are meant to do the initial setup necessary for downloading jenkins. So this is what you do:

Type:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins

Once that's done, use the following for their obvious functions:
sudo service jenkins start
sudo service jenkins stop
sudo service jenkins restart 

So  start Jenkins, open a browser and type "localhost:8080" in the address bar. You'll see the Jenkins page. The default port used by Jenkins is 8080. 

_______________________________________


Bonus info

You can create aliases for Jenkins in bashrc so you won't have to type those long commands again.
Open up bashrc with 

vi ~/.bashrc

and type in these lines into it.

alias startjen='sudo service jenkins start'
alias stopjen='sudo service jenkins stop'
alias rejen='sudo service jenkins restart'

Save and exit by pressing. (Make sure you type capital Z's).

Escape key and ZZ

Type this at the command prompt to activate the aliases you just created

source ~/.bashrc

The feel of Linux UI vs Windows UI vs Mac UI vs the ideal UI

I've worked on all three OS'es, and it's just a personal opinion that the UI I've loved the most is that of Windows XP.

People who haven't had the chance to venture into the field of interaction design would usually not mind this aspect, but after having had internationally acclaimed interaction designers as my bosses for two years, I've developed a similar gut -feel for quality that they have.

A product has to look and feel right. It has to have an emotional value that appeals to a certain kind of user.

The Windows XP UI has a nimble, crisp, efficient feel to it. Especially after you disable the special animations and effects in the performance settings. The 'click' sound played on every folder click adds to the experience. It just feels right. Feels comfortable to work on (except maybe for the way the taskbar tab flashes in orange :-) ). The UI responds promptly to clicks and key-presses. A good operating system for a new person entering the world of computers.

The Linux UI has a lot of visible effort put into creating it. With distros like Fedora and Ubuntu opting for a minimalist design, the UI has become less usable for a person already accustomed to an OS like Windows. Much less usable for a person with no experience with computers. The UI feels cumbersome to use. It's not as responsive to clicks as Windows XP, and some operations are just un-intuitive. Eg: If a Firefox window is open and you click the Firefox icon again, it doesn't open another window. Right clicking on the file-browser does not produce the option for creating a new text file. Clicking the shutdown button shows options to shutdown, but no logout button (you have to click the user icon to see the logout button). 
But then again, Linux was not really meant to have a lovely UI (although I wish they'd make it like Windows XP). It's power comes from the commandline, and that's what programmers love about it! In terms of the commandline and security, Linux beats Windows hands-down any day. As a programmer, this is the reason I like Linux.

The Mac UI, although pretty much like Linux, has a kind of a sticky, dragging feel to it (as compared to the crisp feel of XP). I was using a G4. It's a combined effect of the hardware and the software that produces this feel. In terms of intuitiveness, the Mac was good. I just loved the fact that to remove a program, I could just delete the folder instead of being like the add and remove programs of Windows or the uninstall techniques of Linux. The animations and sounds were un-intrusive and pleasant. 

The Ideal UI though, as just a figment of my imagination, would be part of a machine that can read the mind of a living being (note that I didn't mention it as 'human'). It would be a machine we wouldn't have to talk to, for it to understand exactly what task we want to accomplish. It would not be made of metal or plastic or any material which would incorporate delays in input/response. It would give us the perfect aesthetic and emotional feel customized to our personality and interface needs. Such a technology may be very far away in the future, but I'm predicting it now because I do believe it can be a reality.

Until then, back I go to working on my hobby project for which I'm trying to design an intuitive UI.

18 January 2014

Installing Adobe Flash on Fedora 20

Numerous people including me have been at a loss when we tried installing Adobe Flash on or Fedora installations and it never worked!
Finally, I found that there is a solution that works:
 
sudo yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl
 
Enjoy! :)

Installing Net-SNMP and SNMPTT in Fedora 20

Documenting this on-the-fly for my reference and anyone else who would find it useful.

After freshly installing Fedora 20, I was perplexed to find that it didn't have gcc or g++ installed. So step 1 is to get them. (You don't really have to use sudo in all steps below)

sudo yum install gcc 

sudo yum install gcc-c++

You can also optionally install mysql (if you wish to have MYSQL Trap Logging) like so:

sudo yum install mysql
sudo yum install mysql-server
sudo yum install mysql-devel
sudo chgrp -R mysql /var/lib/mysql
sudo chmod -R 770 /var/lib/mysql
sudo service mysqld start 


Also ensure Perl and a supporting module is installed:

sudo yum install perl

(you might be able to install all supporting modules for Perl like this: "sudo yum install perl-*", do give it a shot. It'll be a larger download though)

You'll need two ExtUtils of Perl which you can either install separately like this:

sudo yum install perl-ExtUtils-MakeMaker
sudo yum install perl-ExtUtils-Embed

or install everything in one go like so:

sudo yum install perl-ExtUtils-*

For running snmptt, you'll also need:

sudo yum install perl-Config-*
 
 

Then download Net-SNMP, and extract it into your /usr/local/ folder with:

sudo tar -xvzf net-snmp-5.7.2.tar.gz.

Navigate into the newly created net-snmp directory and type:


sudo ./configure --enable-embedded-perl --enable-shared --with-mysql

Or if you don't want embedded perl, type (you'll need to install with embedded perl for this tutorial):

sudo ./configure --with-perl-modules --with-mysql

You'll be given a lot of options. Just keep pressing enter for all of them (unless you want to configure it differently).
Once configuration is done, type:

sudo make -j 4

The -j 4 is to tell make that it can use the four cores of my processor. It works faster this way, by dividing the make process into separate jobs which complete parallelly. You can also simply type "sudo make". At any point if you want to redo the make process, type "sudo make clean" and you'll be able to start from the configure step again.


Now you can optionally start "make test" which is not really required, but it is what helped me find out that I didn't have ExtUtils-MakeMaker installed. I wasn't able to make install without it, and the net-snmp mailing list was unable to figure it out either. I updated the mailing list with the solution when I found it.

sudo make test
sudo make install 

...and tadaah! You now have net-snmp installed!
The snmptrapd file which snmptt requires, you'll now find installed in /usr/local/sbin/snmptrapd

To be able to start and stop snmptrapd, a script is also included.
sudo cp /usr/local/net-snmp-5.7.2/dist/snmptrapd-init.d /etc/rc.d/init.d/snmptrapd

You can optionally use the above script to start snmptrapd with the command "sudo service snmptrapd start"or "snmptrapd -On"



------------------------------------

Now for snmptt:

Extract the snmptt tar file into /usr/local/ using:

sudo tar -xvzf snmptt_1.4.tgz

Navigate into the newly created snmptt_1.4 directory and create a file named snmptrapd.conf:

sudo vim snmptrapd.conf



To test out snmptrapd, add the line "disableAuthorization yes" to the snmptrapd.conf file (remove this line later for proper authorizations) and type the following command at the terminal:

sudo /usr/local/sbin/snmptrapd -f -Lo -c /usr/local/snmptt_1.4/snmptrapd.conf

snmptrapd will start and will keep listening for traps.
Meanwhile, download and start a MIB browser like the one iReasoning has.
Go to Tools > Trap sender in the MIB browser and type the address to send traps to, as "localhost" (without the quotes). Then click the "Send Trap" and immediately, you'll see the trap being received at the terminal where you started snmptrapd.


You have the choice of installing snmptt as a standard handler or as an embedded handler. I'd recommend installing as the embedded handler, because it is loaded when snmptrapd is started, so it won't need a process to be created everytime a trap is received (which is what happens with the standard handler). Type the following commands:

sudo cp snmptt /usr/sbin 
sudo chmod +x /usr/sbin/snmptt
sudo cp snmptthandler-embedded /usr/sbin/
sudo mkdir /etc/snmp/
sudo cp snmptt.ini /etc/snmp/ (you can change settings in this file)

sudo cp examples/snmptt.conf.generic /etc/snmp/snmptt.conf
sudo mkdir /var/log/snmptt/

Open the snmptrapd.conf file and add the following line to it "perl do "/usr/sbin/snmptthandler-embedded";"

sudo mkdir /var/spool/snmptt

sudo cp snmptt-init.d /etc/rc.d/init.d/snmptt (this is a script that can be used to start and stop snmptt)

and now add snmptt as a service:
sudo chkconfig --add snmptt

Configure snmptt to start at runlevel 2345
sudo chkconfig --level 2345 snmptt on

The above command will start snmptt automatically on reboot. You can also start it right now using:

sudo service snmptt start

To stop it, use:
 
sudo service snmptt stop


Copy a script to rotate log files:
sudo cp snmptt.logrotate /etc/logrotate.d/snmptt (you can edit this file if you wish)