コード例 #1
0
ファイル: bits.inc.php プロジェクト: samyscoub/librenms
        }
    }
    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
$units = 'b';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = '8';
$colours_out = 'blues';
// $nototal = 1;
コード例 #2
0
ファイル: rrdtool.inc.php プロジェクト: kelixin/librenms
/**
 * Escapes strings for RRDtool,
 *
 * @return string
 *
 * @param string string to escape
 * @param integer if passed, string will be padded and trimmed to exactly this length (after rrdtool unescapes it)
 */
function rrdtool_escape($string, $maxlength = null)
{
    $result = shorten_interface_type($string);
    $result = str_replace('%', '%%', $result);
    if (is_numeric($maxlength)) {
        $extra = substr_count($string, ':', 0, $maxlength);
        $result = substr(str_pad($result, $maxlength), 0, $maxlength + $extra);
        if ($extra > 0) {
            $result = substr($result, 0, -1 * $extra);
        }
    }
    $result = str_replace(':', '\\:', $result);
    return $result . ' ';
}
コード例 #3
0
ファイル: top-interfaces.inc.php プロジェクト: awlx/librenms
            LIMIT :count
            ';
    }
    $common_output[] = '
<h4>Top ' . $interface_count . ' interfaces polled within ' . $interval . ' minutes</h4>
<div class="table-responsive">
<table class="table table-hover table-condensed table-striped bootgrid-table">
  <thead>
    <tr>
      <th class="text-left">Device</th>
      <th class="text-left">Interface</th>
      <th class="text-left">Total traffic</a></th>
   </tr>
  </thead>
  <tbody>
    ';
    foreach (dbFetchRows($query, $params) as $result) {
        $common_output[] = '
    <tr>
      <td class="text-left">' . generate_device_link($result, shorthost($result['hostname'])) . '</td>
      <td class="text-left">' . generate_port_link($result, shorten_interface_type($result['ifName'])) . '</td>
      <td class="text-left">' . generate_port_link($result, generate_port_thumbnail($result)) . '</td>
    </tr>
        ';
    }
    $common_output[] = '
  </tbody>
</table>
</div>
    ';
}
コード例 #4
0
ファイル: print-map.inc.php プロジェクト: n-st/librenms
    if ($link_in_used > $link_out_used) {
        $link_used = $link_in_used;
    } else {
        $link_used = $link_out_used;
    }
    $link_used = round($link_used, -1);
    if ($link_used > 100) {
        $link_used = 100;
    }
    $link_color = $config['network_map_legend'][$link_used];
    $id1 = $items['local_port_id'] . ':' . $items['remote_port_id'];
    $id2 = $items['remote_port_id'] . ':' . $items['local_port_id'];
    if (!in_array($id1, $tmp_link_ids) || !in_array($id2, $tmp_link_ids)) {
        $local_port = ifNameDescr($local_port);
        $remote_port = ifNameDescr($remote_port);
        $tmp_links[] = array('from' => $items['local_device_id'], 'to' => $items['remote_device_id'], 'label' => shorten_interface_type($local_port['ifName']) . ' > ' . shorten_interface_type($remote_port['ifName']), 'title' => generate_port_link($local_port, "<img src='graph.php?type=port_bits&amp;id=" . $items['local_port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=20&amp;legend=no&amp;bg=" . str_replace("#", "", $row_colour) . "'>\n", '', 0, 1), 'width' => $width, 'color' => $link_color);
    }
    array_push($tmp_link_ids, $id1);
    array_push($tmp_link_ids, $id2);
}
$node_devices = $tmp_devices;
$nodes = json_encode($node_devices);
$edges = json_encode($tmp_links);
if (count($node_devices) > 1 && count($tmp_links) > 0) {
    ?>
 
<div id="visualization"></div>
<script src="js/vis.min.js"></script>
<script type="text/javascript">
var height = $(window).height() - 100;
$('#visualization').height(height + 'px');
コード例 #5
0
ファイル: sensor.inc.php プロジェクト: greggcz/librenms
                    // Critical
                    $state_style = "class='label label-danger'";
                    break;
                case 3:
                    // Unknown
                // Unknown
                default:
                    $state_style = "class='label label-default'";
                    break;
            }
            echo '<tr>
                <td class="col-md-4">' . overlib_link($link, shorten_interface_type($sensor['sensor_descr']), $overlib_content, $sensor_class) . '</td>
                <td class="col-md-4">' . overlib_link($link, $sensor_minigraph, $overlib_content, $sensor_class) . '</td>
                <td class="col-md-4">' . overlib_link($link, '<span ' . $state_style . '>' . $state_translation['0']['state_descr'] . '</span>', $overlib_content, $sensor_class) . '</td>
                </tr>';
        } else {
            echo '<tr>
                <td class="col-md-4">' . overlib_link($link, shorten_interface_type($sensor['sensor_descr']), $overlib_content, $sensor_class) . '</td>
                <td class="col-md-4">' . overlib_link($link, $sensor_minigraph, $overlib_content, $sensor_class) . '</td>
                <td class="col-md-4">' . overlib_link($link, '<span ' . ($sensor['sensor_current'] < $sensor['sensor_limit_low'] || $sensor['sensor_current'] > $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . '</span>', $overlib_content, $sensor_class) . '</td>
                </tr>';
        }
    }
    //end foreach
    echo '</table>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
}
//end if
コード例 #6
0
ファイル: rrdtool.inc.php プロジェクト: nguillaumin/librenms
/**
 * Escapes strings for RRDtool,
 *
 * @return string
 *
 * @param string string to escape
 * @param integer if passed, string will be padded and trimmed to exactly this length (after rrdtool unescapes it)
 */
function rrdtool_escape($string, $maxlength = null)
{
    $result = shorten_interface_type($string);
    $result = str_replace("'", '', $result);
    # remove quotes
    $result = str_replace('%', '%%', $result);
    # double percent signs
    if (is_numeric($maxlength)) {
        $extra = substr_count($string, ':', 0, $maxlength);
        $result = substr(str_pad($result, $maxlength), 0, $maxlength + $extra);
        if ($extra > 0) {
            $result = substr($result, 0, -1 * $extra);
        }
    }
    $result = str_replace(':', '\\:', $result);
    # escape colons
    return $result . ' ';
}
コード例 #7
0
ファイル: print-map.inc.php プロジェクト: REAP720801/librenms
}
$tmp_ids = implode(',', $tmp_ids);
$nodes = json_encode($tmp_devices);
if (is_array($tmp_devices[0])) {
    $tmp_links = array();
    foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ({$tmp_ids}) AND `remote_device_id` IN ({$tmp_ids}))") as $link_devices) {
        $port = '';
        foreach ($tmp_devices as $k => $v) {
            if ($v['id'] == $link_devices['local_device_id']) {
                $from = $v['id'];
                $port = shorten_interface_type($link_devices['ifName']);
                $port_data = $link_devices;
            }
            if ($v['id'] == $link_devices['remote_device_id']) {
                $to = $v['id'];
                $port .= ' > ' . shorten_interface_type($link_devices['remote_port']);
            }
        }
        $speed = $link_devices['ifSpeed'] / 1000 / 1000;
        if ($speed == 100) {
            $width = 3;
        } elseif ($speed == 1000) {
            $width = 5;
        } elseif ($speed == 10000) {
            $width = 10;
        } elseif ($speed == 40000) {
            $width = 15;
        } elseif ($speed == 100000) {
            $width = 20;
        } else {
            $width = 1;
コード例 #8
0
ファイル: sensor.inc.php プロジェクト: n-st/librenms
        $link_array = $graph_array;
        $link_array['page'] = 'graphs';
        unset($link_array['height'], $link_array['width'], $link_array['legend']);
        $link = generate_url($link_array);
        $overlib_content = '<div style="width: 580px;"><h2>' . $device['hostname'] . ' - ' . $sensor['sensor_descr'] . '</h1>';
        foreach (array('day', 'week', 'month', 'year') as $period) {
            $graph_array['from'] = $config['time'][$period];
            $overlib_content .= str_replace('"', "\\'", generate_graph_tag($graph_array));
        }
        $overlib_content .= '</div>';
        $graph_array['width'] = 80;
        $graph_array['height'] = 20;
        $graph_array['bg'] = 'ffffff00';
        // the 00 at the end makes the area transparent.
        $graph_array['from'] = $config['time']['day'];
        $sensor_minigraph = generate_lazy_graph_tag($graph_array);
        $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, '');
        echo '<tr>
            <td><strong>' . overlib_link($link, shorten_interface_type($sensor['sensor_descr']), $overlib_content) . '</strong></td>
            <td>' . overlib_link($link, $sensor_minigraph, $overlib_content) . '</td>
            <td>' . overlib_link($link, '<span ' . ($sensor['sensor_current'] < $sensor['sensor_limit_low'] || $sensor['sensor_current'] > $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . '</span>', $overlib_content) . '</td>
            </tr>';
    }
    //end foreach
    echo '</table>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
}
//end if