Example #1
0
 public function generateUriFromPath($path)
 {
     global $base_url;
     $result = $base_url . 'tiki-webdav.php/Wiki%20Pages' . implode('/', array_map('rawurlencode', explode('/', $path)));
     print_debug("generateUriFromPath({$path}): {$result}\n");
     return $result;
 }
Example #2
0
function sql_run($sql)
{
    if (!mysql_query($sql)) {
        print_debug("MySQL error: " . mysql_error());
        return 0;
    }
    return 1;
}
Example #3
0
 public function generateUriFromPath($path)
 {
     global $base_url;
     $filegallib = TikiLib::lib('filegal');
     $result = $base_url . 'tiki-webdav.php' . implode('/', array_map('rawurlencode', explode('/', $path)));
     print_debug("generateUriFromPath({$path}): {$result}\n");
     return $result;
 }
Example #4
0
/**
 * @param $errno
 * @param $errmsg
 * @param $filename
 * @param $linenum
 * @param $vars
 */
function error_handler($errno, $errmsg, $filename, $linenum, $vars)
{
    print_debug("\n=== ERROR ===\n");
    print_debug("{$filename}\n{$linenum}\n{$errmsg}\n");
    print_debug("\n===  BACTRACE ===\n");
    print_debug(print_r(debug_backtrace(false), true));
    print_debug("\n===  BACTRACE END ===\n");
    print_debug("\n=== ERROR END ===\n");
}
Example #5
0
 public function generateUriFromPath($path)
 {
     global $base_url;
     global $filegallib;
     require_once 'lib/filegals/filegallib.php';
     $result = $base_url . 'tiki-webdav.php' . implode('/', array_map('rawurlencode', explode('/', $path)));
     print_debug("generateUriFromPath({$path}): {$result}\n");
     return $result;
 }
Example #6
0
 function db_get_stock_almacen($id_almacen)
 {
     $tbl = $this->tbl;
     $query = "SELECT a.almacenes\r\n\t\t\t\t\t    ,a.clave_corta as clave_almacen\r\n\t\t\t\t\t    ,pa.pasillos\r\n\t\t\t\t\t    ,pa.clave_corta as clave_pasillo\r\n\t\t\t\t\t    ,ag.gavetas\r\n\t\t\t\t\t    ,ag.clave_corta as clave_gabeta\r\n\t\t\t\t\t    ,er.num_factura\r\n\t\t\t\t\t    ,er.fecha_factura\r\n\t\t\t\t\t    ,er.descuento\r\n\t\t\t\t\t    ,er.subtotal\r\n\t\t\t\t\t    ,er.impuesto\r\n\t\t\t\t\t    ,er.total\r\n\t\t\t\t\t    ,er.n_orden\r\n\t\t\t\t\t    ,er.tipo_orden\r\n\t\t\t\tFROM {$tbl['almacen_stock']} s\r\n\t\t\t\tLEFT JOIN {$tbl['almacen_almacenes']} a on a.id_almacen_almacenes = s.id_almacen\r\n\t\t\t\tLEFT JOIN {$tbl['almacen_pasillos']} pa on pa.id_almacen_pasillos = s.id_pasillo\r\n\t\t\t\tLEFT JOIN {$tbl['almacen_gavetas']} ag on ag.id_almacen_gavetas = s.id_gaveta\r\n\t\t\t\tLEFT JOIN (SELECT\r\n\t\t\t\t\t\t\t\t er.id_almacen_entradas_recepcion\r\n\t\t\t\t\t\t\t\t,er.num_factura\r\n\t\t\t\t\t\t\t\t,er.fecha_factura\r\n\t\t\t\t\t\t\t\t,er.descuento\r\n\t\t\t\t\t\t\t\t,er.subtotal\r\n\t\t\t\t\t\t\t\t,er.impuesto\r\n\t\t\t\t\t\t\t\t,er.total\r\n\t\t\t\t\t\t\t\t,co.orden_num as n_orden\r\n\t\t\t\t\t\t\t\t,ot.orden_tipo as tipo_orden\r\n\t\t\t\t\t\t\tFROM {$tbl['almacen_entradas_recibir']} er\r\n\t\t\t\t\t\t\tLEFT JOIN {$tbl['compras_ordenes']} co on co.id_compras_orden = er.id_compras_orden\r\n\t\t\t\t\t\t\tLEFT JOIN {$tbl['compras_ordenes_tipo']} ot on ot.id_orden_tipo = co.id_orden_tipo) er on (er.id_almacen_entradas_recepcion = s.id_almacen_entradas_recepcion)\r\n\t\t\t\tLEFT JOIN (SELECT o.num_orden\r\n\t\t\t\t\t       FROM {$tbl['compras_ordenes_articulos']} oa\r\n\t\t\t\t\t       LEFT JOIN {$tbl['compras_ordenes']} o on o.id_compras_orden = oa.id_compras_orden) oa on \r\n\t\t\t\tWHERE s.activo = 1 AND s.id_almacen = {$id_almacen}\r\n\t\t\t\tGROUP BY s.id_almacen, pa.pasillos, ag.gavetas, er.num_factura";
     print_debug($query);
     $query = $this->db->query($query);
     if ($query->num_rows >= 1) {
         return $query->result_array();
     }
 }
function exec_command($cmd)
{
    $ast = str_repeat("*", 10);
    ob_start();
    system($cmd, $out);
    $ris = ob_get_contents();
    ob_end_clean();
    print_debug("{$ast}\t ESECUZIONE COMANDO {$cmd} con RETURN CODE {$out}\t{$ast}\n");
    print_debug($arr);
    print_debug("{$ast}{$ast}\tRISULTATO EXEC\t{$ast}{$ast}\n{$ris}\n{$ast}{$ast} FINE ESECUZIONE COMANDO {$ast}{$ast}\n");
}
 function index()
 {
     $GLOBALS['phpgw_info']['flags']['currentapp'] = 'email';
     print_debug('relevant phpgw_info data', $GLOBALS['phpgw_info']['user']['preferences']['email']);
     $this->bo = CreateObject('email.boindex');
     $this->bo->index_data();
     if ($GLOBALS['phpgw']->msg->phpgw_before_xslt) {
         $this->index_old_tpl();
     } else {
         $this->index_xslt_tpl();
     }
 }
Example #9
0
function checksum($sum, $value)
{
    if (!is_numeric($value)) {
        if (!is_null($value)) {
            print_debug("Not a number value:\n" . var_export($value, true) . "\n");
            exit_error("Not a number value\n");
        }
    } else {
        print_debug("Add to sum: " . $value . "\n");
        $sum += $value;
    }
    return $sum;
}
Example #10
0
 public function authorize($user, $path, $access = self::ACCESS_READ)
 {
     global $tikilib;
     print_debug("authorize " . $user . " " . $path . " " . $access . "\n");
     if ($path === '/') {
         return true;
     }
     $page = substr($path, 1);
     $groups = $tikilib->get_user_groups($user);
     $perms = Perms::getInstance();
     $perms->setGroups($groups);
     $perms = $tikilib->page_exists($page) ? Perms::get(array('type' => 'wiki page', 'object' => substr($path, 1))) : Perms::get();
     return $access === self::ACCESS_READ && $perms->view || $access === self::ACCESS_WRITE && $perms->edit;
 }
 public function db_insert_data($data = array())
 {
     print_debug($data);
     // DB Info
     $tbl = $this->tbl;
     // Query
     $existe = $this->row_exist($tbl['administracion_regiones'], array('clave_corta' => $data['clave_corta']));
     if (!$existe) {
         $query = $this->db->insert_item($tbl['administracion_regiones'], $data, true);
         return $query;
     } else {
         return false;
     }
 }
Example #12
0
 public function row_exist($table, $row, $debug = false)
 {
     $this->db->select();
     $this->db->from($table);
     $this->db->where($row);
     $query = $this->db->get();
     if ($debug) {
         print_debug($query->result_array());
     }
     if ($query->num_rows >= 1) {
         return true;
     } else {
         return false;
     }
 }
function custom_port_parser($port)
{
    global $config;
    print_debug($port['ifAlias']);
    // Pull out Type and Description or abort
    if (!preg_match('/^([^:]+):([^\\[\\]\\(\\)\\{\\}]+)/', $port['ifAlias'], $matches)) {
        return array();
    }
    // Munge and Validate type
    $types = array('core', 'peering', 'transit', 'cust', 'server', 'l2tp');
    foreach ($config['int_groups'] as $custom_type) {
        $types[] = strtolower(trim($custom_type));
    }
    $type = strtolower(trim($matches[1], " \t\n\r\v\\/\"'"));
    if (!in_array($type, $types)) {
        return array();
    }
    # Munge and Validate description
    $descr = trim($matches[2]);
    if ($descr == '') {
        return array();
    }
    if (preg_match('/\\{(.*)\\}/', $port['ifAlias'], $matches)) {
        $circuit = $matches[1];
    }
    if (preg_match('/\\[(.*)\\]/', $port['ifAlias'], $matches)) {
        $speed = $matches[1];
    }
    if (preg_match('/\\((.*)\\)/', $port['ifAlias'], $matches)) {
        $notes = $matches[1];
    }
    $port_ifAlias = array();
    $port_ifAlias['type'] = $type;
    $port_ifAlias['descr'] = $descr;
    $port_ifAlias['circuit'] = $circuit;
    $port_ifAlias['speed'] = $speed;
    $port_ifAlias['notes'] = $notes;
    if (OBS_DEBUG > 1) {
        print_vars($port_ifAlias);
    }
    return $port_ifAlias;
}
function float_cmp($a, $b, $epsilon = NULL)
{
    $epsilon = is_numeric($epsilon) ? (double) $epsilon : 1.0E-5;
    // Default epsilon for float compare
    $compare = FALSE;
    $both = 0;
    // Convert to float if possible
    if (is_numeric($a)) {
        $a = (double) $a;
        $both++;
    }
    if (is_numeric($b)) {
        $b = (double) $b;
        $both++;
    }
    if ($both === 2) {
        // Compare numeric variables as float numbers
        if (abs(($a - $b) / $b) < $epsilon) {
            $compare = 0;
            // Float numbers same
        }
        if (OBS_DEBUG > 1) {
            print_debug('比较浮点数: "' . $a . '" with "' . $b . '", epsilon: "' . $epsilon . '", comparision: "' . abs(($a - $b) / $b) . ' < ' . $epsilon . '", numbers: ' . ($compare === 0 ? 'SAME' : 'DIFFERENT'));
        }
    } else {
        // All other compare as usual
        if ($a === $b) {
            $compare = 0;
            // Variables same
        }
    }
    if ($compare === FALSE) {
        // Compare if variables not same
        if ($a > $b) {
            $compare = 1;
            // $a greater than $b
        } else {
            $compare = -1;
            // $a less than $b
        }
    }
    return $compare;
}
     case 'nwhrStorageMSEngineMemory':
     case 'nwhrStorageUnclaimedMemory':
         $deny = TRUE;
         break;
 }
 if (isset($config['ignore_mount_removable']) && $config['ignore_mount_removable'] && $fstype == "hrStorageRemovableDisk") {
     $deny = TRUE;
     print_debug("skip(removable)");
 }
 if (isset($config['ignore_mount_network']) && $config['ignore_mount_network'] && $fstype == "hrStorageNetworkDisk") {
     $deny = TRUE;
     print_debug("skip(network)");
 }
 if (isset($config['ignore_mount_optical']) && $config['ignore_mount_optical'] && $fstype == "hrStorageCompactDisc") {
     $deny = TRUE;
     print_debug("skip(cd)");
 }
 if (!$deny) {
     //32bit counters
     $size = snmp_dewrap32bit($storage['hrStorageSize']) * $units;
     $used = snmp_dewrap32bit($storage['hrStorageUsed']) * $units;
     $path = rewrite_storage($descr);
     // Find index from 'UCD-SNMP-MIB::dskTable'
     foreach ($cache_discovery['ucd-snmp-mib'] as $dsk) {
         if ($dsk['dskPath'] === $path) {
             // Using 64bit counters if available
             if (isset($dsk['dskTotalLow'])) {
                 $dsk['units'] = 1024;
                 $dsk['size'] = $dsk['dskTotalHigh'] * 4294967296.0 + $dsk['dskTotalLow'];
                 $dsk['size'] *= $dsk['units'];
                 if ($dsk['size'] - $size > $units) {
 function get_selectdb_value($val, $fld, $tab, $campo)
 {
     if ($val == -1) {
         return "Non definito";
     } elseif (!$val) {
         switch ($tab) {
             default:
                 $fkey = "Non definito";
                 break;
         }
         return $fkey;
     } else {
         $sql = "SELECT {$campo} FROM {$tab} WHERE {$fld}='{$val}';";
         //echo "<p>$sql</p>";
         if (!isset($this->db)) {
             $this->connettidb();
         }
         print_debug($sql, null, "fkey");
         if (!$this->db->sql_query($sql)) {
             print_debug("Errore Chiave Esterna\n" . $sql, null, "error");
         }
     }
     return $this->db->sql_fetchfield($campo);
 }
<?php

require_once "login.php";
$id = $_REQUEST["id"];
$pratica = $_REQUEST["pratica"];
if ($pratica != "null" && $pratica) {
    $db = appUtils::getDB();
    $sql = "SELECT file_doc FROM stp.stampe WHERE id=?";
    $fName = $db->fetchColumn($sql, array($id));
    $pr = new pratica($pratica);
    $url = $pr->smb_documenti . $fName;
    print_debug($url . "\n", NULL, "documento");
} else {
    $db = appUtils::getDB();
    $sql = "SELECT nome FROM stp.e_modelli WHERE id=?";
    $fName = $db->fetchColumn($sql, array($id));
    $url = SMB_MODELLI . $fName;
}
//if (file_exists(DATA_DIR.implode(DIRECTORY_SEPARATOR,Array("praticaweb",'documenti')).DIRECTORY_SEPARATOR)) {
//    echo $url;exit;
//}
header("Content-type: application/vnd.ms-word");
@header("Location: {$url}");
<?php

include_once "login.php";
//print_r($_REQUEST);
$db = new sql_db(DB_HOST, DB_USER, DB_PWD, DB_NAME, false);
if (!$db->db_connect_id) {
    die("Impossibile connettersi al database");
}
$object = $_POST["obj"];
$id = $_POST["id"];
$azione = $_POST["action"];
$sql = "select distinct zona.nome_tavola as id from vincoli.zona left join vincoli.tavola on(zona.nome_tavola=tavola.nome_tavola) where zona.nome_vincolo= '{$id}' and tavola.cdu=1;";
$db->sql_query($sql);
print_debug($sql);
$ris = $db->sql_fetchrowset();
for ($i = 0; $i < count($ris); $i++) {
    $out[] = "{id:'" . $ris[$i]["id"] . "',name:'" . $ris[$i]["id"] . "'}";
}
header("Content-Type: text/plain; Charset=UTF-8");
$debug = "{id:'{$object}',values:[" . implode(',', $out) . "]}";
print_debug($debug);
echo $debug;
         }
     }
     break;
     // Exit while
 } else {
     if ($device['os'] == 'arista_eos' && $sensor_port['entPhysicalClass'] == 'container' && strlen($sensor_port['entPhysicalAlias'])) {
         // Arista not have entAliasMappingIdentifier, but used entPhysicalAlias as ifDescr
         $port_id = get_port_id_by_ifDescr($device['device_id'], $sensor_port['entPhysicalAlias']);
         if (is_numeric($port_id)) {
             // Hola, port really found
             $port = get_port_by_id($port_id);
             $ifIndex = $port['ifIndex'];
             $options['entPhysicalIndex_measured'] = $ifIndex;
             $options['measured_class'] = 'port';
             $options['measured_entity'] = $port_id;
             print_debug("Port is found: ifIndex = {$ifIndex}, port_id = " . $port_id);
             break;
             // Exit while
         }
         $sensor_index = $sensor_port['entPhysicalContainedIn'];
         // Next ifIndex
     } else {
         if ($sensor_index == $sensor_port['entPhysicalContainedIn']) {
             break;
             // Break if current index same as next to avoid loop
         } else {
             $sensor_index = $sensor_port['entPhysicalContainedIn'];
             // Next ifIndex
         }
     }
 }
Example #20
0
 public function releaseLock($user, $lockToken)
 {
     print_debug("Releasing Lock({$user}, {$lockToken})...\n");
     if ($user == '') {
         $user = '******';
     }
     unset($this->tokens[$user][$lockToken]);
 }
Example #21
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// Force rediscover os if os definition changed
if (!isset($config['os'][$device['os']])) {
    print_debug('OS name change detected, forced os rediscover.');
    force_discovery($device, 'os');
}
// Cache hardware/version/serial info from ENTITY-MIB (if possible use inventory module data)
if (is_device_mib($device, 'ENTITY-MIB') && (in_array($device['os_group'], array('unix', 'cisco')) || in_array($device['os'], array('acme', 'nos', 'ibmnos', 'acsw', 'fabos', 'wlc', 'h3c', 'hh3c', 'hpuww')))) {
    // Get entPhysical tables for some OS and OS groups
    if ($config['discovery_modules']['inventory']) {
        $entPhysical = dbFetchRow('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ?', array($device['device_id'], '0'));
    } else {
        switch (TRUE) {
            case $device['os_group'] == 'cisco' || in_array($device['os'], array('acme', 'h3c', 'hh3c')):
                $oids = 'entPhysicalDescr.1 entPhysicalSerialNum.1 entPhysicalModelName.1 entPhysicalContainedIn.1 entPhysicalName.1 entPhysicalSoftwareRev.1';
                break;
            case $device['os'] == 'qnap':
                $oids = 'entPhysicalDescr.1 entPhysicalName.1 entPhysicalSerialNum.1 entPhysicalFirmwareRev.1';
                break;
            case $device['os'] == 'ibmnos':
        // SNMP-FRAMEWORK-MIB::snmpEngineTime.0 = INTEGER: 72393514 seconds
        $snmpEngineTime = snmp_get($device, "snmpEngineTime.0", "-OUqv", "SNMP-FRAMEWORK-MIB", mib_dirs());
        if ($device['os'] == 'aos' && strlen($snmpEngineTime) > 8) {
            // Some Alcatel have bug with snmpEngineTime
            // http://jira.observium.org/browse/OBSERVIUM-763
            $snmpEngineTime = 0;
        } else {
            if (is_numeric($snmpEngineTime) && $snmpEngineTime > 0 && $snmpEngineTime > $uptime) {
                $polled = time();
                $uptime = $snmpEngineTime;
                $uptime_msg = "Using SNMP Agent snmpEngineTime";
            }
        }
    }
}
print_debug("{$uptime_msg} ({$uptime} seconds)");
if (is_numeric($uptime)) {
    // Notify only if current uptime less than one month (eg if changed from sysUpTime to snmpEngineTime)
    if ($uptime < $device['uptime'] && $uptime < 2628000) {
        notify($device, "Device rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . formatUptime($uptime) . " ago.");
        log_event('Device rebooted after ' . formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
    }
    $uptime_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd";
    if (!is_file($uptime_rrd)) {
        rrdtool_create($uptime_rrd, "DS:uptime:GAUGE:600:0:U ");
    }
    rrdtool_update($uptime_rrd, "N:" . $uptime);
    $graphs['uptime'] = TRUE;
    print_message("Uptime: " . formatUptime($uptime));
    $update_array['uptime'] = $uptime;
    $cache['devices']['uptime'][$device['device_id']]['uptime'] = $uptime;
Example #23
0
$poller_time = substr($poller_run, 0, 5);
if ($polled_devices) {
    dbInsert(array('type' => 'poll', 'doing' => $doing, 'start' => $poller_start, 'duration' => $poller_time, 'devices' => $polled_devices), 'perf_times');
    if (is_numeric($doing)) {
        $doing = $device['hostname'];
    }
    // Single device ID convert to hostname for log
} else {
    print_warning("WARNING: 0 devices polled. Did you specify a device that does not exist?");
}
$string = $argv[0] . ": {$doing} - {$polled_devices} devices polled in {$poller_time} secs";
print_debug($string);
print_cli_heading("%WCompleted polling run at " . date("Y-m-d H:i:s"), 0);
if (!isset($options['q'])) {
    if ($config['snmp']['hide_auth']) {
        print_debug("NOTE, \$config['snmp']['hide_auth'] is set to TRUE, snmp community and snmp v3 auth hidden from debug output.");
    }
    print_cli_data('Devices Polled', $polled_devices, 0);
    print_cli_data('Poller Time', $poller_time . " secs", 0);
    print_cli_data('Memory usage', formatStorage(memory_get_usage(TRUE), 2, 4) . ' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
    $mysql_time = 0;
    foreach ($db_stats as $cmd => $count) {
        if (isset($db_stats[$cmd . '_sec'])) {
            $mysql_times[] = ucfirst(str_replace("fetch", "", $cmd)) . "[" . $count . "/" . round($db_stats[$cmd . '_sec'], 3) . "s]";
            $mysql_time += $db_stats[$cmd . '_sec'];
        }
    }
    print_cli_data('MySQL Usage', implode(" ", $mysql_times) . ' (' . round($mysql_time, 3) . 's ' . round($mysql_time / $poller_time * 100, 3) . '%)', 0);
    $rrd_time = 0;
    foreach ($GLOBALS['rrdtool'] as $cmd => $data) {
        $rrd_times[] = $cmd . "[" . $data['count'] . "/" . round($data['time'], 3) . "s]";
	\****************************************************************************/
register_shutdown_function(array($GLOBALS['phpgw']->common, 'phpgw_final'));
/****************************************************************************\
	* Stuff to use if logging in or logging out                                  *
	\****************************************************************************/
if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout') {
    if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login') {
        if (@$_POST['login'] != '') {
            if (count($GLOBALS['phpgw_domain']) > 1) {
                list($login) = explode('@', $_POST['login']);
            } else {
                $login = $_POST['login'];
            }
            print_debug('LID', $login, 'app');
            $login_id = $GLOBALS['phpgw']->accounts->name2id($login);
            print_debug('User ID', $login_id, 'app');
            $GLOBALS['phpgw']->accounts->accounts($login_id);
            $GLOBALS['phpgw']->preferences->preferences($login_id);
            $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.datetime');
        }
    }
    /**************************************************************************\
    	* Everything from this point on will ONLY happen if                        *
    	* the currentapp is not login or logout                                    *
    	\**************************************************************************/
} else {
    if (!$GLOBALS['phpgw']->session->verify()) {
        // we forward to the same place after the re-login
        if ($GLOBALS['phpgw_info']['server']['webserver_url'] && $GLOBALS['phpgw_info']['server']['webserver_url'] != '/') {
            list(, $relpath) = explode($GLOBALS['phpgw_info']['server']['webserver_url'], $_SERVER['PHP_SELF'], 2);
        } else {
Example #25
0
function poll_mib_def($device, $mib_name_table, $mib_subdir, $mib_oids, $mib_graphs, &$graphs)
{
    global $config;
    echo "This is poll_mib_def Processing\n";
    $mib = null;
    if (stristr($mib_name_table, 'UBNT')) {
        list($mib, ) = explode(':', $mib_name_table, 2);
        // $mib_dirs = mib_dirs($mib_subdir);
        $rrd_file = strtolower(safename($mib)) . '.rrd';
    } else {
        list($mib, $file) = explode(':', $mib_name_table, 2);
        $rrd_file = strtolower(safename($file)) . '.rrd';
    }
    $rrdcreate = '--step 300 ';
    $oidglist = array();
    $oidnamelist = array();
    foreach ($mib_oids as $oid => $param) {
        $oidindex = $param[0];
        $oiddsname = $param[1];
        $oiddsdesc = $param[2];
        $oiddstype = $param[3];
        $oiddsopts = $param[4];
        if (strlen($oiddsname) > 19) {
            $oiddsname = truncate($oiddsname, 19, '');
        }
        if (empty($oiddsopts)) {
            $oiddsopts = '600:U:100000000000';
        }
        $rrdcreate .= ' DS:' . $oiddsname . ':' . $oiddstype . ':' . $oiddsopts;
        if ($oidindex != '') {
            $fulloid = $oid . '.' . $oidindex;
        } else {
            $fulloid = $oid;
        }
        // Add to oid GET list
        $oidglist[] = $fulloid;
        $oidnamelist[] = $oiddsname;
    }
    //end foreach
    // Implde for LibreNMS Version
    $oidilist = implode(' ', $oidglist);
    $snmpdata = snmp_get_multi($device, $oidilist, '-OQUs', $mib);
    if (isset($GLOBALS['exec_status']['exitcode']) && $GLOBALS['exec_status']['exitcode'] !== 0) {
        print_debug('  ERROR, bad snmp response');
        return false;
    }
    $oid_count = 0;
    $fields = array();
    foreach ($oidglist as $fulloid) {
        list($splitoid, $splitindex) = explode('.', $fulloid, 2);
        if (is_numeric($snmpdata[$splitindex][$splitoid])) {
            $fields[$oidnamelist[$oid_count]] = $snmpdata[$splitindex][$splitoid];
        } else {
            $fields[$oidnamelist[$oid_count]] = 'U';
        }
        $oid_count++;
    }
    $rrdfilename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . $rrd_file;
    if (!is_file($rrdfilename)) {
        rrdtool_create($rrdfilename, $rrdcreate . ' ' . $config['rrd_rra']);
    }
    rrdtool_update($rrdfilename, $fields);
    foreach ($mib_graphs as $graphtoenable) {
        $graphs[$graphtoenable] = true;
    }
    return true;
}
Example #26
0
/**
 * The function returns list of all template files for specific template type(s)
 *
 * @param mixed $types Type name of list of types as array
 * @return array $template_list List of template files with type as array keys
 */
function get_templates_list($types)
{
    $template_list = array();
    // If templates not found, return empty list
    $template_dir = $GLOBALS['config']['template_dir'];
    $default_dir = $GLOBALS['config']['install_dir'] . '/includes/templates';
    if (!is_array($types)) {
        $types = array($types);
    }
    foreach ($types as $type) {
        switch ($type) {
            case 'alert':
            case 'group':
            case 'notification':
                if ($type == 'notification') {
                    $ext = '.tpl';
                } else {
                    $ext = '.xml';
                }
                foreach (glob($default_dir . '/' . $type . '/?*_?*' . $ext) as $filename) {
                    // Default templates, before user templates for override
                    $template_list[$type][] = $filename;
                }
                // Examples:
                //  /opt/observium/templates/alert/device_myname.xml
                //  /opt/observium/templates/notification/email_html.tpl
                foreach (glob($template_dir . '/' . $type . '/?*_?*' . $ext) as $filename) {
                    // User templates
                    $template_list[$type][] = $filename;
                }
                break;
            default:
                print_debug("Template type '{$type}' unknown!");
        }
    }
    return $template_list;
}
Example #27
0
                }
            }
            print_debug("Timing housekeeping: deleted {$rows} entries (per-device)");
            logfile("housekeeping.log", "Timing: deleted {$rows} entries older than " . format_unixtime($cutoff) . " (per-device)");
            $rows = dbDelete('perf_times', $where);
            if ($rows === FALSE) {
                // Use LIMIT with big tables
                print_debug("Performance table (per-run) is too big, using LIMIT for delete entries");
                $rows = 0;
                $i = 1000;
                while ($i && $rows < $count_run) {
                    $iter = dbDelete('perf_times', $where . ' LIMIT 1000000');
                    if ($iter === FALSE) {
                        break;
                    }
                    $rows += $iter;
                    $i--;
                }
            }
            print_debug("Timing housekeeping: deleted {$rows} entries (per-run)");
            logfile("housekeeping.log", "Timing: deleted {$rows} entries older than " . format_unixtime($cutoff) . " (per-run)");
        }
    } else {
        if ($prompt) {
            print_message("No perfomance entries found older than " . format_unixtime($cutoff));
        }
    }
} else {
    print_message("Timing housekeeping disabled in configuration or less than 24h.");
}
// EOF
Example #28
0
        if (!in_array($descr, $iem_sensors['humidity'])) {
            discover_sensor($valid['sensor'], 'humidity', $device, $oid, "uioSensorStatusHumidity.{$index}", 'apc', $descr, 1, $value);
        } else {
            print_debug("Sensor was already found through iem table, skipping uio");
        }
    }
    // Temperature
    $value = $entry['uioSensorStatusTemperatureDegC'];
    $oid = ".1.3.6.1.4.1.318.1.1.25.1.2.1.6.{$index}";
    // No thresholds in the uio MIB table :(
    if ($value != '' && $value != -1) {
        // Skip if already discovered through iem
        if (!in_array($descr, $iem_sensors['temperature'])) {
            discover_sensor($valid['sensor'], 'temperature', $device, $oid, "uioSensorStatusTemperatureDegC.{$index}", 'apc', $descr, 1, $value);
        } else {
            print_debug("Sensor was already found through iem table, skipping uio");
        }
    }
    // FIXME we could add the state sensors here too (ViolationStatus, AlarmStatus)
}
unset($iem_sensors);
// Unset variable used by iem/uio deduplication code
// Environmental monitoring on rPDU2
$cache['apc'] = snmpwalk_cache_oid($device, "rPDU2SensorTempHumidityConfigTable", array(), "PowerNet-MIB");
$cache['apc'] = snmpwalk_cache_oid($device, "rPDU2SensorTempHumidityStatusTable", $cache['apc'], "PowerNet-MIB");
foreach ($cache['apc'] as $index => $entry) {
    $descr = $entry['rPDU2SensorTempHumidityStatusName'];
    // Humidity
    $value = $entry['rPDU2SensorTempHumidityStatusRelativeHumidity'];
    $oid = ".1.3.6.1.4.1.318.1.1.26.10.2.2.1.10.{$index}";
    $limits = array('limit_low' => $entry['rPDU2SensorTempHumidityConfigHumidityMinThresh'], 'limit_low_warn' => $entry['rPDU2SensorTempHumidityConfigHumidityLowThresh']);
        if ($port_low['ifType'] == 'propVirtual') {
            continue;
        }
        //Skip stacking on Vlan ports (F.u. Cisco SB)
        $ifStackStatus = $entry_low['ifStackStatus'];
        if (isset($stack_db_array[$port_id_high][$port_id_low])) {
            if ($stack_db_array[$port_id_high][$port_id_low]['ifStackStatus'] == $ifStackStatus) {
                echo ".";
            } else {
                $update_array = array('ifStackStatus' => $ifStackStatus);
                dbUpdate($update_array, 'ports_stack', "`device_id` = ? AND `port_id_high` = ? AND `port_id_low` = ?", array($device['device_id'], $port_id_high, $port_id_low));
                echo "U";
            }
            unset($stack_db_array[$port_id_high][$port_id_low]);
        } else {
            $update_array = array('device_id' => $device['device_id'], 'port_id_high' => $port_id_high, 'port_id_low' => $port_id_low, 'ifStackStatus' => $ifStackStatus);
            dbInsert($update_array, 'ports_stack');
            echo "+";
        }
    }
}
foreach ($stack_db_array as $port_id_high => $array) {
    foreach ($array as $port_id_low => $blah) {
        print_debug("DELETE STACK: " . $device['device_id'] . " " . $port_id_low . " " . $port_id_high);
        dbDelete('ports_stack', "`device_id` =  ? AND port_id_high = ? AND port_id_low = ?", array($device['device_id'], $port_id_high, $port_id_low));
        echo "-";
    }
}
unset($update_array);
echo "\n";
// EOF
	*  option) any later version.                                              *
	* --------------------------------------------                             *
	* This program was sponsered by Golden Glair productions                   *
	* http://www.goldenglair.com                                               *
	\**************************************************************************/
/* $Id: hook_home.inc.php,v 1.7.2.1 2004/09/04 09:57:45 dawnlinux Exp $ */
$showevents = (int) $GLOBALS['phpgw_info']['user']['preferences']['news_admin']['homeShowLatest'];
if ($showevents > 0) {
    $GLOBALS['phpgw']->translation->add_app('news_admin');
    $title = lang('News Admin');
    $portalbox = CreateObject('phpgwapi.listbox', array('title' => $title, 'primary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 'tertiary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 'width' => '100%', 'outerborderwidth' => '0', 'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/default', 'bg_filler')));
    $latestcount = (int) $GLOBALS['phpgw_info']['user']['preferences']['news_admin']['homeShowLatestCount'];
    if ($latestcount <= 0) {
        $latestcount = 10;
    }
    print_debug("showing {$latestcount} news items");
    $app_id = $GLOBALS['phpgw']->applications->name2id('news_admin');
    $GLOBALS['portal_order'][] = $app_id;
    $news = CreateObject('news_admin.uinews');
    $newslist = $news->bo->get_newslist('all', 0, '', '', $latestcount, True);
    $image_path = $GLOBALS['phpgw']->common->get_image_path('news_admin');
    if (is_array($newslist)) {
        foreach ($newslist as $newsitem) {
            $text = $newsitem['subject'];
            if ($showevents == 1) {
                $text .= ' - ' . lang('Submitted by') . ' ' . $GLOBALS['phpgw']->common->grab_owner_name($newsitem['submittedby']) . ' ' . lang('on') . ' ' . $GLOBALS['phpgw']->common->show_date($newsitem['date']);
            }
            $portalbox->data[] = array('text' => $text, 'link' => $GLOBALS['phpgw']->link('/index.php', 'menuaction=news_admin.uinews.read_news&news_id=' . $newsitem['id']));
        }
        unset($text);
    } else {