All posts by albertw

Remote X displays

Another ‘damn! I keep forgetting how to do that!’ post…

When you want to display something from one unix box to another there are two ways of doing it.
1. Use ssh. You need to use ‘ssh -X’ specifically which will allow X11 forwarding. ssh takes care of setting the DISPLAY variable for you. You also need to ensure that the server is configured for X forwarding:

# X11 tunneling options
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

This just works if you are a regular user, but if you need to display something as another user then you run into problems. For example you may need to run a gui installer that can only run as root.
So heres how to get it to work as root.
Firstly, as your normal user get your DISPLAY variable and the corresponding xauth entry. This can be a little tricky

$ echo $DISPLAY
localhost:10.0

Now search the xauth list for the corresponding entry. If you got localhost above, then search for the actual hostname. On some systems ‘xauth list $DISPLAY’ may work fine, others you’ll need to search:

$ xauth list|grep :10|grep server
server/unix:10  MIT-MAGIC-COOKIE-1  99410f7406b0f93e6117ae55a72a7eca

Next become the root user, or whatever user you need to be.
Set the display variable and add the xauth entry:

# DISPLAY=localhost:10
# export DISPLAY
# xauth add server/unix:10  MIT-MAGIC-COOKIE-1  99410f7406b0f93e6117ae55a72a7eca

You should now be able to fire up an xterm on the system as the new user and it will appear on your desktop.

2. Use xhosts. This is the more traditional way, but does have a gotcha for newer versions of solaris, which are more secure than previously.
On your desktop do:

$ xhost +
access control disabled, clients can connect from any host
$ echo $DISPLAY
:0.0

Now log onto the remote system and set the display variable and try an xterm. It will probably fail:

$ DISPLAY=desktop:0.0
$ export DISPLAY
$ xterm
xterm Xt error: Can't open display: desktop:0.0
$ 

Whats happening here is that although you have allowed the xserver access control to accept connections from any host, the X server itself isnt actually listening for connections. To change that you need to do the following on your desktop:

 svccfg -s svc:/application/x11/x11-server setprop options/tcp_listen = true 

Then restart the Xserver.
This method will work for all users, so you can log in, become root, then just set your display.

3 ok there are alternative methods if you are really stuck. For example start up a VNC session on the server and view it on your desktop. Though thats only worth doing if you need someone else to be able to view what you are doing.

EFI and SUN Disk Labels

Every now and again an install on a new machine fails for me and I have to google to remember how to change the label. So this time I’m writing it down!

Docs.sun.com has some information on the differences between the two formats http://docs.sun.com/app/docs/doc/817-5093/disksconcepts-47761?l=en&a=view

But suffice to say that you cant install Solaris on an EFI disk, you need to change it to an SMI label. Thats done using ‘format -e’.

Select the label option, and then SMI Label. Once you have done that you can check the partition table as normal and your install can progress.

Letter: Council Vandalism of Dalkey Quarry

Dear Councilors & TD’s,

It was with incredulity that I read reports in the Irish Times of the destruction of parts of Dalkey Quarry.

The first recorded climbs by the Irish Mountaineering Council were undertaken in the 1940’s. Today the quarry is used almost daily by climbers and the routes range from the very beginner level up to some of the hardest climbs in the country. It is the only quarry that I know of in Ireland with a guidebook of its routes, and a popular crag with foreign climbers due to its easy access from the city. As someone who grew up a few minutes from the Quarry, I regularly climbed the lower grade climbs and my dog even managed to make it up an easy route on one occasion!

Climbers and residents are rightly annoyed that the council therefore decided to destroy parts of these established climbs. An area that is used for climbing is very unlikely to have been unsafe, if it was the climbers would not be using it, so the actions of the council can only be interpreted as a willful act of destruction. John Duignan of the Irish Mountaineering Club was right to call this ‘vandalising the sport’, a sport which DLRCC should be very proud to have in its county. Then again the councils recent record of preserving important sites in the county is dismal – Carlisle Pier for example…

All such destruction must cease, and any further destruction must take place only following a full public consultation with the public and mountaineering groups. I welcome the reports that talks have taken place today between the MCI and council but that should have taken place last week.

The council should publish any correspondence relating to this decision including any complaints received and any internal letters/emails between council employees relating to the plans. The council employee responsible for taking the decision to destroy parts of the quarry must be immediately removed from employment with the council.

Best Wishes,
~Albert White

Sometimes you can be proud of the EU

The start of 2010 has been an interesting time in the EU. Where, in stark contrast to most places, we seem to be coming up with good legislation and ideas.

February 22nd:
The EU Commission proposes a ban on all commercial fishing of Atlantic bluefin tuna by 2011. Predictably the Japanese are the ones who are protesting most. But you would expect that from a nation that seems to have a policy of making marine wildlife extinct. Release Here.

February 25th:
Since 2000 Israel has enjoyed a special relationship with the EU resulting in exemption of import duties. However the German water filtering company Brita imports good from the occupied west bank, and German customs, seeing the goods were manufactured in illegal settlements denied the company the preferential treatment they expected. This went to the German courts who asked the European Court of Justice for a decision. That decision, came on February 25th and clarified that since settlements in Palestinian territory are illegal under international law that goods from these areas cannot be classified as ‘Made in Israel’ and therefore cannot avail of preferential trade agreements with Israel.

March 10th:
The Anti-Counterfeiting Trade Agreement (ACTA) is a treaty that is being negotiated in secret outside of any established framework. No portions of the discussions have been made officially public and from the leaks it is clear that this is treaty is a very bad one. The Lisbon treaty that is now in force contained a provision intended to make the workings of the EU more transparent and to give the Parliament (the elected bit of the EU) more power, that provision required that the Parliament must have full and immediate access to information at all stages of international negotiations. They clearly didn’t have that with the ACTA so the Parliament voted, by 663 to 13, to demand that this information be made available to them. Not only that but they threaten to go to the Court of Justice if that doesn’t happen.

But the MEP’s didn’t stop there. They scupperd any plans of a so called three strike policy being automatically implemented also. And they also have called for investigations into the issue of warrant-less searches of data while crossing EU borders.

The full press release from the Parliament is here.

Monitoring a BT Voyager 2110

Recently out broadband usage seems to have gone up quite significantly. This, naturally, has been blamed on me. And the Mac. As Min put it “this only became an issue since the mac came into the house!”.

Now you can log into the web interface of the Voyager and get the bytes since it connected. You can also reset some network traffic counters in Status -> Traffic Stats, but none of these really give you a feel for whats happening over time. Enter MRTG. I’ve been using MRTG to monitor traffic on interfaces since college and it’s very good at it. By default it will communicate with a device by SNMP, however the Voyager does not appear to have an SNMP daemon.

Thankfully MRTG can also execute a command to get its data.

You can log into the Voyager using ssh with the admin user and your admin password. This gets you to a very basic shell but one thing you can run is ifconfig which will report on the network interfaces in the box including their TX and TX byte counts.

There doesnt appear to be an easy way to set up public key authentication with the voyager so I fell back on some old school tricks for automating logins – perl & expect.

This expect script will log into the Voyager and get your ifconfig output:

#!/usr/bin/expect -f
spawn ssh [email protected]
expect "password:"
sleep 1
send "YOUR-PASSWORD\n"
expect "> "
sleep 1
send "ifconfig\n"
expect "> "
send "logout\n"

Next we need to grab the counters from there in a way that MRTG will understand. That is the recieved count on the first line, the transmitted count on the second, uptime is the third and the name is the fourth (mrtg docs). I just use the first and second. ppp_8_35_1 is the interface I need on my router, yours may be different. This perl script calls the expect script above to get the data.

#!/usr/bin/perl

my $flag=0;

@op=<code>/rusr/local/bin/bt.expect</code>;

foreach $_ (@op) {
    if ($_ =~ /ppp_8_35_1/ ){
        $flag=1;
        next;
    }

    if ($flag == 1 &amp;&amp; $_ =~ /RX bytes:(\d+).*TX bytes:(\d+)/){
        print $1."\n";
        print $2."\n";
        print "0\n";
        print "0\n";
        last;
    }
}

Next we need a configuration file for MRTG. Mine is below. The various options are explained in the mrtg docs

EnableIPv6: no
WorkDir: /var/www/mrtg

Interval: 5

Title[ppp]: Network traffic (ppp)
PageTop[ppp]:
<h1>Network traffic (ppp)</h1>
Target[ppp]: <code>/usr/local/bin/gettraffic.pl</code>
Unscaled[ppp]: n
WithPeak[ppp]: ymw

It’s the just a matter of setting up a cron job for MRTG to get the data every 5 minutes:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/mrtg /usr/local/etc/bt.cfg > /dev/null 2>&amp;1

Over the course of a few hours you’ll see the patterns in your usage:
mrtg graph

30 day song challenge in one go

Right. Enough people have messaged me about this on facebook so rather than do the day by day thing, which I’ll get bored of by tomorrow, I’ll just list them all now. This is a bit of an oldskool list; i should do it again with more tunes from this century sometime 🙂

day 01 – your favorite song
Disarm – Smashing Pumpkins http://www.youtube.com/watch?v=QQtLoJlQD6E
day 02 – your least favorite song
Sinead – nothing compares 2u. Radio gets turned off when this comes on

day 03 – a song that makes you happy
Tequila – Terrorvision

day 04 – a song that makes you sad
Cure – pictures of you

day 05 – a song that reminds you of someone
Tom Petty – Learning to Fly

day 06 – a song that reminds you of somewhere
Garbage – Stupid Girl

day 07 – a song that reminds you of a certain event
Nelly Furtado – Turn Off The Light

day 08 – a song that you know all the words to
Cant find the Clancy Brothers version on youtube – The Boys of Wexford!

day 09 – a song that you can dance to
Nellie the Elephant. I can still picture Skippy holding on to the record player in the teachers club trying to stop it skipping while a roomful of Goths thumped the floor!

day 10 – a song that makes you fall asleep
Chris de Burgh – Don’t Pay The Ferryman

day 11 – a song from your favorite band
I am one – Smashing Pumpkins.
Could have picked any number of songs here.

day 12 – a song from a band you hate
Whipping Boy – any song will do, but here’s We Don’t Need Nobody Else

day 13 – a song that is a guilty pleasure
Whigfield – Saturday Night 🙂

day 14 – a song that no one would expect you to love
Ace of Base – The sign

day 15 – a song that describes you
Hard to answer without coming across as a total muppet.
So I better pick a good song at least. Levellers – One Way, this version from Glastonbury

day 16 – a song that you used to love but now hate
Madonna – Like a Prayer. Just got overplayed at the time.

day 17 – a song that you hear often on the radio
BellX1 – Great Defector

day 18 – a song that you wish you heard on the radio
Temple of Love – Sisters of Mercy

day 19 – a song from your favorite album
Cherub Rock – Smashing Pumpkins from Siamese dream.
Could also bee anything from Doolittle.

day 20 – a song that you listen to when you’re angry

day 21 – a song that you listen to when you’re happy
Something Happens – Hello Hello Hello Hello Hello Petrol

day 22 – a song that you listen to when you’re sad
In the rare auld times

day 23 – a song that you want to play at your wedding
And did! The Foundations – Buttercup (KOH!)

day 24 – a song that you want to play at your funeral
Salve Regina

followed by Prince Buster and Suggs! Madness Enjoy yourself

day 25 – a song that makes you laugh
Wierd Al – Yoda

day 26 – a song that you can play on an instrument
Well I used to be able to play most of it.
The Entertainer – Scott Joplin

day 27 – a song that you wish you could play
Joe Satriani – Surfing with the Alien

day 28 – a song that makes you feel guilty
No song makes me feel guilty. ?
day 29 – a song from your childhood
A-ha – Take on me

day 30 – your favorite song at this time last year
Eliza Doolittle – Pack Up