Periodic monitoring connection to certain port of certain ip address

in

While running a kannel server, I need to make sure certain connections to telcos are up. And here is a simple technique taiyal from ##linux suggested me. It is pretty simple though.

$ netcat -z -w 2 192.168.10.1 5020 -v -n

Netcat is a very simple utility command to connect to a certain ip at certain port. The parameters are as follows.

-z              zero-I/O mode [used for scanning]
-w 2            timeout for connects and final net reads
                in our case try to connect for just 2 seconds
-v              verbose [use twice to be more verbose]
-n              numeric-only IP addresses, no DNS
                No need for dns resolution

Add this to a cron and redirect the output to log file and we're set.

Here is my crontab

$ crontab -e

# m h  dom mon dow   command
*/5 * * * * /home/monitor/bin/checksmsc.sh

And here is my checksmsc.sh code

$ cat /home/monitor/bin/checksmsc.sh
#! /bin/bash
datetime=`date`
log=`netcat -z -w 2 192.168.10.1 5020 -vn 2>&1`
echo $datetime $log >> /home/monitor/log/connection.log

Make sure you make the log folder

$ mkdir /home/monitor/log

Output is in the format as

Sat Jan 30 14:25:02 NPT 2010 (UNKNOWN) [192.80.10.1] 5020 (?) open

Besides netcat, you could also use nmap command

$ nmap 192.168.10.1 -p T:5020 -oG filename.txt

Where -oG specifies output in Greppable format and writes out to filename.txt

Simple tcp monitor :)

Where do you find brilliant ideas?

Seriously, where do you find brilliant ideas? Do you have to brilliant, creative, active, thoughful, ..., ?? to get the ideas? Well it might be that being brilliant or creative or thoughtful is just a bi-product of having great ideas.

I have been in search of a great idea, a great *Product* idea to be specific. Last week I saw the video from David Heinemeier Hansson (http://www.loudthinking.com/) where he speaks about creating a profitable startup company. See the video here http://www.youtube.com/watch?v=0CDXJ6bMkMY . It is pretty impressive, thanks to Geshan (http://twitter.com/geshan). He talks about the small challenges startups face and the why not to fear for not being successful. It is not necessary to target to be the next facebook or twitter or google or microsoft and a startup should just focus on getting your own product up and build your own small client base and keep them happy. I've seen few other products, small but quiet useful. I think they should have a mediocre client base and have good revenue stream. 

Take the mockup tool Balsamiq for example. It costs 79$. That isn't much for a tool of such good use and a lot of people will actually prefer to pay for it. If you build something useful, people will pay for it. The same goes for the online source code hosting website github (http://github.org). Pretty awesome right?

A lof of these ideas aren't the very first time people have come up with. There must have been a lot of mockup tools before Balsamiq and a lot of source code hosting facilities other than GitHub, and there will be others too. The idea it seems is to not to focus to beat the other guy, but to start delivering products to your clients. If you focus on 5 clients today, it is very much possible to have 10 clients tomorrow if you have a good product. To constantly deliver and innovate should suffice one to stay in the business. Why not you stay in the business and let others do their own business. Take it small I guess.

And to once again come back to topic, it seems when nurturing a concept, its more of a we than I, when coming up with ideas. I alone might come up with 3 ideas and only one of it might actually be good enough, but when there is a group, innovation starts to flow. Two person with three ideas each will be six ideas to start of. Take one good idea from it, work on it, brainstorm and modify to make it better. Sounds interesting.

And to have the *we* thing, ie to build a good team there needs to be communication. That is where this post comes in. I have been lacking enough creativeness to really start blogging till now. And shall I now start blogging just to get my point out to open, no matter how small or how insignificant it is.

Living in Kathmandu

Living in Kathmandu is really weird, one day you could be full of cash and another day you have a hole in your pocket. You really need a money management strategy to have a peace of mind. On a typical day, I see people spend around 250 Rs and that too on daily items like food, transportation, telephone etc. A decent mid day meal costs anywhere from 100 Rs to above. Add a cup of coffee in a good restaurant and that jumps to 150. And an occasional friday night out for some quality time at bars would mean I have the shelve out 500 to 1000 rs.

Converting .wav files to .mp3 files in Ubuntu 9.04

The process is a two step process:

First,
Install the required packages
$ sudo apt-get install libavcodec-unstripped-52

Second,
Use proper command line tools for the conversion
$ ffmpeg -i source.wav -acodec libmp3lame -ab 64k destination.mp3

Now although it looks simple, I wasted two hours trying out different tools lame, mencoder, etc and wrong options with ffmpeg. Unnecessary bheja fry!

Cheers

RTFTR came second in OSCN Competition

in

After a year of work put into the project and lots of ups and downs during the development, RTFTR has finally won second prize in the "Open Source Competition Nepal" organized jointly by D2HawkEye services and Pulchowk Engineering Campus.

The environment during the event was quite entertaining and exciting. Everyone in the d2provided TShirts were already hacking into their softwares for the final day demo.

The patient people

in

Some people have too much patience. I went to the doctor today. Having lost my Record Book with all past histories I was feeling guilty because we grown ups are supposed to be more careful about our stuffs. I went to the hospital, waited outside doctors room. Wasn't sure if the doctor will see me. The nurses couldn't put me in queue since I had no RecordBook.

The doctor came out of his room hurriedly, he must have thought no more patients. Saw me, Oh ur still left.. humm come in and took me inside, got me a new Record Book, couple of questions regarding my history and everything is good.

Choosing a senior year project.

I've listed myself at Technorati. Technorati Profile

The senior-most year at our college, IOE (http://www.ioe.edu.np) has a course that requires everyone to complete a Project. We call it Major Project, reason being the junior year has similar but small scale project thats called Minor Project. A lot of students I've seen are really confused as to what topic to choose to do their projects in.

Now that I've completed my undergraduate and am working as a full time employee, let me share my experiences.

Loadshedding Schedule as of May 20, 2009

New loadshedding schedule with 8 hours per day.

Update links

PDF version
Doc version

Cheers

Arsenal 4 - 4 Liverpool

What an exciting game full of highs and lows. Today's game at Anfield, I would remember it for the poor defense Arsenal has played in a long time. Our "should be a rock solid" backbone of Sagna, Toure, Silvester and Gibbs put up a "couldn't have sucked more" display.

Arsene didn't have any other choice, with Clichy, Gallas and Alumnia out till a distant future, I could only imagine what would Ronaldo and Rooney do to our defenders on the Champions League game on wednesday.

The game started with some smooth passing from Arsenal and I was expecting the regular Arsenal game. After a while Liverpool pressure started to build up. Arshavin's first half goal was some relief.

Second half, two goals in quick succession within 10 minutes was an amazing display by Liverpool. Just what i feared the most. After watching them play against Chelsea, I knew anything was possible. But it is quite few a times when you get to see Arsenal come back from behind. That amazing thing happened as Arshavin, our savior in tonight's game rescued us and secured a point.

The difference I felt was mainly due to Walcotts introduction in the second half. Denilson who was replaced by Theo was barely visible, to be honest i just saw him playing when his name got called during the substitution.

Whenever we went forward, there was a sense of hope. 0-1, 1-1, 2-1, 2-2, 2-3, 3-3, 3-4 and 4-4 was far more than breathtaking. At times I was down on my knees praying to god, trying to bribe him that I'd start believing in him if we won. I guess he doesn't take any bribe but the match was sensational.

And of course a 6 minutes extra time in the end and liverpool shouting for penalty .. nearly gave me a heart attack.

Hopefully Gibbs learned more from this game..

If we can produce this result with such defence, I'm more hopeful for Arsenal's further pefromance.

Go GUNNERS!!!

jQuery code to get the x, y coordinate of mouse click of any visible element.

in

While trying to get the x and y coordinates of the location where a user clicked on a particular image, i just stumbled upon a "not-a-definite-solution" with posts written on different blogs and a lot of different techniques people have used.

So here is my version with bits and pieces put together.

First lets get the x,y coordinates of any given element on the page.

File: jquery.elementlocation.js

  1. jQuery.fn.elementlocation = function() {
  2. var curleft = 0;
  3. var curtop = 0;
  4.  
  5. var obj = this;
  6.  
  7. do {
  8. curleft += obj.attr('offsetLeft');

Syndicate content