General Utilities: User Guide
General Utilities: User Guide
Version 2.00
User Guide
Nanometrics Inc.
Kanata, Ontario
Canada
© 2000–2005 Nanometrics Inc. All Rights Reserved.
General Utilities Version 2.00 User Guide
The information in this document has been carefully reviewed and is believed to be reliable for Version
2.00.xx. Nanometrics, Inc. reserves the right to make changes at any time without notice to improve the reli-
ability and function of the product.
No part of this publication may be reproduced, stored in a retrieval system or transmitted, in any form or by
any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permis-
sion of Nanometrics Inc.
Nanometrics, Inc.
250 Herzberg Road
Kanata, Ontario, Canada K2K 2A1
Tel (613)592-6776
Fax (613)592-5929
Email [email protected]
i
Contents
ii
Tables
1-1 Service options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2-1 [ WatchTiming ] section parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2-2 [ WatchEntry ] section parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
iii
Tables
iv
Chapter 1 NmxSC v1.0.0
1.1 Description
NmxSC service management software is a command-line utility that can create, delete,
start, stop and query a Windows service.
A Windows service is a special program which runs in the background to provide some
service or computing capability on a continuous basis. Service programs usually cannot
run on their own, but must be started, stopped, and managed through the Windows
Service Control Manager. Service programs must therefore respond appropriately to
commands and queries from the Service Control Manager.
Services are normally managed using the Services Panel which is accessible through
the Windows Control Panel. NmxSC allows you to create, delete, and manage services
from the command line.
1.1.1 Synopsis
NmxSC create servicename binPath= path\service.exe [options]
NmxSC <start | stop | delete | query> servicename
1.2 Operation
Option Description
type= <own | share> share means the service may be shared by other services;
own means the service is used alone.
interact= <yes | no> Indicates whether or not the service may interact with the
desktop (for example, via dialogs). This does not affect
child programs started by the service.
Option Description
start= <auto | demand> Indicates whether the service should start automatically
when the system boots (auto), or manually on demand.
error= <normal | severe Specifies the type of error reported to the Windows event
| critical | ignore> log if the service malfunctions.
If the service cannot be started, an error message will be written to the command win-
dow. Typical reasons that a service cannot be started include:
The service is already running.
The service is not installed.
The Service Control Manager cannot find the specified executable file.
A service-specific error has occurred (see log file for the specific service).
If the service is already stopped or is not installed, an error message will be written to
the screen.
1.4 Files
NmxSC.exe
1.5 Environment
NmxSC runs on Windows NT, Windows 2000, and Windows XP Professional.
2.1 Description
NmxWatchdog is a Windows Service that starts and monitors tasks. It starts up one or
more tasks specified in its configuration file, then monitors each task and restarts any
task that stops running (or that stops pinging the NmxWatchdog semaphore). This max-
imizes the availability of critical data acquisition and communication programs by
ensuring that they are always restarted after stopping for any reason.
NmxWatchdog also monitors the disk space of the current drive. If the number of meg-
abytes of free space falls below a user configured level, the watchdog will shut down
and close all of its child processes. It is then up to the user to clear sufficient disk space
and restart the watchdog. This is done to avoid corruption of the hard disk when the
system runs out of disk space.
NmxWatchdog must always be installed and run as a Windows Service. Like any serv-
ice, it may be started and stopped manually using the Windows Services Panel, or from
a command line using the Nanometrics Service Control Manager, NmxSC. However,
it is normally configured to start automatically when the system boots up. In this mode,
it remains running when users log on or off, but shuts down and closes its child proc-
esses on system shutdown.
NmxWatchdog maintains a log of its activity in a date-stamped log file,
watchdog.yyyymmdd.log, where yyyymmdd is the current date. Any unexpected
termination of watchdog (or failure to start) is also written to the Windows Event log.
2.2 Installation
To install NmxWatchdog as a service which starts automatically on bootup, enter
this command in a command window:
NmxSC create NmxWatchdog binPath= C:\nmx\bin\NmxWatchdog.exe start= auto
NmxSC will check for the specified executable, verify that the service does not
already exist, then create the service. The service will then appear in the Windows
Services Panel.
If you have made an error installing the service, you can delete the service using
the command
NmxSC delete NmxWatchdog
and then recreate it.
2.4 Operation
NmxWatchdog runs as a Windows Service.
You may start, stop, or determine the status of the service using either of these methods:
Use the Windows Services Panel.
Use the command line using the following commands:
To start NmxWatchdog:
NmxSC start NmxWatchdog
To stop NmxWatchdog:
NmxSC stop NmxWatchdog
Should the service fail to start, an error code will be written to the command window:
If the error code is 1001-1008, the error is a failure to read the watchdog.ini
file (described in Section 2.5). See the watchdog log file in the nmx\user direc-
tory for an explanation of the problem.
Watchdog can be set to start and monitor third-party (non-Nanometrics) tasks:
Set the PingSemaphore flag to FALSE for the appropriate WatchEntry (see also
Section 2.5.3).
2.5 Configuration
NmxWatchdog is configured by setting options in a plain text configuration file,
c:\nmx\user\watchdog.ini. This file has three types of sections:
[ Watchdog.ini ]
[ WatchTiming ]
[ WatchEntry N ]
2.5.1 [ Watchdog.ini ]
The [ Watchdog.ini ] section must be the first section in the file. It has no variables.
2.5.2 [ WatchTiming ]
The [ WatchTiming ] section defines the start, restart, and ping timing for tasks. It must
contain the parameters described in Table 2-1, in the order listed.
Parameter Description
LogFileDirectory The directory in which to store the watchdog log file. The
directory name must be enclosed in double quotation marks.
Watchdog will create the directory if it does not already exist.
NumberEntries The number of tasks to start and monitor. You must have one
WatchEntry section for each task that you want watchdog to
monitor. If you have more WatchEntry sections than
NumberEntries indicates, watchdog ignores the extra entries.
Verbosity Parameter controlling how much log information is written to the
log file. This should be one or more of the following choices,
separated by the vertical bar "|" symbol:
• Error – messages indicating errors with the NmxWatchdog
service.
• Warning – messages indicating changes of state of monitored
tasks, or possible minor problems with the NmxXatchdog serv-
ice.
• Info – messages indicating the normal progress of the serv-
ice.
• Debug – detailed messages (usually useful only to the devel-
oper).
SemPingInterval How often, in seconds, watchdog expects task to ping it. If a task
has not pinged within this time then watchdog considers it in
error and kills and restarts it. Default is 30 seconds.
SemPingStartDelay The number of seconds watchdog waits after starting a task
before expecting the first ping. Default is 60 seconds.
ErrorExitRestartDelay The number of seconds watchdog waits before restarting a task
that has shutdown improperly (either due to a crash or watchdog
killing it). Default is 120 seconds.
NormalExitRestartDelay The number of seconds watchdog waits before restarting a task
that has shutdown properly. If a task shut downs with a exit code
of 0, watchdog assumes it shut down properly. Default is 60
seconds.
Parameter Description
2.5.3 [ WatchEntry N ]
Each WatchEntry section defines a single task to be started and monitored by Nmx-
Watchdog.
There must be a separate WatchEntry section for each task to be started:
If there are 2 or more WatchEntry sections then each section must be num-
bered, starting at 1. That is, [ WatchEntry 1 ], [ WatchEntry 2 ], ...,
[ WatchEntry n ].
If there is only one WatchEntry section, then the section header must not have a
number. That is, the section header is [ WatchEntry ].
Each WatchEntry section must have the parameters described in Table 2-2, in the order
listed.
Parameter Description
ProgramTitle Name of the task to start. Watchdog will refer to the task in the log file
using this name. The parameter value must be enclosed in double
quotation marks.
ProgramPathName Filename of the program to start, with mandatory extension and full
pathname, including drive, and directory if not in the path. Parameters
to the program may be specified on the line as well. The entire
parameter value must be enclosed in double quotation marks.
WorkingDirectory Working directory in which this program is to run. The parameter value
must be enclosed in double quotation marks.
ExitAction Indicates what watchdog should do if the task stops. Options are:
• Ignore – do not restart the task.
• Restart – restart the task.
PingsSemaphore Whether this task will ping the watchdog semaphore to indicate it is
alive (TRUE or FALSE). If this flag is TRUE then watchdog will consider
the process dead if it does not receive the ping within the
[ WatchTiming ] SemPingInterval.
(Watchdog can also be set to start and monitor third-party (non-
Nanometrics) tasks: Set the PingSemaphore flag to FALSE for the
appropriate WatchEntry.)
StartDelay The number of seconds to wait before starting this task.
This example watchdog.ini file would configure NmxWatchdog to start two tasks:
[ watchdog.ini ]
[ WatchTiming ]
LogFileDirectory = "c:\nmx\user\WatchdogLogs"
NumberEntries = 2
Verbosity = Error|Warning
SemPingInterval = 30s
SemPingStartDelay = 1m
ErrorExitRestartDelay = 10s
NormalExitRestartDelay = 10s
MinimumDiskSpace(Megs) = 100
[ WatchEntry 1 ]
ProgramTitle = "NaqsServer"
ProgramPathname = "java -Xrs -ms5m -cp c:\nmx\bin\NaqsServer.jar NaqsServer"
WorkingDirectory = "c:\nmx\user"
ExitAction = Restart
PingsSemaphore = TRUE
StartDelay = 6s
[ WatchEntry 2 ]
ProgramTitle = "DataServer"
ProgramPathname = "java -Xrs -ms5m -cp c:\nmx\bin\DataServer.jar DataServer"
WorkingDirectory = "c:\nmx\user"
ExitAction = Restart
PingsSemaphore = TRUE
StartDelay = 6s
2.7 Files
Watchdog.ini
2.8 Environment
NmxWatchdog runs on Windows NT, Windows 2000, Windows XP Professional.