/** * Datastore-independent function which should be used for all polled metrics. * * RRD Tags: * rrd_def array|string: (required) an array of rrd field definitions example: "DS:dataName:COUNTER:600:U:100000000000" * rrd_name array|string: the rrd filename, will be processed with rrd_name() * rrd_oldname array|string: old rrd filename to rename, will be processed with rrd_name() * rrd_step int: rrd step, defaults to 300 * * @param array $device * @param string $measurement Name of this measurement * @param array $tags tags for the data (or to control rrdtool) * @param array $fields */ function data_update($device, $measurement, $tags, $fields) { // convenience conversion to allow calling with a single value, so, e.g., these are equivalent: // data_update($device, 'mymeasurement', $tags, 1234); // AND // data_update($device, 'mymeasurement', $tags, array('mymeasurement' => 1234)); if (!is_array($fields)) { $fields = array($measurement => $fields); } // rrdtool_data_update() will only use the tags it deems relevant, so we pass all of them. // However, influxdb saves all tags, so we filter out the ones beginning with 'rrd_'. rrdtool_data_update($device, $measurement, $tags, $fields); influx_update($device, $measurement, rrd_array_filter($tags), $fields); }
$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); $tags = array('index' => $index, 'subindex' => $subindex); influx_update($device, 'c6kxbar', $tags, $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']]); }
$cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host']; } // FIXME -- memcached $cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop']; $cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt']; $cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host']; $cef_stat['update']['drop_prev'] = $cef_entry['drop']; $cef_stat['update']['punt_prev'] = $cef_entry['punt']; $cef_stat['update']['punt2host_prev'] = $cef_entry['punt2host']; $cef_stat['update']['updated'] = $polled; $cef_stat['update']['updated_prev'] = $cef_entry['updated']; dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path)); $fields = array('drop' => $cef_stat['cefSwitchingDrop'], 'punt' => $cef_stat['cefSwitchingPunt'], 'hostpunt' => $cef_stat['cefSwitchingPunt2Host']); $ret = rrdtool_update("{$filename}", $fields); $tags = array('entity' => $entity, 'afi' => $afi, 'index' => $path); influx_update($device, 'cefswitching', $tags, $fields); echo "\n"; } //end foreach } //end foreach } //end foreach } //end if // FIXME - need to delete old ones. FIXME REALLY. print_r($cefs_db); foreach ($cefs_db as $cef_switching_id) { dbDelete('cef_switching', '`cef_switching_id` = ?', array($cef_switching_id)); echo '-'; }
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; }
if (isset($stats['ipSystemStatsHCOutForwDatagrams'])) { $stats['ipSystemStatsOutForwDatagrams'] = $stats['ipSystemStatsHCOutForwDatagrams']; } unset($snmpstring, $files, $snmpdata, $snmpdata_cmd, $rrd_create); $rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('ipSystemStats-' . $af . '.rrd'); $rrd_create = $config['rrd_rra']; $fields = array(); foreach ($oids as $oid) { $oid_ds = str_replace('ipSystemStats', '', $oid); $oid_ds = truncate($oid_ds, 19, ''); $rrd_create .= " DS:{$oid_ds}:COUNTER:600:U:100000000000"; if (strstr($stats[$oid], 'No') || strstr($stats[$oid], 'd') || strstr($stats[$oid], 's')) { $stats[$oid] = '0'; } $fields[$oid] = $stats[$oid]; } if (!file_exists($rrdfile)) { rrdtool_create($rrdfile, $rrd_create); } rrdtool_update($rrdfile, $fields); $tags = array('af' => $af); influx_update($device, 'ipSystemStats', $tags, $fields); unset($fields, $rrd_create); // FIXME per-AF? $graphs['ipsystemstats_' . $af] = true; $graphs['ipsystemstats_' . $af . '_frag'] = true; } //end foreach } //end if echo "\n";
echo str_pad($vsvr['vsvrName'], 25) . ' | ' . str_pad($vsvr['vsvrType'], 5) . ' | ' . str_pad($vsvr['vsvrState'], 6) . ' | ' . str_pad($vsvr['vsvrIpAddress'], 16) . ' | ' . str_pad($vsvr['vsvrPort'], 5); echo ' | ' . str_pad($vsvr['vsvrRequestRate'], 8) . ' | ' . str_pad($vsvr['vsvrRxBytesRate'] . 'B/s', 8) . ' | ' . str_pad($vsvr['vsvrTxBytesRate'] . 'B/s', 8); $db_update = array('vsvr_ip' => $vsvr['vsvrIpAddress'], 'vsvr_port' => $vsvr['vsvrPort'], 'vsvr_state' => $vsvr['vsvrState'], 'vsvr_type' => $vsvr['vsvrType'], 'vsvr_req_rate' => $vsvr['RequestRate'], 'vsvr_bps_in' => $vsvr['vsvrRxBytesRate'], 'vsvr_bps_out' => $vsvr['vsvrTxBytesRate']); if (!is_array($vsvrs[$vsvr['vsvrName']])) { $db_insert = array_merge(array('device_id' => $device['device_id'], 'vsvr_name' => $vsvr['vsvrName']), $db_update); $vsvr_id = dbInsert($db_insert, 'netscaler_vservers'); echo ' +'; } else { $updated = dbUpdate($db_update, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvrs[$vsvr['vsvrName']]['vsvr_id'])); echo ' U'; } if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } rrdtool_update($rrd_file, $fields); $tags = array('vsvrName' => $vsvr['vsvrName']); influx_update($device, 'netscaler-vsvr', $tags, $fields); echo "\n"; } //end if } //end foreach d_echo($vsvr_exist); foreach ($vsvrs as $db_name => $db_id) { if (!$vsvr_exist[$db_name]) { echo '-' . $db_name; dbDelete('netscaler_vservers', '`vsvr_id` = ?', array($db_id)); } } } //end if
<?php if ($this_port['dot3StatsIndex'] and $port['ifType'] == 'ethernetCsmacd') { // TODO: remove legacy check? $old_rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('etherlike-' . $port['ifIndex'] . '.rrd'); $rrd_file = get_port_rrdfile_path($device['hostname'], $port_id, 'dot3'); $rrd_create = $config['rrd_rra']; if (!file_exists($rrdfile)) { if (file_exists($old_rrdfile)) { rename($old_rrdfile, $rrd_file); } else { foreach ($etherlike_oids as $oid) { $oid = truncate(str_replace('dot3Stats', '', $oid), 19, ''); $rrd_create .= " DS:{$oid}:COUNTER:600:U:100000000000"; } rrdtool_create($rrdfile, $rrd_create); } } $fields = array(); foreach ($etherlike_oids as $oid) { $data = $this_port[$oid] + 0; $fields[$oid] = $data; } rrdtool_update($rrdfile, $fields); $tags = array('ifName' => $port['ifName']); influx_update($device, 'dot3', $tags, $fields); echo 'EtherLike '; }
$oids = array('ipCidrRouteNumber'); unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/netstats-ip_forward.rrd'; $rrd_create = $config['rrd_rra']; foreach ($oids as $oid) { $oid_ds = truncate($oid, 19, ''); $rrd_create .= " DS:{$oid_ds}:GAUGE:600:U:1000000"; // Limit to 1MPPS? $snmpstring .= ' IP-FORWARD-MIB::' . $oid . '.0'; } $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'IP-FORWARD-MIB'); $fields = array(); foreach ($oids as $oid) { if (is_numeric($data[0][$oid])) { $value = $data[0][$oid]; } else { $value = 'U'; } $fields[$oid] = $value; } if (isset($data[0]['ipCidrRouteNumber'])) { if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } rrdtool_update($rrd_file, $fields); $tags = array(); influx_update($device, 'netstats-ip_forward', $tags, $fields); $graphs['netstat_ip_forward'] = true; } } unset($oids, $data, $data_array, $oid, $protos, $snmpstring);
// FIXME - This needs a good cleanup... $cmd = 'snmpget -O qv ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' 1.3.6.1.2.1.7526.2.4'; $poll_device['sysDescr'] = `{$cmd}`; $poll_device['sysDescr'] = str_replace('-', ' ', $poll_device['sysDescr']); $poll_device['sysDescr'] = str_replace('"', '', $poll_device['sysDescr']); list($hardware, $features, $version) = explode(' ', $poll_device['sysDescr']); // Get data for calls and network from SNOM specific SNMP OIDs. $cmda = 'snmpget -O qv ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' 1.3.6.1.2.1.7526.2.1.1 1.3.6.1.2.1.7526.2.1.2 1.3.6.1.2.1.7526.2.2.1 1.3.6.1.2.1.7526.2.2.2'; $cmdb = 'snmpget -O qv ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' 1.3.6.1.2.1.7526.2.5 1.3.6.1.2.1.7526.2.6'; // echo($cmda); $snmpdata = `{$cmda}`; $snmpdatab = `{$cmdb}`; list($rxbytes, $rxpkts, $txbytes, $txpkts) = explode("\n", $snmpdata); list($calls, $registrations) = explode("\n", $snmpdatab); $txbytes = 0 - $txbytes * 8; $rxbytes = 0 - $rxbytes * 8; echo "{$rxbytes}, {$rxpkts}, {$txbytes}, {$txpkts}, {$calls}, {$registrations}"; $rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/data.rrd'; if (!is_file($rrdfile)) { rrdtool_create($rrdfile, 'DS:INOCTETS:COUNTER:600:U:100000000000 DS:OUTOCTETS:COUNTER:600:U:10000000000 DS:INPKTS:COUNTER:600:U:10000000000 DS:OUTPKTS:COUNTER:600:U:10000000000 DS:CALLS:COUNTER:600:U:10000000000 DS:REGISTRATIONS:COUNTER:600:U:10000000000 ' . $config['rrd_rra']); } $fields = array('INOCTETS' => $rxbytes, 'OUTOCTETS' => $txbytes, 'INPKTS' => $rxpkts, 'OUTPKTS' => $rxbytes, 'CALLS' => $calls, 'REGISTRATIONS' => $registrations); rrdtool_update("{$rrdfile}", $fields); $tags = array(); influx_update($device, 'snom-data', $tags, $fields);
$id = intval($prop_id[1]); $sla_table[$id][$property] = trim($value); } // Update timestamps foreach ($sla_table as &$sla) { $sla['UnixTime'] = intval($sla['Time'] / 100 + $time_offset); $sla['TimeStr'] = strftime('%Y-%m-%d %H:%M:%S', $sla['UnixTime']); } unset($sla); foreach (dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 AND `status` = 1', array($device['device_id'])) as $sla) { echo 'SLA ' . $sla['sla_nr'] . ': ' . $sla['rtt_type'] . ' ' . $sla['owner'] . ' ' . $sla['tag'] . '... '; $slarrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('sla-' . $sla['sla_nr'] . '.rrd'); if (!is_file($slarrd)) { rrdtool_create($slarrd, '--step 300 DS:rtt:GAUGE:600:0:300000 ' . $config['rrd_rra']); } if (isset($sla_table[$sla['sla_nr']])) { $slaval = $sla_table[$sla['sla_nr']]; echo $slaval['CompletionTime'] . 'ms at ' . $slaval['TimeStr']; $val = $slaval['CompletionTime']; } else { echo 'NaN'; $val = 'U'; } $fields = array('rtt' => $val); rrdtool_update($slarrd, $fields); $tags = array('sla_nr' => $sla['sla_nr']); influx_update($device, 'sla', $tags, $fields); echo "\n"; } //end foreach
<?php // CISCO-VPDN-MGMT-MIB::cvpdnTunnelTotal.0 = Gauge32: 0 tunnels // CISCO-VPDN-MGMT-MIB::cvpdnSessionTotal.0 = Gauge32: 0 users // CISCO-VPDN-MGMT-MIB::cvpdnDeniedUsersTotal.0 = Counter32: 0 attempts // CISCO-VPDN-MGMT-MIB::cvpdnSystemTunnelTotal.l2tp = Gauge32: 437 tunnels // CISCO-VPDN-MGMT-MIB::cvpdnSystemSessionTotal.l2tp = Gauge32: 1029 sessions // CISCO-VPDN-MGMT-MIB::cvpdnSystemDeniedUsersTotal.l2tp = Counter32: 0 attempts // CISCO-VPDN-MGMT-MIB::cvpdnSystemClearSessions.0 = INTEGER: none(1) if ($device['os_group'] == 'cisco') { $data = snmpwalk_cache_oid($device, 'cvpdnSystemEntry', null, 'CISCO-VPDN-MGMT-MIB'); foreach ($data as $type => $vpdn) { $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('vpdn-' . $type . '.rrd'); if (is_file($rrd_filename) || $vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) { if (!file_exists($rrd_filename)) { rrdtool_create($rrd_filename, ' DS:tunnels:GAUGE:600:0:U DS:sessions:GAUGE:600:0:U DS:denied:COUNTER:600:0:100000' . $config['rrd_rra']); } $fields = array('tunnels' => $vpdn['cvpdnSystemTunnelTotal'], 'sessions' => $vpdn['cvpdnSystemSessionTotal'], 'denied' => $vpdn['cvpdnSystemDeniedUsersTotal']); rrdtool_update($rrd_filename, $fields); $tags = array('type' => $type); influx_update($device, 'vpdn', $tags, $fields); $graphs['vpdn_sessions_' . $type] = true; $graphs['vpdn_tunnels_' . $type] = true; echo " Cisco VPDN ({$type}) "; } } unset($data, $vpdn, $type, $rrd_filename); } //end if
$hardware = substr($hardware, 24); } $altversion = trim(snmp_get($device, 'hpSwitchOsVersion.0', '-Oqv', 'NETSWITCH-MIB'), '"'); if ($altversion) { $version = $altversion; } $altversion = trim(snmp_get($device, '.1.3.6.1.4.1.11.2.3.7.11.12.1.2.1.11.0', '-Oqv'), '"'); if ($altversion) { $version = $altversion; } if (preg_match('/^PROCURVE (.*) - (.*)/', $poll_device['sysDescr'], $regexp_result)) { $hardware = 'ProCurve ' . $regexp_result[1]; $version = $regexp_result[2]; } $serial = snmp_get($device, '.1.3.6.1.4.1.11.2.36.1.1.2.9.0', '-Oqv', 'SEMI-MIB'); $serial = trim(str_replace('"', '', $serial)); // FIXME maybe genericise? or do away with it if we ever walk the full dot1qTpFdbTable as we can count ourselves then ;) $fdb_rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/fdb_count.rrd'; $FdbAddressCount = snmp_get($device, 'hpSwitchFdbAddressCount.0', '-Ovqn', 'STATISTICS-MIB'); if (is_numeric($FdbAddressCount)) { if (!is_file($fdb_rrd_file)) { rrdtool_create($fdb_rrd_file, ' --step 300 DS:value:GAUGE:600:-1:100000 ' . $config['rrd_rra']); } $fields = array('value' => $FdbAddressCount); rrdtool_update($fdb_rrd_file, $fields); $tags = array(); influx_update($device, 'fdb_count', $tags, $fields); $graphs['fdb_count'] = true; echo 'FDB Count '; }
$hardware = $rewrite_fortinet_hardware[$poll_device['sysObjectID']]; } if (empty($hardware)) { $hardware = snmp_get($device, 'ENTITY-MIB::entPhysicalModelName.1', '-Ovq'); } $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"; $fields = array('sessions' => $sessions); rrdtool_update($sessrrd, $fields); $tags = array(); influx_update($device, 'fortigate_sessions', $tags, $fields); $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"; $fields = array('LOAD' => $cpu_usage); rrdtool_update($cpurrd, $fields); $tags = array(); influx_update($device, 'fortigate_cpu', $tags, $fields); $graphs['fortigate_cpu'] = true; }
$tunnel['cipSecTunInDecompOctets'] = $tunnel['cipSecTunHcInDecompOctets']; $tunnel['cipSecTunOutOctets'] = $tunnel['cipSecTunHcOutOctets']; $tunnel['cipSecTunOutUncompOctets'] = $tunnel['cipSecTunHcOutUncompOctets']; } $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/ipsectunnel-' . $address . '.rrd'; $rrd_create = $config['rrd_rra']; foreach ($oids as $oid) { $oid_ds = truncate(str_replace('cipSec', '', $oid), 19, ''); $rrd_create .= " DS:{$oid_ds}:COUNTER:600:U:1000000000"; } $fields = array(); foreach ($oids as $oid) { if (is_numeric($tunnel[$oid])) { $value = $tunnel[$oid]; } else { $value = '0'; } $fields[$oid] = $value; } if (isset($tunnel['cikeTunRemoteValue'])) { if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } rrdtool_update($rrd_file, $fields); $tags = array('address' => $address); influx_update($device, 'ipsectunnel', $tags, $fields); // $graphs['ipsec_tunnels'] = TRUE; } } //end foreach unset($rrd_file, $rrd_create, $fields, $oids, $data, $data_array, $oid, $tunnel);
// HOST-RESOURCES-MIB // Generic System Statistics $oid_list = 'hrSystemProcesses.0 hrSystemNumUsers.0'; $hrSystem = snmp_get_multi($device, $oid_list, '-OUQs', 'HOST-RESOURCES-MIB'); if (is_numeric($hrSystem[0]['hrSystemProcesses'])) { $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/hr_processes.rrd'; if (!is_file($rrd_file)) { rrdtool_create($rrd_file, '--step 300 DS:procs:GAUGE:600:0:U ' . $config['rrd_rra']); } $fields = array('procs' => $hrSystem[0]['hrSystemProcesses']); rrdtool_update($rrd_file, $fields); $tags = array(); influx_update($device, 'hr_processes', $tags, $fields); $graphs['hr_processes'] = true; echo ' Processes'; } if (is_numeric($hrSystem[0]['hrSystemNumUsers'])) { $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/hr_users.rrd'; if (!is_file($rrd_file)) { rrdtool_create($rrd_file, '--step 300 DS:users:GAUGE:600:0:U ' . $config['rrd_rra']); } $fields = array('users' => $hrSystem[0]['hrSystemNumUsers']); rrdtool_update($rrd_file, $fields); $tags = array(); influx_update($device, 'hr_users', $tags, $fields); $graphs['hr_users'] = true; echo ' Users'; } echo "\n";
<?php $storage_cache = array(); foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device['device_id'])) as $storage) { echo 'Storage ' . $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 DS:used:GAUGE:600:0:U DS:free:GAUGE:600:0:U ' . $config['rrd_rra']); } $file = $config['install_dir'] . '/includes/polling/storage/' . $storage['storage_mib'] . '.inc.php'; if (is_file($file)) { include $file; } else { // FIXME Generic poller goes here if we ever have a discovery module which uses it. } d_echo($storage); if ($storage['size']) { $percent = round($storage['used'] / $storage['size'] * 100); } else { $percent = 0; } echo $percent . '% '; $fields = array('used' => $storage['used'], 'free' => $storage['free']); rrdtool_update($storage_rrd, $fields); $tags = array('mib' => $storage['storage_mib'], 'descr' => $storage['storage_descr']); influx_update($device, 'storage', $tags, $fields); $update = dbUpdate(array('storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage', '`storage_id` = ?', array($storage['storage_id'])); echo "\n"; } //end foreach unset($storage);
echo ' TCP'; $oids = array('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab', 'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts'); // $oids['tcp_collect'] = $oids['tcp']; // $oids['tcp_collect'][] = 'tcpHCInSegs'; // $oids['tcp_collect'][] = 'tcpHCOutSegs'; unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/netstats-tcp.rrd'; $rrd_create = $config['rrd_rra']; foreach ($oids as $oid) { $oid_ds = truncate($oid, 19, ''); $rrd_create .= " DS:{$oid_ds}:COUNTER:600:U:10000000"; // Limit to 10MPPS $snmpstring .= ' TCP-MIB::' . $oid . '.0'; } $snmpstring .= ' tcpHCInSegs.0'; $snmpstring .= ' tcpHCOutSegs.0'; $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'TCP-MIB'); $fields = $data[0]; unset($snmpstring); if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs'])) { if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } rrdtool_update($rrd_file, $fields); $tags = array(); influx_update($device, 'netstats-tcp', $tags, $fields); $graphs['netstat_tcp'] = true; } unset($oids, $data, $data_array, $oid, $protos); } //end if
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); $tags = array('name' => $name, 'radionum' => $radionum); influx_update($device, 'aruba', $tags, $fields); } // generate the mac address $macparts = explode('.', $radioid, -1); $mac = ''; foreach ($macparts as $part) { $mac .= sprintf('%02x', $part) . ':'; } $mac = rtrim($mac, ':'); $foundid = 0; for ($z = 0; $z < sizeof($ap_db); $z++) { if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) { $foundid = $ap_db[$z]['accesspoint_id']; $ap_db[$z]['seen'] = 1; continue; }
$rrd_def = array('DS:INOCTETS:DERIVE:600:0:12500000000', 'DS:OUTOCTETS:DERIVE:600:0:12500000000', 'DS:INERRORS:DERIVE:600:0:12500000000', 'DS:OUTERRORS:DERIVE:600:0:12500000000', 'DS:INUCASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTUCASTPKTS:DERIVE:600:0:12500000000', 'DS:INNUCASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000', 'DS:INDISCARDS:DERIVE:600:0:12500000000', 'DS:OUTDISCARDS:DERIVE:600:0:12500000000', 'DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000', 'DS:INBROADCASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000', 'DS:INMULTICASTPKTS:DERIVE:600:0:12500000000', 'DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000'); $fields = array('INOCTETS' => $this_port['ifInOctets'], 'OUTOCTETS' => $this_port['ifOutOctets'], 'INERRORS' => $this_port['ifInErrors'], 'OUTERRORS' => $this_port['ifOutErrors'], 'INUCASTPKTS' => $this_port['ifInUcastPkts'], 'OUTUCASTPKTS' => $this_port['ifOutUcastPkts'], 'INNUCASTPKTS' => $this_port['ifInNUcastPkts'], 'OUTNUCASTPKTS' => $this_port['ifOutNUcastPkts'], 'INDISCARDS' => $this_port['ifInDiscards'], 'OUTDISCARDS' => $this_port['ifOutDiscards'], 'INUNKNOWNPROTOS' => $this_port['ifInUnknownProtos'], 'INBROADCASTPKTS' => $this_port['ifInBroadcastPkts'], 'OUTBROADCASTPKTS' => $this_port['ifOutBroadcastPkts'], 'INMULTICASTPKTS' => $this_port['ifInMulticastPkts'], 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts']); if ($tune_port === true) { rrdtool_tune('port', $rrdfile, $this_port['ifSpeed']); } $port_descr_type = $port['port_descr_type']; $ifName = $port['ifName']; $tags = compact('ifName', 'port_descr_type', 'rrd_name', 'rrd_def'); rrdtool_data_update($device, 'ports', $tags, $fields); $fields['ifInUcastPkts_rate'] = $port['ifInUcastPkts_rate']; $fields['ifOutUcastPkts_rate'] = $port['ifOutUcastPkts_rate']; $fields['ifInErrors_rate'] = $port['ifInErrors_rate']; $fields['ifOutErrors_rate'] = $port['ifOutErrors_rate']; $fields['ifInOctets_rate'] = $port['ifInOctets_rate']; $fields['ifOutOctets_rate'] = $port['ifOutOctets_rate']; influx_update($device, 'ports', rrd_array_filter($tags), $fields); // End Update IF-MIB // Update PAgP if ($this_port['pagpOperationMode'] || $port['pagpOperationMode']) { foreach ($pagp_oids as $oid) { // Loop the OIDs if ($this_port[$oid] != $port[$oid]) { // If data has changed, build a query $port['update'][$oid] = $this_port[$oid]; echo 'PAgP '; log_event("{$oid} -> " . $this_port[$oid], $device, 'interface', $port['port_id']); } } } // End Update PAgP // Do EtherLike-MIB
<?php $hardware = trim(snmp_get($device, '1.3.6.1.4.1.25461.2.1.2.2.1.0', '-OQv', '', ''), '" '); $version = trim(snmp_get($device, '1.3.6.1.4.1.25461.2.1.2.1.1.0', '-OQv', '', ''), '" '); $serial = trim(snmp_get($device, '1.3.6.1.4.1.25461.2.1.2.1.3.0', '-OQv', '', ''), '" '); // list(,,,$hardware) = explode (" ", $poll_device['sysDescr']); $sessrrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/panos-sessions.rrd'; $sessions = snmp_get($device, '1.3.6.1.4.1.25461.2.1.2.3.3.0', '-Ovq'); if (is_numeric($sessions)) { if (!is_file($sessrrd)) { rrdtool_create($sessrrd, ' --step 300 DS:sessions:GAUGE:600:0:3000000 ' . $config['rrd_rra']); } $fields = array('sessions' => $sessions); rrdtool_update($sessrrd, $fields); $tags = array(); influx_update($device, 'panos-sessions', $tags, $fields); $graphs['panos_sessions'] = true; }
// CISCO-REMOTE-ACCESS-MONITOR-MIB::crasSVCNumSessions.0 = Gauge32: 7 Sessions // CISCO-REMOTE-ACCESS-MONITOR-MIB::crasSVCCumulateSessions.0 = Counter32: 53 Sessions // CISCO-REMOTE-ACCESS-MONITOR-MIB::crasSVCPeakConcurrentSessions.0 = Gauge32: 9 Sessions // CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnNumSessions.0 = Gauge32: 7 Sessions // CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnCumulateSessions.0 = Counter32: 29 Sessions // CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnPeakConcurrentSessions.0 = Gauge32: 9 Sessions if ($device['os_group'] == 'cisco') { $oid_list = 'crasEmailNumSessions.0 crasIPSecNumSessions.0 crasL2LNumSessions.0 crasLBNumSessions.0 crasSVCNumSessions.0 crasWebvpnNumSessions.0'; $data = snmp_get_multi($device, $oid_list, '-OUQs', 'CISCO-REMOTE-ACCESS-MONITOR-MIB'); $data = $data[0]; $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cras_sessions.rrd'); $rrd_create .= ' DS:email:GAUGE:600:0:U'; $rrd_create .= ' DS:ipsec:GAUGE:600:0:U'; $rrd_create .= ' DS:l2l:GAUGE:600:0:U'; $rrd_create .= ' DS:lb:GAUGE:600:0:U'; $rrd_create .= ' DS:svc:GAUGE:600:0:U'; $rrd_create .= ' DS:webvpn:GAUGE:600:0:U'; $rrd_create .= $config['rrd_rra']; if (is_file($rrd_filename) || $data['crasEmailNumSessions'] || $data['crasIPSecNumSessions'] || $data['crasL2LNumSessions'] || $data['crasLBNumSessions'] || $data['crasSVCNumSessions'] || $data['crasWebvpnSessions']) { if (!file_exists($rrd_filename)) { rrdtool_create($rrd_filename, $rrd_create); } $fields = array('email' => $data['crasEmailNumSessions'], 'ipsec' => $data['crasIPSecNumSessions'], 'l2l' => $data['crasL2LNumSessions'], 'lb' => $data['crasLBNumSessions'], 'svc' => $data['crasSVCNumSessions'], 'webvpn' => $data['crasWebvpnNumSessions']); rrdtool_update($rrd_filename, $fields); $tags = array(); influx_update($device, 'cras_sessions', $tags, $fields); $graphs['cras_sessions'] = true; } unset($data, ${$rrd_filename}, $rrd_create, $fields); } //end if
unset($ospf_nbr_db); $ospf_nbr_count++; } else { dbDelete('ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ? AND `context_name` = ?', array($device['device_id'], $ospf_nbr_db['ospf_nbr_id'], $device['context_name'])); echo '-'; } //end if } //end foreach } //end if unset($ospf_nbrs_db); unset($ospf_nbrs_poll); echo "\n"; } unset($device['context_name']); unset($vrfs_lite_cisco); // Create device-wide statistics RRD $filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('ospf-statistics.rrd'); if (!is_file($filename)) { rrdtool_create($filename, '--step 300 DS:instances:GAUGE:600:0:1000000 DS:areas:GAUGE:600:0:1000000 DS:ports:GAUGE:600:0:1000000 DS:neighbours:GAUGE:600:0:1000000 ' . $config['rrd_rra']); } $fields = array('instances' => $ospf_instance_count, 'areas' => $ospf_area_count, 'ports' => $ospf_port_count, 'neighbours' => $ospf_neighbour_count); $ret = rrdtool_update("{$filename}", $fields); $tags = array(); influx_update($device, 'ospf-statistics', $tags, $fields); echo "\n";
foreach ($db_oids as $db_oid => $db_value) { $db_update[$db_value] = $serverfarm[$db_oid]; } $updated = dbUpdate($db_update, 'loadbalancer_rservers', '`rserver_id` = ?', $serverfarm['cesServerFarmRserverFailedConns']['farm_id']); } $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/rserver-' . $serverfarms[$clean_index]['rserver_id'] . '.rrd'; foreach ($oids as $oid) { $oid_ds = truncate(str_replace('cesServerFarm', '', $oid), 19, ''); $rrd_create .= " DS:{$oid_ds}:GAUGE:600:-1:100000000"; } $fields = array(); foreach ($oids as $oid) { if (is_numeric($serverfarm[$oid])) { $value = $serverfarm[$oid]; } else { $value = '0'; } $fields[$oid] = $value; } $rrd_create .= ' ' . $config['rrd_rra']; if (isset($serverfarms[$clean_index])) { if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } rrdtool_update($rrd_file, $fields); $tags = array('farm_id' => $clean_index); influx_update($device, 'rservers', $tags, $fields); } } //end foreach unset($oids, $oid, $serverfarm);
} $results = external_exec($config['ipmitool'] . ' -I ' . $ipmi['type'] . ' -c ' . $remote . ' sdr 2>/dev/null'); d_echo($results); echo " done.\n"; foreach (explode("\n", $results) as $row) { list($desc, $value, $type, $status) = explode(',', $row); $ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['value'] = $value; $ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['unit'] = $type; } foreach ($ipmi_rows as $ipmisensors) { echo 'Updating IPMI sensor ' . $ipmisensors['sensor_descr'] . '... '; $sensor = $ipmi_sensor[$ipmisensors['sensor_descr']][$ipmisensors['sensor_class']]['value']; $unit = $ipmi_sensor[$ipmisensors['sensor_descr']][$ipmisensors['sensor_class']]['unit']; $rrd_file = get_sensor_rrd($device, $ipmisensors); if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } if (!is_file($rrd_file)) { rrdtool_create($rrd_file, '--step 300 DS:sensor:GAUGE:600:-20000:20000 ' . $config['rrd_rra']); } echo $sensor . " {$unit}\n"; $fields = array('sensor' => $sensor); rrdtool_update($rrd_file, $fields); $tags = array('sensor_class' => $sensor['sensor_class'], 'sensor_type' => $sensor['sensor_type'], 'sensor_descr' => $sensor['sensor_descr'], 'sensor_index' => $sensor['sensor_index']); influx_update($device, 'ipmi', $tags, $fields); // FIXME warnings in event & mail not done here yet! dbUpdate(array('sensor_current' => $sensor, 'lastupdate' => array('NOW()')), 'sensors', 'poller_type = ? AND sensor_class = ? AND sensor_id = ?', array('ipmi', $ipmisensors['sensor_class'], $ipmisensors['sensor_id'])); } unset($ipmi_sensor); }
* Copyright (c) 2015 Aaron Daniels <*****@*****.**> * * 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. */ if ($device['os_group'] == "cisco") { // Total $total = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.7.1.0", NULL); $total = $total['1.3.6.1.4.1.9.9.86.1.7.1.0']['']; if (isset($total) && $total != "" && $total != 0) { // Available $available = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.7.2.0", NULL); $available = $available['1.3.6.1.4.1.9.9.86.1.7.2.0']['']; // Active $active = $total - $available; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cisco-iosxcode.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-iosxcode', $tags, $fields); $graphs['cisco-iosxcode'] = TRUE; echo " Cisco IOS Transcoder "; } unset($rrd_filename, $total, $active, $available); }
$rrd_create .= ' DS:OutDrops:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:InAuths:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:OutAuths:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:InAuthFails:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:OutAuthFails:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:InDencrypts:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:OutEncrypts:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:InDecryptFails:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:OutEncryptFails:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:ProtocolUseFails:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:NoSaFails:COUNTER:600:0:100000000000'; $rrd_create .= ' DS:SysCapFails:COUNTER:600:0:100000000000'; $rrd_create .= $config['rrd_rra']; if (is_file($rrd_filename) || $data['cipSecGlobalActiveTunnels']) { if (!file_exists($rrd_filename)) { rrdtool_create($rrd_filename, $rrd_create); } $fields = array('Tunnels' => $data['cipSecGlobalActiveTunnels'], 'InOctets' => $data['cipSecGlobalInOctets'], 'OutOctets' => $data['cipSecGlobalOutOctets'], 'InDecompOctets' => $data['cipSecGlobalInDecompOctets'], 'OutUncompOctets' => $data['cipSecGlobalOutUncompOctets'], 'InPkts' => $data['cipSecGlobalInPkts'], 'OutPkts' => $data['cipSecGlobalOutPkts'], 'InDrops' => $data['cipSecGlobalInDrops'], 'InReplayDrops' => $data['cipSecGlobalInReplayDrops'], 'OutDrops' => $data['cipSecGlobalOutDrops'], 'InAuths' => $data['cipSecGlobalInAuths'], 'OutAuths' => $data['cipSecGlobalOutAuths'], 'InAuthFails' => $data['cipSecGlobalInAuthFails'], 'OutAuthFails' => $data['cipSecGlobalOutAuthFails'], 'InDencrypts' => $data['cipSecGlobalInDecrypts'], 'OutEncrypts' => $data['cipSecGlobalOutEncrypts'], 'InDecryptFails' => $data['cipSecGlobalInDecryptFails'], 'OutEncryptFails' => $data['cipSecGlobalOutEncryptFails'], 'ProtocolUseFails' => $data['cipSecGlobalProtocolUseFails'], 'NoSaFails' => $data['cipSecGlobalNoSaFails'], 'SysCapFails' => $data['cipSecGlobalSysCapFails']); rrdtool_update($rrd_filename, $fields); $tags = array(); influx_update($device, 'cipsec_flow', $tags, $fields); $graphs['cipsec_flow_tunnels'] = true; $graphs['cipsec_flow_pkts'] = true; $graphs['cipsec_flow_bits'] = true; $graphs['cipsec_flow_stats'] = true; echo ' cipsec_flow'; } //end if unset($data, $rrd_filename, $rrd_create, $rrd_update); } //end if
* 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); }
if ($agentinfo['timed_out']) { echo 'Connection to UNIX agent timed out during fetch on port ' . $port . '.'; } } $agent_end = microtime(true); $agent_time = round(($agent_end - $agent_start) * 1000); if (!empty($agent_raw)) { echo 'execution time: ' . $agent_time . 'ms'; $agent_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/agent.rrd'; if (!is_file($agent_rrd)) { rrdtool_create($agent_rrd, 'DS:time:GAUGE:600:0:U ' . $config['rrd_rra']); } $fields = array('time' => $agent_time); rrdtool_update($agent_rrd, $fields); $tags = array(); influx_update($device, 'agent', $tags, $fields); $graphs['agent'] = true; foreach (explode('<<<', $agent_raw) as $section) { list($section, $data) = explode('>>>', $section); list($sa, $sb) = explode('-', $section, 2); $agentapps = array("apache", "ceph", "mysql", "nginx", "bind", "powerdns", "proxmox", "tinydns"); if (in_array($section, $agentapps)) { $agent_data['app'][$section] = trim($data); } if (!empty($sa) && !empty($sb)) { $agent_data[$sa][$sb] = trim($data); } else { $agent_data[$section] = trim($data); } } //end foreach
<?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);
DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 ' . $config['rrd_rra']); } //end if $fields = array('INOCTETS' => $this_port['ifInOctets'], 'OUTOCTETS' => $this_port['ifOutOctets'], 'INERRORS' => $this_port['ifInErrors'], 'OUTERRORS' => $this_port['ifOutErrors'], 'INUCASTPKTS' => $this_port['ifInUcastPkts'], 'OUTUCASTPKTS' => $this_port['ifOutUcastPkts'], 'INNUCASTPKTS' => $this_port['ifInNUcastPkts'], 'OUTNUCASTPKTS' => $this_port['ifOutNUcastPkts'], 'INDISCARDS' => $this_port['ifInDiscards'], 'OUTDISCARDS' => $this_port['ifOutDiscards'], 'INUNKNOWNPROTOS' => $this_port['ifInUnknownProtos'], 'INBROADCASTPKTS' => $this_port['ifInBroadcastPkts'], 'OUTBROADCASTPKTS' => $this_port['ifOutBroadcastPkts'], 'INMULTICASTPKTS' => $this_port['ifInMulticastPkts'], 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts']); if ($tune_port === true) { rrdtool_tune('port', $rrdfile, $this_port['ifSpeed']); } rrdtool_update("{$rrdfile}", $fields); $fields['ifInUcastPkts_rate'] = $port['ifInUcastPkts_rate']; $fields['ifOutUcastPkts_rate'] = $port['ifOutUcastPkts_rate']; $fields['ifInErrors_rate'] = $port['ifInErrors_rate']; $fields['ifOutErrors_rate'] = $port['ifOutErrors_rate']; $fields['ifInOctets_rate'] = $port['ifInOctets_rate']; $fields['ifOutOctets_rate'] = $port['ifOutOctets_rate']; $tags = array('ifName' => $port['ifName'], 'port_descr_type' => $port['port_descr_type']); influx_update($device, 'ports', $tags, $fields); // End Update IF-MIB // Update PAgP if ($this_port['pagpOperationMode'] || $port['pagpOperationMode']) { foreach ($pagp_oids as $oid) { // Loop the OIDs if ($this_port[$oid] != $port[$oid]) { // If data has changed, build a query $port['update'][$oid] = $this_port[$oid]; echo 'PAgP '; log_event("{$oid} -> " . $this_port[$oid], $device, 'interface', $port['port_id']); } } } // End Update PAgP // Do EtherLike-MIB