Package com.sun.faban.common

Examples of com.sun.faban.common.CommandHandle


        Command startCmd = new Command(mysqlCmd);
        logger.fine("Starting mysql with: " + mysqlCmd);
        startCmd.setSynchronous(false); // to run in bg
        try {
            // Run the command in the background
            CommandHandle ch = RunContext.exec(myServer, startCmd);
            /*
             * Make sure the server has started.
             */
            if ( !checkServerStarted(myServer)) {
                logger.severe("Failed to find MySQL pidfile " + pidFile +
View Full Code Here


        success = RunContext.isFile(myServer, pidFile);
        if (success) {
            try {
                // First kill mysqld_safe
                Command stopCmd = new Command("pkill mysqld_safe");
                CommandHandle ch = RunContext.exec(myServer, stopCmd);

                // Get the pid from the pidFile
                ByteArrayOutputStream bs = new ByteArrayOutputStream(10);
                RunContext.writeFileToStream(myServer, pidFile, bs);
                pidString = bs.toString();
View Full Code Here

            beginDate + "\"" + " \"" + endDate + "\" " +
            outFile);
             ****/
            Command parseCommand = new Command("mysql_trunc_err.sh " +
                    beginDate + " " + endDate + " " + outFile);
            CommandHandle ch = RunContext.exec(parseCommand);

        } catch (Exception e) {

            logger.log(Level.WARNING, "Failed to tranfer log of " +
                    myServer + '.', e);
View Full Code Here

                    // Get system info
                    PrintStream syslog =
                                    new PrintStream(new FileOutputStream(f));
                    Command sysinfo = new Command("sysinfo");
                    sysinfo.setStreamHandling(Command.STDOUT, Command.CAPTURE);
                    CommandHandle handle = cmds.execute(host, sysinfo, null);
                    byte[] info = handle.fetchOutput(Command.STDOUT);

                    // Write header and info to file.
                    syslog.println("<html><head><title>System Info for Server "
                            + machineName + "</title></head><body>");

                    syslog.write(info);

                    // Get User Commands output if specified
                    if (hostConfig.userCommands != null &&
                            hostConfig.userCommands.trim().length() > 0) {
                        String[] cmdStrings = hostConfig.userCommands.
                                                            split(";");
                        for (String cmdString : cmdStrings) {
                            Command c = new Command(cmdString);
                            c.setStreamHandling(Command.STDOUT,Command.CAPTURE);
                            logger.info("Executing '" + cmdString + "'");
                            handle = cmds.execute(host, c, null);
                            info = handle.fetchOutput(Command.STDOUT);
                            if (info != null) {
                                syslog.println(linesep);
                                syslog.println("<h3>" + hostConfig.userCommands+
                                        " on server " + machineName + "</h3>");
                                syslog.println("<pre>\n");
View Full Code Here

                    cmds.execute(hosts[j], cmd, null);

                    cmd = new Command("/usr/sbin/psrinfo");
                    cmd.setStreamHandling(Command.STDOUT, Command.CAPTURE);
                    logger.fine("Getting cpus");
                    CommandHandle handle = cmds.execute(hosts[j], cmd, null);
                    byte[] buffer = handle.fetchOutput(Command.STDOUT);

                    if (buffer != null) {
                        StringTokenizer t =
                                new StringTokenizer(new String(buffer), "\n");
View Full Code Here

        logger.fine("Run ended Month = " + endMon
                + " Day = " + endDay + " Time = " + etime);

        // Now, get /var/adm/messages and look for messages between
        // start and end
        CommandHandle handle;
        Command c = new Command("messages", "\"" +
                startMon + " " + startDay + " " + stime + "\"",
                "\""  + endMon + " " + endDay + " " + etime + "\"");
        c.setStreamHandling(Command.STDOUT, Command.CAPTURE);
        logger.fine("Getting system messages");

        for (ParamRepository.HostConfig hostConfig : hostConfigs) {
            for(String host : hostConfig.hosts) {
                String machineName = cmds.getHostName(host);
                File f = new File(sysfile + "." + machineName);
                f.delete();
                try {
                    syslog = new PrintStream(new FileOutputStream(f));
                    handle = cmds.execute(host, c, null);
                    byte[] messages = handle.fetchOutput(Command.STDOUT);
                    syslog.println(linesep);
                    syslog.println("System messages during run from server " +
                            host);
                    syslog.println("\n");
                    if (messages != null) // Null if no messages.
View Full Code Here

   * Check if Glassfish server is started.
   */
    private static boolean checkServerStarted(String hostName)
            throws Exception {
        Command checkCmd = new Command(asadminCmd, "list-domains");    
        CommandHandle handle = RunContext.exec(hostName, checkCmd);
        byte[] output = handle.fetchOutput(Command.STDOUT);
        if (output != null) {
            String outStr = new String(output);
        if (outStr.indexOf("domain1 running") != -1)
            return true;
        else
View Full Code Here

            Integer retVal = 0;
            try {
                Command stopCmd = new Command(asadminCmd, "stop-domain");
              
                // Run the command in the foreground
                CommandHandle ch = RunContext.exec(myServers[i], stopCmd);

                // Check if the server was even running before stop was issued
                // If not running, asadmin will print that on stdout
                byte[] output = ch.fetchOutput(Command.STDOUT);

                if (output != null) {
                    String outStr = new String(output);
                    if (outStr.indexOf("stopped.") != -1 ||
                            outStr.indexOf("isn't running.") != -1) {
View Full Code Here

   * Check if glassfish server is stopped.
   */
    private static Integer checkServerStopped(String hostName)
            throws Exception {
        Command checkCmd = new Command(asadminCmd, "list-domains");
        CommandHandle handle = RunContext.exec(hostName, checkCmd);
        byte[] output = handle.fetchOutput(Command.STDOUT);
        if (output != null) {
            String outStr = new String(output);
            if (outStr.indexOf("domain1 not running") != -1)
                return 1;
            else
View Full Code Here

                    Command stopCmd = new Command(cmd);
                    stopCmd.setLogLevel(Command.STDOUT, Level.FINE);
                    stopCmd.setLogLevel(Command.STDERR, Level.FINE);

                    // Run the command in the foreground
                    CommandHandle ch = RunContext.exec(myServers[i], stopCmd);
                    // Check if the server was running before stop was issued
                    // If not running, apachectl will print that on stdout
                    byte[] output = ch.fetchOutput(Command.STDOUT);

                    if (output != null)
                        if ((output.toString()).indexOf("not running") != -1) {
                           continue;
                        }
View Full Code Here

TOP

Related Classes of com.sun.faban.common.CommandHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.