Monday, January 28, 2013

Windows remote control

I'm going to try and gather some useful commands and tools here for controlling servers. Initially this is based ona  need to control a windows server, bu tI may add unix commands too just for completness.

Start Stop services
  • sc [command]
 One issue I had was permissions. Some service (run as local system user) were unable to start/ stop services on a different server (return code 5: Access Denied was returned)

To counter this you can use the following PsExec -    (taken from

If you want to script using the sysInteranl files then the popUp EULA can cause problems. (It pops up and you have to accept it). One way around this is to add -accepteula to your script

pskill -accepteula

Remote Desktop controls
List existing Remote Desktop connections. (Note in the end I ran these on the remote machine in question (after using the mstsc command to login below)
  • qwinsta /SERVER:
once you have the list, you can evict some users using
  •  rwinsta /SERVER:
dir> qwinsta
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>rdp-tcp#29        myUser                  0  Active  rdpwd
 rdp-tcp                                 65536  Listen  rdpwd
                   sa507823                  1  Disc    rdpwd
 console                                     4  Conn    wdcon

Here I had a disconnected instance still hanging around. This could be killed using
rwinsta 1

Also to 'force' a login you remoteDesktop command in console mode e.g.

You can run the remote desktop in consoel mode ( )
If you need to force, follow this trick :
- From the Start menu  click RUN Command
- type mstsc /console /v:nameserver or ip address of remote computer 
for example:   mstsc /console /v: 
- type mstsc /console /v:nameserver or ip address of remote computer /admin
for example:   mstsc /console /v: /admin
- Click OK

Performance Monitoring

One of my goals for the next few months is to start colelcting system data from a number of computers, and run some data mining techniques to capture performance statistics, and monitor behaviour, and downtimes.

To this end the first step is to collect system data.

For windows machines I'm am trying out perfmon.msc. (See It captures various metrics and can output them to a file. I can then periodically batch the file to a central area for processing

There are lots of various tools for unix varients. See
  • top
  • vmstat
  • ps aux
  • bonnie (for disk monitoring)
from here

Unix Performance Montioring commands
vmstat - report virtual memory statistics
iostat - report io statistics
mpstat - report processor statistics
netstat - report network statists
prstat - process statistics

Thursday, January 10, 2013

VisualVM notes and tcServer

Over the years I have had to use visualVM every one in a while in order to help monitor a running application, or help isolate some problem, or generate a thread dump (eg. for a remote running application server)

Heres some notes on my experiences.

1/ Where is it.
VisualVM is located in your JVM (1.6 rel 7 and above).. Note filename is jvisualvm in the jdk/bin fir, e.g. $JAVA_HOME/bin/jvisualvm

2/ When running locally it shoudl immediately list all jvms running.
One case where I didn't see this happening was when testing a tcServer instance. This was launched via the wrapper.exe prog (to turn it into a service).

In orer to conenct to these you simply have to point at the JMX port.
This can  be found in the server.xml in the conf folder on tcServer. There should be a configuration for a listener e.g.

In my case the $base.jmx.port was specified in the catalina.propeties

Conencting was simply a case of right clicking and entering localhost:21069 as the jmx connection url.

Login credentials are required. Again these are configured via the listener in the  server.xml above. In my case it was using the default values of admin/ springsource