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)

SysInternals
To counter this you can use the following PsExec - http://technet.microsoft.com/en-us/sysinternals/bb897553    (taken from  http://serverfault.com/questions/359010/execute-windows-sc-command-as-another-user)

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

e.g.
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:
e.g.
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 (http://h0w2.blogspot.com/2011/04/how-to-force-go-in-to-remote-desktop.html )
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:192.168.0.10 
Or 
- type mstsc /console /v:nameserver or ip address of remote computer /admin
for example:   mstsc /console /v:192.168.0.10 /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.

Windows
For windows machines I'm am trying out perfmon.msc. (See http://support.microsoft.com/kb/305610) It captures various metrics and can output them to a file. I can then periodically batch the file to a central area for processing

Unix
There are lots of various tools for unix varients. See http://www.informit.com/articles/article.aspx?p=29666&seqNum=4
  • top
  • vmstat
  • ps aux
  • bonnie (for disk monitoring)
from here http://www.unix.com/linux/24390-linux-unix-performance-monitoring-2.html

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.
              authenticate="true"
              bind="127.0.0.1"
              className="com.springsource.tcserver.serviceability.rmi.JmxSocketListener"
              passwordFile="${catalina.base}/conf/jmxremote.password"
              port="${base.jmx.port}"
              useSSL="false"/>


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

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