Exemple #1
0
<?php

# Fetch dynamic PNP template from Check_MK's new metrics system
function get_apache_port()
{
    $path = getenv("OMD_ROOT") . "/etc/omd/site.conf";
    foreach (file($path) as $line) {
        if (strpos($line, "CONFIG_APACHE_TCP_PORT") === 0) {
            list($key, $val) = explode("=", $line);
            return trim($val, "'\n\r");
        }
    }
}
$omd_site = getenv("OMD_SITE");
if ($omd_site) {
    $url = "http://localhost:" . get_apache_port() . "/{$omd_site}/check_mk/";
    $template_cache_dir = getenv("OMD_ROOT") . "/var/check_mk/pnp_template_cache";
} else {
    $url = "http://localhost/check_mk/";
    $template_cache_dir = "/tmp/check_mk_pnp_template_cache";
}
if (!file_exists($template_cache_dir)) {
    mkdir($template_cache_dir, 0755, TRUE);
}
# Get the list of performance variables and convert them to a string,
# prepend the command name, # e.g. "check_mk-hr_fs:fs_trend,fs_used,zabelfoobar"
$perf_vars = array();
foreach ($NAME as $i => $n) {
    $perf_vars[] = $n;
}
sort($perf_vars);
Exemple #2
0
include_once "../main/includes/config.inc.php";
include_once "../main/includes/functions.php";
run_location_tracker();
// Have servers moved if moved update configuration
print "\n";
//=== If no parameters passed use defaults from config.inc.php
if ($argc == 2) {
    // Was a parameter passed
    $information = $argv[1];
    // yes:
} else {
    exit;
    // no: Give up
}
$mysql_port = get_mysql_port();
$apache_port = get_apache_port();
$ssl_port = get_apache_ssl_port();
//=== Display Admin Panel in browser ==========================================
if ($information == 1) {
    $command = "start http://localhost:{$apache_port}/apanel/";
    // display index page
    exec($command, $dummy, $return);
    // run command
    exit;
}
//=== Display phpMyAdmin in browser ==========================================
if ($information == 2) {
    $command = "start http://localhost:{$apache_port}/apanel/phpmyadmin/";
    // display index page
    exec($command, $dummy, $return);
    // run command
Exemple #3
0
function test_access()
{
    global $ip_current;
    // IP address result of running get_ip_current()
    // get_ip_current()
    if (!get_ip_current()) {
        // Cannot get current IP address
        return false;
        // give up
    }
    $port = get_apache_port();
    // Get apache port from configuration
    // Build complete URL string
    $str = 'http://' . $ip_current . ':' . $port . '/test_access/index.html';
    // Access page using Curl SSL
    $ch = curl_init();
    // Initialize Curl get handle
    curl_setopt($ch, CURLOPT_URL, $str);
    // Set the Curl URL option
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
    // timeout set to 3 sceonds
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // force curl_exec ouput string
    $buffer = curl_exec($ch);
    // save returned page to buffer
    curl_close($ch);
    // Close Curl frees memory
    // Test returned page
    if (preg_match("/UniServer\\saccess/", $buffer)) {
        // Is value "UniServer access"
        return true;
        // yes: update OK
    } else {
        // no: Failed
        return false;
    }
}
Exemple #4
0
    }
}
//===========================================================================
print "\n PORT STATUS:\n\n";
//=== Apache Ports
if (apache_running() && get_apache_tracker() != "free") {
    print "   Apache port     = " . get_apache_port() . " In use by this server\n";
}
if (!apache_running() && get_apache_tracker() != "free") {
    print "   Apache port     = " . get_apache_port() . " Undefined!\n";
}
if (port_in_use(get_apache_port()) && get_apache_tracker() == "free") {
    print "   Apache port     = " . get_apache_port() . " In use by another program.\n";
}
if (!port_in_use(get_apache_port()) && get_apache_tracker() == "free") {
    print "   Apache port     = " . get_apache_port() . " Is free to use\n";
}
//=== SSL port
if (apache_running() && get_apache_tracker() != "free" && ssl_enabled()) {
    print "   Apache SSL port = " . get_apache_ssl_port() . " In use by this server\n";
}
if (!apache_running() && get_apache_tracker() != "free" && ssl_enabled()) {
    print "   Apache SSL port = " . get_apache_ssl_port() . " Undefined!\n";
}
if (!apache_running() && get_apache_tracker() != "free" && !ssl_enabled()) {
    print "   Apache SSL port = " . get_apache_ssl_port() . " Undefined!\n";
}
if (apache_running() && get_apache_tracker() != "free" && !ssl_enabled()) {
    print "   Apache SSL port = " . get_apache_ssl_port() . " SSL Not enabled free to use\n";
}
if (port_in_use(get_apache_ssl_port()) && get_apache_tracker() == "free") {
Exemple #5
0
print " #                                                                                            #\n";
print " # Uniform Server: Move Server to different ports change service name                         #\n";
print " #                                                                                            #\n";
print " #--------------------------------------------------------------------------------------------#\n";
print " # This script must be run on a clean server                                                  #\n";
print " #                                                                                            #\n";
print " # 1) To accept defaults [shown in square brackets] press enter                               #\n";
print " #                                                                                            #\n";
print " #--------------------------------------------------------------------------------------------#\n\n";
//# == Var used
$avoid1 = '135';
# Avoid this port
$avoid2 = '445';
# Avoid this port
// Old and proposed new
$Apache_port_old = get_apache_port();
# Server port
$Apache_port = $Apache_port_old + 1;
# New Server port
# Avoid these ports
if ($Apache_port == $avoid1 || $Apache_port == $avoid2) {
    $Apache_port = $Apache_port + 1;
}
$Apache_ssl_port_old = get_apache_ssl_port();
# SSL Server port
$Apache_ssl_port = $Apache_ssl_port_old + 1;
# New SSL Server port
# Avoid these ports
if ($Apache_ssl_port == $avoid1 || $Apache_ssl_port == $avoid2) {
    $Apache_ssl_port = $Apache_ssl_port + 1;
}