BUG#: 4314
authordenise.eckstein <denise.eckstein>
Wed, 21 Jan 2009 01:37:13 +0000 (01:37 +0000)
committerdenise.eckstein <denise.eckstein>
Wed, 21 Jan 2009 01:37:13 +0000 (01:37 +0000)
TITLE: Need a command to detect whether a cimserver is running.

DESCRIPTION: Added --status option to the cimserver command.

OpenPegasusNOTICE.txt
rpm/manLinux/man8.Z/cimserver.8
src/Executor/Options.c
src/Executor/Options.h
src/Executor/main.c
src/Pegasus/msg/Server/pegasusServer_en.txt
src/Server/cimserver.cpp

index c414a9109b2ef4a2185dfbc6f1a70356ad2bca42..7341ef327dfdb1c6f0dfa6c2a06161e7a8bc1245 100644 (file)
@@ -2,7 +2,7 @@ OpenPegasus is subject to one or more of the following copyrights:
 
        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.
index 1f53fb0893dccb65ecc9785fd7c34282aa46e045..ee67d8b0af64f82065aa8cd26e827db0b612db52 100644 (file)
@@ -1,7 +1,7 @@
 .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
@@ -17,6 +17,8 @@ cimserver \- start or stop the CIM Server; display the version number of the CIM
 .B cimserver --help
 
 .B cimserver --version
+
+.B cimserver --status
 .SS Remarks
 This command can only be executed by a privileged user.
 .SH DESCRIPTION
@@ -25,7 +27,7 @@ The
 .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 
@@ -116,11 +118,14 @@ command recognizes the following options:
 .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
@@ -151,6 +156,24 @@ Error
 .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
index dfaebee88a1ede67831c0b46ce8bbae0b6f063d8..ac576585248774856e28a795f58e86f19314a6c9 100644 (file)
@@ -93,6 +93,9 @@ void GetOptions(int* argc, char*** argv, struct Options* options)
     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;
 
index 18bf44097e9ba40d00b97252213d59c43d220283..19a79d9adda31c8e6d917a92fbb7aca8bc476bf4 100644 (file)
@@ -37,6 +37,7 @@
 struct Options
 {
     int dump; /* --dump */
+    int status; /* --status */
     int version; /* --version or -v */
     int help; /* --help or -h */
     int shutdown; /* -s */
index 4fa677943c0aa3b363144db4ba43a2af6dfb0905..1d1888a99d661d67464cc9235b9d6b8b16dce7cc 100644 (file)
@@ -321,17 +321,32 @@ int main(int argc, char** argv)
      * 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. */
 
index d8d29634a8dbe802d2de8f80050169518d029357..0b4242cb99043154c47e9dfc429e214fa91ea559 100644 (file)
@@ -3644,6 +3644,7 @@ CIM server listening on HTTPS port {0}."}
         "  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"
@@ -3663,6 +3664,7 @@ CIM server listening on HTTPS port {0}."}
         "  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"
@@ -3681,6 +3683,7 @@ CIM server listening on HTTPS port {0}."}
         "  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"
@@ -3766,6 +3769,18 @@ CIM server listening on HTTPS port {0}."}
         */
         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"
index c3ee7a7715f696f02bc176a58dda13e82f8eea8b..5a90e90d2fda139074f5d926b46bda46293d7e67 100644 (file)
@@ -275,6 +275,8 @@ void PrintHelp(const char* arg0)
     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)
@@ -503,7 +505,7 @@ int main(int argc, char** argv)
 
 #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; )
         {
@@ -514,6 +516,27 @@ int main(int argc, char** argv)
                 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;