Wednesday, October 31, 2012

TWS - How to add a new workstation

Below are the steps to add a new FTA to your Tivoli Workload Scheduler environment.

Create a file, ws.txt, with the workstation definition,like this

CPUNAME MACHINE_NAME
  OS UNIX
  NODE MACHINE_NAME TCPADDR 31111
  DOMAIN MASTERDM
  FOR MAESTRO
    TYPE FTA
    AUTOLINK ON
    BEHINDFIREWALL OFF
    FULLSTATUS OFF
    SERVER D
END



Run this command to add the workstation

composer add ws.txt

To start the netman process on the workstation, login to the workstation as the tws_user, and run this command
StartUp
or
/opt/IBM/TWS/TWS/StartUp 


To create the Symphony file on the workstation, run this command on the master
JnextPlan -for 0000


To link the  new workstation to the master, run this from the master
conman 'link MACHINE_NAME'

To raise the limit of the number of jobs that can be run on the machine at one time,
conman 'lc MACHINE_NAME;40'

Once this is done, you can start scheduling new jobs on this workstation.
 

Starting with vim

To open a file in vim, at the prompt, type
$ vim test.txt

This opens test.txt if it already exists. Otherwise, it creates a new empty file named test.txt and opens it.

You can not type anything as soon as you open the file, because there are two modes in vim. And when you first open the file, vim is in command mode.

In the command mode almost every key on the keyboard is a command. For example, i is the command to start inserting text.

In the commands which follow, I will say esc before the command every time(eg: esc i), because we are usually using these commands after we finish typing something. But if you are already in command mode, you can just hit the key and there is not need to hit the escape key every time.

esc i    Insert text
Now, you can start typing in any text.

Once you have finished, press escape again, to go back to command mode.


esc :w Save File
esc :wq Save and Quit
esc :q! Quit without saving   
esc u Undo changes
esc control R     Redo changes

esc dd Delete a line
esc dw Delete a word
esc x Delete one character
esc yy Copy a line
esc yw Copy a word
esc p Paste last copy or cut contents

When you want to learn more, you can try this vim tutorial.

Tuesday, October 30, 2012

Happiness

The more I want someone to suffer, the more I suffer myself.

The more I want someone to be happy, the happier I find myself.

How to check your TWS workstation

ps -u twsuser
Displays a list of processes owned by twsuser which are currently running.

ps -aef | grep tws
Displays a list of processes which contain the string 'tws'

Any of these commands should show that these processes are running:
netman, monman, writer, mailman, batchman

$ ps -u twsadm
  PID TTY          TIME CMD
 5312 ?        00:00:22 netman
 5403 ?        00:01:30 monman
12041 ?        00:00:00 writer
12042 ?        00:00:00 mailman
12044 ?        00:00:00 batchman
$

conman start
If netman is not running, use this command to start it. If that doesn't work, try using the full path.

/opt/IBM/TWS/TWS/bin/conman start


conman 'link  MACHINE_NAME'
If netman is running, but the other commands are not running, you will have to link this workstation from the master. Login to the master domain manager as the tws_user, and run the command. Or, you can run this command to link to all machines.

conman 'link @!@'

Perforce Environment Variables

To use Perforce commands from the command line, we need to set up these environment variables.

P4USER=myusername
P4PORT=path.to.p4.com:1666
P4PASSWD=mypass

You can find a list of commands for developers here.
Admin commands are here.

TWS composer commands

Here is a list of Tivoli Workload Schedule composer commands that I have used.


composer display ws=@
Display details of all workstations.

composer display ws=MACHINE_NAME
Display details about the workstation MACHINE_NAME

composer modify ws=MACHINE_NAME
This displays a temporary file with the details of the workstation in the default editor, usually vi. You can edit the file as necessary and save it. Sample file is below.

CPUNAME MACHINE_NAME
  OS UNIX
  NODE MACHINE_NAME TCPADDR 31111
  DOMAIN MASTERDM
  FOR MAESTRO
    TYPE FTA
    IGNORE
    AUTOLINK ON
    BEHINDFIREWALL OFF
    FULLSTATUS OFF
    SERVER D
END

This file shows the definition of an FTA which is ignored by the master domain manager.
If you don't want your FTA to be ignored, remove the line with 'IGNORE' in it.

For more information, please go here.

Monday, October 29, 2012

How to schedule a TWS job from the command line

Create a text file with the information of the job stream and the job. Make sure that the names of the jobs and the job streams are not the same as any other jobs on that machine. Then run the composer command to schedule the job.

To get a list of all the jobs on any system,
conman 'ds MACHINE_NAME#@' > all_jobs.txt

To check if you have used the name already,
cat all_jobs.txt | grep NEWNAME

Create a new file, new_job.txt, with content like this:

SCHEDULE MACHINE_NAME#JOB-STREAM-NAME
ON RUNCYCLE RC1 VALIDFROM 10/29/2012 "FREQ=DAILY;INTERVAL=2"
( AT 1230 )
KEYSCHED
:
MACHINE_NAME#JOB-NAME
 SCRIPTNAME "/path/to/some/dir/script.sh"
 STREAMLOGON username
 TASKTYPE UNIX
 RECOVERY STOP
 KEYJOB
END

This creates a schedule for a job which starts from October 29th 2012, and runs daily. There is an interval of 2 days between each run, so, the job runs on alternate days. Make INTERVAL=1 if you want the job to run every day.
TWS creates a new shell and logs into the system as 'username' and then runs the command. Make sure that username has permissions to execute the script.

Once the file is created and has all the details, run this command to schedule the job
composer replace new_job.txt

To check if the job has been scheduled properly, again run the conman ds command and check that the new job shows up.
conman 'ds MACHINE_NAME#@' > all_jobs.txt

Perforce admin commands

Some useful commands in case your Perforce ever gets hung.


p4 counters
If this displays monitor = 2, it means that you have monitoring enabled.

p4 monitor show
Shows perforce process ids, the owners of those processes, the current status/job type and how long they have been running.
p4 monitor show -ela | grep -v IDLE 
Shows a longer output. And removes the idle processes from the list.

p4 monitor terminate
If you find that any commands are running for a long time, you can delete them with this command.
p4 sync and p4 submit commands are not terminated this way because even though they may be long running, they do not hold excessive database locks and are not the cause of hung systems.

p4 admin stop
To stop perforce

p4 users
To show a list of Perforce users

p4 groups
Displays a list of Perforce groups.

p4 workspaces
Displays a list of client workspaces of all the Perforce users.

p4 opened -a
Displays a list of all opened files in all client workspaces

p4 info
Displays client information.

p4 lockstat
Displays the locks which are held by Perforce.