Example #1
0
  function setUsername($username)
	{
	  $userObj = object('user');
	  
	  $userObj->isNewUser = $this->ds['u_entity'] == 0;
	  $userObj->server = new HubbubServer(cfg('service/server'), true);
		$userObj->loadEntity();
		
		$userObj->entityDS['user'] = safename($username);
		$userObj->entityDS['url'] = getDefault($userObj->entityDS['url'], cfg('service/server').'/'.(cfg('service/url_rewrite') ? '' : '?').$username);
		$userObj->entityDS['_local'] = 'Y';
		$userObj->entityDS['_serverkey'] = $userObj->server->ds['s_key'];
		$userObj->entityDS['server'] = cfg('service/server');
		
		if(trim($userObj->entityDS['user']) != '') $ekey = DB_UpdateDataset('entities', $userObj->entityDS);
		$userObj->ds['u_entity'] = $ekey;
		
		if(trim($userObj->ds['u_name']) != '') DB_UpdateDataset('users', $userObj->ds);
    if($userObj->isNewUser) h2_execute_event('user_new', $userObj->entityDS, $userObj->ds);
	}
/**
 * Returns icon tag (by default) or icon name for current device array
 *
 * @param array $device Array with device info (from DB)
 * @param bool $base_icon Return complete img tag with icon (by default) or just base icon name
 *
 * @return string Img tag with icon or base icon name
 */
function get_device_icon($device, $base_icon = FALSE)
{
    global $config;
    $icon = 'generic';
    $device['os'] = strtolower($device['os']);
    if ($device['icon'] && is_file($config['html_dir'] . '/images/os/' . $device['icon'] . '.png')) {
        // Custom device icon from DB
        $icon = $device['icon'];
    } else {
        if ($config['os'][$device['os']]['icon'] && is_file($config['html_dir'] . '/images/os/' . $config['os'][$device['os']]['icon'] . '.png')) {
            // Icon defined in os definition
            $icon = $config['os'][$device['os']]['icon'];
        } else {
            if ($device['distro']) {
                // Icon by distro name
                $distro = safename(strtolower(trim($device['distro'])));
                if (is_file($config['html_dir'] . '/images/os/' . $distro . '.png')) {
                    $icon = $distro;
                }
            }
            if ($icon == 'generic' && is_file($config['html_dir'] . '/images/os/' . $device['os'] . '.png')) {
                // Icon by OS name
                $icon = $device['os'];
            }
        }
    }
    if ($icon == 'generic' && $config['os'][$device['os']]['vendor']) {
        // Icon by vendor name
        $vendor = safename(strtolower(trim($config['os'][$device['os']]['vendor'])));
        if (is_file($config['html_dir'] . '/images/os/' . $vendor . '.png')) {
            $icon = $vendor;
        }
    }
    if ($base_icon) {
        return $icon;
    } else {
        // Image tag
        $image = '<img src="' . $config['base_url'] . '/images/os/' . $icon . '.png" alt="" />';
        return $image;
    }
}
Example #3
0
function get_rrd_path($device, $filename)
{
    global $config;
    $filename = safename(trim($filename));
    // If filename empty, return base rrd dirname for device (for example in delete_device())
    $rrd_file = trim($config['rrd_dir']) . '/';
    if (strlen($device['hostname'])) {
        $rrd_file .= $device['hostname'] . '/';
    }
    if (strlen($filename) > 0) {
        $ext = pathinfo($filename, PATHINFO_EXTENSION);
        if ($ext != 'rrd') {
            $filename .= '.rrd';
        }
        // Add rrd extension if not already set
        $rrd_file .= safename($filename);
        // Add rrd filename to global array $graph_return
        $GLOBALS['graph_return']['rrds'][] = $rrd_file;
    }
    return $rrd_file;
}
<?php

foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device['device_id'])) as $mempool) {
    echo "Mempool " . $mempool['mempool_descr'] . ": ";
    $mempool_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_type'] . "-" . $mempool['mempool_index'] . ".rrd");
    $file = $config['install_dir'] . "/includes/polling/mempools/" . $mempool['mempool_type'] . ".inc.php";
    if (is_file($file)) {
        include $file;
    } else {
        // Do we need a generic mempool poller?
    }
    if ($mempool['total']) {
        $percent = round($mempool['used'] / $mempool['total'] * 100, 2);
    } else {
        $percent = 0;
    }
    echo $percent . "% ";
    if (!is_file($mempool_rrd)) {
        rrdtool_create($mempool_rrd, "--step 300 DS:used:GAUGE:600:0:U DS:free:GAUGE:600:0:U " . $config['rrd_rra']);
    }
    rrdtool_update($mempool_rrd, "N:" . $mempool['used'] . ":" . $mempool['free']);
    $mempool['state'] = array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'], 'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']);
    if ($config['memcached']['enable']) {
        if ($debug) {
            print_r($mempool['state']);
        }
        $memcache->set('mempool-' . $mempool['mempool_id'] . '-value', $mempool['state']);
    } else {
        dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
    }
    echo "\n";
Example #5
0
}
if (empty($hardware)) {
    $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB');
}
$oids_AP_Name = array('bsnAPName');
$oids_AP_Users = array('bsnApIfNoOfUsers');
foreach ($oids_AP_Name as $oid) {
    $stats = snmpwalk_cache_oid($device, $oid, $stats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
}
foreach ($oids_AP_Users as $oid) {
    $APstats = snmpwalk_cache_oid($device, $oid, $APstats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
}
$numAccessPoints = count($stats);
$numClients = 0;
foreach ($APstats as $key => $value) {
    $numClients += $value['bsnApIfNoOfUsers'];
}
$rrdfile = $host_rrd . '/ciscowlc' . safename('.rrd');
if (!is_file($rrdfile)) {
    rrdtool_create($rrdfile, ' --step 300 DS:NUMAPS:GAUGE:600:0:12500000000 DS:NUMCLIENTS:GAUGE:600:0:12500000000 ' . $config['rrd_rra']);
}
$fields = array('NUMAPS' => $numAccessPoints, 'NUMCLIENTS' => $numClients);
$ret = rrdtool_update($rrdfile, $fields);
// also save the info about how many clients in the same place as the wireless module
$wificlientsrrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('wificlients-radio1.rrd');
if (!is_file($wificlientsrrd)) {
    rrdtool_create($wificlientsrrd, '--step 300 DS:wificlients:GAUGE:600:-273:10000 ' . $config['rrd_rra']);
}
$fields = array('wificlients' => $numClients);
rrdtool_update($wificlientsrrd, $fields);
$graphs['wifi_clients'] = true;
<?php

$rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cbgp-' . $data['bgpPeerIdentifier'] . '.ipv6.vpn.rrd');
require 'includes/graphs/bgp/prefixes.inc.php';
Example #7
0
function get_sensor_rrd($device, $sensor)
{
    global $config;
    # For IPMI, sensors tend to change order, and there is no index, so we prefer to use the description as key here.
    if ($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi") {
        $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sensor-" . $sensor['sensor_class'] . "-" . $sensor['sensor_type'] . "-" . $sensor['sensor_descr'] . ".rrd");
    } else {
        $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sensor-" . $sensor['sensor_class'] . "-" . $sensor['sensor_type'] . "-" . $sensor['sensor_index'] . ".rrd");
    }
    return $rrd_file;
}
 $interference = $aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.3.1.6.1.11.{$radioid}"][''] + 0;
 $radionum = substr($radioid, strlen($radioid) - 1, 1);
 if ($debug) {
     echo "* radioid: {$radioid}\n";
     echo "  radionum: {$radionum}\n";
     echo "  name: {$name}\n";
     echo "  type: {$type}\n";
     echo "  channel: {$channel}\n";
     echo "  txpow: {$txpow}\n";
     echo "  radioutil: {$radioutil}\n";
     echo "  numasoclients: {$numasoclients}\n";
     echo "  interference: {$interference}\n";
 }
 // if there is a numeric channel, assume the rest of the data is valid, I guess
 if (is_numeric($channel)) {
     $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename("arubaap-{$name}.{$radionum}.rrd");
     if (!is_file($rrd_file)) {
         $dslist = 'DS:channel:GAUGE:600:0:200 ';
         $dslist .= 'DS:txpow:GAUGE:600:0:200 ';
         $dslist .= 'DS:radioutil:GAUGE:600:0:100 ';
         $dslist .= 'DS:nummonclients:GAUGE:600:0:500 ';
         $dslist .= 'DS:nummonbssid:GAUGE:600:0:200 ';
         $dslist .= 'DS:numasoclients:GAUGE:600:0:500 ';
         $dslist .= 'DS:interference:GAUGE:600:0:2000 ';
         rrdtool_create($rrd_file, "--step 300 {$dslist} " . $config['rrd_rra']);
     }
     $fields = array('channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'nummonclients' => $nummonclients, 'nummonbssid' => $nummonbssid, 'numasoclients' => $numasoclients, 'interference' => $interference);
     rrdtool_update($rrd_file, $fields);
 }
 // generate the mac address
 $macparts = explode('.', $radioid, -1);
Example #9
0
<?php

$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . "-adsl.rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Downstream";
$rrd_list[0]['ds'] = "AturChanCurrTxRate";
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = "Upstream";
$rrd_list[1]['ds'] = "AtucChanCurrTxRate";
$unit_text = "Bits/sec";
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list) {
    include "includes/graphs/generic_multi_line.inc.php";
}
Example #10
0
<?php

$i = 1;
foreach (dbFetchRows('SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id', array($device['device_id'])) as $disk) {
    $rrd_filename = $config['rrd_dir'] . '/' . $disk['hostname'] . '/ucd_diskio-' . safename($disk['diskio_descr'] . '.rrd');
    if (is_file($rrd_filename)) {
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $disk['diskio_descr'];
        $rrd_list[$i]['ds_in'] = $ds_in;
        $rrd_list[$i]['ds_out'] = $ds_out;
        $i++;
    }
}
<?php

require 'includes/graphs/common.inc.php';
$rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('ib_dns_performance.rrd');
$rrd_options .= " --vertical-label='Answer time in milliseconds'";
$rrd_options .= " --lower-limit='0'";
$stats = array('PerfAA' => '#74C366FF', 'PerfnonAA' => '#007283FF');
$i = 0;
foreach ($stats as $stat => $color) {
    $i++;
    $rrd_list[$i]['filename'] = $rrd_filename;
    $rrd_list[$i]['descr'] = ucfirst($stat);
    $rrd_list[$i]['ds'] = $stat;
    # Set up DEFs
    $rrd_options .= " DEF:" . $stat . "=" . $rrd_filename . ':' . $stat . ':AVERAGE ';
    # Set up area graphing with stacking
    if ($i == "0") {
        $rrd_options .= " 'AREA:" . $stat . $color . ":" . $stat . "'";
    } else {
        $rrd_options .= " 'AREA:" . $stat . $color . ":" . $stat . ":STACK'";
    }
    # Set up legend, with consistent indent
    $filler = 15 - strlen($stat);
    $current_pad = str_pad("", $filler, ' ', STR_PAD_LEFT);
    $rrd_options .= " 'GPRINT:" . $stat . ":LAST: " . $current_pad . "Current\\:%8.0lf'";
    $rrd_options .= " 'GPRINT:" . $stat . ":AVERAGE:Average\\:%8.0lf'";
    $rrd_options .= " 'GPRINT:" . $stat . ":MAX:Maximum\\:%8.0lf\\n'";
}
# Add total value
$rrd_options .= " 'CDEF:cdeftotal=PerfAA,PerfnonAA,+'";
$rrd_options .= " 'LINE1:cdeftotal#000000FF:Total'";
Example #12
0
<?php

$cpe_oids = array('cpeExtPsePortEnable', 'cpeExtPsePortDiscoverMode', 'cpeExtPsePortDeviceDetected', 'cpeExtPsePortIeeePd', 'cpeExtPsePortAdditionalStatus', 'cpeExtPsePortPwrMax', 'cpeExtPsePortPwrAllocated', 'cpeExtPsePortPwrAvailable', 'cpeExtPsePortPwrConsumption', 'cpeExtPsePortMaxPwrDrawn', 'cpeExtPsePortEntPhyIndex', 'cpeExtPsePortEntPhyIndex', 'cpeExtPsePortPolicingCapable', 'cpeExtPsePortPolicingEnable', 'cpeExtPsePortPolicingAction', 'cpeExtPsePortPwrManAlloc');
$peth_oids = array('pethPsePortAdminEnable', 'pethPsePortPowerPairsControlAbility', 'pethPsePortPowerPairs', 'pethPsePortDetectionStatus', 'pethPsePortPowerPriority', 'pethPsePortMPSAbsentCounter', 'pethPsePortType', 'pethPsePortPowerClassifications', 'pethPsePortInvalidSignatureCounter', 'pethPsePortPowerDeniedCounter', 'pethPsePortOverLoadCounter', 'pethPsePortShortCounter', 'pethMainPseConsumptionPower');
$port_stats = snmpwalk_cache_oid($device, 'pethPsePortEntry', $port_stats, 'POWER-ETHERNET-MIB');
$port_stats = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', $port_stats, 'CISCO-POWER-ETHERNET-EXT-MIB');
if ($port_stats[$port['ifIndex']] && $port['ifType'] == 'ethernetCsmacd' && isset($port_stats[$port['ifIndex']]['dot3StatsIndex'])) {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    $rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('port-' . $port['ifIndex'] . '-poe.rrd');
    if (!file_exists($rrdfile)) {
        $rrd_create .= $config['rrd_rra'];
        // FIXME CISCOSPECIFIC
        $rrd_create .= ' DS:PortPwrAllocated:GAUGE:600:0:U';
        $rrd_create .= ' DS:PortPwrAvailable:GAUGE:600:0:U';
        $rrd_create .= ' DS:PortConsumption:DERIVE:600:0:U';
        $rrd_create .= ' DS:PortMaxPwrDrawn:GAUGE:600:0:U ';
        rrdtool_create($rrdfile, $rrd_create);
    }
    $upd = "{$polled}:" . $port['cpeExtPsePortPwrAllocated'] . ':' . $port['cpeExtPsePortPwrAvailable'] . ':' . $port['cpeExtPsePortPwrConsumption'] . ':' . $port['cpeExtPsePortMaxPwrDrawn'];
    $ret = rrdtool_update("{$rrdfile}", $upd);
    echo 'PoE ';
}
//end if
Example #13
0
 foreach ($cefs as $entity => $afis) {
     $entity_name = $entity_array[$entity]['entPhysicalName'] . ' - ' . $entity_array[$entity]['entPhysicalModelName'];
     echo "\n{$entity} {$entity_name}\n";
     foreach ($afis as $afi => $paths) {
         echo " |- {$afi}\n";
         foreach ($paths as $path => $cef_stat) {
             echo ' | |-' . $path . ': ' . $cef_stat['cefSwitchingPath'];
             $cef_id = $device['device_id'] . '-' . $entity . '-' . $afi . '-' . $path;
             // if (dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1")
             if (!isset($cefs_db[$cef_id])) {
                 dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $path, 'cef_path' => $cef_stat['cefSwitchingPath']), 'cef_switching');
                 echo '+';
             }
             unset($cefs_db[$cef_id]);
             $cef_entry = dbFetchRow('SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path));
             $filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cefswitching-' . $entity . '-' . $afi . '-' . $path . '.rrd');
             if (!is_file($filename)) {
                 rrdtool_create($filename, '--step 300 
                     DS:drop:DERIVE:600:0:1000000 
                     DS:punt:DERIVE:600:0:1000000 
                     DS:hostpunt:DERIVE:600:0:1000000 ' . $config['rrd_rra']);
             }
             // Copy HC to non-HC if they exist
             if (is_numeric($cef_stat['cefSwitchingHCDrop'])) {
                 $cef_stat['cefSwitchingDrop'] = $cef_stat['cefSwitchingHCDrop'];
             }
             if (is_numeric($cef_stat['cefSwitchingHCPunt'])) {
                 $cef_stat['cefSwitchingPunt'] = $cef_stat['cefSwitchingHCPunt'];
             }
             if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) {
                 $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host'];
Example #14
0
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if ($device['os_group'] == "cisco") {
    // TODO: Need to test partial PRI.
    // Total
    $total = 0;
    foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.2.1.2.2.1.3", NULL) as $key => $value) {
        // 81 is the ifType for DS0's
        if ($value[''] == "81") {
            $total++;
        }
    }
    // Active
    $active = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.10.19.1.1.4.0", NULL);
    $active = $active['1.3.6.1.4.1.9.10.19.1.1.4.0'][''];
    if (isset($active) && $active != "" && $total != 0) {
        $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cisco-iospri.rrd");
        if (!file_exists($rrd_filename)) {
            rrdtool_create($rrd_filename, " DS:total:GAUGE:600:0:U DS:active:GAUGE:600:0:U" . $config['rrd_rra']);
        }
        $fields = array('total' => $total, 'active' => $active);
        rrdtool_update($rrd_filename, $fields);
        $tags = array();
        influx_update($device, 'cisco-iospri', $tags, $fields);
        $graphs['cisco-iospri'] = TRUE;
        echo " Cisco IOS PRI ";
    }
    unset($rrd_filename, $total, $active);
}
Example #15
0
<?php

$scale_min = "0";
include "common.inc.php";
$rrd_options .= " COMMENT:'                                 Last   Max\\n'";
$voltage = mysql_fetch_array(mysql_query("SELECT * FROM voltage where volt_id = '" . mres($_GET['id']) . "'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $voltage['device_id'] . "'"), 0);
$voltage['volt_descr_fixed'] = substr(str_pad($voltage['volt_descr'], 28), 0, 28);
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . safename("volt-" . $voltage['volt_descr'] . ".rrd");
$rrd_options .= " DEF:volt={$rrd_filename}:volt:AVERAGE";
$rrd_options .= " AREA:volt#FFFF99";
$rrd_options .= " LINE1.5:volt#cc0000:'" . $voltage['volt_descr_fixed'] . "'";
$rrd_options .= " GPRINT:volt:LAST:%3.0lfV";
$rrd_options .= " GPRINT:volt:MAX:%3.0lfV\\\\l";
Example #16
0
<?php

$i = 0;
foreach (explode(",", $vars['id']) as $ifid) {
    $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
    if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) {
        $port = ifLabel($port);
        $rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
        $rrd_list[$i]['descr'] = $port['hostname'] . " " . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = $port['hostname'];
        $rrd_list[$i]['descr_out'] = makeshortif($port['label']);
        $i++;
    }
}
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
$ds_in = "INOCTETS";
$ds_out = "OUTOCTETS";
include "includes/graphs/generic_multi_bits_separated.inc.php";
     foreach (array('input', 'output') as $dir) {
         $oid_dir = $oid . '_' . $dir;
         $acc['update'][$oid_dir] = $this_ma[$oid][$dir];
         $acc['update'][$oid_dir . '_prev'] = $acc[$oid_dir];
         $oid_prev = $oid_dir . '_prev';
         if ($this_ma[$oid][$dir]) {
             $oid_diff = $this_ma[$oid][$dir] - $acc[$oid_dir];
             $oid_rate = $oid_diff / $polled_period;
             $acc['update'][$oid_dir . '_rate'] = $oid_rate;
             $acc['update'][$oid_dir . '_delta'] = $oid_diff;
             d_echo("\n {$oid_dir} ({$oid_diff} B) {$oid_rate} Bps {$polled_period} secs\n");
         }
     }
 }
 d_echo("\n" . $acc['hostname'] . ' ' . $acc['ifDescr'] . "  {$mac} -> {$b_in}:{$b_out}:{$p_in}:{$p_out} ");
 $rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cip-' . $acc['ifIndex'] . '-' . $acc['mac'] . '.rrd');
 if (!is_file($rrdfile)) {
     rrdtool_create($rrdfile, 'DS:IN:COUNTER:600:0:12500000000 
         DS:OUT:COUNTER:600:0:12500000000 
         DS:PIN:COUNTER:600:0:12500000000 
         DS:POUT:COUNTER:600:0:12500000000 ' . $config['rrd_rra']);
 }
 // FIXME - use memcached to make sure these values don't go backwards?
 $fields = array('IN' => $b_in, 'OUT' => $b_out, 'PIN' => $p_in, 'POUT' => $p_out);
 rrdtool_update($rrdfile, $fields);
 $tags = array('ifIndex' => $acc['ifIndex'], 'mac' => $acc['mac']);
 influx_update($device, 'cip', $tags, $fields);
 if ($acc['update']) {
     // Do Updates
     dbUpdate($acc['update'], 'mac_accounting', '`ma_id` = ?', array($acc['ma_id']));
 }
Example #18
0
     if ($device['os'] == "engenius" && empty($entry['hrDeviceDescr'])) {
         $descr = "Processor";
     }
     // Workaround to set fake description for Ubiquiti EdgeOS who don't populate hrDeviceDescr
     if ($device['os'] == "edgeos" && empty($entry['hrDeviceDescr'])) {
         $descr = "Processor";
     }
     // Workaround to set fake description for Windows who use Unknown Processor Type
     if ($device['os'] == "windows" && $entry['hrDeviceDescr'] == "Unknown Processor Type") {
         $descr = "Processor";
     }
     $descr = str_replace("CPU ", "", $descr);
     $descr = str_replace("(TM)", "", $descr);
     $descr = str_replace("(R)", "", $descr);
     $old_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("hrProcessor-" . $index . ".rrd");
     $new_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-hr-" . $index . ".rrd");
     if ($debug) {
         echo "{$old_rrd} {$new_rrd}";
     }
     if (is_file($old_rrd)) {
         rename($old_rrd, $new_rrd);
         echo "Moved RRD ";
     }
     if ($device['os'] == "arista-eos" && $index == "1") {
         unset($descr);
     }
     if (isset($descr) && $descr != "An electronic chip that makes the computer work.") {
         discover_processor($valid['processor'], $device, $usage_oid, $index, "hr", $descr, "1", $usage, NULL, $hrDeviceIndex);
     }
     unset($old_rrd, $new_rrd, $descr, $entry, $usage_oid, $index, $usage, $hrDeviceIndex, $descr_array);
 }
Example #19
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;
}
<?php

$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbgp-" . $data['bgpPeerRemoteAddr'] . ".ipv4.unicast.rrd");
include "includes/graphs/bgp/prefixes.inc.php";
Example #21
0
function rrd_name($host, $extra, $exten = ".rrd")
{
    global $config;
    $filename = safename(is_array($extra) ? implode("-", $extra) : $extra);
    return implode("/", array($config['rrd_dir'], $host, $filename . $exten));
}
Example #22
0
<?php

if (is_numeric($vars['id'])) {
    // $auth= TRUE;
    $rserver = dbFetchRow('SELECT * FROM `loadbalancer_rservers` AS I, `devices` AS D WHERE I.rserver_id = ? AND I.device_id = D.device_id', array($vars['id']));
    if (is_numeric($rserver['device_id']) && ($auth || device_permitted($rserver['device_id']))) {
        $device = device_by_id_cache($rserver['device_id']);
        $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('rserver-' . $rserver['rserver_id'] . '.rrd');
        $title = generate_device_link($device);
        $title .= ' :: Rserver :: ' . htmlentities($rserver['farm_id']);
        $auth = true;
    }
}
Example #23
0
function get_port_rrdfile_path($hostname, $port_id, $suffix = '')
{
    global $config;
    if (!empty($suffix)) {
        $suffix = '-' . $suffix;
    }
    return trim($config['rrd_dir']) . '/' . safename($hostname) . '/' . 'port-id' . safename($port_id) . safename($suffix) . '.rrd';
}
Example #24
0
    foreach ($components as $id => $array) {
        if ($array['qos-type'] == 1 && $array['ifindex'] == $port['ifIndex'] && $array['parent'] == 0) {
            // Found the first policy
            $vars['policy'] = $id;
            continue;
        }
    }
}
include "includes/graphs/common.inc.php";
$rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'Class-Map              Now      Avg      Max\\n'";
$rrd_additions = "";
$count = 0;
foreach ($components as $id => $array) {
    if ($array['qos-type'] == 2 && $array['parent'] == $components[$vars['policy']]['sp-obj'] && $array['sp-id'] == $components[$vars['policy']]['sp-id']) {
        $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename("port-" . $array['ifindex'] . "-cbqos-" . $array['sp-id'] . "-" . $array['sp-obj'] . ".rrd");
        if (file_exists($rrd_filename)) {
            // Stack the area on the second and subsequent DS's
            $stack = "";
            if ($count != 0) {
                $stack = ":STACK ";
            }
            // Grab a color from the array.
            if (isset($config['graph_colours']['mixed'][$count])) {
                $color = $config['graph_colours']['mixed'][$count];
            } else {
                $color = $config['graph_colours']['oranges'][$count - 7];
            }
            $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":qosdrops:AVERAGE ";
            $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* ";
            $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'], 0, 15), 15) . "'" . $stack;
<?php

$file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("screenos_sessions.rrd");
$rrd_list[0]['filename'] = $file;
$rrd_list[0]['descr'] = "Maximum";
$rrd_list[0]['ds'] = "max";
$rrd_list[1]['filename'] = $file;
$rrd_list[1]['descr'] = "Allocated";
$rrd_list[1]['ds'] = "allocate";
$rrd_list[2]['filename'] = $file;
$rrd_list[2]['descr'] = "Failed";
$rrd_list[2]['ds'] = "failed";
if ($_GET['debug']) {
    print_vars($rrd_list);
}
$colours = "mixed";
$nototal = 1;
$unit_text = "Sessions";
$scale_min = "0";
include "includes/graphs/generic_multi_line.inc.php";
Example #26
0
<?php

$i = 0;
foreach (explode(',', $vars['id']) as $ifid) {
    $port = dbFetchRow('SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
    if (is_file($config['rrd_dir'] . '/' . $port['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd'))) {
        $port = ifLabel($port);
        $rrd_list[$i]['filename'] = $config['rrd_dir'] . '/' . $port['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd');
        $rrd_list[$i]['descr'] = $port['hostname'] . ' ' . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = $port['hostname'];
        $rrd_list[$i]['descr_out'] = makeshortif($port['label']);
        $i++;
    }
}
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = '8';
$colours_out = 'blues';
$nototal = 1;
$ds_in = 'INOCTETS';
$ds_out = 'OUTOCTETS';
require 'includes/graphs/generic_multi_bits_separated.inc.php';
Example #27
0
             unset($j_bgp);
             unset($j_peerIndexes);
         }
         //end if
         // FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
         $update = 'UPDATE bgpPeers_cbgp SET';
         $peer['c_update']['AcceptedPrefixes'] = $cbgpPeerAcceptedPrefixes;
         $peer['c_update']['DeniedPrefixes'] = $cbgpPeerDeniedPrefixes;
         $peer['c_update']['PrefixAdminLimit'] = $cbgpPeerAdminLimit;
         $peer['c_update']['PrefixThreshold'] = $cbgpPeerPrefixThreshold;
         $peer['c_update']['PrefixClearThreshold'] = $cbgpPeerPrefixClearThreshold;
         $peer['c_update']['AdvertisedPrefixes'] = $cbgpPeerAdvertisedPrefixes;
         $peer['c_update']['SuppressedPrefixes'] = $cbgpPeerSuppressedPrefixes;
         $peer['c_update']['WithdrawnPrefixes'] = $cbgpPeerWithdrawnPrefixes;
         dbUpdate($peer['c_update'], 'bgpPeers_cbgp', '`device_id` = ? AND bgpPeerIdentifier = ? AND afi = ? AND safi = ?', array($device['device_id'], $peer['bgpPeerIdentifier'], $afi, $safi));
         $cbgp_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cbgp-' . $peer['bgpPeerIdentifier'] . ".{$afi}.{$safi}.rrd");
         if (!is_file($cbgp_rrd)) {
             $rrd_create = 'DS:AcceptedPrefixes:GAUGE:600:U:100000000000 
                 DS:DeniedPrefixes:GAUGE:600:U:100000000000 
                 DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 
                 DS:SuppressedPrefixes:GAUGE:600:U:100000000000 
                 DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 ' . $config['rrd_rra'];
             rrdtool_create($cbgp_rrd, $rrd_create);
         }
         $fields = array('AcceptedPrefixes' => $cbgpPeerAcceptedPrefixes, 'DeniedPrefixes' => $cbgpPeerDeniedPrefixes, 'AdvertisedPrefixes' => $cbgpPeerAdvertisedPrefixes, 'SuppressedPrefixes' => $cbgpPeerSuppressedPrefixes, 'WithdrawnPrefixes' => $cbgpPeerWithdrawnPrefixes);
         rrdtool_update("{$cbgp_rrd}", $fields);
     }
     //end foreach
 }
 //end if
 echo "\n";
Example #28
0
    $ignore = 0;
    if (is_array($config['device_traffic_iftype'])) {
        foreach ($config['device_traffic_iftype'] as $iftype) {
            if (preg_match($iftype . 'i', $port['ifType'])) {
                $ignore = 1;
            }
        }
    }
    if (is_array($config['device_traffic_descr'])) {
        foreach ($config['device_traffic_descr'] as $ifdescr) {
            if (preg_match($ifdescr . 'i', $port['ifDescr']) || preg_match($ifdescr . 'i', $port['ifName']) || preg_match($ifdescr . 'i', $port['portName'])) {
                $ignore = 1;
            }
        }
    }
    $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd');
    if ($ignore != 1 && is_file($rrd_filename)) {
        $port = ifLabel($port);
        // Fix Labels! ARGH. This needs to be in the bloody database!
        $rrd_filenames[] = $rrd_filename;
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = shorten_interface_type($port['label']);
        $rrd_list[$i]['descr_in'] = $port['label'];
        $rrd_list[$i]['descr_out'] = $port['ifAlias'];
        $rrd_list[$i]['ds_in'] = $ds_in;
        $rrd_list[$i]['ds_out'] = $ds_out;
        $i++;
    }
    unset($ignore);
}
//end foreach
Example #29
0
<?php

$rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename("arubaap-{$ap['name']}.{$ap['radio_number']}.rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Interference';
$rrd_list[0]['ds'] = 'interference';
$unit_text = 'Int';
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = '0';
$nototal = 1;
if ($rrd_list) {
    include 'includes/graphs/generic_multi_line.inc.php';
}
<?php

$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("juniperive_meetings.rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Users";
$rrd_list[0]['ds'] = "meetingusers";
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = "Meetings";
$rrd_list[1]['ds'] = "meetings";
if ($_GET['debug']) {
    print_vars($rrd_list);
}
$colours = "juniperive";
$nototal = 1;
$unit_text = "Meetings";
$scale_min = "0";
include "includes/graphs/generic_multi_line.inc.php";