本文整理汇总了PHP中rrdtool_create函数的典型用法代码示例。如果您正苦于以下问题:PHP rrdtool_create函数的具体用法?PHP rrdtool_create怎么用?PHP rrdtool_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rrdtool_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_debug
$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;
$cache['devices']['uptime'][$device['device_id']]['polled'] = $polled;
}
$poll_device['sysLocation'] = str_replace("\"", "", $poll_device['sysLocation']);
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation'])) {
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace("\"", "", $poll_device['sysContact']);
if ($poll_device['sysLocation'] == "not set") {
示例2: 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);
示例3: 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);
}
示例4: 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
示例5: snmp_get
$uptime = $secs;
}
}
// Use snmpEngineTime (68 year rollover) to cross-reference for false positives in device rebooting due to sysUpTime rollover issues
$snmpEngineTime = (int) snmp_get($device, "snmpEngineTime.0", "-OUqv", "SNMP-FRAMEWORK-MIB");
if (!is_numeric($snmpEngineTime)) {
$snmpEngineTime = 0;
}
if (is_numeric($uptime)) {
if ($uptime < $device['uptime'] && $uptime >= $snmpEngineTime) {
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 " . $config['rrd_rra']);
}
rrdtool_update($uptime_rrd, "N:" . $uptime);
$graphs['uptime'] = TRUE;
echo "Uptime: " . formatUptime($uptime) . "\n";
$update_array['uptime'] = $uptime;
}
$poll_device['sysLocation'] = str_replace("\"", "", $poll_device['sysLocation']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysLocation'] = trim($poll_device['sysLocation'], "\\");
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation']) && is_array($config['location_map'])) {
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace("\"", "", $poll_device['sysContact']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
示例6: list
}
echo ' powerdns';
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);
示例7: 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);
示例8: snmp_get
}
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;
示例9: array
if (!empty($agent_data['app']['nfs'])) {
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-nfs-" . $app['app_id'] . ".rrd";
/* Based DIRECTLY on nfsstats.c labels */
$nfsLabel = array();
$nfsLabel['proc2'] = array("null", "getattr", "setattr", "root", "lookup", "readlink", "read", "wrcache", "write", "create", "remove", "rename", "link", "symlink", "mkdir", "rmdir", "readdir", "fsstat");
$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) {
示例10: 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
示例11: 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");
示例12: explode
$servers = explode("\n", $shoutcast);
foreach ($servers as $item => $server) {
$server = trim($server);
if (!empty($server)) {
$data = explode(';', $server);
list($host, $port) = split(':', $data['0'], 2);
$bitrate = $data['1'];
$traf_in = $data['2'];
$traf_out = $data['3'];
$current = $data['4'];
$status = $data['5'];
$peak = $data['6'];
$max = $data['7'];
$unique = $data['8'];
$rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/app-shoutcast-' . $app['app_id'] . '-' . $host . '_' . $port . '.rrd';
if (!is_file($rrdfile)) {
rrdtool_create($rrdfile, '--step 300 \\
DS:bitrate:GAUGE:600:0:125000000000 \\
DS:traf_in:GAUGE:600:0:125000000000 \\
DS:traf_out:GAUGE:600:0:125000000000 \\
DS:current:GAUGE:600:0:125000000000 \\
DS:status:GAUGE:600:0:125000000000 \\
DS:peak:GAUGE:600:0:125000000000 \\
DS:max:GAUGE:600:0:125000000000 \\
DS:unique:GAUGE:600:0:125000000000 ' . $config['rrd_rra']);
}
rrdtool_update($rrdfile, "N:{$bitrate}:{$traf_in}:{$traf_out}:{$current}:{$status}:{$peak}:{$max}:{$unique}");
}
//end if
}
//end foreach
示例13: 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;
}
示例14: trim
*
* 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($poll_device['sysName'], '"');
$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']);
}
$fields = array('users' => $users);
rrdtool_update($usersrrd, $fields);
$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']);
}
$fields = array('sessions' => $sessions);
rrdtool_update($sessrrd, $fields);
$graphs['pulse_sessions'] = true;
}
示例15: array
<?php
$storage_cache = array();
$query = "SELECT * FROM storage WHERE device_id = '" . $device['device_id'] . "'";
$storage_data = mysql_query($query);
while ($storage = mysql_fetch_array($storage_data)) {
echo $storage['storage_descr'] . ": ";
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("storage-" . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".rrd");
if (!is_file($storage_rrd)) {
rrdtool_create($storage_rrd, "--step 300 \\\n DS:used:GAUGE:600:0:U \\\n DS:free:GAUGE:600:0:U \\\n RRA:AVERAGE:0.5:1:600 \\\n RRA:AVERAGE:0.5:6:700 \\\n RRA:AVERAGE:0.5:24:775 \\\n RRA:AVERAGE:0.5:288:797 \\\n RRA:MIN:0.5:1:600 \\\n RRA:MIN:0.5:6:700 \\\n RRA:MIN:0.5:24:775 \\\n RRA:MIN:0.5:288:797 \\\n RRA:MAX:0.5:1:600 \\\n RRA:MAX:0.5:6:700 \\\n RRA:MAX:0.5:24:775 \\\n RRA:MAX:0.5:288:797");
}
$file = $config['install_dir'] . "/includes/polling/storage-" . $storage['storage_mib'] . ".inc.php";
if (is_file($file)) {
include $file;
} else {
### FIXME GENERIC
}
if ($debug) {
print_r($storage);
}
$percent = round($storage['used'] / $storage['size'] * 100);
echo $percent . "% ";
rrdtool_update($storage_rrd, "N:" . $storage['used'] . ":" . $storage['free']);
$update_query = "UPDATE `storage` SET `storage_used` = '" . $storage['used'] . "'";
$update_query .= ", `storage_free` = '" . $storage['free'] . "', `storage_size` = '" . $storage['size'] . "'";
$update_query .= ", `storage_units` = '" . $storage['units'] . "', `storage_perc` = '" . $percent . "'";
$update_query .= " WHERE `storage_id` = '" . $storage['storage_id'] . "'";
if ($debug) {
echo "{$update_query}\n";
}
mysql_query($update_query);