TITLE: Need a command to detect whether a cimserver is running.
DESCRIPTION: Added --status option to the cimserver command.
Copyright (c) 2000, 2004 BMC Software.
Copyright (c) 2003, 2008 EMC Corporation.
- Copyright (c) 2000-2008 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2000-2009 Hewlett-Packard Development Company, L.P.
Copyright (c) 2000, 2008 IBM Corp.
Copyright (c) 2005, 2008 Inova Development Inc.
Copyright (c) 2000, 2003 Michael Day.
.TA c \" lowercase initial letter of .TH name
.TH cimserver 8
.SH NAME
-cimserver \- start or stop the CIM Server; display the version number of the CIM Server
+cimserver \- start or stop the CIM Server; display the version number or running status of the CIM Server
.SH SYNOPSIS
.B cimserver
.B cimserver --help
.B cimserver --version
+
+.B cimserver --status
.SS Remarks
This command can only be executed by a privileged user.
.SH DESCRIPTION
.B cimserver
command provides a command line interface to stop
and start the CIM Server, as well as to display the version number
-of the CIM Server.
+or running status of the CIM Server.
.PP
After installation, the CIM Server must be started using the
.B cimserver
.RS
.TP 15
.B -v, --version
-Display the version number of the CIM Server.
+Display the version number or running status of the CIM Server.
.TP
.B -h, --help
Display the command usage.
.TP
+.B --status
+Display the running status of the CIM Server.
+.TP
.B -s
Stop the CIM Server.
.TP
.PD
.RE
.PP
+The
+.B cimserver --status
+command returns one of the following values:
+.RS
+.TP
+.B 0
+The CIM Server is running
+.PD 0
+.TP
+.B 1
+Error
+.PD 0
+.TP
+.B 2
+The CIM Server is not running
+.PD
+.RE
+.PP
When an error occurs, an error message is written to stderr and an error
value of 1 is returned.
.SH DIAGNOSTICS
if (_TestFlagOption(argc, argv, "--dump", 1) == 0)
options->dump = 1;
+ if (_TestFlagOption(argc, argv, "--status", 1) == 0)
+ options->status = 1;
+
if (_TestFlagOption(argc, argv, "--version", 0) == 0)
options->version = 1;
struct Options
{
int dump; /* --dump */
+ int status; /* --status */
int version; /* --version or -v */
int help; /* --help or -h */
int shutdown; /* -s */
* passed through to CIMSERVERMAIN).
*/
- if (!options.version &&
- !options.help &&
- TestProcessRunning(PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN) == 0)
+ if (!options.version && !options.help)
{
- fprintf(stderr,
- "%s: cimserver is already running (the PID found in the file "
- "\"%s\" corresponds to an existing process named \"%s\").\n\n",
- globals.argv[0], PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN);
-
- exit(1);
- }
+ int isRunning = (TestProcessRunning(
+ PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN) == 0);
+ if (options.status)
+ {
+ if (isRunning)
+ {
+ fprintf(stderr, "CIM Server is running.\n");
+ exit(0);
+ }
+ else
+ {
+ fprintf(stderr, "CIM Server is not running.\n");
+ exit(2);
+ }
+ }
+ else if (isRunning)
+ {
+ fprintf(stderr,
+ "%s: cimserver is already running (the PID found in the file "
+ "\"%s\" corresponds to an existing process named \"%s\").\n\n",
+ globals.argv[0], PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN);
+ exit(1);
+ }
+ }
/* Get enableAuthentication configuration option. */
" options\n"
" -v, --version - Display CIM server version number.\n"
" -h, --help - Print this help message.\n"
+ " --status - Display the running status of CIM server.\n"
" -s - Shut down CIM server.\n"
" -D [home] - Set the PEGASUS_HOME directory.\n"
" configProperty=value\n"
" options\n"
" -v, --version - Display CIM server version number.\n"
" -h, --help - Print this help message.\n"
+ " --status - Display the running status of CIM server.\n"
" -s - Shut down CIM server.\n"
" configProperty=value\n"
" - Sets the CIM server configuration property.\n"
" options\n"
" -v, --version - Display CIM server version number.\n"
" -h, --help - Print this help message.\n"
+ " --status - Display the running status of CIM server.\n"
" -s - Shut down CIM server.\n"
" -D [home] - Set pegasus home directory.\n"
" -install [name] - Installs pegasus as a Windows service.\n"
*/
src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON:string {"PGS10043: The configuration setting daemon=false is ignored with privilege separation enabled."}
+ /**
+ * @version 2.9
+ * @note PGS10044:
+ */
+ src.Server.cimserver.CIMSERVER_RUNNING:string {"PGS10044: The CIM Server is running."}
+
+ /**
+ * @version 2.9
+ * @note PGS10045:
+ */
+ src.Server.cimserver.CIMSERVER_NOT_RUNNING:string {"PGS10045: The CIM Server is not running."}
+
// ==========================================================
// Messages for IndicationService
// Please use message prefix "PGS10200"
usage.append(" [ [ options ] | [ configProperty=value, ... ] ]\n");
usage.append(" options\n");
usage.append(" -v, --version - displays CIM Server version number\n");
+ usage.append(" --status - displays the running status of"
+ " the CIM Server\n");
usage.append(" -h, --help - prints this help message\n");
usage.append(" -s - shuts down CIM Server\n");
#if !defined(PEGASUS_USE_RELEASE_DIRS)
#endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
- // Get help, version, and shutdown options
+ // Get help, version, status and shutdown options
for (int i = 1; i < argc; )
{
Executor::daemonizeExecutor();
exit(0);
}
+ if (strcmp(arg, "--status") == 0)
+ {
+ int retValue = 0;
+ if (_serverRunStatus.isServerRunning())
+ {
+ MessageLoaderParms parms(
+ "src.Server.cimserver.CIMSERVER_RUNNING",
+ "The CIM Server is running.");
+ cout << MessageLoader::getMessage(parms) << endl;
+ }
+ else
+ {
+ MessageLoaderParms parms(
+ "src.Server.cimserver.CIMSERVER_NOT_RUNNING",
+ "The CIM Server is not running.");
+ cout << MessageLoader::getMessage(parms) << endl;
+ retValue = 2;
+ }
+ Executor::daemonizeExecutor();
+ exit(retValue);
+ }
else if (strcmp(arg, "--version") == 0)
{
cout << _cimServerProcess->getCompleteVersion() << endl;