Notify-send command

So the other day I was looking around and discovered the notify-send command. It basically sends notifications to the desktop. Pretty useful now adays.

[11:49:13] xavi@thinkpad: ~ $ sudo dpkg -S `which notify-send`
libnotify-bin: /usr/bin/notify-send
[11:49:15] xavi@thinkpad: ~ $

It is installed with libnotify-bin via aptitude.

[11:50:35] xavi@thinkpad: ~ $ sudo aptitude install libnotify-bin

So, once installed lets create a practical script. On my job I need to have a permanente VPN connection. Once in a while the VPN connection drops and we have to connect again. Lets create a simple script that notifies us when the connection drops.

#!/bin/bash

# Check tunnel interface
while "true"; do
        /sbin/ifconfig tun0 &> /dev/null
        while [ $? -ne 0 ]; do
                notify-send -t 5000 "VPN" "VPN is down"
        done
        sleep 300
done

We save and copy the script, give it execution permissions with chmod and send it to background.

[11:55:47] xavi@thinkpad: ~ $ chmod +x /tmp/check-vpn.sh; /tmp/check-vpn.sh &
[1] 15613
[12:00:43] xavi@thinkpad: ~ $

Here is a screenshot of it working.

vpn notify-send

Enjoy.

Checking connections on a particular service

So lets say you want to see how many established connections we have on a particular port/service. Most of the people would use netstat, however I prefer ss.

On a Debian based system ss can be installed with the iproute package.

user@server: ~ $ sudo dpkg -S `which ss`
iproute: /sbin/ss
user@server: ~ $

On a Red Hat based system it will be installed with iproute too.

[user@redhat ~]# sudo rpm -qf `which ss`
iproute-2.6.18-11.el5
[user@redhat ~]#

aptitude install iproute and yum install iproute will install the package on a Debian and Red Hat system respectively.

Now lets show some examples. Lets say we want to see how many established ssh connections there are.

[user@redhat ~]# sudo ss -t '( sport = :22 )'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 ::ffff:10.40.7.12:ssh ::ffff:10.16.241.194:56325
ESTAB 0 0 ::ffff:10.40.7.12:ssh ::ffff:10.16.241.194:53804
ESTAB 0 0 ::ffff:10.40.7.12:ssh ::ffff:10.16.241.194:60486
ESTAB 0 0 ::ffff:10.40.7.12:ssh ::ffff:10.14.17.48:37471
ESTAB 0 0 ::ffff:10.40.7.12:ssh ::ffff:10.16.241.194:57982
ESTAB 0 0 ::ffff:10.40.7.12:ssh ::ffff:10.16.241.194:57525
ESTAB 0 304 ::ffff:10.40.7.9:ssh ::ffff:10.14.17.22:46376
ESTAB 0 0 ::ffff:10.40.7.9:ssh ::ffff:10.16.241.28:42654
ESTAB 0 0 ::ffff:10.40.7.9:ssh ::ffff:10.16.241.12:36276
ESTAB 0 0 ::ffff:10.40.7.9:ssh ::ffff:10.16.241.8:57936
ESTAB 0 0 ::ffff:10.40.7.9:ssh ::ffff:10.16.241.28:42855
[user@redhat ~]#

-t displays all TCP sockets

You can also substitute the port number by the name of the service that runs in it by default.

user@debian:~$ sudo ss -t '( sport = :mysql )'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 192.168.140.121:mysql 192.168.137.234:35512
user@debian:~$

To see all opened ports on the server use the -a option.

xavi@linode2:~$ sudo ss -t -a
State       Recv-Q Send-Q                   Local Address:Port       Peer Address:Port   
LISTEN      0      5                                    *:nrpe              *:*       
LISTEN      0      50                     192.168.140.121:mysql             *:*       
LISTEN      0      8                                    *:pop3              *:*       
LISTEN      0      8                                    *:imap2             *:*       
LISTEN      0      128                                 :::www              :::*       
LISTEN      0      128                                  *:ssh               *:*       
LISTEN      0      128                                 :::ssh              :::*       
LISTEN      0      100                                  *:smtp              *:*       
LISTEN      0      128                                 :::https            :::*       
TIME-WAIT   0      0               ::ffff:173.255.231.252:www          ::ffff:79.158.142.28:55032   
ESTAB       0      0                      192.168.140.121:mysql               192.168.137.234:35512  
ESTAB       0      48                     173.255.231.252:ssh                 79.158.142.28:48395   
TIME-WAIT   0      0               ::ffff:173.255.231.252:www          ::ffff:79.158.142.28:55033   
TIME-WAIT   0      0               ::ffff:173.255.231.252:www          ::ffff:173.255.231.252:37223 
xavi@linode2:~$

I believe ss command is simpler to use but less known than netstat. Enjoy.

Trumpeter PT-76 part 2

So here is the PT-76 for this week. Not much so far. Lower and upper hull aren’t finished yet, but we can see the tank taking shape.

Building has been going really well. No errors on the pieces, only a little bit of sanding every now and then. I haven’t glued the tracks yet, Ill wait to get my hands on some Tamiya primer. I’m pretty happy with this Trumpeter kit so far.

Trumpeter PT-76 part 1

OK, so this post is not going to be about Open Source or software. This is going to be about scale modeling and particularly about Trumpeter PT-76 that was given to me as a birthday gift. Below is the picture.



I must admit this is the first Trumpeter kit I have to build and looking at the kit and the way its been going so far I must say its high quality. Not as good as Tamiya, but I would score it with an eight out of ten. Below is a picture of the components of the kit.


I think this page gives a good description of the kit.

I will probably paint the kit olive green and try to add some weathering to it together with some mud on the tracks. I will probably use Tamiya paints. I already painted a T-62 with it and the results were quite good.

And this is the last picture. The tracks mounted and sanded ready to be added unto the tank. Not much sanding was needed for the trackss and I used Testors glue for it.

pt-76 tracks

Forgive the quality of some pictures, they were taken with my cellphone camera.