Example #1
0
function boost_rrdtool_execute($command, $output_to_stdout, $rrd_tool_output_options)
{
    global $boost_sock;
    $return_value = "";
    if (read_config_option("boost_server_enable") == "" || $boost_sock == "") {
        boost_rrdtool_execute_internal($command, $output_to_stdout, $rrd_tool_output_options, "BOOST");
        return "OK";
    } else {
        return boost_server_run($command);
    }
}
Example #2
0
function run_command($socket, $command, $multiprocess)
{
    global $config, $eol, $rrdtool_pipe, $rrd_path, $php_binary_path, $rrd_update_path, $rrdupdates_in_process;
    $output = 'OK';
    /* process the command, don't accept bad commands */
    if (substr_count(strtolower($command), 'quit')) {
        close_connection($socket, 'Host Disconnect Request Received.');
        return 'OK';
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'update')) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'graph')) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'tune')) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'create')) {
        /* ok to run, check for structured paths */
        if (read_config_option('extended_paths') == 'on') {
            $parts = explode(' ', $command);
            $data_source_path = $parts[1];
            if (!is_dir(dirname($data_source_path))) {
                if (mkdir(dirname($data_source_path), 0775)) {
                    if ($config['cacti_server_os'] != 'win32') {
                        $owner_id = fileowner($config['rra_path']);
                        $group_id = filegroup($config['rra_path']);
                        if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
                            /* permissions set ok */
                        } else {
                            cacti_log("ERROR: Unable to set directory permissions for '" . dirname($data_source_path) . "'", FALSE);
                        }
                    }
                } else {
                    cacti_log("ERROR: Unable to create directory '" . dirname($data_source_path) . "'", FALSE);
                }
            }
        }
    } elseif (substr_count(strtolower(substr($command, 0, 10)), 'status')) {
        close_connection($socket, 'Server Status OK');
        return 'OK';
    } else {
        close_connection($socket, "WARNING: Unknown RRD Command '" . $command . "' This activity will be logged!! Goodbye.");
        return 'OK';
    }
    boost_svr_log("RRD Command '" . $command . "'");
    /* update/create the rrd */
    if (!$multiprocess) {
        boost_rrdtool_execute_internal($command, false, RRDTOOL_OUTPUT_STDOUT, 'BOOST SERVER');
    } else {
        /* store the correct information in the array */
        $rrdupdates_in_process[intval($socket)]['socket'] = $socket;
        if (strlen($rrd_update_path) && !substr_count($command, 'create ')) {
            $command = str_replace('update ', '', $command);
            exec_background($php_binary_path, 'boost_rrdupdate.php ' . intval($socket) . ' ' . $rrd_update_path . ' ' . $command);
        } else {
            exec_background($php_binary_path, 'boost_rrdupdate.php ' . intval($socket) . ' ' . $rrd_path . ' ' . $command);
        }
    }
    /* send the output back to the cleint if not multiprocess */
    if (!$multiprocess) {
        socket_write($socket, $output . $eol, strlen($output . $eol));
    }
}
Example #3
0
function boost_rrdtool_execute($command, $output_to_stdout, $rrd_tool_output_options)
{
    global $boost_sock;
    $return_value = '';
    if (read_config_option('boost_server_enable') == '' || $boost_sock == '') {
        boost_rrdtool_execute_internal($command, $output_to_stdout, $rrd_tool_output_options, 'BOOST');
        return 'OK';
    } else {
        return boost_server_run($command);
    }
}
Example #4
0
function run_command($socket, $command, $multiprocess)
{
    global $config, $eol, $rrdtool_pipe, $rrd_path, $php_binary_path, $rrd_update_path, $rrdupdates_in_process;
    $output = "OK";
    /* process the command, don't accept bad commands */
    if (substr_count(strtolower($command), "quit")) {
        close_connection($socket, "Host Disconnect Request Received.");
        return "OK";
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "update")) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "graph")) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "tune")) {
        /* ok to run */
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "create")) {
        /* ok to run, check for structured paths */
        if (read_config_option("extended_paths") == "on") {
            $parts = explode(" ", $command);
            $data_source_path = $parts[1];
            if (!is_dir(dirname($data_source_path))) {
                if (mkdir(dirname($data_source_path), 0775)) {
                    if ($config["cacti_server_os"] != "win32") {
                        $owner_id = fileowner($config["rra_path"]);
                        $group_id = filegroup($config["rra_path"]);
                        if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
                            /* permissions set ok */
                        } else {
                            cacti_log("ERROR: Unable to set directory permissions for '" . dirname($data_source_path) . "'", FALSE);
                        }
                    }
                } else {
                    cacti_log("ERROR: Unable to create directory '" . dirname($data_source_path) . "'", FALSE);
                }
            }
        }
    } elseif (substr_count(strtolower(substr($command, 0, 10)), "status")) {
        close_connection($socket, "Server Status OK");
        return "OK";
    } else {
        close_connection($socket, "WARNING: Unknown RRD Command '" . $command . "' This activity will be logged!! Goodbye.");
        return "OK";
    }
    boost_svr_log("RRD Command '" . $command . "'");
    /* update/create the rrd */
    if (!$multiprocess) {
        boost_rrdtool_execute_internal($command, false, RRDTOOL_OUTPUT_STDOUT, "BOOST SERVER");
    } else {
        /* store the correct information in the array */
        $rrdupdates_in_process[intval($socket)]["socket"] = $socket;
        if (strlen($rrd_update_path) && !substr_count($command, "create ")) {
            $command = str_replace("update ", "", $command);
            exec_background($php_binary_path, "plugins/boost/boost_rrdupdate.php " . intval($socket) . " " . $rrd_update_path . " " . $command);
        } else {
            exec_background($php_binary_path, "plugins/boost/boost_rrdupdate.php " . intval($socket) . " " . $rrd_path . " " . $command);
        }
    }
    /* send the output back to the cleint if not multiprocess */
    if (!$multiprocess) {
        socket_write($socket, $output . $eol, strlen($output . $eol));
    }
}