Thursday, April 3, 2014

SSH tunnel to multiple vSphere/ESXi hosts

An SSH tunnel to a single host is easy; reference: http://www.virtuallifestyle.nl/2010/03/tunneling-a-vsphere-client-connection-over-ssh/

However, if you want to open the vSphere client multiple times for simultaneous connections to multiple ESXi/vCenter hosts, then you have to get a little creative. Basically you follow the same instructions as above, except you don't need to edit the hosts file. Just use a single address in the loopback network (127.0.0.2 - 127.255.255.254 ) for each remote ESXi host.  e.g.:

ESXi host Tunnel Source Tunnel Destination
host1 127.0.0.2:443 esxhost1:443
host1 127.0.0.2:902 esxhost1:902
host1 127.0.0.2:903 esxhost1:903
host2 127.0.0.3:443 esxhost2:443
host2 127.0.0.3:902 esxhost2:902
host2 127.0.0.3:903 esxhost2:903

Then simply connect vSphere client to one of the loopback addresses you used.  In the example above, to connect to esxhost1, you connect vSphere Client to 127.0.0.2.  For esxhost2, 127.0.0.3.

You should be able to make up to ~16 million tunnels this way!

NOTE: When using an SSH tunnel, the vSphere Client will not show the "Hardware" tab for your hosts.

Monday, November 25, 2013

Perl script to convert JPL Horizons Ephemeris data to Celestia SSC Elliptical Orbit Parameters

With Comet ISON coming up, I've been playing with Celestia a bit to see if I can get it to show me with reasonable accuracy where the spacecraft SDO and STEREO (-A and -B) are in relation to the comet.

Long story short -- I had to make my own Celestia ".ssc" files to describe the spacecraft. Using the JPL HORIZONS web interfaceyou can get recent orbital elements, but you have to convert these to something Celestia will understand (an "EllipticalOrbit" stanza in the ".ssc" file).

The perl script below does the conversion; just run it and paste in a single block of Ephemeris data like this:

2456621.500000000 = A.D. 2013-Nov-25 00:00:00.0000 (CT)
 EC= 4.143129880700237E-02 QR= 9.996672652291025E-01 IN= 2.936558964716465E-01
 OM= 3.363978705358475E+02 W = 1.469845587993808E+02 Tp=  2456458.185749091208
 N = 9.254559117051611E-01 MA= 1.511401389693867E+02 TA= 1.533315740323342E+02
 A = 1.042874927988944E+00 AD= 1.086082590748784E+00 PR= 3.889974610856358E+02
And you'll get output line this:
EllipticalOrbit
{
        Epoch 2456621.500000000
        Period 1.06499689086802
        SemiMajorAxis 1.04287492798894
        Eccentricity 0.041431298807
        Inclination 0.293655896472
        AscendingNode 336.397870535848
        ArgOfPericenter 146.984558799381
        MeanAnomaly 151.140138969387
}
The perl script is below, or you can download it here.
#!/usr/bin/perl -w

# input an ephem set like this:
#2456621.500000000 = A.D. 2013-Nov-25 00:00:00.0000 (CT)
# EC= 4.143129880700237E-02 QR= 9.996672652291025E-01 IN= 2.936558964716465E-01
# OM= 3.363978705358475E+02 W = 1.469845587993808E+02 Tp=  2456458.185749091208
# N = 9.254559117051611E-01 MA= 1.511401389693867E+02 TA= 1.533315740323342E+02
# A = 1.042874927988944E+00 AD= 1.086082590748784E+00 PR= 3.889974610856358E+02

# output like this:
#        EllipticalOrbit
#        {
#                Epoch 2456621.500000000 # = A.D. 2013-Nov-25 00:00:00.0000 (CT)
#                # reference http://www.lepp.cornell.edu/~seb/celestia/transforming_ephemeris.html
#                Period 1.06499689086801936 # P = (q/(1-e))^1.5 for a closed, elliptical orbit (q = QR, e = ER)
#                SemiMajorAxis 1.04287492798894325 # a = (q+Q)/2, where Q is Apoapsis distance (AD in horizons ELEMENTS)
#                Eccentricity 0.04143129880700237 # (EC)
#                Inclination 0.2936558964716465 # (IN)
#                AscendingNode 336.3978705358475 # (OM)
#                ArgOfPericenter 146.9845587993808 # (W)
#                MeanAnomaly 151.1401389693867 # (MA)
#        }

my ($Epoch, $EC, $QR, $IN, $OM, $W, $Tp, $N, $MA, $TA, $A, $AD, $PR);
my ($Period, $SemiMajorAxis);


print "Input a single block of ephem data\n";

while () {
        if ( /^((\w|\.)+)/ ) {
                $Epoch = $1;
        }

        if ( /EC=/ ) {
                ($EC, $QR, $IN) = (split())[1,3,5];
        }

        if ( /OM= / ) {
                #$_ = readline; chomp;
                ($OM, $W, $Tp) = (split())[1,4,6];
        }

        if ( /N = / ) {
                #$_ = readline; chomp;
                ($N, $MA, $TA) = (split())[2,4,6];
        }

        if ( /AD= / ) {
                #$_ = readline; chomp;
                ($A, $AD, $PR) = (split())[2,4,6];
                last;
        }
}

$Period = ( $QR / (1 - $EC) )**1.5 ;
$SemiMajorAxis = ( $QR + $AD ) / 2 ;

print "EllipticalOrbit\n";
print "{\n";
print "\tEpoch $Epoch\n";
print "\tPeriod $Period\n";
print "\tSemiMajorAxis $SemiMajorAxis\n";
print "\tEccentricity " . sprintf("%12.12f\n",$EC);
print "\tInclination " . sprintf("%12.12f\n",$IN);
print "\tAscendingNode " . sprintf("%12.12f\n",$OM);
print "\tArgOfPericenter " . sprintf("%12.12f\n",$W);
print "\tMeanAnomaly " . sprintf("%12.12f\n",$MA);
print "}\n";

Friday, July 19, 2013

non-existent remote syslog server causes SSH and su to pause/hang

I recently setup a VMware lab for a project at work. As a quick start, I used some of our existing kickstart deployments (actually using cobbler), which included a bunch of operational configuration items.

Soon my users were experiencing some issues on logging in via SSH. The symptom was one of the following would occur:

  • User would immediately get the error "ssh_exchange_identification: Connection closed by remote host"
  • User would have to wait ~20 seconds to get a password prompt. After entering a password, another ~20 seconds would pass before getting the shell prompt.

I did a lot of different things to try to find the problem. I found that rebooting the system resolved the issue temporarily. Exacerbating the issue was that only a couple systems were experiencing the problem -- not all of them. So at first I discounted it being an issue with the configuration of the system. I chased the red herring of a certain application we were running on *only* those systems.

Another symptom of the issue was that "su" would also pause for ~20 seconds before presenting the password prompt, so I knew it wasn't limited to sshd.

Eventually I found the problem by doing the following:

 # strace su -
[...]
###  The output would pause here:
    connect(3, {sa_family=AF_FILE, path="/dev/log"}, 110) = 0
    sendto(3, "<86>Jul 19 16:36:59 su: pam_unix"..., 96, MSG_NOSIGNAL, NULL, 0) = 
/dev/log is a UNIX domain socket, used by the syslog (and rsyslog) daemons. The system was trying to write to the socket, and it was taking a long time.

When I looked at the config file (/etc/rsyslog.conf), I found that it had been setup to log to a remote server on our production network. Of course, the lab did not have access to the production network! So rsyslog was trying to log to a non-existent system.

The fix was simply to remove the non-existent remote syslog server from rsyslog.conf and restart syslog.

Why didn't *all* the lab systems have the same problem? I believe this is because the "problem" systems had much more syslog messages than the other systems -- due to the application we were running on those systems. So it was only indirectly related to the application!

Friday, June 28, 2013

mental health

I had a very weird encounter at the Community Center gym this evening. While I'm jogging on the treadmill, a guy approaches me and says something. I didn't understand what he said because of my headphones and all the noise -- but he seemed to be trying to hand me some kind of flyer. I took it and started reading it; he seemed satisfied and walked away.

The flyer was some silliness about "cleansing" your body every month with cabbage or something, so I stopped reading and put it aside so I could concentrate on the Science podcast I had been listening to.

I had assumed our encounter was over, but he had taken the machine right next to my treadmill. When I accidentally dropped the baseball cap I use to keep my hair out of my face, I decided to stop running long enough to pick it up. That's when he verbally pounced on me.

"You know the government doesn't like me passing out those flyers."

Oh shit here we go, I thought. "What do you mean, the government?" I wanted to distinguish between police officers, NSA, etc. but I guess I wasn't clear.

"You don't know who the government is?" he seemed surprised.

"I mean, I don't understand why anyone would care about you passing out these flyers." Why am I still talking to this guy?

I don't remember exactly what he said, but it was something like "They like to brainwash people. You ever hear of mind-control devices?"

The dubious expression on my face must've given me away because he seemed to be upset or hurt that I didn't believe him. He took his flyer back, saying I didn't deserve it or respect him. As he walked away I tried to ignore him and resume listening to my podcast.

But he didn't leave the gym right away, and I was a bit uncomfortable every time he walked by me, worried he'd try to to talk to me again. He soon left the gym, though, and I relaxed again.

After I finished jogging, I saw I was alone in the gym with a woman riding one of the upright stationary bikes. I thought perhaps I should warn her about this guy. I apologized for interrupting her workout, and briefly told her how he had talked about his flyer, and his paranoid thoughts about brainwashing and mind-control devices from the government. She told me he had tried to give her a flyer but she refused it. He didn't bother her after that.

As I continued my workout and started thinking more about the guy, my selfish annoyance changed to (slight) concern. I had seen him around the Community Center a few times -- usually in the gym, or as I walked past him with the dog as he sat on one of the benches around the man-made pond at the Center, smoking a cigarette. (Hey at least he works out... and apparently "cleanses"). He had never talked to me before, though.

Why today, though? Was this a way for him to call out for help? Should I tell "the government" about him? I realized that even had I the will to help him, I hadn't the slightest idea how to go about it. If he had a broken ankle, I could call an ambulance for him. But a slightly broken psyche? Unless he's threatening someone or himself, the 911 personnel would probably laugh at me.

I don't think this guy is going to hurt anyone -- but that doesn't mean he doesn't need help. If you have any thoughts about this please comment.

Tuesday, January 25, 2011

Word and Excel 2007 slow to open documents

One of my users had this apparently common problem -- opening either Word or Excel documents in Office 2007 was taking a long time (about 1 minute). Opening the document from within the application was fine.

This was the solution:
http://excel2007-slow-open-file.blogspot.com/

Basically, installing the "Analysis Toolpak" addin "fixed" the excel problem, but Word was still slow. So I installed "Lookup Wizard" (in Excel) and the Word problem was also fixed. Awesome, yes? I LOVE MICROSOFT!!!11!

Enable Microsoft Update in Windows 7 via script

By default, the Automatic Updates feature of Windows 7 does not include updates to other Microsoft Products such as Microsoft Office.

In the Windows Update control panel, you can enable Microsoft Update, but I needed to automate this for all of my systems.

It turns out that you can enable Microsoft Update using a simple VBS. You can run this script via any means you like (psexec, GPO startup/login script, etc.)

Monday, October 25, 2010

Increase the maxiumum number of windows in Windows!

I tend to keep a lot of windows open on my main desktop (Windows XP). Right now I have 21 windows -- that's a low number for me actually, because I had to reboot recently after a software install.

As time goes by, I accumulate more and more windows. Eventually, when I try to open a new window, I find that either 1) nothing happens or 2) the window opens, but it's missing vital elements (menu bar, icons, etc.).

It turns out that this is due to Windows running out of space in the "desktop heap" (If I understand correctly! See this MSDN article). The default size of the heap is 3072 KB in XP (the default is larger in Vista and Windows 7). Obviously this is not enough for me, so I edited the registry as described in the MSDN article (here's another article with more explicit instructions). I changed 3072 to 8096. (note: you must reboot for changes in the heap size to take effect; logging out and back in is not sufficient)

Now I can open more windows without any of the interface issues I was seeing before. At least, I haven't run into any issues again since I made the registry edit.

For the intensely curious, you can see the current size of your desktop heap using a debugging tool from Microsoft called "Desktop Heap Monitor"

After you unzip the download, you have to install it manually from the CMD prompt:
C:\dheapmon8.1\x86>dheapinst.exe -y %SYSTEMROOT%\Symbols
  dheapinst - Desktop Heap Monitor installed successfully

(The installer seems to copy the necessary files to %SYSTEM32%\kktools)

Then, load the heap driver with "dheapmon -l"

Now you can see your heap:
C:\WINDOWS\system32\kktools>dheapmon
Desktop Heap Information Monitor Tool (Version 8.1.2925.0)
Copyright (c) Microsoft Corporation.  All rights reserved.
-------------------------------------------------------------
  Session ID:    0 Total Desktop: ( 10848 KB -    8 desktops)

  WinStation\Desktop            Heap Size(KB)    Used Rate(%)
-------------------------------------------------------------
  WinSta0\Default                    8096             29.1
  WinSta0\Disconnect                   64              4.5
  WinSta0\Winlogon                    128             17.8
  Service-0x0-3e7$\Default            512             29.6
  Service-0x0-3e4$\Default            512              6.3
  Service-0x0-3e5$\Default            512             10.8
  SAWinSta\SADesktop                  512              0.5
  Service-0x0-2a22a$\Default          512              2.5
-------------------------------------------------------------