本文整理汇总了PHP中rrdtool_update函数的典型用法代码示例。如果您正苦于以下问题:PHP rrdtool_update函数的具体用法?PHP rrdtool_update怎么用?PHP rrdtool_update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rrdtool_update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: snmpwalk_cache_oid
} else {
$data = snmpwalk_cache_oid($device, $type, array(), $netstats['mib']);
if (!count($data)) {
continue;
}
$data_array = $data[0];
}
$rrd_file = 'netstats-' . $type . '.rrd';
$rrd_create = '';
$rrd_update = 'N';
foreach ($oids as $oid) {
$oid_ds = truncate($oid, 19, '');
if ($oid == 'tcpCurrEstab') {
$rrd_create .= ' DS:' . $oid_ds . ':GAUGE:600:U:4294967295';
// Gauge32 max value 2^32 = 4294967295
} else {
$rrd_create .= ' DS:' . $oid_ds . ':COUNTER:600:U:4294967295';
// Counter32 max value 2^32 = 4294967295
}
$value = is_numeric($data_array[$oid]) ? $data_array[$oid] : 'U';
$rrd_update .= ':' . $value;
}
rrdtool_create($device, $rrd_file, $rrd_create);
rrdtool_update($device, $rrd_file, $rrd_update);
foreach ($netstats['graphs'] as $graph) {
$graphs[$graph] = TRUE;
}
print_cli_data(nicecase($type) . " Graphs", implode(" ", $netstats['graphs']), 2);
}
unset($netstats_poll, $netstats, $type, $oids, $oid, $oid_ds, $oids_string, $data, $data_array, $rrd_create, $rrd_file, $rrd_update, $value, $mibs_blacklist);
// EOF
示例2: trim
/*
* LibreNMS Pulse Secure OS information module
*
* Copyright (c) 2015 Christophe Martinet Chrisgfx <martinet.christophe@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* 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.
*/
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"), '"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"), '"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"), '"');
$usersrrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/pulse_users.rrd';
$users = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
if (is_numeric($users)) {
if (!is_file($usersrrd)) {
rrdtool_create($usersrrd, ' DS:users:GAUGE:600:0:U' . $config['rrd_rra']);
}
rrdtool_update($usersrrd, "N:{$users}");
$graphs['pulse_users'] = true;
}
$sessrrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/pulse_sessions.rrd';
$sessions = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');
if (is_numeric($sessions)) {
if (!is_file($sessrrd)) {
rrdtool_create($sessrrd, ' DS:sessions:GAUGE:600:0:U ' . $config['rrd_rra']);
}
rrdtool_update($sessrrd, "N:{$sessions}");
$graphs['pulse_sessions'] = true;
}
示例3: array
<?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
示例4: foreach
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";
}
unset($mempool_cache);
示例5: rrd_create_update
function rrd_create_update($device, $name, $def, $val, $step = 300)
{
global $config;
$rrd = rrd_name($device['hostname'], $name);
if (!is_file($rrd) && $def != null) {
// add the --step and the rra definitions to the array
$newdef = "--step {$step} " . implode(' ', $def) . $config['rrd_rra'];
rrdtool_create($rrd, $newdef);
}
rrdtool_update($rrd, $val);
}
示例6: foreach
$group = 'c6kxbar';
foreach ($entry as $key => $value) {
$entPhysical_state[$index][$subindex][$group][$key] = $value;
}
$fields = array('inutil' => $entry['cc6kxbarStatisticsInUtil'], 'oututil' => $entry['cc6kxbarStatisticsOutUtil'], 'outdropped' => $entry['cc6kxbarStatisticsOutDropped'], 'outerrors' => $entry['cc6kxbarStatisticsOutErrors'], 'inerrors' => $entry['cc6kxbarStatisticsInErrors']);
$rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('c6kxbar-' . $index . '-' . $subindex . '.rrd');
d_echo("{$rrd} ");
if (!is_file($rrd)) {
rrdtool_create($rrd, '--step 300
DS:inutil:GAUGE:600:0:100
DS:oututil:GAUGE:600:0:100
DS:outdropped:DERIVE:600:0:125000000000
DS:outerrors:DERIVE:600:0:125000000000
DS:inerrors:DERIVE:600:0:125000000000 ' . $config['rrd_rra']);
}
rrdtool_update($rrd, $fields);
}
//end foreach
// print_r($entPhysical_state);
}
//end if
// Set Entity state
foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', array($device['device_id'])) as $entity) {
if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) {
dbDelete('entPhysical_state', '`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?', array($device['device_id'], $entity['entPhysicalIndex'], $entity['subindex'], $entity['group'], $entity['key']));
} else {
if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) {
echo 'no match!';
}
unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]);
}
示例7: d_echo
$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']));
}
//end if
}
//end if
}
//end foreach
unset($cip_array);
if ($mac_entries) {
echo " {$mac_entries} MAC accounting entries\n";
}
示例8: snmp_get
<?php
if (!empty($agent_data['app']['nginx'])) {
$nginx = $agent_data['app']['nginx'];
} else {
// Polls nginx statistics from script via SNMP
$nginx = snmp_get($device, 'nsExtendOutputFull.5.110.103.105.110.120', '-Ovq', 'NET-SNMP-EXTEND-MIB');
}
$nginx_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/app-nginx-' . $app['app_id'] . '.rrd';
echo ' nginx';
list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
if (!is_file($nginx_rrd)) {
rrdtool_create($nginx_rrd, '--step 300
DS:Requests:DERIVE:600:0:125000000000
DS:Active:GAUGE:600:0:125000000000
DS:Reading:GAUGE:600:0:125000000000
DS:Writing:GAUGE:600:0:125000000000
DS:Waiting:GAUGE:600:0:125000000000 ' . $config['rrd_rra']);
}
d_echo("active: {$active} reading: {$reading} writing: {$writing} waiting: {$waiting} Requests: {$req}");
$fields = array('Requests' => $req, 'Active' => $active, 'Reading' => $reading, 'Writing' => $writing, 'Waiting' => $waiting);
rrdtool_update($nginx_rrd, $fields);
$tags = array('name' => 'nginx', 'app_id' => $app['app_id']);
influx_update($device, 'app', $tags, $fields);
// Unset the variables we set here
unset($nginx);
unset($nginx_rrd);
unset($active);
unset($reading);
unset($writing);
unset($req);
示例9: dbUpdate
// 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";
}
//end foreach
}
//end if
示例10: array
$nfsLabel['proc3'] = array("null", "getattr", "setattr", "lookup", "access", "readlink", "read", "write", "create", "mkdir", "symlink", "mknod", "remove", "rmdir", "rename", "link", "readdir", "readdirplus", "fsstat", "fsinfo", "pathconf", "commit");
$nfsLabel['proc4'] = array("null", "read", "write", "commit", "open", "open_conf", "open_noat", "open_dgrd", "close", "setattr", "fsinfo", "renew", "setclntid", "confirm", "lock", "lockt", "locku", "access", "getattr", "lookup", "lookup_root", "remove", "rename", "link", "symlink", "create", "pathconf", "statfs", "readlink", "readdir", "server_caps", "delegreturn", "getacl", "setacl", "fs_locations", "rel_lkowner", "secinfo", "exchange_id", "create_ses", "destroy_ses", "sequence", "get_lease_t", "reclaim_comp", "layoutget", "getdevinfo", "layoutcommit", "layoutreturn", "getdevlist");
if (!is_file($rrd_filename)) {
$definition = "--step 300 ";
foreach ($nfsLabel as $key => $values) {
foreach ($values as $name) {
$definition .= " DS:" . ($key . $name) . ":DERIVE:600:0:12500000 ";
}
}
rrdtool_create($rrd_filename, $definition . " " . $config['rrd_rra']);
}
$datas = array();
foreach ($nfsLabel as $key => $values) {
foreach ($values as $name) {
$datas[$key . $name] = "U";
}
}
$lines = explode("\n", $agent_data['app']['nfs']);
foreach ($lines as $line) {
$tokens = explode(" ", $line);
if (isset($tokens[0]) && isset($nfsLabel[strtolower($tokens[0])])) {
$base = strtolower($tokens[0]);
array_shift($tokens);
array_shift($tokens);
foreach ($tokens as $k => $v) {
$datas[$base . $nfsLabel[$base][$k]] = $v;
}
}
}
rrdtool_update($rrd_filename, "N:" . implode(':', $datas));
}
示例11: list
list($corrupt, $def_cacheInserts, $def_cacheLookup, $latency, $pc_hit, $pc_miss, $pc_size, $qsize, $qc_hit, $qc_miss, $rec_answers, $rec_questions, $servfail, $tcp_answers, $tcp_queries, $timedout, $udp_answers, $udp_queries, $udp4_answers, $udp4_queries, $udp6_answers, $udp6_queries) = explode("\n", $powerdns);
if (!is_file($rrd_filename)) {
rrdtool_create($rrd_filename, '--step 300
DS:corruptPackets:DERIVE:600:0:125000000000
DS:def_cacheInserts:DERIVE:600:0:125000000000
DS:def_cacheLookup:DERIVE:600:0:125000000000
DS:latency:DERIVE:600:0:125000000000
DS:pc_hit:DERIVE:600:0:125000000000
DS:pc_miss:DERIVE:600:0:125000000000
DS:pc_size:DERIVE:600:0:125000000000
DS:qsize:DERIVE:600:0:125000000000
DS:qc_hit:DERIVE:600:0:125000000000
DS:qc_miss:DERIVE:600:0:125000000000
DS:rec_answers:DERIVE:600:0:125000000000
DS:rec_questions:DERIVE:600:0:125000000000
DS:servfailPackets:DERIVE:600:0:125000000000
DS:q_tcpAnswers:DERIVE:600:0:125000000000
DS:q_tcpQueries:DERIVE:600:0:125000000000
DS:q_timedout:DERIVE:600:0:125000000000
DS:q_udpAnswers:DERIVE:600:0:125000000000
DS:q_udpQueries:DERIVE:600:0:125000000000
DS:q_udp4Answers:DERIVE:600:0:125000000000
DS:q_udp4Queries:DERIVE:600:0:125000000000
DS:q_udp6Answers:DERIVE:600:0:125000000000
DS:q_udp6Queries:DERIVE:600:0:125000000000 ' . $config['rrd_rra']);
}
//end if
$fields = array('corruptPackets' => $corrupt, 'def_cacheInserts' => $def_cacheInserts, 'def_cacheLookup' => $def_cacheLookup, 'latency' => $latency, 'pc_hit' => $pc_hit, 'pc_miss' => $pc_miss, 'pc_size' => $pc_size, 'qsize' => $qsize, 'qc_hit' => $qc_hit, 'qc_miss' => $qc_miss, 'rec_answers' => $rec_answers, 'rec_questions' => $rec_questions, 'servfailPackets' => $servfail, 'q_tcpAnswers' => $tcp_answers, 'q_tcpQueries' => $tcp_queries, 'q_timedout' => $timedout, 'q_udpAnswers' => $udp_answers, 'q_udpQueries' => $udp_queries, 'q_udp4Answers' => $udp4_answers, 'q_udp4Queries' => $udp4_queries, 'q_udp6Answers' => $udp6_answers, 'q_udp6Queries' => $udp6_queries);
rrdtool_update($rrd_filename, $fields);
$tags = array('name' => 'powerdns', 'app_id' => $app['app_id']);
influx_update($device, 'app', $tags, $fields);
示例12: unset
if ($ciscomodel) {
$hardware = $ciscomodel;
unset($ciscomodel);
}
$cpu5m = shell_exec($config['snmpget'] . " -m OLD-CISCO-CPU-MIB -O qv -{$snmpver} -c {$community} {$hostname}:{$port} avgBusy5.0");
$cpu5m = $cpu5m + 0;
echo "{$hostname}\n";
if (!is_file($cpurrd)) {
$rrdcreate = shell_exec($config['rrdtool'] . " create {$cpurrd} --step 300 \\\n DS:LOAD5M:GAUGE:600:-1:100 \\\n RRA:AVERAGE:0.5:1:2000 \\\n RRA:AVERAGE:0.5:6:2000 \\\n RRA:AVERAGE:0.5:24:2000 \\\n RRA:AVERAGE:0.5:288:2000 \\\n RRA:MAX:0.5:1:2000 \\\n RRA:MAX:0.5:6:2000 \\\n RRA:MAX:0.5:24:2000 \\\n RRA:MAX:0.5:288:2000 \\\n RRA:MIN:0.5:1:2000 \\\n RRA:MIN:0.5:6:2000 \\\n RRA:MIN:0.5:24:2000 \\\n RRA:MIN:0.5:288:2000");
}
shell_exec($config['rrdtool'] . " update {$cpurrd} N:{$cpu5m}");
$mem_get = ".1.3.6.1.4.1.9.9.48.1.1.1.6.2 .1.3.6.1.4.1.9.9.48.1.1.1.6.1 .1.3.6.1.4.1.9.9.48.1.1.1.6.3";
$mem_get .= ".1.3.6.1.4.1.9.9.48.1.1.1.5.2 .1.3.6.1.4.1.9.9.48.1.1.1.5.1 .1.3.6.1.4.1.9.9.48.1.1.1.5.3";
$mem_raw = shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c {$community} {$hostname}:{$port} {$mem_get}");
$mem_raw = str_replace("No Such Instance currently exists at this OID", "0", $mem_raw);
list($memfreeio, $memfreeproc, $memfreeprocb, $memusedio, $memusedproc, $memusedprocb) = explode("\n", $mem_raw);
$memfreeproc = $memfreeproc + $memfreeprocb;
$memusedproc = $memusedproc + $memusedprocb;
$memfreeio = $memfreeio + 0;
$memfreeproc = $memfreeproc + 0;
$memusedio = $memusedio + 0;
$memusedproc = $memusedproc + 0;
$memtotal = $memfreeio + $memfreeproc + $memusedio + $memusedproc;
if (!is_file($memrrd)) {
shell_exec($config['rrdtool'] . " create {$memrrd} --step 300 \\\n DS:IOFREE:GAUGE:600:0:U \\\n DS:IOUSED:GAUGE:600:-1:U \\\n DS:PROCFREE:GAUGE:600:0:U \\\n DS:PROCUSED:GAUGE:600:-1:U \\\n DS:MEMTOTAL:GAUGE:600:-1:U \\\n RRA:AVERAGE:0.5:1:2000 \\\n RRA:AVERAGE:0.5:6:2000 \\\n RRA:AVERAGE:0.5:24:2000 \\\n RRA:AVERAGE:0.5:288:2000 \\\n RRA:MAX:0.5:1:2000 \\\n RRA:MAX:0.5:6:2000 \\\n RRA:MAX:0.5:24:2000 \\\n RRA:MAX:0.5:288:2000 \\\n RRA:MIN:0.5:1:2000 \\\n RRA:MIN:0.5:6:2000 \\\n RRA:MIN:0.5:24:2000 \\\n RRA:MIN:0.5:288:2000");
}
rrdtool_update($memrrd, "N:{$memfreeio}:{$memusedio}:{$memfreeproc}:{$memusedproc}:{$memtotal}");
# include("includes/polling/cisco-processors.inc.php");
# include("includes/polling/cisco-enhanced-mempool.inc.php");
# include("includes/polling/cisco-mempool.inc.php");
# include("includes/polling/cisco-entity-sensors.inc.php");
示例13: preg_replace
$version = preg_replace("/(.+),(.+),(.+)/", "\\1||\\2||\\3", $fnSysVersion);
list($version, $features) = explode("||", $version);
if (isset($rewrite_fortinet_hardware[$poll_device['sysObjectID']])) {
$hardware = $rewrite_fortinet_hardware[$poll_device['sysObjectID']];
}
#$cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m FORTINET-MIB-280 -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
#$cmd .= " fnSysCpuUsage.0 fnSysMemUsage.0 fnSysSesCount.0 fnSysMemCapacity.0";
#$data = shell_exec($cmd);
#list ($cpu, $mem, $ses, $memsize) = explode("\n", $data);
$sessrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate_sessions.rrd";
$sessions = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysSesCount.0", "-Ovq");
if (is_numeric($sessions)) {
if (!is_file($sessrrd)) {
rrdtool_create($sessrrd, " --step 300 DS:sessions:GAUGE:600:0:3000000 " . $config['rrd_rra']);
}
print "Sessions: {$sessions}\n";
rrdtool_update($sessrrd, "N:" . $sessions);
$graphs['fortigate_sessions'] = TRUE;
}
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate_cpu.rrd";
$cpu_usage = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0", "-Ovq");
if (is_numeric($cpu_usage)) {
if (!is_file($cpurrd)) {
rrdtool_create($cpurrd, " --step 300 DS:LOAD:GAUGE:600:-1:100 " . $config['rrd_rra']);
}
echo "CPU: {$cpu_usage}%\n";
rrdtool_update($cpurrd, " N:{$cpu_usage}");
$graphs['fortigate_cpu'] = TRUE;
}
#$mem=snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemUsage.0", "-Ovq");
#$memsize=snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemCapacity", "-Ovq");
示例14: poll_mib_def
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';
$influx_name = strtolower(safename($mib));
} else {
list($mib, $file) = explode(':', $mib_name_table, 2);
$rrd_file = strtolower(safename($file)) . '.rrd';
$influx_name = strtolower(safename($file));
}
$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);
$val = $snmpdata[$splitindex][$splitoid];
if (is_numeric($val)) {
$fields[$oidnamelist[$oid_count]] = $val;
} elseif (preg_match("/^\"(.*)\"\$/", $val, $number) && is_numeric($number[1])) {
$fields[$oidnamelist[$oid_count]] = $number[1];
} 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);
$tags = array();
influx_update($device, $influx_name, $tags, $fields);
foreach ($mib_graphs as $graphtoenable) {
$graphs[$graphtoenable] = true;
}
return true;
}
示例15: snmp_get
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
// Polls MailScanner statistics from script via SNMP
// FIXME do we still support this in some way?
$rrd_filename = "app-mailscannerV2-" . $app['app_id'] . ".rrd";
$options = "-O qv";
$oid = "nsExtendOutputFull.11.109.97.105.108.115.99.97.110.110.101.114";
$mailscanner = snmp_get($device, $oid, $options);
echo " mailscanner";
list($msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $virus) = explode("\n", $mailscanner);
rrdtool_create($device, $rrd_filename, " \\\n DS:msg_recv:COUNTER:600:0:125000000000 \\\n DS:msg_rejected:COUNTER:600:0:125000000000 \\\n DS:msg_relay:COUNTER:600:0:125000000000 \\\n DS:msg_sent:COUNTER:600:0:125000000000 \\\n DS:msg_waiting:COUNTER:600:0:125000000000 \\\n DS:spam:COUNTER:600:0:125000000000 \\\n DS:virus:COUNTER:600:0:125000000000 ");
rrdtool_update($device, $rrd_filename, "N:{$msg_recv}:{$msg_rejected}:{$msg_relay}:{$msg_sent}:{$msg_waiting}:{$spam}:{$virus}");
// EOF