From 57650e4ffcff4abb13bb6eafa955af77f09c709b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 7 Jul 2016 01:33:43 -0500 Subject: [PATCH 01/67] Remove nfs requirement for distributed poller (with rrdtool 1.5+) Use data_update instead of rrd_update/rrd_create and influx_update Centralize rrd file check so we can check against a remote rrdcached server too Use rrd_name() to generate rrd file names --- doc/Support/Support-New-OS.md | 26 +- .../graphs/XXX_device_memory_windows.inc.php | 2 +- .../graphs/accesspoints/channel.inc.php | 2 +- .../graphs/accesspoints/interference.inc.php | 2 +- .../graphs/accesspoints/numasoclients.inc.php | 2 +- .../graphs/accesspoints/nummonbssid.inc.php | 2 +- .../graphs/accesspoints/nummonclients.inc.php | 2 +- .../graphs/accesspoints/radioutil.inc.php | 2 +- .../graphs/accesspoints/txpow.inc.php | 2 +- .../graphs/altiga_ssl_sessions.inc.php | 2 +- .../graphs/application/apache_bits.inc.php | 2 +- .../graphs/application/apache_cpu.inc.php | 2 +- .../graphs/application/apache_hits.inc.php | 2 +- .../application/apache_scoreboard.inc.php | 2 +- .../graphs/application/bind_queries.inc.php | 2 +- .../graphs/application/drbd_disk_bits.inc.php | 2 +- .../application/drbd_network_bits.inc.php | 2 +- .../graphs/application/drbd_queue.inc.php | 2 +- .../graphs/application/drbd_unsynced.inc.php | 2 +- .../application/mailscanner_reject.inc.php | 2 +- .../application/mailscanner_sent.inc.php | 2 +- .../application/mailscanner_spam.inc.php | 2 +- .../graphs/application/memcached.inc.php | 2 +- .../mysql_command_counters.inc.php | 2 +- .../application/mysql_connections.inc.php | 2 +- .../application/mysql_files_tables.inc.php | 2 +- .../mysql_innodb_buffer_pool.inc.php | 2 +- .../mysql_innodb_buffer_pool_activity.inc.php | 2 +- .../mysql_innodb_insert_buffer.inc.php | 2 +- .../application/mysql_innodb_io.inc.php | 2 +- .../mysql_innodb_io_pending.inc.php | 2 +- .../application/mysql_innodb_log.inc.php | 2 +- .../mysql_innodb_row_operations.inc.php | 2 +- .../mysql_innodb_semaphores.inc.php | 2 +- .../mysql_innodb_transactions.inc.php | 2 +- .../application/mysql_myisam_indexes.inc.php | 2 +- .../application/mysql_network_traffic.inc.php | 2 +- .../application/mysql_query_cache.inc.php | 2 +- .../mysql_query_cache_memory.inc.php | 2 +- .../application/mysql_select_types.inc.php | 2 +- .../application/mysql_slow_queries.inc.php | 2 +- .../graphs/application/mysql_sorts.inc.php | 2 +- .../graphs/application/mysql_status.inc.php | 2 +- .../application/mysql_table_locks.inc.php | 2 +- .../mysql_temporary_objects.inc.php | 2 +- .../application/nginx_connections.inc.php | 2 +- .../graphs/application/nginx_req.inc.php | 2 +- .../graphs/application/ntpclient_freq.inc.php | 2 +- .../application/ntpclient_stats.inc.php | 2 +- .../application/ntpdserver_bits.inc.php | 2 +- .../application/ntpdserver_buffer.inc.php | 2 +- .../application/ntpdserver_freq.inc.php | 2 +- .../application/ntpdserver_packets.inc.php | 2 +- .../application/ntpdserver_stats.inc.php | 2 +- .../application/ntpdserver_stratum.inc.php | 2 +- .../application/ntpdserver_uptime.inc.php | 2 +- .../graphs/application/powerdns_fail.inc.php | 2 +- .../application/powerdns_latency.inc.php | 2 +- .../application/powerdns_packetcache.inc.php | 2 +- .../application/powerdns_queries.inc.php | 2 +- .../application/powerdns_queries_udp.inc.php | 2 +- .../application/powerdns_querycache.inc.php | 2 +- .../application/powerdns_recursing.inc.php | 2 +- .../application/proxmox_traffic.inc.php | 2 +- .../graphs/application/shoutcast_bits.inc.php | 5 +- .../application/shoutcast_multi_bits.inc.php | 35 +-- .../application/shoutcast_multi_stats.inc.php | 34 +-- .../application/shoutcast_stats.inc.php | 3 +- .../graphs/application/tinydns_dnssec.inc.php | 2 +- .../graphs/application/tinydns_errors.inc.php | 2 +- .../graphs/application/tinydns_other.inc.php | 2 +- .../application/tinydns_queries.inc.php | 2 +- html/includes/graphs/atmvp/auth.inc.php | 2 +- .../graphs/bgp/prefixes_ipv4multicast.inc.php | 2 +- .../graphs/bgp/prefixes_ipv4unicast.inc.php | 2 +- .../graphs/bgp/prefixes_ipv4vpn.inc.php | 2 +- .../graphs/bgp/prefixes_ipv6multicast.inc.php | 2 +- .../graphs/bgp/prefixes_ipv6unicast.inc.php | 2 +- .../graphs/bgp/prefixes_ipv6vpn.inc.php | 2 +- html/includes/graphs/bgp/updates.inc.php | 2 +- html/includes/graphs/c6kxbar/auth.inc.php | 2 +- .../includes/graphs/cefswitching/auth.inc.php | 2 +- html/includes/graphs/device/agent.inc.php | 2 +- .../device/arubacontroller_numaps.inc.php | 2 +- .../device/arubacontroller_numclients.inc.php | 2 +- html/includes/graphs/device/asa_conns.inc.php | 2 +- .../device/cambium_250_dataRate.inc.php | 2 +- .../device/cambium_250_modulationMode.inc.php | 2 +- .../device/cambium_250_receivePower.inc.php | 2 +- .../graphs/device/cambium_250_ssr.inc.php | 2 +- .../device/cambium_250_transmitPower.inc.php | 2 +- .../device/cambium_650_dataRate.inc.php | 2 +- .../graphs/device/cambium_650_gps.inc.php | 2 +- .../device/cambium_650_modulationMode.inc.php | 2 +- .../cambium_650_rawReceivePower.inc.php | 2 +- .../graphs/device/cambium_650_ssr.inc.php | 2 +- .../device/cambium_650_transmitPower.inc.php | 2 +- .../device/cambium_epmp_RFStatus.inc.php | 2 +- .../graphs/device/cambium_epmp_access.inc.php | 2 +- .../graphs/device/cambium_epmp_freq.inc.php | 2 +- .../graphs/device/cambium_epmp_gps.inc.php | 2 +- .../device/cambium_epmp_gpsSync.inc.php | 2 +- .../device/cambium_epmp_modulation.inc.php | 2 +- .../device/cambium_epmp_registeredSM.inc.php | 2 +- .../canopy_generic_450_linkRadioDbm.inc.php | 2 +- .../canopy_generic_450_masterSSR.inc.php | 2 +- .../canopy_generic_450_powerlevel.inc.php | 2 +- .../device/canopy_generic_450_ptpSNR.inc.php | 2 +- .../device/canopy_generic_450_slaveHV.inc.php | 2 +- .../canopy_generic_450_slaveSNR.inc.php | 2 +- .../canopy_generic_450_slaveSSR.inc.php | 2 +- .../device/canopy_generic_crcErrors.inc.php | 2 +- .../device/canopy_generic_errorCount.inc.php | 2 +- .../graphs/device/canopy_generic_freq.inc.php | 2 +- .../device/canopy_generic_gpsStats.inc.php | 2 +- .../device/canopy_generic_jitter.inc.php | 2 +- .../device/canopy_generic_radioDbm.inc.php | 2 +- .../device/canopy_generic_regCount.inc.php | 2 +- .../graphs/device/canopy_generic_rssi.inc.php | 2 +- .../device/canopy_generic_signalHV.inc.php | 2 +- .../device/canopy_generic_snrHV.inc.php | 2 +- .../canopy_generic_whispGPSStats.inc.php | 2 +- .../graphs/device/cipsec_flow_bits.inc.php | 2 +- .../graphs/device/cipsec_flow_pkts.inc.php | 2 +- .../graphs/device/cipsec_flow_stats.inc.php | 2 +- .../graphs/device/cipsec_flow_tunnels.inc.php | 2 +- .../graphs/device/cisco-iosdsp.inc.php | 2 +- .../graphs/device/cisco-iosmtp.inc.php | 2 +- .../graphs/device/cisco-iospri.inc.php | 2 +- .../graphs/device/cisco-iosxcode.inc.php | 2 +- .../graphs/device/cisco-otv-mac.inc.php | 2 +- .../graphs/device/cisco-otv-vlan.inc.php | 2 +- .../graphs/device/cisco_wwan_mnc.inc.php | 2 +- .../graphs/device/cisco_wwan_rssi.inc.php | 2 +- .../graphs/device/ciscowlc_numaps.inc.php | 2 +- .../graphs/device/ciscowlc_numclients.inc.php | 2 +- .../graphs/device/cras_sessions.inc.php | 2 +- .../graphs/device/diskio_common.inc.php | 2 +- html/includes/graphs/device/fdb_count.inc.php | 2 +- .../graphs/device/fortigate_cpu.inc.php | 2 +- .../graphs/device/fortigate_sessions.inc.php | 2 +- .../graphs/device/hr_processes.inc.php | 2 +- html/includes/graphs/device/hr_users.inc.php | 2 +- .../graphs/device/ib_dhcp_messages.inc.php | 2 +- .../graphs/device/ib_dns_dyn_updates.inc.php | 2 +- .../graphs/device/ib_dns_performance.inc.php | 2 +- .../ib_dns_request_return_codes.inc.php | 2 +- .../graphs/device/ipSystemStats.inc.php | 4 +- .../graphs/device/ipsystemstats_ipv4.inc.php | 2 +- .../device/ipsystemstats_ipv4_frag.inc.php | 2 +- .../graphs/device/ipsystemstats_ipv6.inc.php | 2 +- .../device/ipsystemstats_ipv6_frag.inc.php | 2 +- html/includes/graphs/device/mempool.inc.php | 2 +- .../graphs/device/netscaler_tcp_bits.inc.php | 2 +- .../graphs/device/netscaler_tcp_conn.inc.php | 2 +- .../graphs/device/netscaler_tcp_pkts.inc.php | 2 +- .../graphs/device/netstat_icmp.inc.php | 2 +- .../graphs/device/netstat_icmp_info.inc.php | 2 +- .../includes/graphs/device/netstat_ip.inc.php | 2 +- .../graphs/device/netstat_ip_forward.inc.php | 2 +- .../graphs/device/netstat_ip_frag.inc.php | 2 +- .../graphs/device/netstat_snmp.inc.php | 2 +- .../graphs/device/netstat_snmp_pkt.inc.php | 2 +- .../graphs/device/netstat_tcp.inc.php | 2 +- .../graphs/device/netstat_udp.inc.php | 2 +- .../graphs/device/panos_sessions.inc.php | 2 +- html/includes/graphs/device/ping_perf.inc.php | 2 +- .../graphs/device/poller_perf.inc.php | 2 +- .../graphs/device/processor_separate.inc.php | 2 +- .../graphs/device/processor_stack.inc.php | 2 +- .../graphs/device/pulse_sessions.inc.php | 2 +- .../graphs/device/pulse_users.inc.php | 2 +- .../graphs/device/screenos_sessions.inc.php | 2 +- html/includes/graphs/device/service.inc.php | 3 +- .../graphs/device/siklu_rfAverageCinr.inc.php | 2 +- .../graphs/device/siklu_rfAverageRssi.inc.php | 2 +- .../siklu_rfOperationalFrequency.inc.php | 2 +- .../device/siklu_rfinterfaceOctets.inc.php | 2 +- .../siklu_rfinterfaceOtherOctets.inc.php | 2 +- .../device/siklu_rfinterfaceOtherPkts.inc.php | 2 +- .../device/siklu_rfinterfacePkts.inc.php | 2 +- html/includes/graphs/device/sla.inc.php | 2 +- html/includes/graphs/device/storage.inc.php | 2 +- .../device/sub10_sub10RadioLclAFER.inc.php | 2 +- .../sub10_sub10RadioLclDataRate.inc.php | 2 +- .../device/sub10_sub10RadioLclLnkLoss.inc.php | 2 +- .../device/sub10_sub10RadioLclRxPower.inc.php | 2 +- .../device/sub10_sub10RadioLclTxPower.inc.php | 2 +- .../device/sub10_sub10RadioLclVectErr.inc.php | 2 +- html/includes/graphs/device/toner.inc.php | 2 +- .../device/ubnt_airfiber_Capacity.inc.php | 2 +- .../device/ubnt_airfiber_LinkDist.inc.php | 2 +- .../ubnt_airfiber_RFTotOctetsRx.inc.php | 2 +- .../ubnt_airfiber_RFTotOctetsTx.inc.php | 2 +- .../device/ubnt_airfiber_RFTotPktsRx.inc.php | 2 +- .../device/ubnt_airfiber_RFTotPktsTx.inc.php | 2 +- .../device/ubnt_airfiber_RadioFreqs.inc.php | 2 +- .../device/ubnt_airfiber_RadioTemp.inc.php | 2 +- .../device/ubnt_airfiber_TxPower.inc.php | 2 +- .../device/ubnt_airmax_AirMaxCapacity.inc.php | 2 +- .../device/ubnt_airmax_AirMaxQuality.inc.php | 2 +- .../device/ubnt_airmax_RadioDistance.inc.php | 2 +- .../device/ubnt_airmax_RadioFreq.inc.php | 2 +- .../device/ubnt_airmax_RadioRssi_0.inc.php | 2 +- .../device/ubnt_airmax_RadioRssi_1.inc.php | 2 +- .../device/ubnt_airmax_RadioTxPower.inc.php | 2 +- .../device/ubnt_airmax_WlStatCcq.inc.php | 2 +- .../ubnt_airmax_WlStatNoiseFloor.inc.php | 2 +- .../device/ubnt_airmax_WlStatRssi.inc.php | 2 +- .../device/ubnt_airmax_WlStatRxRate.inc.php | 2 +- .../device/ubnt_airmax_WlStatSignal.inc.php | 2 +- .../device/ubnt_airmax_WlStatStaCount.inc.php | 2 +- .../device/ubnt_airmax_WlStatTxRate.inc.php | 2 +- .../graphs/device/ucd_contexts.inc.php | 2 +- html/includes/graphs/device/ucd_cpu.inc.php | 2 +- .../graphs/device/ucd_interrupts.inc.php | 2 +- html/includes/graphs/device/ucd_io.inc.php | 4 +- html/includes/graphs/device/ucd_load.inc.php | 2 +- .../includes/graphs/device/ucd_memory.inc.php | 2 +- .../graphs/device/ucd_swap_io.inc.php | 4 +- html/includes/graphs/device/uptime.inc.php | 2 +- .../graphs/device/vpdn_sessions_l2tp.inc.php | 2 +- .../graphs/device/vpdn_tunnels_l2tp.inc.php | 2 +- .../graphs/device/wifi_clients.inc.php | 4 +- .../graphs/device/xirrus_dataRates.inc.php | 2 +- .../graphs/device/xirrus_noiseFloor.inc.php | 2 +- .../graphs/device/xirrus_rssi.inc.php | 2 +- .../graphs/device/xirrus_stations.inc.php | 2 +- html/includes/graphs/diskio/auth.inc.php | 2 +- .../graphs/global/processor_separate.inc.php | 2 +- .../graphs/global/processor_stack.inc.php | 2 +- html/includes/graphs/ipsectunnel/auth.inc.php | 2 +- .../graphs/macaccounting/auth.inc.php | 7 +- html/includes/graphs/mempool/auth.inc.php | 2 +- html/includes/graphs/munin/auth.inc.php | 1 - html/includes/graphs/munin/graph.inc.php | 2 +- .../graphs/netscalervsvr/auth.inc.php | 2 +- .../graphs/port/cbqos_bufferdrops.inc.php | 2 +- .../graphs/port/cbqos_qosdrops.inc.php | 2 +- .../graphs/port/cbqos_traffic.inc.php | 2 +- .../graphs/port/mac_acc_total.inc.php | 2 +- html/includes/graphs/processor/auth.inc.php | 2 +- html/includes/graphs/rserver/auth.inc.php | 2 +- .../includes/graphs/screenos_sessions.inc.php | 2 +- html/includes/graphs/sensor/auth.inc.php | 2 - html/includes/graphs/service/auth.inc.php | 2 +- html/includes/graphs/storage/auth.inc.php | 2 +- html/includes/graphs/toner/auth.inc.php | 2 +- html/includes/graphs/vserver/auth.inc.php | 2 +- html/pages/device/apps/ceph.inc.php | 8 +- html/pages/device/apps/shoutcast.inc.php | 19 +- html/pages/device/graphs/ipSytemStats.inc.php | 4 +- html/pages/device/graphs/memory.inc.php | 2 +- .../device/graphs/netstats_icmp_stat.inc.php | 2 +- html/pages/device/graphs/netstats_ip.inc.php | 2 +- .../device/graphs/netstats_ip_forward.inc.php | 2 +- html/pages/device/graphs/netstats_tcp.inc.php | 2 +- html/pages/device/graphs/netstats_udp.inc.php | 2 +- html/pages/device/graphs/screenos.inc.php | 2 +- html/pages/device/graphs/wireless.inc.php | 2 +- html/pages/device/routing/bgp.inc.php | 2 +- html/pages/routing/bgp.inc.php | 2 +- includes/common.php | 25 +- includes/datastore.inc.php | 12 +- includes/discovery/ports.inc.php | 14 +- .../discovery/processors/hrdevice.inc.php | 12 +- includes/discovery/processors/ios.inc.php | 13 +- includes/discovery/storage/hrstorage.inc.php | 9 +- includes/functions.php | 6 +- includes/polling/applications/apache.inc.php | 63 ++-- includes/polling/applications/bind.inc.php | 64 ++--- includes/polling/applications/ceph.inc.php | 80 +++--- includes/polling/applications/drbd.inc.php | 44 ++- .../polling/applications/mailscanner.inc.php | 49 ++-- .../polling/applications/memcached.inc.php | 58 ++-- includes/polling/applications/mysql.inc.php | 208 +++++++------- includes/polling/applications/nginx.inc.php | 53 ++-- .../polling/applications/ntp-client.inc.php | 41 ++- .../polling/applications/ntpd-server.inc.php | 48 ++-- .../polling/applications/powerdns.inc.php | 112 ++++---- includes/polling/applications/proxmox.inc.php | 41 +-- .../polling/applications/rrdcached.inc.php | 50 ++-- .../polling/applications/shoutcast.inc.php | 64 ++--- includes/polling/applications/tinydns.inc.php | 60 ++-- includes/polling/aruba-controller.inc.php | 63 ++-- includes/polling/bgp-peers.inc.php | 55 ++-- includes/polling/cipsec-tunnels.inc.php | 19 +- .../polling/cisco-ace-loadbalancer.inc.php | 31 +- .../polling/cisco-ace-serverfarms.inc.php | 22 +- includes/polling/cisco-asa-firewall.inc.php | 20 +- includes/polling/cisco-cbqos.inc.php | 30 +- includes/polling/cisco-cef.inc.php | 35 +-- .../polling/cisco-ipsec-flow-monitor.inc.php | 59 ++-- includes/polling/cisco-mac-accounting.inc.php | 23 +- includes/polling/cisco-otv.inc.php | 43 ++- .../cisco-remote-access-monitor.inc.php | 31 +- includes/polling/cisco-sla.inc.php | 25 +- .../polling/cisco-voice/cisco-iosdsp.inc.php | 16 +- .../polling/cisco-voice/cisco-iosmtp.inc.php | 16 +- .../polling/cisco-voice/cisco-iospri.inc.php | 17 +- .../cisco-voice/cisco-iosxcode.inc.php | 16 +- includes/polling/cisco-vpdn.inc.php | 18 +- includes/polling/entity-physical.inc.php | 31 +- includes/polling/functions.inc.php | 48 ++-- includes/polling/hr-mib.inc.php | 34 +-- includes/polling/ipSystemStats.inc.php | 68 ++--- includes/polling/ipmi.inc.php | 30 +- includes/polling/junose-atm-vp.inc.php | 43 ++- includes/polling/mempools.inc.php | 23 +- includes/polling/netscaler-stats.inc.php | 38 +-- includes/polling/netscaler-vsvr.inc.php | 32 +-- includes/polling/netstats-icmp.inc.php | 34 +-- includes/polling/netstats-ip.inc.php | 23 +- includes/polling/netstats-ip_forward.inc.php | 24 +- includes/polling/netstats-snmp.inc.php | 30 +- includes/polling/netstats-tcp.inc.php | 24 +- includes/polling/netstats-udp.inc.php | 22 +- includes/polling/os/ciscowlc.inc.php | 30 +- includes/polling/os/fortigate.inc.php | 26 +- includes/polling/os/nios.inc.php | 156 ++++------ includes/polling/os/panos.inc.php | 11 +- includes/polling/os/procurve.inc.php | 16 +- includes/polling/os/pulse.inc.php | 16 +- includes/polling/os/screenos.inc.php | 21 +- includes/polling/os/snom.inc.php | 27 +- includes/polling/ospf.inc.php | 23 +- includes/polling/port-adsl.inc.php | 63 ++-- includes/polling/port-etherlike.inc.php | 28 +- includes/polling/port-poe.inc.php | 25 +- includes/polling/ports.inc.php | 62 ++-- includes/polling/processors.inc.php | 22 +- includes/polling/storage.inc.php | 24 +- includes/polling/ucd-mib.inc.php | 92 +++--- .../polling/unix-agent/munin-plugins.inc.php | 33 +-- includes/polling/wireless/cambium-250.inc.php | 72 ++--- includes/polling/wireless/cambium-650.inc.php | 73 +++-- .../polling/wireless/cambium-epmp.inc.php | 69 +++-- .../polling/wireless/cambium-generic.inc.php | 166 ++++++----- .../polling/wireless/canopy-generic.inc.php | 268 +++++++++--------- includes/polling/wireless/cisco-wwan.inc.php | 24 +- includes/polling/wireless/xirrus.inc.php | 47 +-- includes/rrdtool.inc.php | 69 +++-- includes/services.inc.php | 45 +-- includes/snom-graphing.php | 58 ---- 344 files changed, 1920 insertions(+), 2470 deletions(-) delete mode 100644 includes/snom-graphing.php diff --git a/doc/Support/Support-New-OS.md b/doc/Support/Support-New-OS.md index be2bec7c96..c7f2b2840e 100644 --- a/doc/Support/Support-New-OS.md +++ b/doc/Support/Support-New-OS.md @@ -300,25 +300,29 @@ $version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-M $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"); + $rrd_def = 'DS:users:GAUGE:600:0:U'; + $fields = array( + 'users' => $users + ) + $tags = compact('rrd_def'); + data_update($device, 'pulse_users', $tags, $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']); + $rrd_def = array( + 'DS:sessions:GAUGE:600:0:U' } - rrdtool_update($sessrrd, "N:$sessions"); + $fields = array( + 'sessions' => $sessions + ); + $tags = compact('rrd_def'); + data_update($device, 'pulse_sessions', $tags, $fields); $graphs['pulse_sessions'] = true; } ``` @@ -353,7 +357,7 @@ html/includes/graphs/device/pulse_sessions.inc.php ```php array( diff --git a/html/includes/graphs/application/bind_queries.inc.php b/html/includes/graphs/application/bind_queries.inc.php index 3df1abf45a..94625bef2d 100644 --- a/html/includes/graphs/application/bind_queries.inc.php +++ b/html/includes/graphs/application/bind_queries.inc.php @@ -30,7 +30,7 @@ $i = 0; $scale_min = 0; $nototal = 1; $unit_text = 'Query/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-bind-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'bind', $app['app_id'])); $array = array( 'any', 'a', diff --git a/html/includes/graphs/application/drbd_disk_bits.inc.php b/html/includes/graphs/application/drbd_disk_bits.inc.php index d3458c72a6..bc9961f51e 100644 --- a/html/includes/graphs/application/drbd_disk_bits.inc.php +++ b/html/includes/graphs/application/drbd_disk_bits.inc.php @@ -4,7 +4,7 @@ $scale_min = 0; require 'includes/graphs/common.inc.php'; -$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; +$drbd_rrd = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); if (is_file($drbd_rrd)) { $rrd_filename = $drbd_rrd; diff --git a/html/includes/graphs/application/drbd_network_bits.inc.php b/html/includes/graphs/application/drbd_network_bits.inc.php index d20c1b3043..ebd6bce27f 100644 --- a/html/includes/graphs/application/drbd_network_bits.inc.php +++ b/html/includes/graphs/application/drbd_network_bits.inc.php @@ -4,7 +4,7 @@ $scale_min = 0; require 'includes/graphs/common.inc.php'; -$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; +$drbd_rrd = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); if (is_file($drbd_rrd)) { $rrd_filename = $drbd_rrd; diff --git a/html/includes/graphs/application/drbd_queue.inc.php b/html/includes/graphs/application/drbd_queue.inc.php index a04a4080b6..50237b4a12 100644 --- a/html/includes/graphs/application/drbd_queue.inc.php +++ b/html/includes/graphs/application/drbd_queue.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); $array = array( 'lo' => 'Local I/O', diff --git a/html/includes/graphs/application/drbd_unsynced.inc.php b/html/includes/graphs/application/drbd_unsynced.inc.php index f2a551ba8c..dd16019c22 100644 --- a/html/includes/graphs/application/drbd_unsynced.inc.php +++ b/html/includes/graphs/application/drbd_unsynced.inc.php @@ -4,7 +4,7 @@ $scale_min = 0; require 'includes/graphs/common.inc.php'; -$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; +$drbd_rrd = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); if (is_file($drbd_rrd)) { $rrd_filename = $drbd_rrd; diff --git a/html/includes/graphs/application/mailscanner_reject.inc.php b/html/includes/graphs/application/mailscanner_reject.inc.php index 9298460db4..4ab82707fa 100644 --- a/html/includes/graphs/application/mailscanner_reject.inc.php +++ b/html/includes/graphs/application/mailscanner_reject.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'mixed'; $nototal = (($width < 550) ? 1 : 0); $unit_text = 'Messages/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mailscannerV2-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mailscannerV2', $app['app_id'])); $array = array( 'msg_rejected' => array('descr' => 'Rejected'), 'msg_relay' => array('descr' => 'Relayed'), diff --git a/html/includes/graphs/application/mailscanner_sent.inc.php b/html/includes/graphs/application/mailscanner_sent.inc.php index f9cb4c4a67..2a19397357 100644 --- a/html/includes/graphs/application/mailscanner_sent.inc.php +++ b/html/includes/graphs/application/mailscanner_sent.inc.php @@ -15,7 +15,7 @@ $colour_area_out = 'CECEFF66'; $colour_area_in_max = 'CC88CC'; $colour_area_out_max = 'FFEFAA'; -$mailscanner_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mailscannerV2-'.$app['app_id'].'.rrd'; +$mailscanner_rrd = rrd_name($device['hostname'], array('app', 'mailscannerV2', $app['app_id'])); if (is_file($mailscanner_rrd)) { $rrd_filename = $mailscanner_rrd; diff --git a/html/includes/graphs/application/mailscanner_spam.inc.php b/html/includes/graphs/application/mailscanner_spam.inc.php index f68b5200b7..bb805addf2 100644 --- a/html/includes/graphs/application/mailscanner_spam.inc.php +++ b/html/includes/graphs/application/mailscanner_spam.inc.php @@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php'; $scale_min = 0; $nototal = (($width < 550) ? 1 : 0); $unit_text = 'Messages/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mailscannerV2-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mailscannerV2', $app['app_id'])); $array = array( 'spam' => array( 'descr' => 'Spam', diff --git a/html/includes/graphs/application/memcached.inc.php b/html/includes/graphs/application/memcached.inc.php index 6bd8d58824..5bd7e7bb27 100644 --- a/html/includes/graphs/application/memcached.inc.php +++ b/html/includes/graphs/application/memcached.inc.php @@ -1,5 +1,5 @@ array( diff --git a/html/includes/graphs/application/mysql_connections.inc.php b/html/includes/graphs/application/mysql_connections.inc.php index d8024a9ed4..b74234a676 100644 --- a/html/includes/graphs/application/mysql_connections.inc.php +++ b/html/includes/graphs/application/mysql_connections.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'MaCs' => array( diff --git a/html/includes/graphs/application/mysql_files_tables.inc.php b/html/includes/graphs/application/mysql_files_tables.inc.php index f02593e607..40cc28578d 100644 --- a/html/includes/graphs/application/mysql_files_tables.inc.php +++ b/html/includes/graphs/application/mysql_files_tables.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'TOC' => array('descr' => 'Table Cache'), diff --git a/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php b/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php index 6f9255ffac..5b1478e9d7 100644 --- a/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php +++ b/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'IBPse' => 'Buffer Pool Size', diff --git a/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php b/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php index e2e3f84418..ba6bc1af5e 100644 --- a/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php +++ b/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'IBRd' => 'Pages Read', diff --git a/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php b/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php index 9cbde97ff6..51256965e5 100644 --- a/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php +++ b/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'IBIIs' => 'Inserts', diff --git a/html/includes/graphs/application/mysql_innodb_io.inc.php b/html/includes/graphs/application/mysql_innodb_io.inc.php index 0140303705..5f2ca64c58 100644 --- a/html/includes/graphs/application/mysql_innodb_io.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$mysql_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); if (is_file($mysql_rrd)) { $rrd_filename = $mysql_rrd; diff --git a/html/includes/graphs/application/mysql_innodb_io_pending.inc.php b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php index 7b578e0522..3cd0d7f325 100644 --- a/html/includes/graphs/application/mysql_innodb_io_pending.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'IBILog' => 'AIO Log', diff --git a/html/includes/graphs/application/mysql_innodb_log.inc.php b/html/includes/graphs/application/mysql_innodb_log.inc.php index b68890b844..ade5e47f4a 100644 --- a/html/includes/graphs/application/mysql_innodb_log.inc.php +++ b/html/includes/graphs/application/mysql_innodb_log.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$mysql_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); if (is_file($mysql_rrd)) { $rrd_filename = $mysql_rrd; diff --git a/html/includes/graphs/application/mysql_innodb_row_operations.inc.php b/html/includes/graphs/application/mysql_innodb_row_operations.inc.php index f3b74a58b4..c5ab9cda44 100644 --- a/html/includes/graphs/application/mysql_innodb_row_operations.inc.php +++ b/html/includes/graphs/application/mysql_innodb_row_operations.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'IDBRDd' => 'Deletes', diff --git a/html/includes/graphs/application/mysql_innodb_semaphores.inc.php b/html/includes/graphs/application/mysql_innodb_semaphores.inc.php index 4b259ed7a4..8a27ef1bc9 100644 --- a/html/includes/graphs/application/mysql_innodb_semaphores.inc.php +++ b/html/includes/graphs/application/mysql_innodb_semaphores.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'IBSRs' => 'Spin Rounds', diff --git a/html/includes/graphs/application/mysql_innodb_transactions.inc.php b/html/includes/graphs/application/mysql_innodb_transactions.inc.php index 87e64f73e7..04cde3a191 100644 --- a/html/includes/graphs/application/mysql_innodb_transactions.inc.php +++ b/html/includes/graphs/application/mysql_innodb_transactions.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array('IBTNx' => 'Transactions created'); diff --git a/html/includes/graphs/application/mysql_myisam_indexes.inc.php b/html/includes/graphs/application/mysql_myisam_indexes.inc.php index a4d8a36e33..c95b316dbc 100644 --- a/html/includes/graphs/application/mysql_myisam_indexes.inc.php +++ b/html/includes/graphs/application/mysql_myisam_indexes.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'KRRs' => 'read requests', diff --git a/html/includes/graphs/application/mysql_network_traffic.inc.php b/html/includes/graphs/application/mysql_network_traffic.inc.php index c37372eeea..afabd03cac 100644 --- a/html/includes/graphs/application/mysql_network_traffic.inc.php +++ b/html/includes/graphs/application/mysql_network_traffic.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$mysql_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); if (is_file($mysql_rrd)) { $rrd_filename = $mysql_rrd; diff --git a/html/includes/graphs/application/mysql_query_cache.inc.php b/html/includes/graphs/application/mysql_query_cache.inc.php index 1de0634367..c1b76eeb36 100644 --- a/html/includes/graphs/application/mysql_query_cache.inc.php +++ b/html/includes/graphs/application/mysql_query_cache.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$mysql_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$mysql_rrd = rrd_name($device['hostname'], array('app', mysql, $app['app_id'])); if (is_file($mysql_rrd)) { $rrd_filename = $mysql_rrd; diff --git a/html/includes/graphs/application/mysql_query_cache_memory.inc.php b/html/includes/graphs/application/mysql_query_cache_memory.inc.php index f4dcf4737e..6343ed214d 100644 --- a/html/includes/graphs/application/mysql_query_cache_memory.inc.php +++ b/html/includes/graphs/application/mysql_query_cache_memory.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'QCs' => 'Cache size', diff --git a/html/includes/graphs/application/mysql_select_types.inc.php b/html/includes/graphs/application/mysql_select_types.inc.php index 77f15948fe..e7d81dab0b 100644 --- a/html/includes/graphs/application/mysql_select_types.inc.php +++ b/html/includes/graphs/application/mysql_select_types.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'SFJn' => 'Full Join', diff --git a/html/includes/graphs/application/mysql_slow_queries.inc.php b/html/includes/graphs/application/mysql_slow_queries.inc.php index c8304c678b..a70a28a369 100644 --- a/html/includes/graphs/application/mysql_slow_queries.inc.php +++ b/html/includes/graphs/application/mysql_slow_queries.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array('SQs' => 'Slow queries'); diff --git a/html/includes/graphs/application/mysql_sorts.inc.php b/html/includes/graphs/application/mysql_sorts.inc.php index 15396df980..c2df2b06a7 100644 --- a/html/includes/graphs/application/mysql_sorts.inc.php +++ b/html/includes/graphs/application/mysql_sorts.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'SRows' => 'Rows Sorted', diff --git a/html/includes/graphs/application/mysql_status.inc.php b/html/includes/graphs/application/mysql_status.inc.php index 9e8b1fa06f..f74364d698 100644 --- a/html/includes/graphs/application/mysql_status.inc.php +++ b/html/includes/graphs/application/mysql_status.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'-status.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'], 'status')); $array = array( 'State_closing_tables' => 'd2', diff --git a/html/includes/graphs/application/mysql_table_locks.inc.php b/html/includes/graphs/application/mysql_table_locks.inc.php index 7a7b0ed0a5..f2b7a7a136 100644 --- a/html/includes/graphs/application/mysql_table_locks.inc.php +++ b/html/includes/graphs/application/mysql_table_locks.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'TLIe' => 'immed', diff --git a/html/includes/graphs/application/mysql_temporary_objects.inc.php b/html/includes/graphs/application/mysql_temporary_objects.inc.php index 149ec713eb..fc1ef90f40 100644 --- a/html/includes/graphs/application/mysql_temporary_objects.inc.php +++ b/html/includes/graphs/application/mysql_temporary_objects.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( 'CTMPDTs' => 'disk tables', diff --git a/html/includes/graphs/application/nginx_connections.inc.php b/html/includes/graphs/application/nginx_connections.inc.php index 44e2e3a5d9..1339ec64f7 100644 --- a/html/includes/graphs/application/nginx_connections.inc.php +++ b/html/includes/graphs/application/nginx_connections.inc.php @@ -4,7 +4,7 @@ $scale_min = 0; require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nginx-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'nginx', $app['app_id'])); $array = array( 'Reading' => array( diff --git a/html/includes/graphs/application/nginx_req.inc.php b/html/includes/graphs/application/nginx_req.inc.php index 97bff73aef..7d3761380a 100644 --- a/html/includes/graphs/application/nginx_req.inc.php +++ b/html/includes/graphs/application/nginx_req.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nginx-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'nginx', $app['app_id'])); if (is_file($rrd_filename)) { $rrd_options .= ' -b 1000 '; diff --git a/html/includes/graphs/application/ntpclient_freq.inc.php b/html/includes/graphs/application/ntpclient_freq.inc.php index 36d580a507..180dbc3c62 100644 --- a/html/includes/graphs/application/ntpclient_freq.inc.php +++ b/html/includes/graphs/application/ntpclient_freq.inc.php @@ -9,7 +9,7 @@ $colour_line = 'B3D0DB'; $colour_area_max = 'FFEE99'; $graph_max = 100; $unit_text = 'Frequency'; -$ntpclient_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpclient-'.$app['app_id'].'.rrd'; +$ntpclient_rrd = rrd_name($device['hostname'], array('app', 'ntpclient', $app['app_id'])); if (is_file($ntpclient_rrd)) { $rrd_filename = $ntpclient_rrd; diff --git a/html/includes/graphs/application/ntpclient_stats.inc.php b/html/includes/graphs/application/ntpclient_stats.inc.php index b7c6680544..6118f75cd9 100644 --- a/html/includes/graphs/application/ntpclient_stats.inc.php +++ b/html/includes/graphs/application/ntpclient_stats.inc.php @@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php'; $colours = 'mixed'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Milliseconds'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpclient-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpclient', $app['app_id'])); $array = array( 'offset' => array('descr' => 'Offset'), 'jitter' => array('descr' => 'Jitter'), diff --git a/html/includes/graphs/application/ntpdserver_bits.inc.php b/html/includes/graphs/application/ntpdserver_bits.inc.php index b96f3c5a57..9b7996d7ab 100644 --- a/html/includes/graphs/application/ntpdserver_bits.inc.php +++ b/html/includes/graphs/application/ntpdserver_bits.inc.php @@ -20,7 +20,7 @@ $colour_area_out = 'FFDD88'; $colour_area_in_max = 'CC88CC'; $colour_area_out_max = 'FFEFAA'; -$ntpdserver_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); if (is_file($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; diff --git a/html/includes/graphs/application/ntpdserver_buffer.inc.php b/html/includes/graphs/application/ntpdserver_buffer.inc.php index 3e47555f94..7e10be0bda 100644 --- a/html/includes/graphs/application/ntpdserver_buffer.inc.php +++ b/html/includes/graphs/application/ntpdserver_buffer.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'mixed'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Buffer'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); $array = array( 'buffer_recv' => array('descr' => 'Received'), 'buffer_used' => array('descr' => 'Used'), diff --git a/html/includes/graphs/application/ntpdserver_freq.inc.php b/html/includes/graphs/application/ntpdserver_freq.inc.php index 13f64c2950..ac141364a8 100644 --- a/html/includes/graphs/application/ntpdserver_freq.inc.php +++ b/html/includes/graphs/application/ntpdserver_freq.inc.php @@ -9,7 +9,7 @@ $colour_line = 'B3D0DB'; $colour_area_max = 'FFEE99'; $graph_max = 100; $unit_text = 'Frequency'; -$ntpdserver_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); if (is_file($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; diff --git a/html/includes/graphs/application/ntpdserver_packets.inc.php b/html/includes/graphs/application/ntpdserver_packets.inc.php index b3d906aa3c..55440924af 100644 --- a/html/includes/graphs/application/ntpdserver_packets.inc.php +++ b/html/includes/graphs/application/ntpdserver_packets.inc.php @@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php'; $scale_min = 0; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Packets'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); $array = array( 'packets_drop' => array( 'descr' => 'Dropped', diff --git a/html/includes/graphs/application/ntpdserver_stats.inc.php b/html/includes/graphs/application/ntpdserver_stats.inc.php index e6d79d292b..ec411bce06 100644 --- a/html/includes/graphs/application/ntpdserver_stats.inc.php +++ b/html/includes/graphs/application/ntpdserver_stats.inc.php @@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php'; $colours = 'mixed'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Milliseconds'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); $array = array( 'offset' => array('descr' => 'Offset'), 'jitter' => array('descr' => 'Jitter'), diff --git a/html/includes/graphs/application/ntpdserver_stratum.inc.php b/html/includes/graphs/application/ntpdserver_stratum.inc.php index debff062ea..0016db50c5 100644 --- a/html/includes/graphs/application/ntpdserver_stratum.inc.php +++ b/html/includes/graphs/application/ntpdserver_stratum.inc.php @@ -9,7 +9,7 @@ $colour_line = '880000'; $colour_area_max = 'FFCCCC'; $graph_max = 0; $unit_text = 'Stratum'; -$ntpdserver_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); if (is_file($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; diff --git a/html/includes/graphs/application/ntpdserver_uptime.inc.php b/html/includes/graphs/application/ntpdserver_uptime.inc.php index e1b007f3d6..8ea5f1cb73 100644 --- a/html/includes/graphs/application/ntpdserver_uptime.inc.php +++ b/html/includes/graphs/application/ntpdserver_uptime.inc.php @@ -11,7 +11,7 @@ $colour_line = '36393D'; $colour_area_max = 'FFEE99'; $graph_max = 0; $unit_text = 'Seconds'; -$ntpdserver_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; +$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); if (is_file($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; diff --git a/html/includes/graphs/application/powerdns_fail.inc.php b/html/includes/graphs/application/powerdns_fail.inc.php index 469b633ac1..e9c623a283 100644 --- a/html/includes/graphs/application/powerdns_fail.inc.php +++ b/html/includes/graphs/application/powerdns_fail.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'red'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Packets/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); $array = array( 'corruptPackets' => array( 'descr' => 'Corrupt', diff --git a/html/includes/graphs/application/powerdns_latency.inc.php b/html/includes/graphs/application/powerdns_latency.inc.php index 5e716a8dc1..f8f1118808 100644 --- a/html/includes/graphs/application/powerdns_latency.inc.php +++ b/html/includes/graphs/application/powerdns_latency.inc.php @@ -9,7 +9,7 @@ $colour_line = 'B3D0DB'; $colour_area_max = 'FFEE99'; $graph_max = 100; $unit_text = 'Latency'; -$powerdns_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$powerdns_rrd = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); if (is_file($powerdns_rrd)) { $rrd_filename = $powerdns_rrd; diff --git a/html/includes/graphs/application/powerdns_packetcache.inc.php b/html/includes/graphs/application/powerdns_packetcache.inc.php index abd3297cc7..bfdf689da3 100644 --- a/html/includes/graphs/application/powerdns_packetcache.inc.php +++ b/html/includes/graphs/application/powerdns_packetcache.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'blue'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Packets/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); $array = array( 'pc_hit' => array( 'descr' => 'Hits', diff --git a/html/includes/graphs/application/powerdns_queries.inc.php b/html/includes/graphs/application/powerdns_queries.inc.php index 49f5b8d200..27f65eb058 100644 --- a/html/includes/graphs/application/powerdns_queries.inc.php +++ b/html/includes/graphs/application/powerdns_queries.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'mixed'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Packets/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); $array = array( 'q_tcpAnswers' => array( 'descr' => 'TCP Answers', diff --git a/html/includes/graphs/application/powerdns_queries_udp.inc.php b/html/includes/graphs/application/powerdns_queries_udp.inc.php index e680f72dae..a009ab60b6 100644 --- a/html/includes/graphs/application/powerdns_queries_udp.inc.php +++ b/html/includes/graphs/application/powerdns_queries_udp.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'mixed'; $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Packets/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); $array = array( 'q_udp4Answers' => array( 'descr' => 'UDP4 Answers', diff --git a/html/includes/graphs/application/powerdns_querycache.inc.php b/html/includes/graphs/application/powerdns_querycache.inc.php index 694bb88f79..03b424cefb 100644 --- a/html/includes/graphs/application/powerdns_querycache.inc.php +++ b/html/includes/graphs/application/powerdns_querycache.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'mixed'; $nototal = 0; $unit_text = 'Packets/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); $array = array( 'qc_miss' => array( 'descr' => 'Misses', diff --git a/html/includes/graphs/application/powerdns_recursing.inc.php b/html/includes/graphs/application/powerdns_recursing.inc.php index 32a94799a2..47562e1ad6 100644 --- a/html/includes/graphs/application/powerdns_recursing.inc.php +++ b/html/includes/graphs/application/powerdns_recursing.inc.php @@ -6,7 +6,7 @@ $scale_min = 0; $colours = 'mixed'; $nototal = 0; $unit_text = 'Packets/sec'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-powerdns-'.$app['app_id'].'.rrd'; +$rrd_filename = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); $array = array( 'rec_questions' => array( 'descr' => 'Questions', diff --git a/html/includes/graphs/application/proxmox_traffic.inc.php b/html/includes/graphs/application/proxmox_traffic.inc.php index 26d6e66823..8d3b790fc7 100644 --- a/html/includes/graphs/application/proxmox_traffic.inc.php +++ b/html/includes/graphs/application/proxmox_traffic.inc.php @@ -18,7 +18,7 @@ require 'includes/graphs/common.inc.php'; -$proxmox_rrd = $config['rrd_dir'].'/proxmox/'.$vars['cluster'].'/'.$vars['vmid'].'_netif_'.$vars['port'].'.rrd'; +$proxmox_rrd = config['rrd_dir'].'/proxmox/'.$vars['cluster'].'/'.$vars['vmid'].'_netif_'.$vars['port'].'.rrd'; if (is_file($proxmox_rrd)) { $rrd_filename = $proxmox_rrd; diff --git a/html/includes/graphs/application/shoutcast_bits.inc.php b/html/includes/graphs/application/shoutcast_bits.inc.php index 020ce76b99..2a576c7e7b 100644 --- a/html/includes/graphs/application/shoutcast_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_bits.inc.php @@ -18,8 +18,7 @@ $colour_line_out = '000099'; $colour_area_in = 'CDEB8B'; $colour_area_out = 'C3D9FF'; -$rrddir = $config['rrd_dir'].'/'.$device['hostname']; -$hostname = (isset($_GET['hostname']) ? $_GET['hostname'] : 'unkown'); -$rrd_filename = $rrddir.'/app-shoutcast-'.$app['app_id'].'-'.$hostname.'.rrd'; +$hostname = (isset($_GET['hostname']) ? $_GET['hostname'] : 'unknown'); +$rrd_filename = rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], $hostname)); require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php index 06f1585109..5ee3c4c5e1 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -20,30 +20,17 @@ $colour_line_out = '000099'; $colour_area_in = 'CDEB8B'; $colour_area_out = 'C3D9FF'; -$rrddir = $config['rrd_dir'].'/'.$device['hostname']; -$files = array(); -$i = 0; - -if ($handle = opendir($rrddir)) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..') { - if (stripos($file, 'app-shoutcast-'.$app['app_id']) != false) { - array_push($files, $file); - } - } - } -} - -foreach ($files as $id => $file) { - $hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = str_ireplace('.rrd', '', $hostname); - list($host, $port) = explode('_', $hostname, 2); - $rrd_filenames[] = $rrddir.'/'.$file; - $rrd_list[$i]['filename'] = $rrddir.'/'.$file; - $rrd_list[$i]['descr'] = $host.':'.$port; - $rrd_list[$i]['ds_in'] = $ds_in; - $rrd_list[$i]['ds_out'] = $ds_out; - $i++; +$rrd_list = array(); +$rrd_filenames = glob(rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], '*'))); +foreach ($rrd_filenames as $file) { + $hostname = end(explode('-',basename($file, '.rrd'))); + list($host, $port) = explode('_', $hostname, 2); + $rrd_list[] = array( + 'filename' => $file, + 'descr' => $host.':'.$port, + 'ds_in' => $ds_in, + 'ds_out' => $ds_out + ); } require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index 2e2819e84b..77d132c14c 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -7,30 +7,16 @@ $unit_text = 'ShoutCast Server'; $total_text = 'Total of all ShoutCast Servers'; $nototal = 0; -$rrddir = $config['rrd_dir'].'/'.$device['hostname']; -$files = array(); -$i = 0; -$x = 0; - -if ($handle = opendir($rrddir)) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..') { - if (stripos($file, 'app-shoutcast-'.$app['app_id']) !== false) { - array_push($files, $file); - } - } - } -} - -foreach ($files as $id => $file) { - $hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = str_ireplace('.rrd', '', $hostname); - list($host, $port) = explode('_', $hostname, 2); - $rrd_filenames[] = $rrddir.'/'.$file; - $rrd_list[$i]['filename'] = $rrddir.'/'.$file; - $rrd_list[$i]['descr'] = $host.':'.$port; - $rrd_list[$i]['colour'] = $colour; - $i++; +$rrd_list = array(); +$rrd_filenames = glob(rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], '*'))); +foreach ($rrd_filenames as $file) { + $hostname = end(explode('-',basename($file, '.rrd'))); + list($host, $port) = explode('_', $hostname, 2); + $rrd_list[] = array( + 'filename' => $file, + 'descr' => $host.':'.$port, +// 'colour' => $colour + ); } require 'includes/graphs/common.inc.php'; diff --git a/html/includes/graphs/application/shoutcast_stats.inc.php b/html/includes/graphs/application/shoutcast_stats.inc.php index 15f1e654a0..dbbd81989e 100644 --- a/html/includes/graphs/application/shoutcast_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_stats.inc.php @@ -1,8 +1,7 @@ $array) { if ($array['otvtype'] == 'endpoint') { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$array['endpoint']."-mac.rrd"); + $rrd_filename = rrd_name($device['hostname'], array('cisco', 'otv', $array['endpoint'], 'mac')); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's diff --git a/html/includes/graphs/device/cisco-otv-vlan.inc.php b/html/includes/graphs/device/cisco-otv-vlan.inc.php index 1116e056c6..0138348fc8 100644 --- a/html/includes/graphs/device/cisco-otv-vlan.inc.php +++ b/html/includes/graphs/device/cisco-otv-vlan.inc.php @@ -27,7 +27,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { if ($array['otvtype'] == 'overlay') { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$array['label']."-vlan.rrd"); + $rrd_filename = rrd_name($device['hostname'], array('cisco', 'otv', $array['label'], 'vlan')); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's diff --git a/html/includes/graphs/device/cisco_wwan_mnc.inc.php b/html/includes/graphs/device/cisco_wwan_mnc.inc.php index c522403a31..39685d8438 100644 --- a/html/includes/graphs/device/cisco_wwan_mnc.inc.php +++ b/html/includes/graphs/device/cisco_wwan_mnc.inc.php @@ -10,7 +10,7 @@ */ require 'includes/graphs/common.inc.php'; -$rrdfilename = $config['rrd_dir'].'/'.$device['hostname'].'/cisco-wwan-mnc.rrd'; +$rrdfilename = rrd_name($device['hostname'], 'cisco-wwan-mnc'); if (file_exists($rrdfilename)) { $rrd_options .= ' DEF:mnc='.$rrdfilename.':mnc:LAST '; $rrd_options .= ' --lower-limit 0 '; diff --git a/html/includes/graphs/device/cisco_wwan_rssi.inc.php b/html/includes/graphs/device/cisco_wwan_rssi.inc.php index b69740c647..e61a2f9c17 100644 --- a/html/includes/graphs/device/cisco_wwan_rssi.inc.php +++ b/html/includes/graphs/device/cisco_wwan_rssi.inc.php @@ -10,7 +10,7 @@ */ require 'includes/graphs/common.inc.php'; -$rrdfilename = $config['rrd_dir'].'/'.$device['hostname'].'/cisco-wwan-rssi.rrd'; +$rrdfilename = rrd_name($device['hostname'], 'cisco-wwan-rssi'); if (file_exists($rrdfilename)) { $rrd_options .= " COMMENT:'dBm Now Ave Max \\n'"; $rrd_options .= ' DEF:rssi='.$rrdfilename.':rssi:AVERAGE '; diff --git a/html/includes/graphs/device/ciscowlc_numaps.inc.php b/html/includes/graphs/device/ciscowlc_numaps.inc.php index c8507252f2..ed1f898def 100644 --- a/html/includes/graphs/device/ciscowlc_numaps.inc.php +++ b/html/includes/graphs/device/ciscowlc_numaps.inc.php @@ -1,6 +1,6 @@ '00cc00', diff --git a/html/includes/graphs/device/netstat_icmp_info.inc.php b/html/includes/graphs/device/netstat_icmp_info.inc.php index 38ab1e7191..612fc46814 100644 --- a/html/includes/graphs/device/netstat_icmp_info.inc.php +++ b/html/includes/graphs/device/netstat_icmp_info.inc.php @@ -1,6 +1,6 @@ array(), diff --git a/html/includes/graphs/device/netstat_ip.inc.php b/html/includes/graphs/device/netstat_ip.inc.php index 4c0dfad3e2..08424aa049 100644 --- a/html/includes/graphs/device/netstat_ip.inc.php +++ b/html/includes/graphs/device/netstat_ip.inc.php @@ -1,6 +1,6 @@ array(), diff --git a/html/includes/graphs/device/netstat_ip_forward.inc.php b/html/includes/graphs/device/netstat_ip_forward.inc.php index e4f5b04d4d..b15857f963 100644 --- a/html/includes/graphs/device/netstat_ip_forward.inc.php +++ b/html/includes/graphs/device/netstat_ip_forward.inc.php @@ -1,6 +1,6 @@ array()); diff --git a/html/includes/graphs/device/netstat_ip_frag.inc.php b/html/includes/graphs/device/netstat_ip_frag.inc.php index da5ea0249e..d036b3f500 100644 --- a/html/includes/graphs/device/netstat_ip_frag.inc.php +++ b/html/includes/graphs/device/netstat_ip_frag.inc.php @@ -2,7 +2,7 @@ require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/netstats-ip.rrd'; +$rrd_filename = rrd_name($device['hostname'], 'netstats-ip'); $rrd_options .= " DEF:ipInDelivers=$rrd_filename:ipInDelivers:AVERAGE"; $rrd_options .= " DEF:ipReasmReqds=$rrd_filename:ipReasmReqds:AVERAGE"; diff --git a/html/includes/graphs/device/netstat_snmp.inc.php b/html/includes/graphs/device/netstat_snmp.inc.php index 513872d276..e71df3cca5 100644 --- a/html/includes/graphs/device/netstat_snmp.inc.php +++ b/html/includes/graphs/device/netstat_snmp.inc.php @@ -1,6 +1,6 @@ $array) { if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('port', $array['ifindex'], 'cbqos', $array['sp-id'], $array['sp-obj'])); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's diff --git a/html/includes/graphs/port/cbqos_qosdrops.inc.php b/html/includes/graphs/port/cbqos_qosdrops.inc.php index 36f856eed5..9407c01b30 100644 --- a/html/includes/graphs/port/cbqos_qosdrops.inc.php +++ b/html/includes/graphs/port/cbqos_qosdrops.inc.php @@ -38,7 +38,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('port', $array['ifindex'], 'cbqos', $array['sp-id'], $array['sp-obj'])); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's diff --git a/html/includes/graphs/port/cbqos_traffic.inc.php b/html/includes/graphs/port/cbqos_traffic.inc.php index eabd919094..19ccfbc13c 100644 --- a/html/includes/graphs/port/cbqos_traffic.inc.php +++ b/html/includes/graphs/port/cbqos_traffic.inc.php @@ -38,7 +38,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('port', $array['ifindex'], 'cbqos', $array['sp-id'], $array['sp-obj'])); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's diff --git a/html/includes/graphs/port/mac_acc_total.inc.php b/html/includes/graphs/port/mac_acc_total.inc.php index eb9f0622a4..e5ba5721d8 100644 --- a/html/includes/graphs/port/mac_acc_total.inc.php +++ b/html/includes/graphs/port/mac_acc_total.inc.php @@ -64,7 +64,7 @@ $iter = '0'; $rrd_options .= " COMMENT:' In\: Current Maximum Total Out\: Current Maximum Total\\\\n'"; foreach ($accs as $acc) { - $this_rrd = $config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'); + $this_rrd = rrd_name($acc['hostname'], array('cip', $acc['ifIndex'], $acc['mac'])); if (is_file($this_rrd)) { $mac = formatmac($acc['mac']); $name = $mac; diff --git a/html/includes/graphs/processor/auth.inc.php b/html/includes/graphs/processor/auth.inc.php index d925447254..a4565b353f 100644 --- a/html/includes/graphs/processor/auth.inc.php +++ b/html/includes/graphs/processor/auth.inc.php @@ -4,7 +4,7 @@ $proc = dbFetchRow('SELECT * FROM `processors` where `processor_id` = ?', array( if (is_numeric($proc['device_id']) && ($auth || device_permitted($proc['device_id']))) { $device = device_by_id_cache($proc['device_id']); - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('processor-'.$proc['processor_type'].'-'.$proc['processor_index'].'.rrd'); + $rrd_filename = rrd_name($device['hostname'], array('processor', $proc['processor_type'], $proc['processor_index'])); $title = generate_device_link($device); $title .= ' :: Processor :: '.htmlentities($proc['processor_descr']); $auth = true; diff --git a/html/includes/graphs/rserver/auth.inc.php b/html/includes/graphs/rserver/auth.inc.php index d166efd19d..bc908fffe2 100644 --- a/html/includes/graphs/rserver/auth.inc.php +++ b/html/includes/graphs/rserver/auth.inc.php @@ -7,7 +7,7 @@ if (is_numeric($vars['id'])) { if (is_numeric($rserver['device_id']) && ($auth || device_permitted($rserver['device_id']))) { $device = device_by_id_cache($rserver['device_id']); - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('rserver-'.$rserver['rserver_id'].'.rrd'); + $rrd_filename = rrd_name($device['hostname'], array('rserver', $rserver['rserver_id'])); $title = generate_device_link($device); $title .= ' :: Rserver :: '.htmlentities($rserver['farm_id']); diff --git a/html/includes/graphs/screenos_sessions.inc.php b/html/includes/graphs/screenos_sessions.inc.php index 24117d9d0e..32df4dba5e 100644 --- a/html/includes/graphs/screenos_sessions.inc.php +++ b/html/includes/graphs/screenos_sessions.inc.php @@ -3,7 +3,7 @@ // Generate a list of ports and then call the multi_bits grapher to generate from the list $device = device_by_id_cache($id); -$file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('screenos-sessions.rrd'); +$file = rrd_name($device['hostname'], 'screenos-sessions'); $rrd_list[0]['filename'] = $file; $rrd_list[0]['descr'] = 'Maxiumum'; diff --git a/html/includes/graphs/sensor/auth.inc.php b/html/includes/graphs/sensor/auth.inc.php index c86920ecf5..fd213bc29b 100644 --- a/html/includes/graphs/sensor/auth.inc.php +++ b/html/includes/graphs/sensor/auth.inc.php @@ -6,8 +6,6 @@ if (is_numeric($vars['id'])) { if (is_numeric($sensor['device_id']) && ($auth || device_permitted($sensor['device_id']))) { $device = device_by_id_cache($sensor['device_id']); - // This doesn't quite work for all yet. - // $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename($sensor['sensor_class']."-" . $sensor['sensor_type'] . "-".$sensor['sensor_index'].".rrd"); $rrd_filename = get_sensor_rrd($device, $sensor); $title = generate_device_link($device); diff --git a/html/includes/graphs/service/auth.inc.php b/html/includes/graphs/service/auth.inc.php index eb30d023a0..1bdbfdd9b1 100644 --- a/html/includes/graphs/service/auth.inc.php +++ b/html/includes/graphs/service/auth.inc.php @@ -7,7 +7,7 @@ if (is_numeric($vars['id'])) { $device = device_by_id_cache($service['device_id']); // This doesn't quite work for all yet. - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('service-'.$service['service_type'].'-'.$service['service_id'].'.rrd'); + $rrd_filename = rrd_name($device['hostname'], array('service', $service['service_type'], $service['service_id'])); $title = generate_device_link($device); $title .= ' :: Service :: '.htmlentities($service['service_type']); diff --git a/html/includes/graphs/storage/auth.inc.php b/html/includes/graphs/storage/auth.inc.php index 47f8189aa6..962a1506be 100644 --- a/html/includes/graphs/storage/auth.inc.php +++ b/html/includes/graphs/storage/auth.inc.php @@ -5,7 +5,7 @@ if (is_numeric($vars['id'])) { if (is_numeric($storage['device_id']) && ($auth || device_permitted($storage['device_id']))) { $device = device_by_id_cache($storage['device_id']); - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('storage-'.$storage['storage_mib'].'-'.$storage['storage_descr'].'.rrd'); + $rrd_filename = rrd_name($device['hostname'], array('storage', $storage['storage_mib'], $storage['storage_descr'])); $title = generate_device_link($device); $title .= ' :: Storage :: '.htmlentities($storage['storage_descr']); diff --git a/html/includes/graphs/toner/auth.inc.php b/html/includes/graphs/toner/auth.inc.php index 72222f18f4..3c187234b3 100644 --- a/html/includes/graphs/toner/auth.inc.php +++ b/html/includes/graphs/toner/auth.inc.php @@ -5,7 +5,7 @@ if (is_numeric($vars['id'])) { if (is_numeric($toner['device_id']) && ($auth || device_permitted($toner['device_id']))) { $device = device_by_id_cache($toner['device_id']); - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('toner-'.$toner['toner_index'].'.rrd'); + $rrd_filename = rrd_name($device['hostname'], array('toner', $toner['toner_index'])); $title = generate_device_link($device); $title .= ' :: Toner :: '.htmlentities($toner['toner_descr']); diff --git a/html/includes/graphs/vserver/auth.inc.php b/html/includes/graphs/vserver/auth.inc.php index 4cb444871e..38eef28a0a 100644 --- a/html/includes/graphs/vserver/auth.inc.php +++ b/html/includes/graphs/vserver/auth.inc.php @@ -7,7 +7,7 @@ if (is_numeric($vars['id'])) { if (is_numeric($vserver['device_id']) && ($auth || device_permitted($vserver['device_id']))) { $device = device_by_id_cache($vserver['device_id']); - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('vserver-'.$vserver['classmap_id'].'.rrd'); + $rrd_filename = rrd_name(device['hostname'], array('vserver', $vserver['classmap_id'])); $title = generate_device_link($device); $title .= ' :: Serverfarm :: '.htmlentities($vserver['classmap_id']); diff --git a/html/pages/device/apps/ceph.inc.php b/html/pages/device/apps/ceph.inc.php index 9ad7536516..ac79a740e4 100644 --- a/html/pages/device/apps/ceph.inc.php +++ b/html/pages/device/apps/ceph.inc.php @@ -6,8 +6,6 @@ $graphs = array( 'ceph_df' => 'Usage', ); -$rrddir = $config['rrd_dir'].'/'.$device['hostname']; - foreach ($graphs as $key => $text) { echo '

'.$text.'

'; $graph_array['height'] = '100'; @@ -16,7 +14,7 @@ foreach ($graphs as $key => $text) { $graph_array['id'] = $app['app_id']; if ($key == "ceph_poolstats") { - foreach (glob($rrddir."/app-ceph-".$app['app_id']."-pool-*") as $rrd_filename) { + foreach (glob(rrd_name($device['hostname'], array('app', 'ceph', $app['app_id'], 'pool', '*'))) as $rrd_filename) { if (preg_match("/.*-pool-(.+)\.rrd$/", $rrd_filename, $pools)) { $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $app['app_id']; @@ -42,7 +40,7 @@ foreach ($graphs as $key => $text) { } } elseif ($key == "ceph_osdperf") { - foreach (glob($rrddir."/app-ceph-".$app['app_id']."-osd-*") as $rrd_filename) { + foreach (glob(rrd_name($device['hostname'], array('app', 'ceph', $app['app_id'], 'osd', '*'))) as $rrd_filename) { $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $app['app_id']; if (preg_match("/.*-osd-(.+)\.rrd$/", $rrd_filename, $osds)) { @@ -58,7 +56,7 @@ foreach ($graphs as $key => $text) { } } elseif ($key == "ceph_df") { - foreach (glob($rrddir."/app-ceph-".$app['app_id']."-df-*") as $rrd_filename) { + foreach (glob(rrd_name($device['hostname'], array('app', 'ceph', $app['app_id'], 'df', '*'))) as $rrd_filename) { if (preg_match("/.*-df-(.+)\.rrd$/", $rrd_filename, $pools)) { $pool = $pools[1]; if ($pool == "c") { diff --git a/html/pages/device/apps/shoutcast.inc.php b/html/pages/device/apps/shoutcast.inc.php index f9278c650b..dca8b5cca2 100644 --- a/html/pages/device/apps/shoutcast.inc.php +++ b/html/pages/device/apps/shoutcast.inc.php @@ -4,19 +4,6 @@ global $config; $total = true; -$rrddir = $config['rrd_dir'].'/'.$device['hostname']; -$files = array(); - -if ($handle = opendir($rrddir)) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..') { - if (stripos($file, 'app-shoutcast-'.$app['app_id']) !== false) { - array_push($files, $file); - } - } - } -} - if (isset($total) && $total === true) { $graphs = array( 'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers', @@ -44,9 +31,9 @@ if (isset($total) && $total === true) { } } -foreach ($files as $id => $file) { - $hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = str_ireplace('.rrd', '', $hostname); +$files = glob(rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], '*'))); +foreach ($files as $file) { + $hostname = end(explode('-',basename($file, '.rrd'))); list($host, $port) = explode('_', $hostname, 2); $graphs = array( 'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')', diff --git a/html/pages/device/graphs/ipSytemStats.inc.php b/html/pages/device/graphs/ipSytemStats.inc.php index 34873a3d19..dc77999a22 100644 --- a/html/pages/device/graphs/ipSytemStats.inc.php +++ b/html/pages/device/graphs/ipSytemStats.inc.php @@ -1,6 +1,6 @@ $config[\'poller_modules\'][\'mib\'] = 1; in config.php to function ceph_rrd($gtype) { global $device; global $vars; - global $config; if ($gtype == "osd") { $var = $vars['osd']; @@ -1005,8 +1005,7 @@ function ceph_rrd($gtype) { $var = $vars['pool']; } - $rrd = join('-', array('app', 'ceph', $vars['id'], $gtype, $var)).'.rrd'; - return join('/', array($config['rrd_dir'], $device['hostname'], $rrd)); + return rrd_name($device['hostname'], array('app', 'ceph', $vars['id'], $gtype, $var)); } // ceph_rrd /** diff --git a/includes/datastore.inc.php b/includes/datastore.inc.php index 190cd61e30..a214b3f39a 100644 --- a/includes/datastore.inc.php +++ b/includes/datastore.inc.php @@ -38,8 +38,18 @@ function rrd_array_filter($arr) } // rrd_array_filter -/* +/** * Datastore-independent function which should be used for all polled metrics. + * + * RRD Tags: + * rrd_name array|string: the rrd filename + * rrd_oldname array|string: old rrd filename to rename + * 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) { diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 4439934c0e..6a0d0a5cd6 100644 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -27,17 +27,11 @@ $ports_db = $ports_mapped['ports']; // // Rename any old RRD files still named after the previous ifIndex based naming schema. foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) { - foreach (array ('', 'adsl', 'dot3') as $suffix) { - $suffix_tmp = ''; - if ($suffix) - $suffix_tmp = "-$suffix"; + foreach (array ('', '-adsl', '-dot3') as $suffix) { + $old_rrd_name = "port-$ifIndex$suffix.rrd"; + $new_rrd_name = getPortRrdName($port_id, ltrim($suffix, '-')); - $old_rrd_path = trim ($config['rrd_dir']) . '/' . $device['hostname'] . "/port-$ifIndex$suffix_tmp.rrd"; - $new_rrd_path = get_port_rrdfile_path ($device['hostname'], $port_id, $suffix); - - if (is_file ($old_rrd_path)) { - rename ($old_rrd_path, $new_rrd_path); - } + rrd_file_rename($device, $old_rrd_name, $new_rrd_name); } } diff --git a/includes/discovery/processors/hrdevice.inc.php b/includes/discovery/processors/hrdevice.inc.php index 070a49f06f..361d6acb27 100644 --- a/includes/discovery/processors/hrdevice.inc.php +++ b/includes/discovery/processors/hrdevice.inc.php @@ -63,15 +63,9 @@ if (is_array($hrDevice_array)) { $descr = str_replace('(TM)', '', $descr); $descr = str_replace('(R)', '', $descr); - $old_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('hrProcessor-'.$index.'.rrd'); - $new_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('processor-hr-'.$index.'.rrd'); - - d_echo("$old_rrd $new_rrd"); - - if (is_file($old_rrd)) { - rename($old_rrd, $new_rrd); - echo 'Moved RRD '; - } + $old_name = array('hrProcessor', $index); + $new_name = array('processor', 'hr', $index); + rrd_file_rename($device, $old_name, $new_name); if ($device['os'] == 'arista-eos' && $index == '1') { unset($descr); diff --git a/includes/discovery/processors/ios.inc.php b/includes/discovery/processors/ios.inc.php index 4bcaa0ffa7..41cc66c0c9 100644 --- a/includes/discovery/processors/ios.inc.php +++ b/includes/discovery/processors/ios.inc.php @@ -27,15 +27,10 @@ if ($device['os_group'] == 'cisco' || $device['os'] == 'acsw') { $descr = "Processor $index"; } - $old_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('cpmCPU-'.$index.'.rrd'); - $new_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('processor-cpm-'.$index.'.rrd'); - - if (is_file($old_rrd)) { - rename($old_rrd, $new_rrd); - d_echo("$old_rrd $new_rrd"); - - echo 'Moved RRD '; - } + // rename old cpmCPU files + $old_name = array('cpmCPU', $index); + $new_name = array('processor', 'cpm', $index); + rrd_file_rename($device, $old_name, $new_name); if (!strstr($descr, 'No') && !strstr($usage, 'No') && $descr != '') { discover_processor($valid['processor'], $device, $usage_oid, $index, 'cpm', $descr, '1', $usage, $entPhysicalIndex, null); diff --git a/includes/discovery/storage/hrstorage.inc.php b/includes/discovery/storage/hrstorage.inc.php index 04012237b2..83c38e0b45 100644 --- a/includes/discovery/storage/hrstorage.inc.php +++ b/includes/discovery/storage/hrstorage.inc.php @@ -34,9 +34,9 @@ if (is_array($hrstorage_array)) { } if ($device['os'] == 'vmware' && $descr == 'Real Memory') { - $old_rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('storage-hrstorage-'.safename($descr).'.rrd'); - $new_rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('mempool-hrstorage-'.$storage['hrStorageIndex'].'.rrd'); - rename($old_rrdfile, $new_rrdfile); + $old_rrdfile = array('storage', 'hrstorage', $descr); + $new_rrdfile = array('mempool', 'hrstorage', $storage['hrStorageIndex']); + rrd_file_rename($device, $old_rrdfile, $new_rrdfile); $deny = 1; } @@ -80,9 +80,6 @@ if (is_array($hrstorage_array)) { discover_storage($valid_storage, $device, $index, $fstype, 'hrstorage', $descr, $size, $units, $used); } - // $old_storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("hrStorage-" . $index . ".rrd"); - // $storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("storage-hrstorage-" . $index . ".rrd"); - // if (is_file($old_storage_rrd)) { rename($old_storage_rrd,$storage_rrd); } unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $hrstorage_array); }//end foreach }//end if diff --git a/includes/functions.php b/includes/functions.php index e0845036f5..8f28a80249 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -192,13 +192,11 @@ function getImageName($device, $use_database=true) { function renamehost($id, $new, $source = 'console') { global $config; - // FIXME does not check if destination exists! $host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id)); - if (rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new") === TRUE) { + if (!is_dir($config['rrd_dir']."/$new") && rename($config['rrd_dir']."/$host", $config['rrd_dir']."/$new") === TRUE) { dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id)); log_event("Hostname changed -> $new ($source)", $id, 'system'); - } - else { + } else { echo "Renaming of $host failed\n"; log_event("Renaming of $host failed", $id, 'system'); } diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index 71c4a62039..4b1b2cbef7 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -1,8 +1,10 @@ $total_access, @@ -69,8 +66,6 @@ $fields = array( 'sb_open' => $score_open, ); -rrdtool_update($rrd_filename, $fields); - -$tags = array('name' => 'apache', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/bind.inc.php b/includes/polling/applications/bind.inc.php index 0996c2bdd7..52a577a338 100644 --- a/includes/polling/applications/bind.inc.php +++ b/includes/polling/applications/bind.inc.php @@ -24,10 +24,11 @@ * @subpackage Polling */ -if (!empty($agent_data['app']['bind']) && $app['app_id'] > 0) { +$name = 'bind'; +$app_id = $app['app_id']; +if (!empty($agent_data['app'][$name]) && $app_id > 0) { echo ' bind '; - $bind = $agent_data['app']['bind']; - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-bind-'.$app['app_id'].'.rrd'; + $bind = $agent_data['app'][$name]; $bind_parsed = array(); $prefix = ''; foreach (explode("\n", $bind) as $line) { @@ -69,39 +70,34 @@ if (!empty($agent_data['app']['bind']) && $app['app_id'] > 0) { } }//end foreach - if (!is_file($rrd_filename)) { - rrdtool_create( - $rrd_filename, - '--step 300 - DS:any:COUNTER:600:0:125000000000 - DS:a:COUNTER:600:0:125000000000 - DS:aaaa:COUNTER:600:0:125000000000 - DS:cname:COUNTER:600:0:125000000000 - DS:mx:COUNTER:600:0:125000000000 - DS:ns:COUNTER:600:0:125000000000 - DS:ptr:COUNTER:600:0:125000000000 - DS:soa:COUNTER:600:0:125000000000 - DS:srv:COUNTER:600:0:125000000000 - DS:spf:COUNTER:600:0:125000000000 '.$config['rrd_rra'] - ); - } - - $fields = array( - 'any' => ((int) $bind_parsed['incoming_queries']['any']), - 'a' => ((int) $bind_parsed['incoming_queries']['a']), - 'aaaa' => ((int) $bind_parsed['incoming_queries']['aaaa']), - 'cname' => ((int) $bind_parsed['incoming_queries']['cname']), - 'mx' => ((int) $bind_parsed['incoming_queries']['mx']), - 'ns' => ((int) $bind_parsed['incoming_queries']['ns']), - 'ptr' => ((int) $bind_parsed['incoming_queries']['ptr']), - 'soa' => ((int) $bind_parsed['incoming_queries']['soa']), - 'srv' => ((int) $bind_parsed['incoming_queries']['srv']), - 'spf' => ((int) $bind_parsed['incoming_queries']['spf']), + $rrd_name = array('app', $name, $app_id); + $rrd_def = array( + 'DS:any:COUNTER:600:0:125000000000', + 'DS:a:COUNTER:600:0:125000000000', + 'DS:aaaa:COUNTER:600:0:125000000000', + 'DS:cname:COUNTER:600:0:125000000000', + 'DS:mx:COUNTER:600:0:125000000000', + 'DS:ns:COUNTER:600:0:125000000000', + 'DS:ptr:COUNTER:600:0:125000000000', + 'DS:soa:COUNTER:600:0:125000000000', + 'DS:srv:COUNTER:600:0:125000000000', + 'DS:spf:COUNTER:600:0:125000000000' ); - rrdtool_update($rrd_filename, $fields); + $fields = array( + 'any' => ((int)$bind_parsed['incoming_queries']['any']), + 'a' => ((int)$bind_parsed['incoming_queries']['a']), + 'aaaa' => ((int)$bind_parsed['incoming_queries']['aaaa']), + 'cname' => ((int)$bind_parsed['incoming_queries']['cname']), + 'mx' => ((int)$bind_parsed['incoming_queries']['mx']), + 'ns' => ((int)$bind_parsed['incoming_queries']['ns']), + 'ptr' => ((int)$bind_parsed['incoming_queries']['ptr']), + 'soa' => ((int)$bind_parsed['incoming_queries']['soa']), + 'srv' => ((int)$bind_parsed['incoming_queries']['srv']), + 'spf' => ((int)$bind_parsed['incoming_queries']['spf']), + ); - $tags = array('name' => 'bind', 'app_id' => $app['app_id']); - influx_update($device,'app',$tags,$fields); + $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); + data_update($device, 'app', $tags, $fields); }//end if diff --git a/includes/polling/applications/ceph.inc.php b/includes/polling/applications/ceph.inc.php index b3ae5ced77..5d82639d34 100644 --- a/includes/polling/applications/ceph.inc.php +++ b/includes/polling/applications/ceph.inc.php @@ -1,31 +1,34 @@ ', $section); + if ($section == "poolstats") { foreach (explode("\n", $data) as $line) { if (empty($line)) continue; list($pool,$ops,$wrbytes,$rbytes) = explode(':', $line); - $ceph_rrd = $ceph_rrddir.'/app-ceph-'.$app['app_id'].'-pool-'.$pool.'.rrd'; - if (!is_file($ceph_rrd)) { - rrdtool_create( - $ceph_rrd, - '--step 300 - DS:ops:GAUGE:600:0:U - DS:wrbytes:GAUGE:600:0:U - DS:rbytes:GAUGE:600:0:U '.$config['rrd_rra'] - ); - } + $rrd_name = array('app', $name, $app_id, 'pool'.$pool); + $rrd_def = array( + 'DS:ops:GAUGE:600:0:U', + 'DS:wrbytes:GAUGE:600:0:U', + 'DS:rbytes:GAUGE:600:0:U' + ); print "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n"; - rrdtool_update($ceph_rrd, array("ops" => $ops, "wrbytes" => $wrbytes, "rbytes" => $rbytes)); + $fields = array( + 'ops' => $ops, + 'wrbytes' => $wrbytes, + 'rbytes' => $rbytes + ); + $tags = compact($name, $app_id, $pool, $rrd_name, $rrd_def); + data_update($device, 'app', $tags, $fields); } } elseif ($section == "osdperformance") { @@ -33,38 +36,43 @@ if (!empty($agent_data['app']['ceph'])) { if (empty($line)) continue; list($osd,$apply,$commit) = explode(':', $line); - $ceph_rrd = $ceph_rrddir.'/app-ceph-'.$app['app_id'].'-osd-'.$osd.'.rrd'; - if (!is_file($ceph_rrd)) { - rrdtool_create( - $ceph_rrd, - '--step 300 - DS:apply_ms:GAUGE:600:0:U - DS:commit_ms:GAUGE:600:0:U '.$config['rrd_rra'] - ); - } + $rrd_name = array('app', $name, $app_id, 'osd'.$osd); + $rrd_def = array( + 'DS:apply_ms:GAUGE:600:0:U', + 'DS:commit_ms:GAUGE:600:0:U' + ); + print "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n"; - rrdtool_update($ceph_rrd, array("apply_ms" => $apply, "commit_ms" => $commit)); + $fields = array( + 'apply_ms' => $apply, + 'commit_ms' => $commit + ); + $tags = compact($name, $app_id, $osd, $rrd_name, $rrd_def); + data_update($device, 'app', $tags, $fields); } } elseif ($section == "df") { foreach (explode("\n", $data) as $line) { if (empty($line)) continue; - list($pool,$avail,$used,$objects) = explode(':', $line); - $ceph_rrd = $ceph_rrddir.'/app-ceph-'.$app['app_id'].'-df-'.$pool.'.rrd'; - if (!is_file($ceph_rrd)) { - rrdtool_create( - $ceph_rrd, - '--step 300 - DS:avail:GAUGE:600:0:U - DS:used:GAUGE:600:0:U - DS:objects:GAUGE:600:0:U '.$config['rrd_rra'] - ); - } + list($df,$avail,$used,$objects) = explode(':', $line); + $rrd_name = array('app', $name, $app_id, 'df', $df); + $rrd_def = array( + 'DS:avail:GAUGE:600:0:U', + 'DS:used:GAUGE:600:0:U', + 'DS:objects:GAUGE:600:0:U' + ); print "Ceph Pool DF: $pool, Avail: $avail, Used: $used, Objects: $objects\n"; - rrdtool_update($ceph_rrd, array("avail" => $avail, "used" => $used, "objects" => $objects)); + $fields = array( + 'avail' => $avail, + 'used' => $used, + 'objects' => $objects + ); + + $tags = compact($name, $app_id, $df, $rrd_name, $rrd_def); + data_update($device, 'app', $tags, $fields); } } } diff --git a/includes/polling/applications/drbd.inc.php b/includes/polling/applications/drbd.inc.php index 13ae0d3dd7..ec86641878 100644 --- a/includes/polling/applications/drbd.inc.php +++ b/includes/polling/applications/drbd.inc.php @@ -1,31 +1,31 @@ $drbd['ns'], @@ -41,9 +41,7 @@ $fields = array( 'oos' => $drbd['oos'], ); -rrdtool_update($rrd_filename, $fields); - -$tags = array('name' => 'drbd', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = array('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); unset($drbd); diff --git a/includes/polling/applications/mailscanner.inc.php b/includes/polling/applications/mailscanner.inc.php index 8796b506d9..6dbb6977cb 100644 --- a/includes/polling/applications/mailscanner.inc.php +++ b/includes/polling/applications/mailscanner.inc.php @@ -1,7 +1,7 @@ $msg_recv, - 'msg_rejected' => $msg_rejected, - 'msg_relay' => $msg_relay, - 'msg_sent' => $msg_sent, - 'msg_waiting' => $msg_waiting, - 'spam' => $spam, - 'virus' => $virus, +$name = 'mailscannerV2'; +$app_id = $app['app_id']; +$rrd_name = array('app', $name, $app_id); +$rrd_def = array( + 'DS:msg_recv:COUNTER:600:0:125000000000', + 'DS:msg_rejected:COUNTER:600:0:12500000000', + 'DS:msg_relay:COUNTER:600:0:125000000000', + 'DS:msg_sent:COUNTER:600:0:125000000000', + 'DS:msg_waiting:COUNTER:600:0:125000000000', + 'DS:spam:COUNTER:600:0:125000000000', + 'DS:virus:COUNTER:600:0:125000000000' ); -rrdtool_update($rrd_filename, $fields); +$fields = array( + 'msg_recv' => $msg_recv, + 'msg_rejected' => $msg_rejected, + 'msg_relay' => $msg_relay, + 'msg_sent' => $msg_sent, + 'msg_waiting' => $msg_waiting, + 'spam' => $spam, + 'virus' => $virus, +); -$tags = array('name' => 'mailscannerV2', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/memcached.inc.php b/includes/polling/applications/memcached.inc.php index d68013a698..d2d420e3e5 100644 --- a/includes/polling/applications/memcached.inc.php +++ b/includes/polling/applications/memcached.inc.php @@ -1,36 +1,32 @@ $data['uptime'], @@ -53,8 +49,6 @@ $fields = array( 'bytes_written' => $data['bytes_written'], ); -rrdtool_update($rrd_filename, $fields); - -$tags = array('name' => 'memcached', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index 2d08049918..9402cd3de7 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -1,8 +1,10 @@ 'c9', ); -$values = array(); unset($fields); foreach ($mapping as $k => $v) { $fields[$k] = isset($map[$v]) ? $map[$v] : (-1); } -$string = implode(':', $values); +$rrd_name = array('app', $name, $app_id); +$rrd_def = array( + 'DS:IDBLBSe:GAUGE:600:0:125000000000', + 'DS:IBLFh:DERIVE:600:0:125000000000', + 'DS:IBLWn:DERIVE:600:0:125000000000', + 'DS:SRows:DERIVE:600:0:125000000000', + 'DS:SRange:DERIVE:600:0:125000000000', + 'DS:SMPs:DERIVE:600:0:125000000000', + 'DS:SScan:DERIVE:600:0:125000000000', + 'DS:IBIRd:DERIVE:600:0:125000000000', + 'DS:IBIWr:DERIVE:600:0:125000000000', + 'DS:IBILg:DERIVE:600:0:125000000000', + 'DS:IBIFSc:DERIVE:600:0:125000000000', + 'DS:IDBRDd:DERIVE:600:0:125000000000', + 'DS:IDBRId:DERIVE:600:0:125000000000', + 'DS:IDBRRd:DERIVE:600:0:125000000000', + 'DS:IDBRUd:DERIVE:600:0:125000000000', + 'DS:IBRd:DERIVE:600:0:125000000000', + 'DS:IBCd:DERIVE:600:0:125000000000', + 'DS:IBWr:DERIVE:600:0:125000000000', + 'DS:TLIe:DERIVE:600:0:125000000000', + 'DS:TLWd:DERIVE:600:0:125000000000', + 'DS:IBPse:GAUGE:600:0:125000000000', + 'DS:IBPDBp:GAUGE:600:0:125000000000', + 'DS:IBPFe:GAUGE:600:0:125000000000', + 'DS:IBPMps:GAUGE:600:0:125000000000', + 'DS:TOC:GAUGE:600:0:125000000000', + 'DS:OFs:GAUGE:600:0:125000000000', + 'DS:OTs:GAUGE:600:0:125000000000', + 'DS:OdTs:COUNTER:600:0:125000000000', + 'DS:IBSRs:DERIVE:600:0:125000000000', + 'DS:IBSWs:DERIVE:600:0:125000000000', + 'DS:IBOWs:DERIVE:600:0:125000000000', + 'DS:QCs:GAUGE:600:0:125000000000', + 'DS:QCeFy:GAUGE:600:0:125000000000', + 'DS:MaCs:GAUGE:600:0:125000000000', + 'DS:MUCs:GAUGE:600:0:125000000000', + 'DS:ACs:DERIVE:600:0:125000000000', + 'DS:AdCs:DERIVE:600:0:125000000000', + 'DS:TCd:GAUGE:600:0:125000000000', + 'DS:Cs:DERIVE:600:0:125000000000', + 'DS:IBTNx:DERIVE:600:0:125000000000', + 'DS:KRRs:DERIVE:600:0:125000000000', + 'DS:KRs:DERIVE:600:0:125000000000', + 'DS:KWR:DERIVE:600:0:125000000000', + 'DS:KWs:DERIVE:600:0:125000000000', + 'DS:QCQICe:DERIVE:600:0:125000000000', + 'DS:QCHs:DERIVE:600:0:125000000000', + 'DS:QCIs:DERIVE:600:0:125000000000', + 'DS:QCNCd:DERIVE:600:0:125000000000', + 'DS:QCLMPs:DERIVE:600:0:125000000000', + 'DS:CTMPDTs:DERIVE:600:0:125000000000', + 'DS:CTMPTs:DERIVE:600:0:125000000000', + 'DS:CTMPFs:DERIVE:600:0:125000000000', + 'DS:IBIIs:DERIVE:600:0:125000000000', + 'DS:IBIMRd:DERIVE:600:0:125000000000', + 'DS:IBIMs:DERIVE:600:0:125000000000', + 'DS:IBILog:DERIVE:602:0:125000000000', + 'DS:IBISc:DERIVE:602:0:125000000000', + 'DS:IBIFLg:DERIVE:600:0:125000000000', + 'DS:IBFBl:DERIVE:600:0:125000000000', + 'DS:IBIIAo:DERIVE:600:0:125000000000', + 'DS:IBIAd:DERIVE:600:0:125000000000', + 'DS:IBIAe:DERIVE:600:0:125000000000', + 'DS:SFJn:DERIVE:600:0:125000000000', + 'DS:SFRJn:DERIVE:600:0:125000000000', + 'DS:SRe:DERIVE:600:0:125000000000', + 'DS:SRCk:DERIVE:600:0:125000000000', + 'DS:SSn:DERIVE:600:0:125000000000', + 'DS:SQs:DERIVE:600:0:125000000000', + 'DS:BRd:DERIVE:600:0:125000000000', + 'DS:BSt:DERIVE:600:0:125000000000', + 'DS:CDe:DERIVE:600:0:125000000000', + 'DS:CIt:DERIVE:600:0:125000000000', + 'DS:CISt:DERIVE:600:0:125000000000', + 'DS:CLd:DERIVE:600:0:125000000000', + 'DS:CRe:DERIVE:600:0:125000000000', + 'DS:CRSt:DERIVE:600:0:125000000000', + 'DS:CSt:DERIVE:600:0:125000000000', + 'DS:CUe:DERIVE:600:0:125000000000', + 'DS:CUMi:DERIVE:600:0:125000000000' +); -if (!is_file($mysql_rrd)) { - rrdtool_create( - $mysql_rrd, - '--step 300 - DS:IDBLBSe:GAUGE:600:0:125000000000 - DS:IBLFh:DERIVE:600:0:125000000000 - DS:IBLWn:DERIVE:600:0:125000000000 - DS:SRows:DERIVE:600:0:125000000000 - DS:SRange:DERIVE:600:0:125000000000 - DS:SMPs:DERIVE:600:0:125000000000 - DS:SScan:DERIVE:600:0:125000000000 - DS:IBIRd:DERIVE:600:0:125000000000 - DS:IBIWr:DERIVE:600:0:125000000000 - DS:IBILg:DERIVE:600:0:125000000000 - DS:IBIFSc:DERIVE:600:0:125000000000 - DS:IDBRDd:DERIVE:600:0:125000000000 - DS:IDBRId:DERIVE:600:0:125000000000 - DS:IDBRRd:DERIVE:600:0:125000000000 - DS:IDBRUd:DERIVE:600:0:125000000000 - DS:IBRd:DERIVE:600:0:125000000000 - DS:IBCd:DERIVE:600:0:125000000000 - DS:IBWr:DERIVE:600:0:125000000000 - DS:TLIe:DERIVE:600:0:125000000000 - DS:TLWd:DERIVE:600:0:125000000000 - DS:IBPse:GAUGE:600:0:125000000000 - DS:IBPDBp:GAUGE:600:0:125000000000 - DS:IBPFe:GAUGE:600:0:125000000000 - DS:IBPMps:GAUGE:600:0:125000000000 - DS:TOC:GAUGE:600:0:125000000000 - DS:OFs:GAUGE:600:0:125000000000 - DS:OTs:GAUGE:600:0:125000000000 - DS:OdTs:COUNTER:600:0:125000000000 - DS:IBSRs:DERIVE:600:0:125000000000 - DS:IBSWs:DERIVE:600:0:125000000000 - DS:IBOWs:DERIVE:600:0:125000000000 - DS:QCs:GAUGE:600:0:125000000000 - DS:QCeFy:GAUGE:600:0:125000000000 - DS:MaCs:GAUGE:600:0:125000000000 - DS:MUCs:GAUGE:600:0:125000000000 - DS:ACs:DERIVE:600:0:125000000000 - DS:AdCs:DERIVE:600:0:125000000000 - DS:TCd:GAUGE:600:0:125000000000 - DS:Cs:DERIVE:600:0:125000000000 - DS:IBTNx:DERIVE:600:0:125000000000 - DS:KRRs:DERIVE:600:0:125000000000 - DS:KRs:DERIVE:600:0:125000000000 - DS:KWR:DERIVE:600:0:125000000000 - DS:KWs:DERIVE:600:0:125000000000 - DS:QCQICe:DERIVE:600:0:125000000000 - DS:QCHs:DERIVE:600:0:125000000000 - DS:QCIs:DERIVE:600:0:125000000000 - DS:QCNCd:DERIVE:600:0:125000000000 - DS:QCLMPs:DERIVE:600:0:125000000000 - DS:CTMPDTs:DERIVE:600:0:125000000000 - DS:CTMPTs:DERIVE:600:0:125000000000 - DS:CTMPFs:DERIVE:600:0:125000000000 - DS:IBIIs:DERIVE:600:0:125000000000 - DS:IBIMRd:DERIVE:600:0:125000000000 - DS:IBIMs:DERIVE:600:0:125000000000 - DS:IBILog:DERIVE:602:0:125000000000 - DS:IBISc:DERIVE:602:0:125000000000 - DS:IBIFLg:DERIVE:600:0:125000000000 - DS:IBFBl:DERIVE:600:0:125000000000 - DS:IBIIAo:DERIVE:600:0:125000000000 - DS:IBIAd:DERIVE:600:0:125000000000 - DS:IBIAe:DERIVE:600:0:125000000000 - DS:SFJn:DERIVE:600:0:125000000000 - DS:SFRJn:DERIVE:600:0:125000000000 - DS:SRe:DERIVE:600:0:125000000000 - DS:SRCk:DERIVE:600:0:125000000000 - DS:SSn:DERIVE:600:0:125000000000 - DS:SQs:DERIVE:600:0:125000000000 - DS:BRd:DERIVE:600:0:125000000000 - DS:BSt:DERIVE:600:0:125000000000 - DS:CDe:DERIVE:600:0:125000000000 - DS:CIt:DERIVE:600:0:125000000000 - DS:CISt:DERIVE:600:0:125000000000 - DS:CLd:DERIVE:600:0:125000000000 - DS:CRe:DERIVE:600:0:125000000000 - DS:CRSt:DERIVE:600:0:125000000000 - DS:CSt:DERIVE:600:0:125000000000 - DS:CUe:DERIVE:600:0:125000000000 - DS:CUMi:DERIVE:600:0:125000000000 '.$config['rrd_rra'] - ); -}//end if - -rrdtool_update($mysql_rrd, $fields); - -$tags = array('name' => 'mysql', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); // Process state statistics -$mysql_status_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'-status.rrd'; - $mapping_status = array( 'State_closing_tables' => 'd2', 'State_copying_to_tmp_table' => 'd3', @@ -229,22 +219,14 @@ $mapping_status = array( 'State_other' => 'dh', ); -$values = array(); -$rrd_create = ''; +$rrd_name = array('app', $name, $app_id, 'status'); +$rrd_def = array(); unset($fields); foreach ($mapping_status as $desc => $id) { - $fields[$desc] = isset($map[$id]) ? $map[$id] : (-1); - $rrd_create .= ' DS:'.$id.':GAUGE:600:0:125000000000'; + $fields[$desc] = isset($map[$id]) ? $map[$id] : (-1); + $rrd_def[] = 'DS:'.$id.':GAUGE:600:0:125000000000'; } - -$string = implode(':', $values); - -if (!is_file($mysql_status_rrd)) { - rrdtool_create($mysql_status_rrd, '--step 300 '.$rrd_create.' '.$config['rrd_rra']); -} - -rrdtool_update($mysql_status_rrd, $fields); - -$tags = array('name' => 'mysql', 'app_id' => $app['app_id'], 'status' => true); -influx_update($device,'app',$tags,$fields); +$status = true; +$tags = compact('name', 'app_id', 'status', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/nginx.inc.php b/includes/polling/applications/nginx.inc.php index 25950f099b..7a25e697ac 100644 --- a/includes/polling/applications/nginx.inc.php +++ b/includes/polling/applications/nginx.inc.php @@ -1,48 +1,39 @@ $req, - 'Active' => $active, - 'Reading' => $reading, - 'Writing' => $writing, - 'Waiting' => $waiting, + +$rrd_name = array('app', $name, $app_id); +$rrd_def = array( + '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' ); -rrdtool_update($nginx_rrd, $fields); +$fields = array( + 'Requests' => $req, + 'Active' => $active, + 'Reading' => $reading, + 'Writing' => $writing, + 'Waiting' => $waiting, +); -$tags = array('name' => 'nginx', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); // Unset the variables we set here -unset($nginx); -unset($nginx_rrd); -unset($active); -unset($reading); -unset($writing); -unset($req); +unset($nginx, $active, $reading, $writing, $req, $rrd_name, $rrd_def, $tags); diff --git a/includes/polling/applications/ntp-client.inc.php b/includes/polling/applications/ntp-client.inc.php index 0d65ce8ffa..f8195b3de0 100644 --- a/includes/polling/applications/ntp-client.inc.php +++ b/includes/polling/applications/ntp-client.inc.php @@ -1,38 +1,33 @@ $offset, - 'frequency' => $frequency, - 'jitter' => $jitter, - 'noise' => $noise, - 'stability' => $stability, +$rrd_name = array('app', $name, $app_id); +$rrd_def = array( + 'DS:offset:GAUGE:600:-1000:1000', + 'DS:frequency:GAUGE:600:-1000:1000', + 'DS:jitter:GAUGE:600:-1000:1000', + 'DS:noise:GAUGE:600:-1000:1000', + 'DS:stability:GAUGE:600:-1000:1000' ); -rrdtool_update($rrd_filename, $fields); +$fields = array( + 'offset' => $offset, + 'frequency' => $frequency, + 'jitter' => $jitter, + 'noise' => $noise, + 'stability' => $stability, +); -$tags = array('name' => 'ntpclient', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/ntpd-server.inc.php b/includes/polling/applications/ntpd-server.inc.php index a54ae0da57..04942e9288 100644 --- a/includes/polling/applications/ntpd-server.inc.php +++ b/includes/polling/applications/ntpd-server.inc.php @@ -1,11 +1,12 @@ $stratum, @@ -52,7 +50,5 @@ $fields = array( 'packets_sent' => $packets_sent, ); -rrdtool_update($rrd_filename, $fields); - -$tags = array('name' => 'ntpdserver', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rdd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/powerdns.inc.php b/includes/polling/applications/powerdns.inc.php index f34e9423e2..b7d7538053 100644 --- a/includes/polling/applications/powerdns.inc.php +++ b/includes/polling/applications/powerdns.inc.php @@ -1,13 +1,14 @@ $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' => $req_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, +$rrd_name = array('app', $name, $app_id); +$rrd_def = array( + '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' ); -rrdtool_update($rrd_filename, $fields); +$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' => $req_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, +); -$tags = array('name' => 'powerdns', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/proxmox.inc.php b/includes/polling/applications/proxmox.inc.php index c1e366b362..0bcf1e28ad 100644 --- a/includes/polling/applications/proxmox.inc.php +++ b/includes/polling/applications/proxmox.inc.php @@ -1,7 +1,9 @@ $device['device_id'], 'app_type' => 'proxmox', 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], 'proxmox')); +dbUpdate(array('device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $name)); if (count($pmxlines) > 0) { $pmxcache = []; foreach ($pmxlines as $vm) { list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5); - - $rrd_filename = join('/', array( - $pmxcdir, - $vmid.'_netif_'.$vmport.'.rrd')); - - if (!is_file($rrd_filename)) { - rrdtool_create( - $rrd_filename, - ' --step 300 - DS:INOCTETS:DERIVE:600:0:12500000000 - DS:OUTOCTETS:DERIVE:600:0:12500000000 '.$config['rrd_rra']); - } - - rrdtool_update($rrd_filename, array("INOCTETS" => $vmpin, "OUTOCTETS" => $vmpout)); print "Proxmox ($pmxcluster): $vmdesc: $vmpin/$vmpout/$vmport\n"; + $rrd_name = join('/', array($name, $pmxcluster, $vmid)).'_netif_'.$vmport; + $rrd_def = array( + 'DS:INOCTETS:DERIVE:600:0:12500000000', + 'DS:OUTOCTETS:DERIVE:600:0:12500000000' + ); + $fields = array( + 'INOCTETS' => $vmpin, + 'OUTOCTETS' => $vmpout + ); + + $tags = compact('name', 'app_id', 'pmxcluster', 'vmid', 'vmport', 'rrd_name', 'rrd_def'); + data_update($device, 'app', $tags, $fields); + if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) { - dbUpdate(array('device_id' => $device['device_id'], 'last_seen' => array('NOW()'), 'description' => $vmdesc), 'proxmox', '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster)); + dbUpdate(array('device_id' => $device['device_id'], 'last_seen' => array('NOW()'), 'description' => $vmdesc), $name, '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster)); } else { - $pmxcache[$pmxcluster][$vmid] = dbInsert(array('cluster' => $pmxcluster, 'vmid' => $vmid, 'description' => $vmdesc, 'device_id' => $device['device_id']), 'proxmox'); + $pmxcache[$pmxcluster][$vmid] = dbInsert(array('cluster' => $pmxcluster, 'vmid' => $vmid, 'description' => $vmdesc, 'device_id' => $device['device_id']), $name); } if ($portid = proxmox_port_exists($vmid, $pmxcluster, $vmport) !== false) { diff --git a/includes/polling/applications/rrdcached.inc.php b/includes/polling/applications/rrdcached.inc.php index 21bb5e4684..6ea975dc61 100644 --- a/includes/polling/applications/rrdcached.inc.php +++ b/includes/polling/applications/rrdcached.inc.php @@ -28,9 +28,11 @@ echo ' rrdcached'; $data = ""; +$name = 'rrdcached'; +$app_id = $app['app_id']; -if ($agent_data['app']['rrdcached']) { - $data = $agent_data['app']['rrdcached']; +if ($agent_data['app'][$name]) { + $data = $agent_data['app'][$name]; } else { d_echo("\nNo Agent Data. Attempting to connect directly to the rrdcached server " . $device['hostname'] . ":42217\n"); @@ -63,40 +65,30 @@ if ($agent_data['app']['rrdcached']) { } } -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-rrdcached-'.$app['app_id'].'.rrd'; +$rrd_name = array('app', $name, $app_id); +$rrd_def = array( + 'DS:queue_length:GAUGE:600:0:U', + 'DS:updates_received:COUNTER:600:0:U', + 'DS:flushes_received:COUNTER:600:0:U', + 'DS:updates_written:COUNTER:600:0:U', + 'DS:data_sets_written:COUNTER:600:0:U', + 'DS:tree_nodes_number:GAUGE:600:0:U', + 'DS:tree_depth:GAUGE:600:0:U', + 'DS:journal_bytes:COUNTER:600:0:U', + 'DS:journal_rotate:COUNTER:600:0:U' +); -if (!is_file($rrd_filename)) { - rrdtool_create( - $rrd_filename, - '--step 300 - DS:queue_length:GAUGE:600:0:U - DS:updates_received:COUNTER:600:0:U - DS:flushes_received:COUNTER:600:0:U - DS:updates_written:COUNTER:600:0:U - DS:data_sets_written:COUNTER:600:0:U - DS:tree_nodes_number:GAUGE:600:0:U - DS:tree_depth:GAUGE:600:0:U - DS:journal_bytes:COUNTER:600:0:U - DS:journal_rotate:COUNTER:600:0:U - '.$config['rrd_rra'] - ); -} $fields = array(); foreach (explode("\n", $data) as $line) { $split = explode(': ', $line); if (count($split) == 2) { - $name = strtolower(preg_replace('/[A-Z]/', '_$0', lcfirst($split[0]))); - $fields[$name] = $split[1]; + $ds = strtolower(preg_replace('/[A-Z]/', '_$0', lcfirst($split[0]))); + $fields[$ds] = $split[1]; } } -rrdtool_update($rrd_filename, $fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); -$tags = array('name' => 'rrdcached', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); - -unset($data); -unset($rrd_filename); -unset($fields); -unset($tags); +unset($data, $rrd_name, $rrd_def, $fields, $tags); diff --git a/includes/polling/applications/shoutcast.inc.php b/includes/polling/applications/shoutcast.inc.php index a5650d2569..ceaa9f08eb 100644 --- a/includes/polling/applications/shoutcast.inc.php +++ b/includes/polling/applications/shoutcast.inc.php @@ -1,9 +1,11 @@ $server) { $server = trim($server); if (!empty($server)) { - $data = explode(';', $server); + $data = explode(';', $server); list($host, $port) = explode(':', $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'] - ); - } - - $fields = array( - 'bitrate' => $bitrate, - 'traf_in' => $traf_in, - 'traf_out' => $traf_out, - 'current' => $current, - 'status' => $status, - 'peak' => $peak, - 'max' => $max, - 'unique' => $unique, + $rrd_name = array('app', $name, $app_id, $host . '_' . $port); + $rrd_def = array( + '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' ); - rrdtool_update($rrdfile, $fields); + $fields = array( + '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'], + ); - $tags = array('name' => 'shoutcast', 'app_id' => $app['app_id'], 'host' => $host, 'port' => $port); - influx_update($device,'app',$tags,$fields); + $tags = compact('name', 'app_id', 'host', 'port', 'rrd_name', 'rrd_def'); + data_update($device, 'app', $tags, $fields); }//end if }//end foreach diff --git a/includes/polling/applications/tinydns.inc.php b/includes/polling/applications/tinydns.inc.php index 6a79eb7037..677d5c21d7 100644 --- a/includes/polling/applications/tinydns.inc.php +++ b/includes/polling/applications/tinydns.inc.php @@ -24,39 +24,35 @@ * @subpackage Polling */ -if (!empty($agent_data['app']['tinydns']) && $app['app_id'] > 0) { +$name = 'tinydns'; +$app_id = $app['app_id']; +if (!empty($agent_data['app'][$name]) && $app_id > 0) { echo ' tinydns'; - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd'; - if (!is_file($rrd_filename)) { - rrdtool_create( - $rrd_filename, - '--step 300 - DS:a:COUNTER:600:0:125000000000 - DS:ns:COUNTER:600:0:125000000000 - DS:cname:COUNTER:600:0:125000000000 - DS:soa:COUNTER:600:0:125000000000 - DS:ptr:COUNTER:600:0:125000000000 - DS:hinfo:COUNTER:600:0:125000000000 - DS:mx:COUNTER:600:0:125000000000 - DS:txt:COUNTER:600:0:125000000000 - DS:rp:COUNTER:600:0:125000000000 - DS:sig:COUNTER:600:0:125000000000 - DS:key:COUNTER:600:0:125000000000 - DS:aaaa:COUNTER:600:0:125000000000 - DS:axfr:COUNTER:600:0:125000000000 - DS:any:COUNTER:600:0:125000000000 - DS:total:COUNTER:600:0:125000000000 - DS:other:COUNTER:600:0:125000000000 - DS:notauth:COUNTER:600:0:125000000000 - DS:notimpl:COUNTER:600:0:125000000000 - DS:badclass:COUNTER:600:0:125000000000 - DS:noquery:COUNTER:600:0:125000000000 '.$config['rrd_rra'] - ); - }//end if + $rrd_name = array('app', $name, $app_id); + $rrd_def = array( + 'DS:a:COUNTER:600:0:125000000000', + 'DS:ns:COUNTER:600:0:125000000000', + 'DS:cname:COUNTER:600:0:125000000000', + 'DS:soa:COUNTER:600:0:125000000000', + 'DS:ptr:COUNTER:600:0:125000000000', + 'DS:hinfo:COUNTER:600:0:125000000000', + 'DS:mx:COUNTER:600:0:125000000000', + 'DS:txt:COUNTER:600:0:125000000000', + 'DS:rp:COUNTER:600:0:125000000000', + 'DS:sig:COUNTER:600:0:125000000000', + 'DS:key:COUNTER:600:0:125000000000', + 'DS:aaaa:COUNTER:600:0:125000000000', + 'DS:axfr:COUNTER:600:0:125000000000', + 'DS:any:COUNTER:600:0:125000000000', + 'DS:total:COUNTER:600:0:125000000000', + 'DS:other:COUNTER:600:0:125000000000', + 'DS:notauth:COUNTER:600:0:125000000000', + 'DS:notimpl:COUNTER:600:0:125000000000', + 'DS:badclass:COUNTER:600:0:125000000000', + 'DS:noquery:COUNTER:600:0:125000000000' + ); - rrdtool_update($rrd_filename, 'N:'.$agent_data['app']['tinydns']); - - $tags = array('name' => 'tinydns', 'app_id' => $app['app_id']); - influx_update($device,'app',$tags,$fields); + $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); + data_update($device, 'app', $tags, $fields); }//end if diff --git a/includes/polling/aruba-controller.inc.php b/includes/polling/aruba-controller.inc.php index 594056eafe..4c5a26ef12 100644 --- a/includes/polling/aruba-controller.inc.php +++ b/includes/polling/aruba-controller.inc.php @@ -44,34 +44,34 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { echo "\n"; - $rrdfile = $host_rrd.'/aruba-controller'.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']); - } + $rrd_name = 'aruba-controller'; + $rrd_def = array( + 'DS:NUMAPS:GAUGE:600:0:12500000000', + 'DS:NUMCLIENTS:GAUGE:600:0:12500000000' + ); $fields = array( 'NUMAPS' => $aruba_stats[0]['wlsxSwitchTotalNumAccessPoints'], 'NUMCLIENTS' => $aruba_stats[0]['wlsxSwitchTotalNumStationsAssociated'], ); - $ret = rrdtool_update($rrdfile, $fields); - $tags = array(); - influx_update($device,'aruba-controller',$tags,$fields); + $tags = compact('rrd_name', 'rrd_def'); + data_update($device,'aruba-controller',$tags,$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']); - } + $rrd_name = 'wificlients-radio1'; + $rrd_def = 'S:wificlients:GAUGE:600:-273:10000'; $fields = array( 'wificlients' => $aruba_stats[0]['wlsxSwitchTotalNumStationsAssociated'], ); - rrdtool_update($wificlientsrrd, $fields); - $tags = array('radio' => '1'); - influx_update($device,'wificlients',$tags,$fields); + $tags = array( + 'radio' => '1', + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def + ); + data_update($device,'wificlients',$tags,$fields); $graphs['wifi_clients'] = true; @@ -108,17 +108,17 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { // if there is a numeric channel, assume the rest of the data is valid, I guess if (is_numeric($channel)) { - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$name.$radionum.rrd"); - if (!is_file($rrd_file)) { - $dslist = 'DS:channel:GAUGE:600:0:200 '; - $dslist .= 'DS:txpow:GAUGE:600:0:200 '; - $dslist .= 'DS:radioutil:GAUGE:600:0:100 '; - $dslist .= 'DS:nummonclients:GAUGE:600:0:500 '; - $dslist .= 'DS:nummonbssid:GAUGE:600:0:200 '; - $dslist .= 'DS:numasoclients:GAUGE:600:0:500 '; - $dslist .= 'DS:interference:GAUGE:600:0:2000 '; - rrdtool_create($rrd_file, "--step 300 $dslist ".$config['rrd_rra']); - } + $rrd_name = array('arubaap', $name.$radionum); + + $rrd_def = array( + 'DS:channel:GAUGE:600:0:200', + 'DS:txpow:GAUGE:600:0:200', + 'DS:radioutil:GAUGE:600:0:100', + 'DS:nummonclients:GAUGE:600:0:500', + 'DS:nummonbssid:GAUGE:600:0:200', + 'DS:numasoclients:GAUGE:600:0:500', + 'DS:interference:GAUGE:600:0:2000' + ); $fields = array( 'channel' => $channel, @@ -130,11 +130,14 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { 'interference' => $interference, ); - rrdtool_update($rrd_file, $fields); - - $tags = array('name' => $name, 'radionum' => $radionum); - influx_update($device,'aruba',$tags,$fields); + $tags = array( + 'name' => $name, + 'radionum' => $radionum, + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def + ); + data_update($device,'aruba',$tags,$fields); } // generate the mac address diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 34608f1ecc..75c0f0dcde 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -151,16 +151,14 @@ if ($config['enable_bgp']) { } } - $peerrrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('bgp-'.$peer['bgpPeerIdentifier'].'.rrd'); - if (!is_file($peerrrd)) { - $create_rrd = 'DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 - DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 - DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 - DS:bgpPeerInTotal:COUNTER:600:U:100000000000 - DS:bgpPeerEstablished:GAUGE:600:0:U '.$config['rrd_rra']; - - rrdtool_create($peerrrd, $create_rrd); - } + $peer_rrd_name = safename('bgp-'.$peer['bgpPeerIdentifier']); + $peer_rrd_def = array( + 'DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000', + 'DS:bgpPeerInUpdates:COUNTER:600:U:100000000000', + 'DS:bgpPeerOutTotal:COUNTER:600:U:100000000000', + 'DS:bgpPeerInTotal:COUNTER:600:U:100000000000', + 'DS:bgpPeerEstablished:GAUGE:600:0:U' + ); $fields = array( 'bgpPeerOutUpdates' => $bgpPeerOutUpdates, @@ -169,10 +167,13 @@ if ($config['enable_bgp']) { 'bgpPeerInTotal' => $bgpPeerInTotalMessages, 'bgpPeerEstablished' => $bgpPeerFsmEstablishedTime, ); - rrdtool_update("$peerrrd", $fields); - $tags = array('bgpPeerIdentifier' => $peer['bgpPeerIdentifier']); - influx_update($device,'bgp',$tags,$fields); + $tags = array( + 'bgpPeerIdentifier' => $peer['bgpPeerIdentifier'], + 'rrd_name' => $peer_rrd_name, + 'rrd_def' => $peer_rrd_def + ); + data_update($device,'bgp',$tags,$fields); $peer['update']['bgpPeerState'] = $bgpPeerState; $peer['update']['bgpPeerAdminStatus'] = $bgpPeerAdminStatus; @@ -339,15 +340,14 @@ print_r($peer_afis); 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); - } + $cbgp_rrd_name = safename('cbgp-'.$peer['bgpPeerIdentifier'].".$afi.$safi"); + $cbgp_rrd_def = array( + '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' + ); $fields = array( 'AcceptedPrefixes' => $cbgpPeerAcceptedPrefixes, @@ -356,10 +356,15 @@ print_r($peer_afis); 'SuppressedPrefixes' => $cbgpPeerSuppressedPrefixes, 'WithdrawnPrefixes' => $cbgpPeerWithdrawnPrefixes, ); - rrdtool_update("$cbgp_rrd", $fields); - $tags = array('bgpPeerIdentifier' => $peer['bgpPeerIdentifier'], 'afi' => $afi, 'safi' => $safi); - influx_update($device,'cbgp',$tags,$fields); + $tags = array( + 'bgpPeerIdentifier' => $peer['bgpPeerIdentifier'], + 'afi' => $afi, + 'safi' => $safi, + 'rrd_name' => $cbgp_rrd_name, + 'rrd_def' => $cbgp_rrd_def + ); + data_update($device,'cbgp',$tags,$fields); } //end foreach } //end if diff --git a/includes/polling/cipsec-tunnels.inc.php b/includes/polling/cipsec-tunnels.inc.php index 7b11d319f5..d244bcfc43 100644 --- a/includes/polling/cipsec-tunnels.inc.php +++ b/includes/polling/cipsec-tunnels.inc.php @@ -70,13 +70,11 @@ foreach ($ipsec_array as $index => $tunnel) { $tunnel['cipSecTunOutUncompOctets'] = $tunnel['cipSecTunHcOutUncompOctets']; } - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/ipsectunnel-'.$address.'.rrd'; - - $rrd_create = $config['rrd_rra']; - + $rrd_name = array('ipsectunnel', $address); + $rrd_def = array(); foreach ($oids as $oid) { $oid_ds = truncate(str_replace('cipSec', '', $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000000"; + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:1000000000"; } $fields = array(); @@ -92,16 +90,11 @@ foreach ($ipsec_array as $index => $tunnel) { } 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); + $tags = compact('address', 'rrd_name', 'rrd_def'); + data_update($device,'ipsectunnel',$tags,$fields); // $graphs['ipsec_tunnels'] = TRUE; } }//end foreach -unset($rrd_file,$rrd_create,$fields,$oids, $data, $data_array, $oid, $tunnel); +unset($rrd_name,$rrd_def,$fields,$oids, $data, $data, $oid, $tunnel); diff --git a/includes/polling/cisco-ace-loadbalancer.inc.php b/includes/polling/cisco-ace-loadbalancer.inc.php index 98ad13043a..7b00e588b7 100644 --- a/includes/polling/cisco-ace-loadbalancer.inc.php +++ b/includes/polling/cisco-ace-loadbalancer.inc.php @@ -8,7 +8,7 @@ foreach ($rserver_db as $serverfarm) { } foreach ($rserver_array as $index => $serverfarm) { - $clean_index = preg_replace('@\d+\."(.*?)"\.\d+@', '\\1', $index); + $farm_id = preg_replace('@\d+\."(.*?)"\.\d+@', '\\1', $index); $oids = array( 'cesServerFarmRserverTotalConns', @@ -17,12 +17,12 @@ foreach ($rserver_array as $index => $serverfarm) { ); $db_oids = array( - $clean_index => 'farm_id', + $farm_id => 'farm_id', 'cesServerFarmRserverStateDescr' => 'StateDescr', ); - if (!is_array($serverfarms[$clean_index])) { - $rserver_id = dbInsert(array('device_id' => $device['device_id'], 'farm_id' => $clean_index, 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr']), 'loadbalancer_rservers'); + if (!is_array($serverfarms[$farm_id])) { + $rserver_id = dbInsert(array('device_id' => $device['device_id'], 'farm_id' => $farm_id, 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr']), 'loadbalancer_rservers'); } else { foreach ($db_oids as $db_oid => $db_value) { @@ -32,11 +32,12 @@ foreach ($rserver_array as $index => $serverfarm) { $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'; + $rrd_name = array('rserver', $serverfarms[$farm_id]['rserver_id']); + $rrd_def = array(); foreach ($oids as $oid) { - $oid_ds = truncate(str_replace('cesServerFarm', '', $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:GAUGE:600:-1:100000000"; + $oid_ds = truncate(str_replace('cesServerFarm', '', $oid), 19, ''); + $rrd_def[] = "DS:$oid_ds:GAUGE:600:-1:100000000"; } $fields = array(); @@ -51,18 +52,10 @@ foreach ($rserver_array as $index => $serverfarm) { $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); - + if (isset($serverfarms[$farm_id])) { + $tags = compact('farm_id', 'rrd_name', 'rrd_def'); + data_update($device,'rservers',$tags,$fields); } }//end foreach -unset($oids, $oid, $serverfarm); +unset($rrd_name, $rrd_def, $oids, $oid, $serverfarm); diff --git a/includes/polling/cisco-ace-serverfarms.inc.php b/includes/polling/cisco-ace-serverfarms.inc.php index 33ab552cd0..56f30ce1b6 100644 --- a/includes/polling/cisco-ace-serverfarms.inc.php +++ b/includes/polling/cisco-ace-serverfarms.inc.php @@ -37,16 +37,14 @@ foreach ($serverfarm_array as $index => $vserver) { $updated = dbUpdate($db_update, 'loadbalancer_vservers', '`classmap_id` = ?', $vserver['slbVServerState']['classmap']); } - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/vserver-'.$classmap_id.'.rrd'; - $rrd_create = $config['rrd_rra']; - + $rrd_name = array('vserver', $classmap_id); + $rrd_def = array(); foreach ($oids as $oid) { - $oid_ds = truncate(str_replace('slbVServer', '', $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000000"; + $oid_ds = truncate(str_replace('slbVServer', '', $oid), 19, ''); + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:1000000000"; } $fields = array(); - foreach ($oids as $oid) { if (is_numeric($vserver[$oid])) { $value = $vserver[$oid]; @@ -58,15 +56,9 @@ foreach ($serverfarm_array as $index => $vserver) { } if (isset($classmaps[$classmap])) { - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); - } - rrdtool_update($rrd_file, $fields); - - $tags = array('classmap_id' => $classmap_id); - influx_update($device,'vservers',$tags,$fields); - + $tags = compact('classmap_id', 'rrd_name', 'rrd_def'); + data_update($device, 'vservers', $tags, $fields); } }//end foreach -unset($oids, $oid, $vserver); +unset($rrd_name, $rrd_def, $oids, $oid, $vserver); diff --git a/includes/polling/cisco-asa-firewall.inc.php b/includes/polling/cisco-asa-firewall.inc.php index 9fdefe06e9..a692d7b657 100644 --- a/includes/polling/cisco-asa-firewall.inc.php +++ b/includes/polling/cisco-asa-firewall.inc.php @@ -29,28 +29,18 @@ if ($device['os_group'] == 'cisco' && $device['os'] == 'asa' && $device['type'] $data[$oid]['db_id'] = $asa_db; } - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('asa_conns.rrd'); - - $rrd_create .= ' DS:connections:GAUGE:600:0:U'; - $rrd_create .= $config['rrd_rra']; - - if (is_file($rrd_filename) || $data['currentInUse']) { - if (!file_exists($rrd_filename)) { - rrdtool_create($rrd_filename, $rrd_create); - } - + if ($data['currentInUse']) { + $rrd_def = 'DS:connections:GAUGE:600:0:U'; $fields = array( 'connections' => $data['currentInUse']['data'], ); - rrdtool_update($rrd_filename, $fields); - - $tags = array(); - influx_update($device,'asa_conns',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'asa_conns',$tags,$fields); $graphs['asa_conns'] = true; echo ' ASA Connections'; } - unset($data,$rrd_filename,$rrd_create); + unset($data,$rrd_def); }//end if diff --git a/includes/polling/cisco-cbqos.inc.php b/includes/polling/cisco-cbqos.inc.php index a884933237..b17f1d2941 100644 --- a/includes/polling/cisco-cbqos.inc.php +++ b/includes/polling/cisco-cbqos.inc.php @@ -37,12 +37,15 @@ if ($device['os_group'] == "cisco") { // Get data from the class table. if ($type == 2) { // Let's make sure the rrd is setup for this class. - $filename = "port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"; - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); - - if (!file_exists ($rrd_filename)) { - rrdtool_create ($rrd_filename, " DS:postbits:COUNTER:600:0:U DS:bufferdrops:COUNTER:600:0:U DS:qosdrops:COUNTER:600:0:U" . $config['rrd_rra']); - } + $ifIndex = $array['ifindex']; + $spid = $array['sp-id']; + $spobj = $array['sp-obj']; + $rrd_name = array('port', $ifIndex, 'cbqos', $spid, $spobj); + $rrd_def = array( + 'DS:postbits:COUNTER:600:0:U', + 'DS:bufferdrops:COUNTER:600:0:U', + 'DS:qosdrops:COUNTER:600:0:U' + ); // Let's print some debugging info. d_echo("\n\nComponent: ".$key."\n"); @@ -52,15 +55,14 @@ if ($device['os_group'] == "cisco") { d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']]."\n"); d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']]."\n"); - $rrd['postbytes'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']]; - $rrd['bufferdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']]; - $rrd['qosdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']]; + $fields = array( + 'postbits' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']], + 'bufferdrops' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']], + 'qosdrops' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']] + ); - // Update rrd - rrdtool_update ($rrd_filename, $rrd); - - // Clean-up after yourself! - unset($filename, $rrd_filename); + $tags = compact('rrd_name', 'rrd_def', 'ifIndex', 'spid', 'spobj'); + data_update($device, 'cbqos', $tags, $fields); } } // End foreach components diff --git a/includes/polling/cisco-cef.inc.php b/includes/polling/cisco-cef.inc.php index 3784871d56..0b65c28c8a 100644 --- a/includes/polling/cisco-cef.inc.php +++ b/includes/polling/cisco-cef.inc.php @@ -31,32 +31,27 @@ if ($device['os_group'] == 'cisco') { echo "\n$entity $entity_name\n"; foreach ($afis as $afi => $paths) { echo " |- $afi\n"; - foreach ($paths as $path => $cef_stat) { - echo ' | |-'.$path.': '.$cef_stat['cefSwitchingPath']; + foreach ($paths as $index => $cef_stat) { + echo ' | |-'.$index.': '.$cef_stat['cefSwitchingPath']; - $cef_id = $device['device_id'].'-'.$entity.'-'.$afi.'-'.$path; + $cef_id = $device['device_id'].'-'.$entity.'-'.$afi.'-'.$index; // if (dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1") if (!isset($cefs_db[$cef_id])) { - dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $path, 'cef_path' => $cef_stat['cefSwitchingPath']), 'cef_switching'); + dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $index, 'cef_path' => $cef_stat['cefSwitchingPath']), 'cef_switching'); echo '+'; } unset($cefs_db[$cef_id]); - $cef_entry = dbFetchRow('SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path)); + $cef_entry = dbFetchRow('SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $index)); - $filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('cefswitching-'.$entity.'-'.$afi.'-'.$path.'.rrd'); - - if (!is_file($filename)) { - rrdtool_create( - $filename, - '--step 300 - DS:drop:DERIVE:600:0:1000000 - DS:punt:DERIVE:600:0:1000000 - DS:hostpunt:DERIVE:600:0:1000000 '.$config['rrd_rra'] - ); - } + $rrd_name = array('cefswitching', $entity, $afi, $index); + $rrd_def = array( + 'DS:drop:DERIVE:600:0:1000000', + 'DS:punt:DERIVE:600:0:1000000', + 'DS:hostpunt:DERIVE:600:0:1000000' + ); // Copy HC to non-HC if they exist if (is_numeric($cef_stat['cefSwitchingHCDrop'])) { @@ -81,7 +76,7 @@ if ($device['os_group'] == 'cisco') { $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)); + dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $index)); $fields = array( 'drop' => $cef_stat['cefSwitchingDrop'], @@ -89,10 +84,8 @@ if ($device['os_group'] == 'cisco') { 'hostpunt' => $cef_stat['cefSwitchingPunt2Host'], ); - $ret = rrdtool_update("$filename", $fields); - - $tags = array('entity' => $entity, 'afi' => $afi, 'index' => $path); - influx_update($device,'cefswitching',$tags,$fields); + $tags = compact('entity', 'afi', 'index', 'rrd_name', 'rrd_def'); + data_update($device,'cefswitching',$tags,$fields); echo "\n"; }//end foreach diff --git a/includes/polling/cisco-ipsec-flow-monitor.inc.php b/includes/polling/cisco-ipsec-flow-monitor.inc.php index 97fa1f176e..90156505eb 100644 --- a/includes/polling/cisco-ipsec-flow-monitor.inc.php +++ b/includes/polling/cisco-ipsec-flow-monitor.inc.php @@ -52,34 +52,30 @@ if ($device['os_group'] == 'cisco') { $data['cipSecGlobalOutUncompOctets'] = $data['cipSecGlobalHcOutUncompOctets']; } - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('cipsec_flow.rrd'); - $rrd_create = ' DS:Tunnels:GAUGE:600:0:U'; - $rrd_create .= ' DS:InOctets:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:OutOctets:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:InDecompOctets:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:OutUncompOctets:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:InPkts:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:OutPkts:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:InDrops:COUNTER:600:0:100000000000'; - $rrd_create .= ' DS:InReplayDrops:COUNTER:600:0:100000000000'; - $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); - } + if ($data['cipSecGlobalActiveTunnels']) { + $rrd_def = array( + 'DS:Tunnels:GAUGE:600:0:U', + 'DS:InOctets:COUNTER:600:0:100000000000', + 'DS:OutOctets:COUNTER:600:0:100000000000', + 'DS:InDecompOctets:COUNTER:600:0:100000000000', + 'DS:OutUncompOctets:COUNTER:600:0:100000000000', + 'DS:InPkts:COUNTER:600:0:100000000000', + 'DS:OutPkts:COUNTER:600:0:100000000000', + 'DS:InDrops:COUNTER:600:0:100000000000', + 'DS:InReplayDrops:COUNTER:600:0:100000000000', + 'DS:OutDrops:COUNTER:600:0:100000000000', + 'DS:InAuths:COUNTER:600:0:100000000000', + 'DS:OutAuths:COUNTER:600:0:100000000000', + 'DS:InAuthFails:COUNTER:600:0:100000000000', + 'DS:OutAuthFails:COUNTER:600:0:100000000000', + 'DS:InDencrypts:COUNTER:600:0:100000000000', + 'DS:OutEncrypts:COUNTER:600:0:100000000000', + 'DS:InDecryptFails:COUNTER:600:0:100000000000', + 'DS:OutEncryptFails:COUNTER:600:0:100000000000', + 'DS:ProtocolUseFails:COUNTER:600:0:100000000000', + 'DS:NoSaFails:COUNTER:600:0:100000000000', + 'DS:SysCapFails:COUNTER:600:0:100000000000' + ); $fields = array( 'Tunnels' => $data['cipSecGlobalActiveTunnels'], @@ -104,10 +100,9 @@ if ($device['os_group'] == 'cisco') { 'NoSaFails' => $data['cipSecGlobalNoSaFails'], 'SysCapFails' => $data['cipSecGlobalSysCapFails'], ); - rrdtool_update($rrd_filename, $fields); - $tags = array(); - influx_update($device,'cipsec_flow',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'cipsec_flow',$tags,$fields); $graphs['cipsec_flow_tunnels'] = true; $graphs['cipsec_flow_pkts'] = true; @@ -117,5 +112,5 @@ if ($device['os_group'] == 'cisco') { echo ' cipsec_flow'; }//end if - unset($data, $rrd_filename, $rrd_create, $rrd_update); + unset($data, $rrd_def); }//end if diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index dc48af41b1..4811c62f64 100644 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -59,17 +59,13 @@ if ($device['os_group'] == 'cisco') { 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'] - ); - } + $rrd_name = array('cip', $ifIndex, $mac); + $rrd_dev = array( + 'DS:IN:COUNTER:600:0:12500000000', + 'DS:OUT:COUNTER:600:0:12500000000', + 'DS:PIN:COUNTER:600:0:12500000000', + 'DS:POUT:COUNTER:600:0:12500000000' + ); // FIXME - use memcached to make sure these values don't go backwards? $fields = array( @@ -78,10 +74,9 @@ if ($device['os_group'] == 'cisco') { 'PIN' => $p_in, 'POUT' => $p_out, ); - rrdtool_update($rrdfile, $fields); - $tags = array('ifIndex' => $acc['ifIndex'], 'mac' => $acc['mac']); - influx_update($device,'cip',$tags,$fields); + $tags = compact('ifIndex', 'mac', 'rrd_name', 'rrd_def'); + data_update($device,'cip',$tags,$fields); if ($acc['update']) { // Do Updates diff --git a/includes/polling/cisco-otv.inc.php b/includes/polling/cisco-otv.inc.php index 6fdaeff3b1..cc07ea3487 100644 --- a/includes/polling/cisco-otv.inc.php +++ b/includes/polling/cisco-otv.inc.php @@ -129,16 +129,16 @@ if ($device['os_group'] == "cisco") { d_echo(" Message: ".$array['error']."\n"); d_echo(" VLAN Count: ".$count_vlan."\n"); - $filename = "cisco-otv-".$array['label']."-vlan.rrd"; - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + $label = $array['label']; + $rrd_name = array('cisco', 'otv', $label, 'vlan'); + $rrd_def = 'DS:count:GAUGE:600:0:U'; - if (!file_exists ($rrd_filename)) { - rrdtool_create ($rrd_filename, " DS:count:GAUGE:600:0:U" . $config['rrd_rra']); - } - $rrd['count'] = $count_vlan; + $fields = array( + 'count' => $count_vlan + ); - // Update RRD - rrdtool_update ($rrd_filename, $rrd); + $tags = compact('label', 'rrd_name', 'rrd_def'); + data_update($device, 'cisco-otv-vlan', $tags, $fields); } elseif ($array['otvtype'] == 'adjacency') { @@ -169,27 +169,26 @@ if ($device['os_group'] == "cisco") { d_echo(" Message: ".$array['error']."\n"); } elseif ($array['otvtype'] == 'endpoint') { - if (isset($count_mac[$array['endpoint']])) { - $rrd['count'] = $count_mac[$array['endpoint']]; - } - else { - $rrd['count'] = "0"; + $count = 0; + $endpoint = $array['endpoint']; + + if (isset($count_mac[$endpoint])) { + $count = $count_mac[$endpoint]; } // Let's log some debugging d_echo("\n\nEndpoint Component: ".$key."\n"); d_echo(" Label: ".$array['label']."\n"); - d_echo(" MAC Count: ".$rrd['count']."\n"); + d_echo(" MAC Count: ".$count."\n"); - $filename = "cisco-otv-".$array['endpoint']."-mac.rrd"; - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + $rrd_name = array('cisco', 'otv', $endpoint, 'mac'); + $rrd_def = 'DS:count:GAUGE:600:0:U'; + $fields = array( + 'count' => $count + ); - if (!file_exists ($rrd_filename)) { - rrdtool_create ($rrd_filename, " DS:count:GAUGE:600:0:U" . $config['rrd_rra']); - } - - // Update RRD - rrdtool_update ($rrd_filename, $rrd); + $tags = compact('endpoint', 'rrd_name', 'rrd_def'); + data_update($device, 'cisco-otv-mac', $tags, $fields); } // End If diff --git a/includes/polling/cisco-remote-access-monitor.inc.php b/includes/polling/cisco-remote-access-monitor.inc.php index 74530fcb37..f9eb30a6cf 100644 --- a/includes/polling/cisco-remote-access-monitor.inc.php +++ b/includes/polling/cisco-remote-access-monitor.inc.php @@ -35,20 +35,15 @@ if ($device['os_group'] == 'cisco') { $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); - } + if ($data['crasEmailNumSessions'] || $data['crasIPSecNumSessions'] || $data['crasL2LNumSessions'] || $data['crasLBNumSessions'] || $data['crasSVCNumSessions'] || $data['crasWebvpnSessions']) { + $rrd_def = array( + 'DS:email:GAUGE:600:0:U', + 'DS:ipsec:GAUGE:600:0:U', + 'DS:l2l:GAUGE:600:0:U', + 'DS:lb:GAUGE:600:0:U', + 'DS:svc:GAUGE:600:0:U', + 'DS:webvpn:GAUGE:600:0:U' + ); $fields = array( 'email' => $data['crasEmailNumSessions'], @@ -59,13 +54,11 @@ if ($device['os_group'] == 'cisco') { 'webvpn' => $data['crasWebvpnNumSessions'], ); - rrdtool_update($rrd_filename, $fields); - - $tags = array(); - influx_update($device,'cras_sessions',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'cras_sessions',$tags,$fields); $graphs['cras_sessions'] = true; } - unset($data, $$rrd_filename, $rrd_create, $fields); + unset($data, $rrd_def, $fields); }//end if diff --git a/includes/polling/cisco-sla.inc.php b/includes/polling/cisco-sla.inc.php index bf3ce730f3..a9e315f385 100644 --- a/includes/polling/cisco-sla.inc.php +++ b/includes/polling/cisco-sla.inc.php @@ -35,20 +35,11 @@ foreach ($sla_table as &$sla) { 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'].'... '; + $sla_nr = $sla['sla_nr']; + echo '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']]; + if (isset($sla_table[$sla_nr])) { + $slaval = $sla_table[$sla_nr]; echo $slaval['CompletionTime'].'ms at '.$slaval['TimeStr']; $val = $slaval['CompletionTime']; } @@ -57,14 +48,14 @@ foreach (dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = $val = 'U'; } + $rrd_name = array('sla', $sla_nr); + $rrd_def = 'DS:rtt:GAUGE:600:0:300000'; $fields = array( 'rtt' => $val, ); - rrdtool_update($slarrd, $fields); - - $tags = array('sla_nr' => $sla['sla_nr']); - influx_update($device,'sla',$tags,$fields); + $tags = compact('sla_nr', 'rrd_name', 'rrd_def'); + data_update($device,'sla',$tags,$fields); echo "\n"; }//end foreach diff --git a/includes/polling/cisco-voice/cisco-iosdsp.inc.php b/includes/polling/cisco-voice/cisco-iosdsp.inc.php index bac527c19b..c081e265b9 100644 --- a/includes/polling/cisco-voice/cisco-iosdsp.inc.php +++ b/includes/polling/cisco-voice/cisco-iosdsp.inc.php @@ -25,23 +25,21 @@ if ($device['os_group'] == "cisco") { $active += $value['']; } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ("cisco-iosdsp.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']); - } + $rrd_def = array( + 'DS:total:GAUGE:600:0:U', + 'DS:active:GAUGE:600:0:U' + ); $fields = array( 'total' => $total, 'active' => $active, ); - rrdtool_update ($rrd_filename, $fields); - - $tags = array(); - influx_update($device,'cisco-iosdsp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'cisco-iosdsp', $tags, $fields); $graphs['cisco-iosdsp'] = TRUE; echo (" Cisco IOS DSP "); } - unset($rrd_filename, $total, $active); + unset($rrd_def, $total, $active, $tags, $fields); } diff --git a/includes/polling/cisco-voice/cisco-iosmtp.inc.php b/includes/polling/cisco-voice/cisco-iosmtp.inc.php index daa60ca9cd..fdeec03805 100644 --- a/includes/polling/cisco-voice/cisco-iosmtp.inc.php +++ b/includes/polling/cisco-voice/cisco-iosmtp.inc.php @@ -24,23 +24,21 @@ if ($device['os_group'] == "cisco") { // Active $active = $total - $available; - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ("cisco-iosmtp.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']); - } + $rrd_def = array( + 'DS:total:GAUGE:600:0:U', + 'DS:active:GAUGE:600:0:U' + ); $fields = array( 'total' => $total, 'active' => $active, ); - rrdtool_update ($rrd_filename, $fields); - - $tags = array(); - influx_update($device,'cisco-iosmtp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'cisco-iosmtp', $tags, $fields); $graphs['cisco-iosmtp'] = TRUE; echo (" Cisco IOS MTP "); } - unset($rrd_filename, $total, $active, $available); + unset($rrd_def, $total, $active, $available, $fields, $tags); } diff --git a/includes/polling/cisco-voice/cisco-iospri.inc.php b/includes/polling/cisco-voice/cisco-iospri.inc.php index 2729f0873c..0a1a122aac 100644 --- a/includes/polling/cisco-voice/cisco-iospri.inc.php +++ b/includes/polling/cisco-voice/cisco-iospri.inc.php @@ -28,24 +28,21 @@ if ($device['os_group'] == "cisco") { $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']); - } + $rrd_def = array( + 'DS:total:GAUGE:600:0:U', + 'DS:active:GAUGE:600:0:U' + ); $fields = array( 'total' => $total, 'active' => $active, ); - rrdtool_update ($rrd_filename, $fields); - - $tags = array(); - influx_update($device,'cisco-iospri',$tags,$fields); + $tags = copmact('rrd_def'); + data_update($device, 'cisco-iospri', $tags, $fields); $graphs['cisco-iospri'] = TRUE; echo (" Cisco IOS PRI "); } - unset($rrd_filename, $total, $active); + unset($rrd_def, $total, $active, $fields, $tags); } diff --git a/includes/polling/cisco-voice/cisco-iosxcode.inc.php b/includes/polling/cisco-voice/cisco-iosxcode.inc.php index 6be4158557..22044f98f9 100644 --- a/includes/polling/cisco-voice/cisco-iosxcode.inc.php +++ b/includes/polling/cisco-voice/cisco-iosxcode.inc.php @@ -24,23 +24,21 @@ if ($device['os_group'] == "cisco") { // 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']); - } + $rrd_def = array( + 'DS:total:GAUGE:600:0:U', + 'DS:active:GAUGE:600:0:U' + ); $fields = array( 'total' => $total, 'active' => $active, ); - rrdtool_update ($rrd_filename, $fields); - - $tags = array(); - influx_update($device,'cisco-iosxcode',$tags,$fields); + $tags = compact('rrd_def'); + dat_update($device, 'cisco-iosxcode', $tags, $fields); $graphs['cisco-iosxcode'] = TRUE; echo (" Cisco IOS Transcoder "); } - unset($rrd_filename, $total, $active, $available); + unset($rrd_def, $total, $active, $available, $fields, $tags); } diff --git a/includes/polling/cisco-vpdn.inc.php b/includes/polling/cisco-vpdn.inc.php index 55c4969654..ce6b80962a 100644 --- a/includes/polling/cisco-vpdn.inc.php +++ b/includes/polling/cisco-vpdn.inc.php @@ -11,12 +11,13 @@ 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']); - } + if ($vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) { + $rrd_name = array('vpdn', $type); + $rrd_def = array( + 'DS:tunnels:GAUGE:600:0:U', + 'DS:sessions:GAUGE:600:0:U', + 'DS:denied:COUNTER:600:0:100000' + ); $fields = array( 'tunnels' => $vpdn['cvpdnSystemTunnelTotal'], @@ -24,10 +25,9 @@ if ($device['os_group'] == 'cisco') { 'denied' => $vpdn['cvpdnSystemDeniedUsersTotal'], ); - rrdtool_update($rrd_filename, $fields); - $tags = array('type' => $type); - influx_update($device,'vpdn',$tags,$fields); + $tags = compact('type', 'rrd_name', 'rrd_def'); + data_update($device,'vpdn',$tags,$fields); $graphs['vpdn_sessions_'.$type] = true; $graphs['vpdn_tunnels_'.$type] = true; diff --git a/includes/polling/entity-physical.inc.php b/includes/polling/entity-physical.inc.php index 94dd4aaa8d..1724ad66a5 100644 --- a/includes/polling/entity-physical.inc.php +++ b/includes/polling/entity-physical.inc.php @@ -22,6 +22,15 @@ if ($device['os'] == 'ios') { $entPhysical_state[$index][$subindex][$group][$key] = $value; } + $rrd_name = array('c6kxbar', $index, $subindex); + $rrd_def = array( + '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' + ); + $fields = array( 'inutil' => $entry['cc6kxbarStatisticsInUtil'], 'oututil' => $entry['cc6kxbarStatisticsOutUtil'], @@ -30,26 +39,8 @@ if ($device['os'] == 'ios') { '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); + $tags = compact('index', 'subindex', 'rrd_name', 'rrd_def'); + data_update($device,'c6kxbar',$tags,$fields); }//end foreach diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index c674615d3e..d021ddeb0b 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -107,15 +107,8 @@ function poll_sensor($device, $class, $unit) { $sensor_value = ($sensor_value * $sensor['sensor_multiplier']); } - $rrd_file = get_sensor_rrd($device, $sensor); - - if (!is_file($rrd_file)) { - rrdtool_create( - $rrd_file, - '--step 300 - DS:sensor:GAUGE:600:-20000:20000 '.$config['rrd_rra'] - ); - } + $rrd_name = get_sensor_rrd($device, $sensor); + $rrd_def = 'DS:sensor:GAUGE:600:-20000:20000'; echo "$sensor_value $unit\n"; @@ -123,10 +116,15 @@ function poll_sensor($device, $class, $unit) { 'sensor' => $sensor_value, ); - 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,'sensor',$tags,$fields); + $tags = array( + 'sensor_class' => $sensor['sensor_class'], + 'sensor_type' => $sensor['sensor_type'], + 'sensor_descr' => $sensor['sensor_descr'], + 'sensor_index' => $sensor['sensor_index'], + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def + ); + data_update($device,'sensor',$tags,$fields); // FIXME also warn when crossing WARN level!! if ($sensor['sensor_limit_low'] != '' && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value < $sensor['sensor_limit_low'] && $sensor['sensor_alert'] == 1) { @@ -318,6 +316,7 @@ function poll_device($device, $options) { $fields = array( 'poller' => $device_time, ); + data_update($device, 'poller-perf', $tags, $fields); } @@ -367,17 +366,14 @@ function poll_mib_def($device, $mib_name_table, $mib_subdir, $mib_oids, $mib_gra 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)); + $measurement_name = strtolower($mib); } else { list($mib,$file) = explode(':', $mib_name_table, 2); - $rrd_file = strtolower(safename($file)).'.rrd'; - $influx_name = strtolower(safename($file)); + $measurement_name = strtolower($file); } - $rrdcreate = '--step 300 '; + $rrd_def = array(); $oidglist = array(); $oidnamelist = array(); foreach ($mib_oids as $oid => $param) { @@ -395,7 +391,7 @@ function poll_mib_def($device, $mib_name_table, $mib_subdir, $mib_oids, $mib_gra $oiddsopts = '600:U:100000000000'; } - $rrdcreate .= ' DS:'.$oiddsname.':'.$oiddstype.':'.$oiddsopts; + $rrd_def[] = 'DS:'.$oiddsname.':'.$oiddstype.':'.$oiddsopts; if ($oidindex != '') { $fulloid = $oid.'.'.$oidindex; @@ -435,16 +431,8 @@ function poll_mib_def($device, $mib_name_table, $mib_subdir, $mib_oids, $mib_gra $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); + $tags = compact('rrd_def'); + data_update($device,$measurement_name,$tags,$fields); foreach ($mib_graphs as $graphtoenable) { $graphs[$graphtoenable] = true; diff --git a/includes/polling/hr-mib.inc.php b/includes/polling/hr-mib.inc.php index 1a901188d1..7a0cf780e9 100644 --- a/includes/polling/hr-mib.inc.php +++ b/includes/polling/hr-mib.inc.php @@ -6,46 +6,28 @@ $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'] - ); - } - + $tags = array( + 'rrd_def' => 'DS:procs:GAUGE:600:0:U', + ); $fields = array( 'procs' => $hrSystem[0]['hrSystemProcesses'], ); - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'hr_processes',$tags,$fields); + data_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'] - ); - } - + $tags = array( + 'rrd_def' => 'DS:users:GAUGE:600:0:U' + ); $fields = array( 'users' => $hrSystem[0]['hrSystemNumUsers'], ); - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'hr_users',$tags,$fields); + data_update($device,'hr_users',$tags,$fields); $graphs['hr_users'] = true; echo ' Users'; diff --git a/includes/polling/ipSystemStats.inc.php b/includes/polling/ipSystemStats.inc.php index 1e4324c69a..14aa6461bd 100644 --- a/includes/polling/ipSystemStats.inc.php +++ b/includes/polling/ipSystemStats.inc.php @@ -47,31 +47,31 @@ // IP-MIB::ipSystemStatsRefreshRate.ipv4 = Gauge32: 30000 milli-seconds // IP-MIB::ipSystemStatsRefreshRate.ipv6 = Gauge32: 30000 milli-seconds -$ipSystemStats = snmpwalk_cache_oid($device, 'ipSystemStats', null, 'IP-MIB'); +$data = snmpwalk_cache_oid($device, 'ipSystemStats', null, 'IP-MIB'); -if ($ipSystemStats) { - foreach ($ipSystemStats as $af => $stats) { +if ($data) { + $oids = array( + 'ipSystemStatsInReceives', + 'ipSystemStatsInHdrErrors', + 'ipSystemStatsInAddrErrors', + 'ipSystemStatsInUnknownProtos', + 'ipSystemStatsInForwDatagrams', + 'ipSystemStatsReasmReqds', + 'ipSystemStatsReasmOKs', + 'ipSystemStatsReasmFails', + 'ipSystemStatsInDiscards', + 'ipSystemStatsInDelivers', + 'ipSystemStatsOutRequests', + 'ipSystemStatsOutNoRoutes', + 'ipSystemStatsOutDiscards', + 'ipSystemStatsOutFragFails', + 'ipSystemStatsOutFragCreates', + 'ipSystemStatsOutForwDatagrams', + ); + + foreach ($data as $af => $stats) { echo "$af "; - $oids = array( - 'ipSystemStatsInReceives', - 'ipSystemStatsInHdrErrors', - 'ipSystemStatsInAddrErrors', - 'ipSystemStatsInUnknownProtos', - 'ipSystemStatsInForwDatagrams', - 'ipSystemStatsReasmReqds', - 'ipSystemStatsReasmOKs', - 'ipSystemStatsReasmFails', - 'ipSystemStatsInDiscards', - 'ipSystemStatsInDelivers', - 'ipSystemStatsOutRequests', - 'ipSystemStatsOutNoRoutes', - 'ipSystemStatsOutDiscards', - 'ipSystemStatsOutFragFails', - 'ipSystemStatsOutFragCreates', - 'ipSystemStatsOutForwDatagrams', - ); - // Use HC counters instead if they're available. if (isset($stats['ipSystemStatsHCInReceives'])) { $stats['ipSystemStatsInReceives'] = $stats['ipSystemStatsHCInReceives']; @@ -93,33 +93,22 @@ if ($ipSystemStats) { $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']; + $rrd_name = array('ipSystemStats', $af); + $rrd_def = array(); $fields = array(); foreach ($oids as $oid) { - $oid_ds = str_replace('ipSystemStats', '', $oid); + $oid_ds = str_replace('ipSystemStats', '', $oid); $oid_ds = truncate($oid_ds, 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; + $rrd_def[] = "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); + $tags = compact('af', 'rrd_name', 'rrd_def'); + data_update($device,'ipSystemStats',$tags,$fields); // FIXME per-AF? $graphs['ipsystemstats_'.$af] = true; @@ -127,4 +116,5 @@ if ($ipSystemStats) { }//end foreach }//end if +unset($oids, $data); echo "\n"; diff --git a/includes/polling/ipmi.inc.php b/includes/polling/ipmi.inc.php index cfbc5bf7bf..4d7c9f4734 100644 --- a/includes/polling/ipmi.inc.php +++ b/includes/polling/ipmi.inc.php @@ -27,30 +27,24 @@ if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) { $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"; + $rrd_name = get_sensor_rrd($device, $ipmisensors); + $rrd_def = 'DS:sensor:GAUGE:600:-20000:20000'; + $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); + $tags = array( + 'sensor_class' => $sensor['sensor_class'], + 'sensor_type' => $sensor['sensor_type'], + 'sensor_descr' => $sensor['sensor_descr'], + 'sensor_index' => $sensor['sensor_index'], + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def + ); + data_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'])); diff --git a/includes/polling/junose-atm-vp.inc.php b/includes/polling/junose-atm-vp.inc.php index 08fc0e3b96..3ebe02a3f7 100644 --- a/includes/polling/junose-atm-vp.inc.php +++ b/includes/polling/junose-atm-vp.inc.php @@ -13,10 +13,23 @@ if (count($vp_rows)) { $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsOutPacketOctets', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'].'/mibs/junose'); $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsOutPacketErrors', $vp_cache, 'Juniper-UNI-ATM-MIB', $config['install_dir'].'/mibs/junose'); + $rrd_def = array( + 'DS:incells:DERIVE:600:0:125000000000', + 'DS:outcells:DERIVE:600:0:125000000000', + 'DS:inpackets:DERIVE:600:0:125000000000', + 'DS:outpackets:DERIVE:600:0:125000000000', + 'DS:inpacketoctets:DERIVE:600:0:125000000000', + 'DS:outpacketoctets:DERIVE:600:0:125000000000', + 'DS:inpacketerrors:DERIVE:600:0:125000000000', + 'DS:outpacketerrors:DERIVE:600:0:125000000000' + ); + foreach ($vp_rows as $vp) { echo '.'; - $oid = $vp['ifIndex'].'.'.$vp['vp_id']; + $ifIndex = $vp['ifIndex']; + $vp_id = $vp['vp_id']; + $oid = $ifIndex .'.'. $vp_id; d_echo("$oid "); @@ -27,25 +40,7 @@ if (count($vp_rows)) { $vp_update .= ':'.$t_vp['juniAtmVpStatsInPacketOctets'].':'.$t_vp['juniAtmVpStatsOutPacketOctets']; $vp_update .= ':'.$t_vp['juniAtmVpStatsInPacketErrors'].':'.$t_vp['juniAtmVpStatsOutPacketErrors']; - $rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('vp-'.$vp['ifIndex'].'-'.$vp['vp_id'].'.rrd'); - - d_echo("$rrd "); - - if (!is_file($rrd)) { - rrdtool_create( - $rrd, - '--step 300 - DS:incells:DERIVE:600:0:125000000000 - DS:outcells:DERIVE:600:0:125000000000 - DS:inpackets:DERIVE:600:0:125000000000 - DS:outpackets:DERIVE:600:0:125000000000 - DS:inpacketoctets:DERIVE:600:0:125000000000 - DS:outpacketoctets:DERIVE:600:0:125000000000 - DS:inpacketerrors:DERIVE:600:0:125000000000 - DS:outpacketerrors:DERIVE:600:0:125000000000 - '.$config['rrd_rra'] - ); - } + $rrd_name = array('vp', $ifIndex, $vp_id); $fields = array( 'incells' => $t_vp['juniAtmVpStatsInCells'], @@ -58,14 +53,12 @@ if (count($vp_rows)) { 'outpacketerrors' => $t_vp['juniAtmVpStatsOutPacketErrors'], ); - rrdtool_update($rrd, $fields); - - $tags = array('ifIndex' => $vp['ifIndex'], 'vp_id' => $vp['vp_id']); - influx_update($device,'atm-vp',$tags,$fields); + $tags = compact('ifIndex', 'vp_id', 'rrd_name', 'rrd_def'); + data_update($device,'atm-vp',$tags,$fields); }//end foreach echo "\n"; - unset($vp_cache); + unset($vp_cache, $rrd_def); }//end if diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index f23d4c4962..96f2ba6f4a 100644 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -3,15 +3,13 @@ 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'); + $mempool_type = $mempool['mempool_type']; + $mempool_index = $mempool['mempool_index']; - $file = $config['install_dir'].'/includes/polling/mempools/'.$mempool['mempool_type'].'.inc.php'; + $file = $config['install_dir'].'/includes/polling/mempools/'. $mempool_type .'.inc.php'; if (is_file($file)) { include $file; } - else { - // FIXME Do we need a generic mempool poller? - } if ($mempool['total']) { $percent = round(($mempool['used'] / $mempool['total'] * 100), 2); @@ -22,18 +20,19 @@ foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device 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']); - } + $rrd_name = array('mempool', $mempool_type, $mempool_index); + $rrd_def = array( + 'DS:used:GAUGE:600:0:U', + 'DS:free:GAUGE:600:0:U' + ); $fields = array( 'used' => $mempool['used'], 'free' => $mempool['free'], ); - rrdtool_update($mempool_rrd, $fields); - $tags = array('mempool_type' => $mempool['mempool_type'], 'mempool_index' => $mempool['mempool_index']); - influx_update($device,'mempool',$tags,$fields); + $tags = compact('mempool_type', 'mempool_index', 'rrd_name', 'rrd_def'); + data_update($device,'mempool',$tags,$fields); $mempool['state'] = array( 'mempool_used' => $mempool['used'], @@ -54,5 +53,3 @@ foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device echo "\n"; }//end foreach - -unset($mempool_cache); diff --git a/includes/polling/netscaler-stats.inc.php b/includes/polling/netscaler-stats.inc.php index 2892bac40d..85639d1c36 100644 --- a/includes/polling/netscaler-stats.inc.php +++ b/includes/polling/netscaler-stats.inc.php @@ -95,25 +95,19 @@ if ($device['os'] == 'netscaler') { $oids = array_merge($oids_gauge, $oids_counter); - unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netscaler-stats-tcp.rrd'; - - $rrd_create = $config['rrd_rra']; - - foreach ($oids_gauge as $oid) { - $oid_ds = truncate(str_replace('tcp', '', str_replace('Active', 'Ac', str_replace('Passive', 'Ps', str_replace('Zombie', 'Zom', $oid)))), 19, ''); - $rrd_create .= " DS:$oid_ds:GAUGE:600:U:100000000000"; - } - - foreach ($oids_counter as $oid) { - $oid_ds = truncate(str_replace('tcp', '', str_replace('Active', 'Ac', str_replace('Passive', 'Ps', str_replace('Zombie', 'Zom', $oid)))), 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; - } - $data = snmpwalk_cache_oid($device, 'nsTcpStatsGroup', array(), 'NS-ROOT-MIB'); - $fields = array(); + $rrd_def = array(); + foreach ($oids_gauge as $oid) { + $oid_ds = truncate(str_replace('tcp', '', str_replace('Active', 'Ac', str_replace('Passive', 'Ps', str_replace('Zombie', 'Zom', $oid)))), 19, ''); + $rrd_def[] = "DS:$oid_ds:GAUGE:600:U:100000000000"; + } + foreach ($oids_counter as $oid) { + $oid_ds = truncate(str_replace('tcp', '', str_replace('Active', 'Ac', str_replace('Passive', 'Ps', str_replace('Zombie', 'Zom', $oid)))), 19, ''); + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; + } + $fields = array(); foreach ($oids as $oid) { if (is_numeric($data[0][$oid])) { $rrdupdate = ':'.$data[0][$oid]; @@ -124,18 +118,12 @@ if ($device['os'] == 'netscaler') { $fields[$oid] = $rrdupdate; } - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); - } - - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'netscaler-stats-tcp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'netscaler-stats-tcp',$tags,$fields); $graphs['netscaler_tcp_conn'] = true; $graphs['netscaler_tcp_bits'] = true; $graphs['netscaler_tcp_pkts'] = true; }//end if -unset($oids, $data, $data_array, $oid); +unset($oids_gauge, $oids_counter, $oids, $data, $tags, $fields, $rrd_def); diff --git a/includes/polling/netscaler-vsvr.inc.php b/includes/polling/netscaler-vsvr.inc.php index 7bf549d27d..7b3d8495ef 100644 --- a/includes/polling/netscaler-vsvr.inc.php +++ b/includes/polling/netscaler-vsvr.inc.php @@ -54,18 +54,14 @@ if ($device['os'] == 'netscaler') { $oids = array_merge($oids_gauge, $oids_counter); - unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); - - $rrd_create = $config['rrd_rra']; - + $rrd_def = array(); foreach ($oids_gauge as $oid) { - $oid_ds = truncate(str_replace('vsvr', '', $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:GAUGE:600:U:100000000000"; + $oid_ds = truncate(str_replace('vsvr', '', $oid), 19, ''); + $rrd_def[] = "DS:$oid_ds:GAUGE:600:U:100000000000"; } - foreach ($oids_counter as $oid) { - $oid_ds = truncate(str_replace('vsvr', '', $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; + $oid_ds = truncate(str_replace('vsvr', '', $oid), 19, ''); + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; } $vsvr_array = snmpwalk_cache_oid($device, 'vserverEntry', array(), 'NS-ROOT-MIB'); @@ -81,7 +77,7 @@ if ($device['os'] == 'netscaler') { foreach ($vsvr_array as $index => $vsvr) { if (isset($vsvr['vsvrName'])) { $vsvr_exist[$vsvr['vsvrName']] = 1; - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netscaler-vsvr-'.safename($vsvr['vsvrName']).'.rrd'; + $rrd_name = 'netscaler-vsvr-'.$vsvr['vsvrName']; $fields = array(); foreach ($oids as $oid) { @@ -93,6 +89,13 @@ if ($device['os'] == 'netscaler') { } } + $tags = array( + 'vsvrName' => $vsvr['vsvrName'], + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def + ); + data_update($device,'netscaler-vsvr',$tags,$fields); + 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); @@ -116,15 +119,6 @@ if ($device['os'] == 'netscaler') { 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 diff --git a/includes/polling/netstats-icmp.inc.php b/includes/polling/netstats-icmp.inc.php index 19df0a5c4b..5e77ecc927 100644 --- a/includes/polling/netstats-icmp.inc.php +++ b/includes/polling/netstats-icmp.inc.php @@ -33,36 +33,22 @@ if ($device['os'] != 'Snom') { 'icmpOutAddrMaskReps', ); - unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netstats-icmp.rrd'; + $data = snmpwalk_cache_oid($device, 'icmp', array(), 'IP-MIB'); + $fields = $data[0]; - $rrd_create = $config['rrd_rra']; - - foreach ($oids as $oid) { - $oid_ds = truncate($oid, 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; - $snmpstring .= " $oid.0"; - } - - $data_array = snmpwalk_cache_oid($device, 'icmp', array(), 'IP-MIB'); - - $fields = $data_array[0]; - - unset($snmpstring); - - if (isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs'])) { - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); + if (isset($fields['icmpInMsgs']) && isset($fields['icmpOutMsgs'])) { + $rrd_def = array(); + foreach ($oids as $oid) { + $oid_ds = truncate($oid, 19, ''); + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; } - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'netstats-icmp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'netstats-icmp',$tags,$fields); $graphs['netstat_icmp'] = true; $graphs['netstat_icmp_info'] = true; } - unset($oids, $data, $data_array, $oid, $protos); + unset($oids, $data, $rrd_def, $fields, $tags); }//end if diff --git a/includes/polling/netstats-ip.inc.php b/includes/polling/netstats-ip.inc.php index 53f77b5c61..3bbefc1521 100644 --- a/includes/polling/netstats-ip.inc.php +++ b/includes/polling/netstats-ip.inc.php @@ -23,21 +23,17 @@ if ($device['os'] != 'Snom') { 'ipInAddrErrors', ); - unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netstats-ip.rrd'; - - $rrd_create = $config['rrd_rra']; - + $rrd_def = array(); + $snmpstring = ''; foreach ($oids as $oid) { - $oid_ds = truncate($oid, 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; + $oid_ds = truncate($oid, 19, ''); + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; $snmpstring .= ' IP-MIB::'.$oid.'.0'; } $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'IP-MIB'); $fields = array(); - foreach ($oids as $oid) { if (is_numeric($data[0][$oid])) { $value = $data[0][$oid]; @@ -49,18 +45,13 @@ if ($device['os'] != 'Snom') { } if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives'])) { - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); - } - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'netstats-ip',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'netstats-ip', $tags, $fields); $graphs['netstat_ip'] = true; $graphs['netstat_ip_frag'] = true; } }//end if -unset($oids, $data, $data_array, $oid); +unset($oids, $data, $snmpstring, $rrd_def, $fields, $tags); diff --git a/includes/polling/netstats-ip_forward.inc.php b/includes/polling/netstats-ip_forward.inc.php index ccedd37618..9ca7bd1096 100644 --- a/includes/polling/netstats-ip_forward.inc.php +++ b/includes/polling/netstats-ip_forward.inc.php @@ -7,21 +7,18 @@ if ($device['os'] != 'Snom') { $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']; + $rrd_def = array(); + $snmpstring = ''; foreach ($oids as $oid) { - $oid_ds = truncate($oid, 19, ''); - $rrd_create .= " DS:$oid_ds:GAUGE:600:U:1000000"; - // Limit to 1MPPS? + $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]; @@ -33,18 +30,11 @@ if ($device['os'] != 'Snom') { } 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); - + $tags = compact('rrd_def'); + data_update($device,'netstats-ip_forward',$tags,$fields); $graphs['netstat_ip_forward'] = true; } } -unset($oids, $data, $data_array, $oid, $protos, $snmpstring); +unset($oids, $rrd_def, $data, $oid, $fields, $snmpstring, $tags); diff --git a/includes/polling/netstats-snmp.inc.php b/includes/polling/netstats-snmp.inc.php index 0bc04e57d0..60ce024141 100644 --- a/includes/polling/netstats-snmp.inc.php +++ b/includes/polling/netstats-snmp.inc.php @@ -36,34 +36,24 @@ if ($device['os'] != 'Snom') { 'snmpProxyDrops', ); - unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('netstats-snmp.rrd'); + $data = snmpwalk_cache_oid($device, 'snmp', array(), 'SNMPv2-MIB'); - $rrd_create = $config['rrd_rra']; - - foreach ($oids as $oid) { - $oid_ds = truncate($oid, 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; - } - - $data_array = snmpwalk_cache_oid($device, 'snmp', array(), 'SNMPv2-MIB'); - - $fields = $data_array[0]; + $fields = $data[0]; unset($fields['snmpEnableAuthenTraps']); - if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts'])) { - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); + if (isset($fields['snmpInPkts']) && isset($fields['snmpOutPkts'])) { + $rrd_def = array(); + foreach ($oids as $oid) { + $oid_ds = truncate($oid, 19, ''); + $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; } - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'netstats-snmp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'netstats-snmp',$tags,$fields); $graphs['netstat_snmp'] = true; $graphs['netstat_snmp_pkt'] = true; } - unset($oids, $data, $data_array, $oid, $protos); + unset($oids, $data, $feilds, $oid, $rrd_def, $tags); }//end if diff --git a/includes/polling/netstats-tcp.inc.php b/includes/polling/netstats-tcp.inc.php index 3d060f6e4b..26f446243b 100644 --- a/includes/polling/netstats-tcp.inc.php +++ b/includes/polling/netstats-tcp.inc.php @@ -19,15 +19,12 @@ if ($device['os'] != 'Snom') { // $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']; + $rrd_def = array(); + $snmpstring = ''; foreach ($oids as $oid) { - $oid_ds = truncate($oid, 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000"; - // Limit to 10MPPS + $oid_ds = truncate($oid, 19, ''); + $rrd_def[] = " DS:$oid_ds:COUNTER:600:U:10000000"; // Limit to 10MPPS $snmpstring .= ' TCP-MIB::'.$oid.'.0'; } @@ -40,18 +37,13 @@ if ($device['os'] != 'Snom') { unset($snmpstring); - if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs'])) { - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); - } + if (isset($fields['tcpInSegs']) && isset($fields['tcpOutSegs'])) { - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'netstats-tcp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'netstats-tcp',$tags,$fields); $graphs['netstat_tcp'] = true; } - unset($oids, $data, $data_array, $oid, $protos); + unset($oids, $data, $data, $oid, $protos); }//end if diff --git a/includes/polling/netstats-udp.inc.php b/includes/polling/netstats-udp.inc.php index 6af8e6f7f5..ddc27d9e7e 100644 --- a/includes/polling/netstats-udp.inc.php +++ b/includes/polling/netstats-udp.inc.php @@ -11,22 +11,17 @@ if ($device['os'] != 'Snom') { 'udpNoPorts', ); - unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create); - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netstats-udp.rrd'; - - $rrd_create = $config['rrd_rra']; - + $rrd_def = array(); + $snmpstring = ''; foreach ($oids as $oid) { $oid_ds = truncate($oid, 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000"; - // Limit to 1MPPS? + $rrd_def[] = " DS:$oid_ds:COUNTER:600:U:1000000"; // Limit to 1MPPS? $snmpstring .= ' UDP-MIB::'.$oid.'.0'; } $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'UDP-MIB'); $fields = array(); - foreach ($oids as $oid) { if (is_numeric($data[0][$oid])) { $value = $data[0][$oid]; @@ -38,17 +33,12 @@ if ($device['os'] != 'Snom') { } if (isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams'])) { - if (!file_exists($rrd_file)) { - rrdtool_create($rrd_file, $rrd_create); - } - rrdtool_update($rrd_file, $fields); - - $tags = array(); - influx_update($device,'netstats-udp',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'netstats-udp', $tags, $fields); $graphs['netstat_udp'] = true; } }//end if -unset($oids, $data, $data_array, $oid, $protos, $snmpstring); +unset($oids, $data, $rrd_def, $fields, $tags, $snmpstring); diff --git a/includes/polling/os/ciscowlc.inc.php b/includes/polling/os/ciscowlc.inc.php index df4934a874..9c4f07dc0b 100644 --- a/includes/polling/os/ciscowlc.inc.php +++ b/includes/polling/os/ciscowlc.inc.php @@ -56,27 +56,29 @@ 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']); -} +$rrd_def = array( + 'DS:NUMAPS:GAUGE:600:0:12500000000', + 'DS:NUMCLIENTS:GAUGE:600:0:12500000000' +); $fields = array( - 'NUMAPS' => $numAccessPoints, - 'NUMCLIENTS' => $numClients + 'NUMAPS' => $numAccessPoints, + 'NUMCLIENTS' => $numClients ); -$ret = rrdtool_update($rrdfile, $fields); + +$tags = compact('rrd_def'); +data_update($device, 'ciscowlc', $tags, $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']); -} +$radio = 1; +$rrd_name = 'wificlients-radio'.$radio; +$rrd_def = 'DS:wificlients:GAUGE:600:-273:10000'; $fields = array( - 'wificlients' => $numClients + 'wificlients' => $numClients ); -rrdtool_update($wificlientsrrd, $fields); +$tags = compact('radio', 'rrd_name', 'rrd_def'); +data_update($device, 'wificlients', $tags, $fields); + $graphs['wifi_clients'] = true; diff --git a/includes/polling/os/fortigate.inc.php b/includes/polling/os/fortigate.inc.php index 06e604059a..5abb7422af 100644 --- a/includes/polling/os/fortigate.inc.php +++ b/includes/polling/os/fortigate.inc.php @@ -9,33 +9,31 @@ if (isset($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']); - } + $rrd_def = 'DS:sessions:GAUGE:600:0:3000000'; + print "Sessions: $sessions\n"; $fields = array( 'sessions' => $sessions, ); - rrdtool_update($sessrrd, $fields); - $tags = array(); - influx_update($device,'fortigate_sessions',$tags,$fields); + + $tags = compact('rrd_def'); + data_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']); - } + $rrd_def = 'DS:LOAD:GAUGE:600:-1:100'; + echo "CPU: $cpu_usage%\n"; $fields = array( 'LOAD' => $cpu_usage, ); - rrdtool_update($cpurrd, $fields); - $tags = array(); - influx_update($device,'fortigate_cpu',$tags,$fields); + + $tags = compact('rrd_def'); + data_update($device, 'fortigate_cpu', $tags, $fields); $graphs['fortigate_cpu'] = true; } diff --git a/includes/polling/os/nios.inc.php b/includes/polling/os/nios.inc.php index 3f6d4ccfcc..144e813b9d 100644 --- a/includes/polling/os/nios.inc.php +++ b/includes/polling/os/nios.inc.php @@ -7,8 +7,6 @@ $hardware = trim(snmp_get($device, "ibHardwareType.0", "-OQv", "IB-PLATFORMONE-M ############## # Create ddns update rrd ############## -$rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/ib_dns_dyn_updates.rrd'; - $mibs = '+IB-DNSONE-MIB'; $oids = 'IB-DNSONE-MIB::ibDDNSUpdateSuccess.0 ' . @@ -18,37 +16,29 @@ $oids = $data = snmp_get_multi($device, $oids, '-OQUs', $mibs); -$ds1 = $data[0]['ibDDNSUpdateSuccess']; -$ds2 = $data[0]['ibDDNSUpdateFailure']; -$ds3 = $data[0]['ibDDNSUpdateReject']; -$ds4 = $data[0]['ibDDNSUpdatePrerequisiteReject']; - -if (!is_file($rrdfile)) { - rrdtool_create( - $rrdfile, - 'DS:success:DERIVE:600:0:U - DS:failure:DERIVE:600:0:U - DS:reject:DERIVE:600:0:U - DS:prereq_reject:DERIVE:600:0:U '.$config['rrd_rra']); -} +$rrd_def = array( + 'DS:success:DERIVE:600:0:U', + 'DS:failure:DERIVE:600:0:U', + 'DS:reject:DERIVE:600:0:U', + 'DS:prereq_reject:DERIVE:600:0:U' +); $fields = array( - 'success' => $ds1, - 'failure' => $ds2, - 'reject' => $ds3, - 'prereq_reject' => $ds4, + 'success' => $data[0]['ibDDNSUpdateSuccess'], + 'failure' => $data[0]['ibDDNSUpdateFailure'], + 'reject' => $data[0]['ibDDNSUpdateReject'], + 'prereq_reject' => $data[0]['ibDDNSUpdatePrerequisiteReject'], ); -rrdtool_update($rrdfile, $fields); +$tags = compact('rrd_def'); +data_update($device, 'ib_dns_dyn_updates', $tags, $fields); $graphs['ib_dns_dyn_updates'] = true; ################## # Create dns performance graph (latency) ################## -$rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/ib_dns_performance.rrd'; - $mibs = '+IB-PLATFORMONE-MIB'; $oids = 'IB-PLATFORMONE-MIB::ibNetworkMonitorDNSNonAAT1AvgLatency.0 ' . @@ -56,29 +46,23 @@ $oids = $data = snmp_get_multi($device, $oids, '-OQUs', $mibs); -$ds1 = $data[0]['ibNetworkMonitorDNSAAT1AvgLatency']; -$ds2 = $data[0]['ibNetworkMonitorDNSNonAAT1AvgLatency']; - -if (!is_file($rrdfile)) { - rrdtool_create( - $rrdfile, - 'DS:PerfAA:GAUGE:600:0:U - DS:PerfnonAA:GAUGE:600:0:U '.$config['rrd_rra']); -} - -$fields = array( - 'PerfAA' => $ds1, - 'PerfnonAA' => $ds2, +$rrd_def = array( + 'DS:PerfAA:GAUGE:600:0:U', + 'DS:PerfnonAA:GAUGE:600:0:U' ); -rrdtool_update($rrdfile, $fields); +$fields = array( + 'PerfAA' => $data[0]['ibNetworkMonitorDNSAAT1AvgLatency'], + 'PerfnonAA' => $data[0]['ibNetworkMonitorDNSNonAAT1AvgLatency'], +); + +$tags = compact('rrd_def'); +data_update($device, 'ib_dns_performance', $tags, $fields); $graphs['ib_dns_performance'] = true; ################## # Create dns request return code graph ################## -$rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/ib_dns_request_return_codes.rrd'; - $mibs = '+IB-DNSONE-MIB'; $oids = 'IB-DNSONE-MIB::ibBindZoneFailure.\"summary\" ' . @@ -88,37 +72,28 @@ $oids = $data = snmp_get_multi($device, $oids, '-OQUs', $mibs); -$ds1 = $data['"summary"']['ibBindZoneSuccess']; -$ds2 = $data['"summary"']['ibBindZoneFailure']; -$ds3 = $data['"summary"']['ibBindZoneNxDomain']; -$ds4 = $data['"summary"']['ibBindZoneNxRRset']; - - -if (!is_file($rrdfile)) { - rrdtool_create( - $rrdfile, - 'DS:success:DERIVE:600:0:U - DS:failure:DERIVE:600:0:U - DS:nxdomain:DERIVE:600:0:U - DS:nxrrset:DERIVE:600:0:U '.$config['rrd_rra']); -} - -$fields = array( - 'success' => $ds1, - 'failure' => $ds2, - 'nxdomain' => $ds3, - 'nxrrset' => $ds4, +$rrd_def = array( + 'DS:success:DERIVE:600:0:U', + 'DS:failure:DERIVE:600:0:U', + 'DS:nxdomain:DERIVE:600:0:U', + 'DS:nxrrset:DERIVE:600:0:U' ); -rrdtool_update($rrdfile, $fields); +$fields = array( + 'success' => $data['"summary"']['ibBindZoneSuccess'], + 'failure' => $data['"summary"']['ibBindZoneFailure'], + 'nxdomain' => $data['"summary"']['ibBindZoneNxDomain'], + 'nxrrset' => $data['"summary"']['ibBindZoneNxRRset'], +); + +$tags = compact('rrd_def'); +data_update($device, 'ib_dns_request_return_codes', $tags, $fields); $graphs['ib_dns_request_return_codes'] = true; ################## # Create dhcp messages graph ################## -$rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/ib_dhcp_messages.rrd'; - $mibs = '+IB-DHCPONE-MIB'; $oids = 'IB-DHCPONE-MIB::ibDhcpTotalNoOfAcks.0 ' . @@ -133,42 +108,31 @@ $oids = $data = snmp_get_multi($device, $oids, '-OQUs', $mibs); -$ds1 = $data[0]['ibDhcpTotalNoOfAcks']; -$ds2 = $data[0]['ibDhcpTotalNoOfDeclines']; -$ds3 = $data[0]['ibDhcpTotalNoOfDiscovers']; -$ds4 = $data[0]['ibDhcpTotalNoOfInforms']; -$ds5 = $data[0]['ibDhcpTotalNoOfNacks']; -$ds6 = $data[0]['ibDhcpTotalNoOfOffers']; -$ds7 = $data[0]['ibDhcpTotalNoOfOthers']; -$ds8 = $data[0]['ibDhcpTotalNoOfReleases']; -$ds9 = $data[0]['ibDhcpTotalNoOfRequests']; - -if (!is_file($rrdfile)) { - rrdtool_create( - $rrdfile, - 'DS:ack:DERIVE:600:0:U - DS:decline:DERIVE:600:0:U - DS:discover:DERIVE:600:0:U - DS:inform:DERIVE:600:0:U - DS:nack:DERIVE:600:0:U - DS:offer:DERIVE:600:0:U - DS:other:DERIVE:600:0:U - DS:release:DERIVE:600:0:U - DS:request:DERIVE:600:0:U '.$config['rrd_rra']); -} - -$fields = array( - 'ack' => $ds1, - 'decline' => $ds2, - 'discover' => $ds3, - 'inform' => $ds4, - 'nack' => $ds5, - 'offer' => $ds6, - 'other' => $ds7, - 'release' => $ds8, - 'request' => $ds9, +$rrd_def = array( + 'DS:ack:DERIVE:600:0:U', + 'DS:decline:DERIVE:600:0:U', + 'DS:discover:DERIVE:600:0:U', + 'DS:inform:DERIVE:600:0:U', + 'DS:nack:DERIVE:600:0:U', + 'DS:offer:DERIVE:600:0:U', + 'DS:other:DERIVE:600:0:U', + 'DS:release:DERIVE:600:0:U', + 'DS:request:DERIVE:600:0:U' ); -rrdtool_update($rrdfile, $fields); +$fields = array( + 'ack' => $data[0]['ibDhcpTotalNoOfAcks'], + 'decline' => $data[0]['ibDhcpTotalNoOfDeclines'], + 'discover' => $data[0]['ibDhcpTotalNoOfDiscovers'], + 'inform' => $data[0]['ibDhcpTotalNoOfInforms'], + 'nack' => $data[0]['ibDhcpTotalNoOfNacks'], + 'offer' => $data[0]['ibDhcpTotalNoOfOffers'], + 'other' => $data[0]['ibDhcpTotalNoOfOthers'], + 'release' => $data[0]['ibDhcpTotalNoOfReleases'], + 'request' => $data[0]['ibDhcpTotalNoOfRequests'], +); + +$tags = compact('rrd_def'); +data_update($device, 'ib_dhcp_messages', $tags, $fields); $graphs['ib_dhcp_messages'] = true; diff --git a/includes/polling/os/panos.inc.php b/includes/polling/os/panos.inc.php index 2fb556fb19..acc7cca422 100644 --- a/includes/polling/os/panos.inc.php +++ b/includes/polling/os/panos.inc.php @@ -5,22 +5,17 @@ $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']); - } + $rrd_def = 'DS:sessions:GAUGE:600:0:3000000'; $fields = array( 'sessions' => $sessions, ); - rrdtool_update($sessrrd, $fields); - - $tags = array(); - influx_update($device,'panos-sessions',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'panos-sessions', $tags, $fields); $graphs['panos_sessions'] = true; } diff --git a/includes/polling/os/procurve.inc.php b/includes/polling/os/procurve.inc.php index 8c119dcbfd..71509ea165 100644 --- a/includes/polling/os/procurve.inc.php +++ b/includes/polling/os/procurve.inc.php @@ -31,27 +31,17 @@ $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'] - ); - } + $rrd_def = 'DS:value:GAUGE:600:-1:100000'; $fields = array( 'value' => $FdbAddressCount, ); - rrdtool_update($fdb_rrd_file, $fields); - - $tags = array(); - influx_update($device,'fdb_count',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'fdb_count', $tags, $fields); $graphs['fdb_count'] = true; diff --git a/includes/polling/os/pulse.inc.php b/includes/polling/os/pulse.inc.php index a868bc8afe..c012aee69c 100644 --- a/includes/polling/os/pulse.inc.php +++ b/includes/polling/os/pulse.inc.php @@ -14,34 +14,30 @@ $version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-M $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']); - } + $rrd_def = 'DS:users:GAUGE:600:0:U'; $fields = array( 'users' => $users, ); - rrdtool_update($usersrrd, $fields); + $tags = compact('rrd_def'); + data_update($device, 'pulse_users', $tags, $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']); - } + $rrd_def = 'DS:sessions:GAUGE:600:0:U'; $fields = array( 'sessions' => $sessions, ); - rrdtool_update($sessrrd, $fields); + $tags = compact('rrd_def'); + data_update($device, 'pulse_sessions', $tags, $fields); $graphs['pulse_sessions'] = true; } diff --git a/includes/polling/os/screenos.inc.php b/includes/polling/os/screenos.inc.php index 53c4326bd6..c86b9b748a 100644 --- a/includes/polling/os/screenos.inc.php +++ b/includes/polling/os/screenos.inc.php @@ -3,21 +3,16 @@ $version = preg_replace('/(.+)\ version\ (.+)\ \(SN:\ (.+)\,\ (.+)\)/', '\\1||\\2||\\3||\\4', $poll_device['sysDescr']); list($hardware,$version,$serial,$features) = explode('||', $version); -$sessrrd = $config['rrd_dir'].'/'.$device['hostname'].'/screenos_sessions.rrd'; $sess_cmd = $config['snmpget'].' -M '.$config['mibdir'].' -O qv '.snmp_gen_auth($device).' '.$device['hostname']; $sess_cmd .= ' .1.3.6.1.4.1.3224.16.3.2.0 .1.3.6.1.4.1.3224.16.3.3.0 .1.3.6.1.4.1.3224.16.3.4.0'; $sess_data = shell_exec($sess_cmd); list ($sessalloc, $sessmax, $sessfailed) = explode("\n", $sess_data); -if (!is_file($sessrrd)) { - rrdtool_create( - $sessrrd, - ' --step 300 - DS:allocate:GAUGE:600:0:3000000 - DS:max:GAUGE:600:0:3000000 - DS:failed:GAUGE:600:0:1000 '.$config['rrd_rra'] - ); -} +$rrd_def = array( + 'DS:allocate:GAUGE:600:0:3000000', + 'DS:max:GAUGE:600:0:3000000', + 'DS:failed:GAUGE:600:0:1000' +); $fields = array( 'allocate' => $sessalloc, @@ -25,9 +20,7 @@ $fields = array( 'failed' => $sessfailed, ); -rrdtool_update("$sessrrd", $fields); - -$tags = array(); -influx_update($device,'screenos_sessions',$tags,$fields); +$tags = compact('rrd_def'); +data_update($device, 'screenos_sessions', $tags, $fields); $graphs['screenos_sessions'] = true; diff --git a/includes/polling/os/snom.inc.php b/includes/polling/os/snom.inc.php index d778bcf97f..444cf0c017 100644 --- a/includes/polling/os/snom.inc.php +++ b/includes/polling/os/snom.inc.php @@ -23,18 +23,15 @@ $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'] - ); -} +$rrd_name = 'data'; +$rrd_def = array( + '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' +); $fields = array( 'INOCTETS' => $rxbytes, @@ -45,7 +42,5 @@ $fields = array( 'REGISTRATIONS' => $registrations, ); -rrdtool_update("$rrdfile", $fields); - -$tags = array(); -influx_update($device,'snom-data',$tags,$fields); +$tags = compact('rrd_name', 'rrd_def'); +data_update($device, 'snom-data', $tags, $fields); diff --git a/includes/polling/ospf.inc.php b/includes/polling/ospf.inc.php index 32c3b3b7ab..cdf8d9151f 100644 --- a/includes/polling/ospf.inc.php +++ b/includes/polling/ospf.inc.php @@ -379,18 +379,12 @@ foreach ($vrfs_lite_cisco as $vrf_lite) { 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'] - ); -} +$rrd_def = array( + 'DS:instances:GAUGE:600:0:1000000', + 'DS:areas:GAUGE:600:0:1000000', + 'DS:ports:GAUGE:600:0:1000000', + 'DS:neighbours:GAUGE:600:0:1000000' +); $fields = array( 'instances' => $ospf_instance_count, @@ -398,9 +392,8 @@ $fields = array( 'ports' => $ospf_port_count, 'neighbours' => $ospf_neighbour_count, ); -$ret = rrdtool_update("$filename", $fields); -$tags = array(); -influx_update($device,'ospf-statistics',$tags,$fields); +$tags = compact('rrd_def'); +data_update($device, 'ospf-statistics', $tags, $fields); echo "\n"; diff --git a/includes/polling/port-adsl.inc.php b/includes/polling/port-adsl.inc.php index 42b9864288..15847f4777 100644 --- a/includes/polling/port-adsl.inc.php +++ b/includes/polling/port-adsl.inc.php @@ -40,33 +40,32 @@ // adslAturPerfValidIntervals.1 = 0 // adslAturPerfInvalidIntervals.1 = 0 if (isset($this_port['adslLineCoding'])) { - $rrdfile = get_port_rrdfile_path ($device['hostname'], $port_id, 'adsl'); - - $rrd_create = ' --step 300'; - $rrd_create .= ' DS:AtucCurrSnrMgn:GAUGE:600:0:635'; - $rrd_create .= ' DS:AtucCurrAtn:GAUGE:600:0:635'; - $rrd_create .= ' DS:AtucCurrOutputPwr:GAUGE:600:0:635'; - $rrd_create .= ' DS:AtucCurrAttainableR:GAUGE:600:0:U'; - $rrd_create .= ' DS:AtucChanCurrTxRate:GAUGE:600:0:U'; - $rrd_create .= ' DS:AturCurrSnrMgn:GAUGE:600:0:635'; - $rrd_create .= ' DS:AturCurrAtn:GAUGE:600:0:635'; - $rrd_create .= ' DS:AturCurrOutputPwr:GAUGE:600:0:635'; - $rrd_create .= ' DS:AturCurrAttainableR:GAUGE:600:0:U'; - $rrd_create .= ' DS:AturChanCurrTxRate:GAUGE:600:0:U'; - $rrd_create .= ' DS:AtucPerfLofs:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AtucPerfLoss:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AtucPerfLprs:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AtucPerfESs:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AtucPerfInits:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AturPerfLofs:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AturPerfLoss:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AturPerfLprs:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AturPerfESs:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AtucChanCorrectedBl:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AtucChanUncorrectBl:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AturChanCorrectedBl:COUNTER:600:U:100000000000'; - $rrd_create .= ' DS:AturChanUncorrectBl:COUNTER:600:U:100000000000'; - $rrd_create .= $config['rrd_rra']; + $rrd_name = getPortRrdName($port_id, 'adsl'); + $rrd_def = array( + 'DS:AtucCurrSnrMgn:GAUGE:600:0:635', + 'DS:AtucCurrAtn:GAUGE:600:0:635', + 'DS:AtucCurrOutputPwr:GAUGE:600:0:635', + 'DS:AtucCurrAttainableR:GAUGE:600:0:U', + 'DS:AtucChanCurrTxRate:GAUGE:600:0:U', + 'DS:AturCurrSnrMgn:GAUGE:600:0:635', + 'DS:AturCurrAtn:GAUGE:600:0:635', + 'DS:AturCurrOutputPwr:GAUGE:600:0:635', + 'DS:AturCurrAttainableR:GAUGE:600:0:U', + 'DS:AturChanCurrTxRate:GAUGE:600:0:U', + 'DS:AtucPerfLofs:COUNTER:600:U:100000000000', + 'DS:AtucPerfLoss:COUNTER:600:U:100000000000', + 'DS:AtucPerfLprs:COUNTER:600:U:100000000000', + 'DS:AtucPerfESs:COUNTER:600:U:100000000000', + 'DS:AtucPerfInits:COUNTER:600:U:100000000000', + 'DS:AturPerfLofs:COUNTER:600:U:100000000000', + 'DS:AturPerfLoss:COUNTER:600:U:100000000000', + 'DS:AturPerfLprs:COUNTER:600:U:100000000000', + 'DS:AturPerfESs:COUNTER:600:U:100000000000', + 'DS:AtucChanCorrectedBl:COUNTER:600:U:100000000000', + 'DS:AtucChanUncorrectBl:COUNTER:600:U:100000000000', + 'DS:AturChanCorrectedBl:COUNTER:600:U:100000000000', + 'DS:AturChanUncorrectBl:COUNTER:600:U:100000000000', + ); $adsl_oids = array( 'AtucCurrSnrMgn', @@ -159,14 +158,8 @@ if (isset($this_port['adslLineCoding'])) { $fields[$oid] = $data; } - if (!is_file($rrdfile)) { - rrdtool_create($rrdfile, $rrd_create); - } - - rrdtool_update($rrdfile, $fields); - - $tags = array('ifName' => $port['ifName']); - influx_update($device,'adsl',$tags,$fields); + $tags = compact('ifName', 'rrd_name', 'rrd_def'); + data_update($device, 'adsl', $tags, $fields); echo 'ADSL ('.$this_port['adslLineCoding'].'/'.formatRates($this_port['adslAtucChanCurrTxRate']).'/'.formatRates($this_port['adslAturChanCurrTxRate']).')'; }//end if diff --git a/includes/polling/port-etherlike.inc.php b/includes/polling/port-etherlike.inc.php index 7299901620..67a05b77ca 100644 --- a/includes/polling/port-etherlike.inc.php +++ b/includes/polling/port-etherlike.inc.php @@ -1,24 +1,14 @@ $port['ifName']); - influx_update($device,'dot3',$tags,$fields); + $tags = compact('ifName', 'rrd_name', 'rrd_def', 'rrd_oldname'); + data_update($device,'dot3',$tags,$fields); echo 'EtherLike '; } diff --git a/includes/polling/port-poe.inc.php b/includes/polling/port-poe.inc.php index f9fdc99db8..eae9939cc9 100644 --- a/includes/polling/port-poe.inc.php +++ b/includes/polling/port-poe.inc.php @@ -36,18 +36,13 @@ $peth_oids = array( ); if ($this_port['dot3StatsIndex'] && $port['ifType'] == 'ethernetCsmacd') { - $rrdfile = get_port_rrdfile_path ($device['hostname'], $port_id, 'poe'); - 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); - } + $rrd_name = getPortRrdName($port_id, 'poe'); + $rrd_def = array( + 'DS:PortPwrAllocated:GAUGE:600:0:U', + 'DS:PortPwrAvailable:GAUGE:600:0:U', + 'DS:PortConsumption:DERIVE:600:0:U', + 'DS:PortMaxPwrDrawn:GAUGE:600:0:U' + ); $upd = "$polled:".$port['cpeExtPsePortPwrAllocated'].':'.$port['cpeExtPsePortPwrAvailable'].':'.$port['cpeExtPsePortPwrConsumption'].':'.$port['cpeExtPsePortMaxPwrDrawn']; @@ -58,10 +53,8 @@ if ($this_port['dot3StatsIndex'] && $port['ifType'] == 'ethernetCsmacd') { 'PortMaxPwrDrawn' => $port['cpeExtPsePortMaxPwrDrawn'], ); - $ret = rrdtool_update("$rrdfile", $fields); - - $tags = array('ifName' => $port['ifName']); - influx_update($device,'poe',$tags,$fields); + $tags = compact('ifName', 'rrd_name', 'rrd_def'); + data_update($device,'poe',$tags,$fields); echo 'PoE '; }//end if diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 166f741f4e..d8ab64a229 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -209,17 +209,11 @@ $ports = $ports_mapped['ports']; // // Rename any old RRD files still named after the previous ifIndex based naming schema. foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) { - foreach (array ('', 'adsl', 'dot3') as $suffix) { - $suffix_tmp = ''; - if ($suffix) - $suffix_tmp = "-$suffix"; + foreach (array ('', '-adsl', '-dot3') as $suffix) { + $old_rrd_name = "port-$ifIndex$suffix.rrd"; + $new_rrd_name = getPortRrdName($port_id, ltrim($suffix, '-')); - $old_rrd_path = trim ($config['rrd_dir']) . '/' . $device['hostname'] . "/port-$ifIndex$suffix_tmp.rrd"; - $new_rrd_path = get_port_rrdfile_path ($device['hostname'], $port_id, $suffix); - - if (is_file ($old_rrd_path)) { - rename ($old_rrd_path, $new_rrd_path); - } + rrd_file_rename($device, $old_rrd_name, $new_rrd_name); } } @@ -581,29 +575,26 @@ foreach ($ports as $port) { } } - // Update RRDs - $rrdfile = get_port_rrdfile_path ($device['hostname'], $port_id); - if (!is_file($rrdfile)) { - rrdtool_create( - $rrdfile, - ' --step 300 - 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 '.$config['rrd_rra'] - ); - }//end if + // Update data stores + $rrd_name = getPortRrdName($port_id); + $rrdfile = rrd_name($device['hostname'], $rrd_name); + $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'], @@ -626,7 +617,9 @@ foreach ($ports as $port) { if ($tune_port === true) { rrdtool_tune('port',$rrdfile,$this_port['ifSpeed']); } - rrdtool_update("$rrdfile", $fields); + + $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']; @@ -635,7 +628,6 @@ foreach ($ports as $port) { $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 diff --git a/includes/polling/processors.inc.php b/includes/polling/processors.inc.php index 14fc1d8113..6690de34f8 100644 --- a/includes/polling/processors.inc.php +++ b/includes/polling/processors.inc.php @@ -3,7 +3,10 @@ foreach (dbFetchRows('SELECT * FROM processors WHERE device_id = ?', array($device['device_id'])) as $processor) { echo 'Processor '.$processor['processor_descr'].'... '; - $file = $config['install_dir'].'/includes/polling/processors/'.$processor['processor_type'].'.inc.php'; + $processor_type = $processor['processor_type']; + $processor_index = $processor['processor_index']; + + $file = $config['install_dir'].'/includes/polling/processors/'. $processor_type .'.inc.php'; if (is_file($file)) { include $file; } @@ -11,15 +14,8 @@ foreach (dbFetchRows('SELECT * FROM processors WHERE device_id = ?', array($devi $proc = snmp_get($device, $processor['processor_oid'], '-O Uqnv', '""'); } - $procrrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('processor-'.$processor['processor_type'].'-'.$processor['processor_index'].'.rrd'); - - if (!is_file($procrrd)) { - rrdtool_create( - $procrrd, - '--step 300 - DS:usage:GAUGE:600:-273:1000 '.$config['rrd_rra'] - ); - } + $rrd_name = array('processor', $processor_type, $processor_index); + $rrd_def = 'DS:usage:GAUGE:600:-273:1000'; $proc = trim(str_replace('"', '', $proc)); list($proc) = preg_split('@\ @', $proc); @@ -35,10 +31,8 @@ foreach (dbFetchRows('SELECT * FROM processors WHERE device_id = ?', array($devi 'usage' => $proc, ); - rrdtool_update($procrrd, $fields); - - $tags = array('processor_type' => $processor['processor_type']); - influx_update($device,'processors',$tags,$fields); + $tags = compact('processor_type', 'processor_index', 'rrd_name', 'rrd_def'); + data_update($device,'processors',$tags,$fields); dbUpdate(array('processor_usage' => $proc), 'processors', '`processor_id` = ?', array($processor['processor_id'])); }//end foreach diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index 82ba79abd9..a1349eedbe 100644 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -3,21 +3,21 @@ $storage_cache = array(); foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device['device_id'])) as $storage) { - echo 'Storage '.$storage['storage_descr'].': '; + $descr = $storage['storage_descr']; + $mib = $storage['storage_mib']; - $storage_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('storage-'.$storage['storage_mib'].'-'.safename($storage['storage_descr']).'.rrd'); + echo 'Storage '. $descr .': '; - 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']); - } + $rrd_name = array('storage', $mib, $descr); + $rrd_def = array( + 'DS:used:GAUGE:600:0:U', + 'DS:free:GAUGE:600:0:U' + ); - $file = $config['install_dir'].'/includes/polling/storage/'.$storage['storage_mib'].'.inc.php'; + $file = $config['install_dir'].'/includes/polling/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); @@ -35,10 +35,8 @@ foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device[ 'free' => $storage['free'], ); - rrdtool_update($storage_rrd, $fields); - - $tags = array('mib' => $storage['storage_mib'], 'descr' => $storage['storage_descr']); - influx_update($device,'storage',$tags,$fields); + $tags = compact('mib', 'descr', 'rrd_name', 'rrd_def'); + data_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'])); diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index 6dd680485e..857dc7b093 100644 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -1,9 +1,5 @@ $ss['ssCpuRawUser'], @@ -55,10 +44,8 @@ if (is_numeric($ss['ssCpuRawUser']) && is_numeric($ss['ssCpuRawNice']) && is_num 'idle' => $ss['ssCpuRawIdle'], ); - rrdtool_update($cpu_rrd, $fields); - - $tags = array(); - influx_update($device,'ucd_cpu',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'ucd_cpu', $tags, $fields); $graphs['ucd_cpu'] = true; } @@ -83,20 +70,15 @@ $collect_oids = array( foreach ($collect_oids as $oid) { if (is_numeric($ss[$oid])) { - $value = $ss[$oid]; - $filename = $host_rrd.'/ucd_'.$oid.'.rrd'; - if (!is_file($filename)) { - rrdtool_create($filename, ' --step 300 DS:value:COUNTER:600:0:U '.$config['rrd_rra']); - } + $rrd_name = 'ucd_'.$oid; + $rrd_def = 'DS:value:COUNTER:600:0:U'; $fields = array( - 'value' => $value, + 'value' => $ss[$oid], ); - rrdtool_update($filename, $fields); - - $tags = array('oid' => $oid); - influx_update($device,'ucd_cpu',$tags,$fields); + $tags = compact('oid', 'rrd_name', 'rrd_def'); + data_update($device, 'ucd_cpu', $tags, $fields); $graphs['ucd_cpu'] = true; } @@ -133,15 +115,6 @@ if (is_numeric($ss['ssRawInterrupts'])) { // UCD-SNMP-MIB::memCached.0 = INTEGER: 2595556 kB // UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0) // UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING: -$mem_rrd_create = ' --step 300 - DS:totalswap:GAUGE:600:0:10000000000 - DS:availswap:GAUGE:600:0:10000000000 - DS:totalreal:GAUGE:600:0:10000000000 - DS:availreal:GAUGE:600:0:10000000000 - DS:totalfree:GAUGE:600:0:10000000000 - DS:shared:GAUGE:600:0:10000000000 - DS:buffered:GAUGE:600:0:10000000000 - DS:cached:GAUGE:600:0:10000000000 '.$config['rrd_rra']; $snmpdata = snmp_get_multi($device, 'memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0', '-OQUs', 'UCD-SNMP-MIB'); if (is_array($snmpdata[0])) { @@ -153,12 +126,17 @@ if (is_array($snmpdata[0])) { $snmpdata = $snmpdata[0]; -// Check to see that the OIDs are actually populated before we make the rrd if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTotalFree)) { - if (!is_file($mem_rrd)) { - // Create the rrd file if it doesn't exist - rrdtool_create($mem_rrd, $mem_rrd_create); - } + $rrd_def = array( + 'DS:totalswap:GAUGE:600:0:10000000000', + 'DS:availswap:GAUGE:600:0:10000000000', + 'DS:totalreal:GAUGE:600:0:10000000000', + 'DS:availreal:GAUGE:600:0:10000000000', + 'DS:totalfree:GAUGE:600:0:10000000000', + 'DS:shared:GAUGE:600:0:10000000000', + 'DS:buffered:GAUGE:600:0:10000000000', + 'DS:cached:GAUGE:600:0:10000000000' + ); $fields = array( 'totalswap' => $memTotalSwap, @@ -171,10 +149,8 @@ if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTot 'cached' => $memCached, ); - rrdtool_update($mem_rrd, $fields); - - $tags = array(); - influx_update($device,'ucd_mem',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device, 'ucd_mem', $tags, $fields); $graphs['ucd_memory'] = true; } @@ -188,9 +164,11 @@ $load_raw = snmp_get_multi($device, 'laLoadInt.1 laLoadInt.2 laLoadInt.3', '-OQU // Check to see that the 5-min OID is actually populated before we make the rrd if (is_numeric($load_raw[2]['laLoadInt'])) { - if (!is_file($load_rrd)) { - rrdtool_create($load_rrd, ' --step 300 DS:1min:GAUGE:600:0:5000 DS:5min:GAUGE:600:0:5000 DS:15min:GAUGE:600:0:5000 '.$config['rrd_rra']); - } + $rrd_def = array( + 'DS:1min:GAUGE:600:0:5000', + 'DS:5min:GAUGE:600:0:5000', + 'DS:15min:GAUGE:600:0:5000' + ); $fields = array( '1min' => $load_raw[1]['laLoadInt'], @@ -198,14 +176,12 @@ if (is_numeric($load_raw[2]['laLoadInt'])) { '15min' => $load_raw[3]['laLoadInt'], ); - rrdtool_update($load_rrd, $fields); - - $tags = array(); - influx_update($device,'ucd_load',$tags,$fields); + $tags = compact('rrd_def'); + data_update($device,'ucd_load',$tags,$fields); $graphs['ucd_load'] = 'TRUE'; } -unset($ss, $load_rrd, $load_raw, $snmpdata); +unset($ss, $load_raw, $snmpdata); unset($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached); -unset($key, $mem_rrd, $mem_rrd_create, $collect_oids, $value, $filename, $cpu_rrd, $cpu_rrd_create, $oid); +unset($key, $collect_oids, $rrd_name, $rrd_def, $oid); diff --git a/includes/polling/unix-agent/munin-plugins.inc.php b/includes/polling/unix-agent/munin-plugins.inc.php index d6340c2a50..6aaef6185c 100644 --- a/includes/polling/unix-agent/munin-plugins.inc.php +++ b/includes/polling/unix-agent/munin-plugins.inc.php @@ -22,20 +22,12 @@ if (!empty($agent_data['munin'])) { echo "Created directory : $plugins_rrd_dir\n"; } - $plugin = array(); foreach ($agent_data['munin'] as $plugin_type => $plugin_data) { $plugin = array(); - // list($plugin_type, $instance) = explode("_", $plugin_type); - // if (!empty($instance)) - // { - // echo("\nPlugin: $plugin_type ($instance)"); - // $plugin_rrd = $plugins_rrd_dir . "/" . $plugin_type."_".$instance; - // $plugin_uniq = $plugin_type."_".$instance; - // } else { + echo "\nPlugin: $plugin_type"; - $plugin_rrd = $plugins_rrd_dir.'/'.$plugin_type; - $plugin_uniq = $plugin_type.'_'; - // } + $base_rrd_name = 'munin/'.$plugin_type; + d_echo("\n[$plugin_data]\n"); foreach (explode("\n", $plugin_data) as $line) { @@ -76,9 +68,6 @@ if (!empty($agent_data['munin'])) { $ds_list[$vu] = 1; } - unset($dbq); - unset($v); - foreach ($plugin['values'] as $name => $data) { echo " $name"; if (empty($data['type'])) { @@ -97,22 +86,18 @@ if (!empty($agent_data['munin'])) { $data['draw'] = 'LINE1.5'; } - $cmd = '--step 300 DS:val:'.$data['type'].':600:U:U '; - $cmd .= $config['rrd_rra']; $ds_uniq = $mplug_id.'_'.$name; - $filename = $plugin_rrd.'_'.$name.'.rrd'; - if (!is_file($filename)) { - rrdtool_create($filename, $cmd); - } $fields = array( 'val' => $data['value'], ); - rrdtool_update($filename, $fields); - - $tags = array('plugin' => $plugin_type); - influx_update($device,'munin-plugins',$tags,$fields); + $tags = array( + 'plugin' => $plugin_type, + 'rrd_def' => 'DS:val:' . $data['type'] . ':600:U:U', + 'rrd_name' => $base_rrd_name . '_' . $name + ); + data_update($device,'munin-plugins',$tags,$fields); if (empty($ds_list[$ds_uniq])) { $insert = array( diff --git a/includes/polling/wireless/cambium-250.inc.php b/includes/polling/wireless/cambium-250.inc.php index b46ab4f6e8..9a9d3fcf74 100644 --- a/includes/polling/wireless/cambium-250.inc.php +++ b/includes/polling/wireless/cambium-250.inc.php @@ -9,80 +9,80 @@ * the source code distribution for details. */ -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-250-transmitPower.rrd"; $transmitPower = snmp_get($device, "transmitPower.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); if (is_numeric($transmitPower)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:transmitPower:GAUGE:600:0:100".$config['rrd_rra']); - } - $transmitPower = $transmitPower / 10; + $rrd_def = 'DS:transmitPower:GAUGE:600:0:100'; $fields = array( - 'transmitPower' => $transmitPower, + 'transmitPower' => $transmitPower / 10, ); - rrdtool_update($rrd_filename, $fields); + + $tags = compact('rrd_def'); + data_update($device, 'cambium-250-transmitPower', $tags, $fields); $graphs['cambium_250_transmitPower'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-250-receivePower.rrd"; $receivePower = snmp_get($device, "receivePower.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); $noiseFloor = snmp_get($device, "noiseFloor.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); if (is_numeric($receivePower)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:receivePower:GAUGE:600:-150:0 DS:noiseFloor:GAUGE:600:-150:0".$config['rrd_rra']); - } - $receivePower = $receivePower / 10; + $rrd_def = array( + 'DS:receivePower:GAUGE:600:-150:0', + 'DS:noiseFloor:GAUGE:600:-150:0' + ); $fields = array( - 'receivePower' => $receivePower, + 'receivePower' => $receivePower / 10, 'noiseFloor' => $noiseFloor, ); - rrdtool_update($rrd_filename, $fields); + + $tags = compact('rrd_def'); + data_update($device, 'cambium-250-receivePower', $tags, $fields); $graphs['cambium_250_receivePower'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-250-modulationMode.rrd"; $txModulation = snmp_get($device, ".1.3.6.1.4.1.17713.250.5.9.0", "-Ovqn", ""); $rxModulation = snmp_get($device, ".1.3.6.1.4.1.17713.250.5.8.0", "-Ovqn", ""); if (is_numeric($txModulation) && is_numeric($rxModulation)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:txModulation:GAUGE:600:0:24 DS:rxModulation:GAUGE:600:0:24".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:txModulation:GAUGE:600:0:24', + 'DS:rxModulation:GAUGE:600:0:24' + ); $fields = array( 'txModuation' => $txModulation, 'rxModulation' => $rxModulation, ); - rrdtool_update($rrd_filename, $fields); + + $tags = compact('rrd_def'); + data_update($device, 'cambium-250-modulationMode', $tags, $fields); $graphs['cambium_250_modulationMode'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-250-dataRate.rrd"; $receiveDataRate = snmp_get($device, "receiveDataRate.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); $transmitDataRate = snmp_get($device, "transmitDataRate.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); $aggregateDataRate = snmp_get($device, "aggregateDataRate.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); if (is_numeric($receiveDataRate) && is_numeric($transmitDataRate) && is_numeric($aggregateDataRate)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:receiveDataRate:GAUGE:600:0:10000 DS:transmitDataRate:GAUGE:600:0:10000 DS:aggregateDataRate:GAUGE:600:0:10000".$config['rrd_rra']); - } - $receiveDataRate = $receiveDataRate / 100; - $transmitDataRate = $transmitDataRate / 100; - $aggregateDataRate = $aggregateDataRate / 100; - $fields = array( - 'receiveDataRate' => $receiveDataRate, - 'transmitDataRate' => $transmitDataRate, - 'aggregateDataRate' => $aggregateDataRate, + $rrd_def = array( + 'DS:receiveDataRate:GAUGE:600:0:10000', + 'DS:transmitDataRate:GAUGE:600:0:10000', + 'DS:aggregateDataRate:GAUGE:600:0:10000' ); - rrdtool_update($rrd_filename, $fields); + $fields = array( + 'receiveDataRate' => $receiveDataRate / 100, + 'transmitDataRate' => $transmitDataRate / 100, + 'aggregateDataRate' => $aggregateDataRate / 100, + ); + + $tags = compact('rrd_def'); + data_update($device, 'cambium-250-dataRate', $tags, $fields); $graphs['cambium_250_dataRate'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-250-ssr.rrd"; $ssr = snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); if (is_numeric($ssr)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:ssr:GAUGE:600:-150:150".$config['rrd_rra']); - } + $rrd_def = 'DS:ssr:GAUGE:600:-150:150'; $fields = array( 'ssr' => $ssr, ); - rrdtool_update($rrd_filename, $fields); + + $tags = compact('rrd_def'); + data_update($device, 'cambium-250-ssr', $tags, $fields); $graphs['cambium_250_ssr'] = TRUE; } \ No newline at end of file diff --git a/includes/polling/wireless/cambium-650.inc.php b/includes/polling/wireless/cambium-650.inc.php index fe7a573cb5..be95e51461 100644 --- a/includes/polling/wireless/cambium-650.inc.php +++ b/includes/polling/wireless/cambium-650.inc.php @@ -9,83 +9,75 @@ * the source code distribution for details. */ -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-650-transmitPower.rrd"; $transmitPower = snmp_get($device, "transmitPower.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); if (is_numeric($transmitPower)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:transmitPower:GAUGE:600:0:100".$config['rrd_rra']); - } - $transmitPower = $transmitPower / 10; + $rrd_def = 'DS:transmitPower:GAUGE:600:0:100'; $fields = array( - 'transmitPower' => $transmitPower, + 'transmitPower' => $transmitPower / 10, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-650-transmitPower', $tags, $fields); $graphs['cambium_650_transmitPower'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-650-rawReceivePower.rrd"; $rawReceivePower = snmp_get($device, "rawReceivePower.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); if (is_numeric($rawReceivePower)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:rawReceivePower:GAUGE:600:-100:0".$config['rrd_rra']); - } - $rawReceivePower = $rawReceivePower / 10; + $rrd_def = 'DS:rawReceivePower:GAUGE:600:-100:0'; $fields = array( - 'rawReceivePower' => $rawReceivePower, + 'rawReceivePower' => $rawReceivePower / 10, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-650-rawReceivePower', $tags, $fields); $graphs['cambium_650_rawReceivePower'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-650-modulationMode.rrd"; + $txModulation = snmp_get($device, ".1.3.6.1.4.1.17713.7.12.15.0", "-Ovqn", ""); $rxModulation = snmp_get($device, ".1.3.6.1.4.1.17713.7.12.14.0", "-Ovqn", ""); if (is_numeric($txModulation) && is_numeric($rxModulation)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:txModulation:GAUGE:600:0:24 DS:rxModulation:GAUGE:600:0:24".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:txModulation:GAUGE:600:0:24', + 'DS:rxModulation:GAUGE:600:0:24' + ); $fields = array( 'txModuation' => $txModulation, 'rxModulation' => $rxModulation, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-650-modulationMode', $tags, $fields); $graphs['cambium_650_modulationMode'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-650-dataRate.rrd"; $receiveDataRate = snmp_get($device, "receiveDataRate.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); $transmitDataRate = snmp_get($device, "transmitDataRate.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); $aggregateDataRate = snmp_get($device, "aggregateDataRate.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); if (is_numeric($receiveDataRate) && is_numeric($transmitDataRate) && is_numeric($aggregateDataRate)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:receiveDataRate:GAUGE:600:0:10000 DS:transmitDataRate:GAUGE:600:0:10000 DS:aggregateDataRate:GAUGE:600:0:10000".$config['rrd_rra']); - } - $receiveDataRate = $receiveDataRate / 100; - $transmitDataRate = $transmitDataRate / 100; - $aggregateDataRate = $aggregateDataRate / 100; - $fields = array( - 'receiveDataRate' => $receiveDataRate, - 'transmitDataRate' => $transmitDataRate, - 'aggregateDataRate' => $aggregateDataRate, + $rrd_def = array( + 'DS:receiveDataRate:GAUGE:600:0:10000', + 'DS:transmitDataRate:GAUGE:600:0:10000', + 'DS:aggregateDataRate:GAUGE:600:0:10000' ); - rrdtool_update($rrd_filename, $fields); + $fields = array( + 'receiveDataRate' => $receiveDataRate / 100, + 'transmitDataRate' => $transmitDataRate / 100, + 'aggregateDataRate' => $aggregateDataRate / 100, + ); + $tags = compact('rrd_def'); + data_update($device, 'cambium-650-dataRate', $tags, $fields); $graphs['cambium_650_dataRate'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-650-ssr.rrd"; $ssr = snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); if (is_numeric($ssr)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:ssr:GAUGE:600:-150:150".$config['rrd_rra']); - } + $rrd_def = 'DS:ssr:GAUGE:600:-150:150'; $fields = array( 'ssr' => $ssr, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-650-ssr', $tags, $fields); $graphs['cambium_650_ssr'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-650-gps.rrd"; $gps = snmp_get($device, "tDDSynchronizationStatus.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); if ($gps == 'locked') { $gps = 0; @@ -118,12 +110,11 @@ if ($gps == 'locked') { $gps = 9; } if (is_numeric($gps)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:gps:GAUGE:600:0:10".$config['rrd_rra']); - } + $rrd_def = 'DS:gps:GAUGE:600:0:10'; $fields = array( 'gps' => $gps, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-650-gps', $tags, $fields); $graphs['cambium_650_gps'] = TRUE; } \ No newline at end of file diff --git a/includes/polling/wireless/cambium-epmp.inc.php b/includes/polling/wireless/cambium-epmp.inc.php index 48142aa3c5..f331aab52a 100644 --- a/includes/polling/wireless/cambium-epmp.inc.php +++ b/includes/polling/wireless/cambium-epmp.inc.php @@ -6,103 +6,102 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/cambium-epmp-RFStatus.rrd'; $cambiumSTADLRSSI = snmp_get($device, "cambiumSTADLRSSI.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); $cambiumSTADLSNR = snmp_get($device, "cambiumSTADLSNR.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($cambiumSTADLRSSI) && is_numeric($cambiumSTADLSNR)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:cambiumSTADLRSSI:GAUGE:600:-150:0 DS:cambiumSTADLSNR:GAUGE:600:0:150".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:cambiumSTADLRSSI:GAUGE:600:-150:0', + 'DS:cambiumSTADLSNR:GAUGE:600:0:150' + ); $fields = array( 'cambiumSTADLRSSI' => $cambiumSTADLRSSI, 'cambiumSTADLSNR' => $cambiumSTADLSNR ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-RFStatus', $tags, $fields); $graphs['cambium_epmp_RFStatus'] = TRUE; } -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/cambium-epmp-gps.rrd'; $cambiumGPSNumTrackedSat = snmp_get($device, "cambiumGPSNumTrackedSat.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); $cambiumGPSNumVisibleSat = snmp_get($device, "cambiumGPSNumVisibleSat.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($cambiumGPSNumTrackedSat) && is_numeric($cambiumGPSNumVisibleSat)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:numTracked:GAUGE:600:0:100000 DS:numVisible:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:numTracked:GAUGE:600:0:100000', + 'DS:numVisible:GAUGE:600:0:100000' + ); $fields = array( 'numTracked' => $cambiumGPSNumTrackedSat, 'numVisible' => $cambiumGPSNumVisibleSat ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-gps', $tags, $fields); $graphs['cambium_epmp_gps'] = TRUE; } -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/cambium-epmp-modulation.rrd'; $cambiumSTAUplinkMCSMode = snmp_get($device, "cambiumSTAUplinkMCSMode.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); $cambiumSTADownlinkMCSMode = snmp_get($device, "cambiumSTADownlinkMCSMode.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($cambiumSTAUplinkMCSMode) && is_numeric($cambiumSTADownlinkMCSMode)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:uplinkMCSMode:GAUGE:600:-30:30 DS:downlinkMCSMode:GAUGE:600:-30:30".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:uplinkMCSMode:GAUGE:600:-30:30', + 'DS:downlinkMCSMode:GAUGE:600:-30:30' + ); $fields = array( 'uplinkMCSMode' => $cambiumSTAUplinkMCSMode, 'downlinkMCSMode' => $cambiumSTADownlinkMCSMode ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-modulation', $tags, $fields); $graphs['cambium_epmp_modulation'] = TRUE; } -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/cambium-epmp-registeredSM.rrd'; $registeredSM = snmp_get($device, "cambiumAPNumberOfConnectedSTA.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($registeredSM)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:regSM:GAUGE:600:0:10000".$config['rrd_rra']); - } + $rrd_def = 'DS:regSM:GAUGE:600:0:10000'; $fields = array( 'regSM' => $registeredSM, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-registeredSM', $tags, $fields); $graphs['cambium_epmp_registeredSM'] = TRUE; } -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/cambium-epmp-access.rrd'; $sysNetworkEntryAttempt = snmp_get($device, "sysNetworkEntryAttempt.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); $sysNetworkEntrySuccess = snmp_get($device, "sysNetworkEntrySuccess.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); $sysNetworkEntryAuthenticationFailure = snmp_get($device, "sysNetworkEntryAuthenticationFailure.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($sysNetworkEntryAttempt) && is_numeric($sysNetworkEntrySuccess) && is_numeric($sysNetworkEntryAuthenticationFailure)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:entryAttempt:GAUGE:600:0:100000 DS:entryAccess:GAUGE:600:0:100000 DS:authFailure:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:entryAttempt:GAUGE:600:0:100000', + 'DS:entryAccess:GAUGE:600:0:100000', + 'DS:authFailure:GAUGE:600:0:100000' + ); $fields = array( 'entryAttempt' => $sysNetworkEntryAttempt, 'entryAccess' => $sysNetworkEntrySuccess, 'authFailure' => $sysNetworkEntryAuthenticationFailure ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-access', $tags, $fields); $graphs['cambium_epmp_access'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-epmp-gpsSync.rrd"; $gpsSync = snmp_get($device, "cambiumEffectiveSyncSource.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($gpsSync)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:gpsSync:GAUGE:600:0:4".$config['rrd_rra']); - } + $rrd_def = 'DS:gpsSync:GAUGE:600:0:4'; $fields = array( 'gpsSync' => $gpsSync, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-gpsSync', $tags, $fields); $graphs['cambium_epmp_gpsSync'] = TRUE; } -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-epmp-freq.rrd"; $freq = snmp_get($device, "cambiumSTAConnectedRFFrequency.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($freq)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:freq:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = 'DS:freq:GAUGE:600:0:100000'; $fields = array( 'freq' => $freq, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-epmp-freq', $tags, $fields); $graphs['cambium_epmp_freq'] = TRUE; } diff --git a/includes/polling/wireless/cambium-generic.inc.php b/includes/polling/wireless/cambium-generic.inc.php index 6a391f5b9a..46bb47ce60 100644 --- a/includes/polling/wireless/cambium-generic.inc.php +++ b/includes/polling/wireless/cambium-generic.inc.php @@ -9,130 +9,126 @@ * the source code distribution for details. */ if (strstr($hardware, 'CMM') == false) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-errorCount.rrd"; $fecInErrorsCount = snmp_get($device, "fecInErrorsCount.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); $fecOutErrorsCount = snmp_get($device, "fecOutErrorsCount.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); if (is_numeric($fecInErrorsCount) && is_numeric($fecOutErrorsCount)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:fecInErrorsCount:GAUGE:600:0:100000 DS:fecOutErrorsCount:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:fecInErrorsCount:GAUGE:600:0:100000', + 'DS:fecOutErrorsCount:GAUGE:600:0:100000' + ); $fields = array( 'fecInErrorsCount' => $fecInErrorsCount, 'fecOutErrorsCount' => $fecOutErrorsCount, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-errorCount', $tags, $fields); $graphs['cambium_generic_errorCount'] = TRUE; unset($rrd_filename,$fecInErrorsCount,$fecOutErrorsCount); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-crcErrors.rrd"; $crcErrors = snmp_get($device, "fecCRCError.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); if (is_numeric($crcErrors)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:crcErrors:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = 'DS:crcErrors:GAUGE:600:0:100000'; $fields = array( 'crcErrors' => $crcErrors, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-crcErrors', $tags, $fields); $graphs['cambium_generic_crcErrors'] = TRUE; } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-signalHV.rrd"; $vertical = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.117.0", "-Ovqn", "")); $horizontal = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.118.0", "-Ovqn", "")); $combined = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.21.0", "-Ovqn", ""); if (is_numeric($vertical) && is_numeric($horizontal) && is_numeric($combined)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:vertical:GAUGE:600:-150:0 DS:horizontal:GAUGE:600:-150:0 DS:combined:GAUGE:600:-150:0".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:vertical:GAUGE:600:-150:0', + 'DS:horizontal:GAUGE:600:-150:0', + 'DS:combined:GAUGE:600:-150:0' + ); $fields = array( 'vertical' => floatval($vertical), 'horizontal' => floatval($horizontal), 'combined' => $combined, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-signalHV', $tags, $fields); $graphs['cambium_generic_signalHV'] = TRUE; unset($rrd_filename,$vertical,$horizontal,$combined); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-rssi.rrd"; $rssi = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.2.0", "-Ovqn", ""); if (is_numeric($rssi)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:rssi:GAUGE:600:0:5000".$config['rrd_rra']); - } + $rrd_def = 'DS:rssi:GAUGE:600:0:5000'; $fields = array( 'rssi' => $rssi, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-rssi', $tags, $fields); $graphs['cambium_generic_rssi'] = TRUE; unset($rrd_filename,$rssi); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-jitter.rrd"; $jitter = snmp_get($device, "jitter.0", "-Ovqn", "WHISP-SM-MIB"); if (is_numeric($jitter)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:jitter:GAUGE:600:0:20".$config['rrd_rra']); - } + $rrd_def = 'DS:jitter:GAUGE:600:0:20'; $fields = array( 'jitter' => $jitter, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-jitter', $tags, $fields); $graphs['cambium_generic_jitter'] = TRUE; unset($rrd_filename,$jitter); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-slaveHV.rrd"; $horizontal = str_replace('"',"",snmp_get($device, "radioDbmHorizontal.0", "-Ovqn", "WHISP-SM-MIB")); $vertical = str_replace('"',"",snmp_get($device, "radioDbmVertical.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:-100:100 DS:vertical:GAUGE:600:-100:100".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:-100:100', + 'DS:vertical:GAUGE:600:-100:100' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-slaveHV', $tags, $fields); $graphs['cambium_generic_450_slaveHV'] = TRUE; unset($rrd_filename,$horizontal,$vertical); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-slaveSSR.rrd"; $ssr = str_replace('"',"",snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($ssr)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:ssr:GAUGE:600:-150:150".$config['rrd_rra']); - } + $rrd_def = 'DS:ssr:GAUGE:600:-150:150'; $fields = array( 'ssr' => $ssr, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-slaveSSR', $tags, $fields); $graphs['cambium_generic_450_slaveSSR'] = TRUE; unset($rrd_filename,$ssr); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-slaveSNR.rrd"; $horizontal = str_replace('"',"",snmp_get($device, "signalToNoiseRatioSMHorizontal.0", "-Ovqn", "WHISP-SM-MIB")); $vertical = str_replace('"',"",snmp_get($device, "signalToNoiseRatioSMVertical.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:0:100 DS:vertical:GAUGE:600:0:100".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:0:100', + 'DS:vertical:GAUGE:600:0:100' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-slaveSNR', $tags, $fields); $graphs['cambium_generic_450_slaveSNR'] = TRUE; unset($rrd_filename,$horizontal,$vertical); } } if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, 'CMM')) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-whispGPSStats.rrd"; $gpsStatus = snmp_get($device, "whispGPSStats.0", "-Ovqn", "WHISP-APS-MIB"); if ($gpsStatus == 'generatingSync') { $gpsStatus = 3; @@ -144,113 +140,114 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, $gpsStatus = 1; } if (is_numeric($gpsStatus)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:whispGPSStats:GAUGE:600:0:4".$config['rrd_rra']); - } + $rrd_def = 'DS:whispGPSStats:GAUGE:600:0:4'; $fields = array( 'whispGPSStats' => $gpsStatus, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-whispGPSStats', $tags, $fields); $graphs['cambium_generic_whispGPSStats'] = TRUE; unset($rrd_filename,$gpsStatus); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-gpsStats.rrd"; $visible = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.7.0", "-Ovqn", "")); $tracked = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.8.0", "-Ovqn", "")); if (is_numeric($visible) && is_numeric($tracked)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:visible:GAUGE:600:0:1000 DS:tracked:GAUGE:600:0:1000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:visible:GAUGE:600:0:1000', + 'DS:tracked:GAUGE:600:0:1000' + ); $fields = array( 'visible' => floatval($visible), 'tracked' => floatval($tracked), ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-gpsStats', $tags, $fields); $graphs['cambium_generic_gpsStats'] = TRUE; unset($rrd_filename,$visible,$tracked); } } //PTP Equipment - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-powerlevel.rrd"; $lastLevel = str_replace('"',"",snmp_get($device, "lastPowerLevel.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($lastLevel)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:last:GAUGE:600:-100:0".$config['rrd_rra']); - } + $rrd_def = 'DS:last:GAUGE:600:-100:0'; $fields = array( 'last' => $lastLevel, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-powerlevel', $tags, $fields); $graphs['cambium_generic_450_powerlevel'] = TRUE; unset($lastLevel); } if (strstr($version, 'AP') == false) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-linkRadioDbm.rrd"; $horizontal = str_replace('"',"",snmp_get($device, "linkRadioDbmHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); $vertical = str_replace('"',"",snmp_get($device, "linkRadioDbmVertical.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:-100:0 DS:vertical:GAUGE:600:-100:0".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:-100:0', + 'DS:vertical:GAUGE:600:-100:0' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-linkRadioDbm', $tags, $fields); $graphs['cambium_generic_450_linkRadioDbm'] = TRUE; unset($rrd_filename,$horizontal,$horizontal); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-ptpSNR.rrd"; $horizontal = str_replace('"',"",snmp_get($device, "signalToNoiseRatioHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); $vertical = str_replace('"',"",snmp_get($device, "signalToNoiseRatioVertical.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:0:100 DS:vertical:GAUGE:600:0:100".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:0:100', + 'DS:vertical:GAUGE:600:0:100' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-ptpSNR', $tags, $fields); $graphs['cambium_generic_450_ptpSNR'] = TRUE; unset($rrd_filename,$horizontal,$horizontal); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-450-masterSSR.rrd"; $ssr = str_replace('"',"",snmp_get($device, "linkSignalStrengthRatio.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($ssr)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:ssr:GAUGE:600:-150:150".$config['rrd_rra']); - } + $rrd_def = 'DS:ssr:GAUGE:600:-150:150'; $fields = array( 'ssr' => $ssr, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-450-masterSSR', $tags, $fields); $graphs['cambium_generic_450_masterSSR'] = TRUE; unset($rrd_filename,$ssr); } if (strstr($hardware, 'PTP 230')) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-radioDbm.rrd"; $dbmRadio = str_replace('"',"",snmp_get($device, "radioDbmInt.0", "-Ovqn", "WHISP-SM-MIB")); $minRadio = str_replace('"',"",snmp_get($device, "minRadioDbm.0", "-Ovqn", "WHISP-SM-MIB")); $maxRadio = str_replace('"',"",snmp_get($device, "maxRadioDbm.0", "-Ovqn", "WHISP-SM-MIB")); $avgRadio = str_replace('"',"",snmp_get($device, "radioDbmAvg.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($dbmRadio) && is_numeric($minRadio) && is_numeric($maxRadio) && is_numeric($avgRadio)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:dbm:GAUGE:600:-100:0 DS:min:GAUGE:600:-100:0 DS:max:GAUGE:600:-100:0 DS:avg:GAUGE:600:-100:0".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:dbm:GAUGE:600:-100:0', + 'DS:min:GAUGE:600:-100:0', + 'DS:max:GAUGE:600:-100:0', + 'DS:avg:GAUGE:600:-100:0' + ); $fields = array( 'dbm' => $dbmRadio, 'min' => $minRadio, 'max' => $maxRadio, 'avg' => $avgRadio, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-radioDbm', $tags, $fields); $graphs['cambium_generic_radioDbm'] = TRUE; unset($rrd_filename,$dbmRadio,$minRadio,$maxRadio,$avgRadio); } @@ -259,28 +256,26 @@ if (strstr($version, 'AP') == false) { //AP Equipment if (strstr($version, 'AP')) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-regCount.rrd"; $registered = str_replace('"',"",snmp_get($device, "regCount.0", "-Ovqn", "WHISP-APS-MIB")); $failed = str_replace('"',"",snmp_get($device, "regFailureCount.0", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($registered) && is_numeric($failed)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:regCount:GAUGE:600:0:15000 DS:failed:GAUGE:600:0:15000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:regCount:GAUGE:600:0:15000', + 'DS:failed:GAUGE:600:0:15000' + ); $fields = array( 'regCount' => $registered, 'failed' => $failed, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-regCount', $tags, $fields); $graphs['cambium_generic_regCount'] = TRUE; unset($rrd_filename,$registered,$failed); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cambium-generic-freq.rrd"; $freq = str_replace('"',"",snmp_get($device, "currentRadioFreqCarrier.0", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($freq)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:freq:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = 'DS:freq:GAUGE:600:0:100000'; if ($freq > 99999) { $freq = $freq / 100000; } @@ -290,7 +285,8 @@ if (strstr($version, 'AP')) { $fields = array( 'freq' => $freq, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cambium-generic-freq', $tags, $fields); $graphs['cambium_generic_freq'] = TRUE; unset($rrd_filename,$freq); } diff --git a/includes/polling/wireless/canopy-generic.inc.php b/includes/polling/wireless/canopy-generic.inc.php index db1f0d761c..f5465c14e0 100644 --- a/includes/polling/wireless/canopy-generic.inc.php +++ b/includes/polling/wireless/canopy-generic.inc.php @@ -9,289 +9,285 @@ * the source code distribution for details. */ if (strstr($hardware, 'CMM') == false) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-errorCount.rrd"; $fecInErrorsCount = snmp_get($device, "fecInErrorsCount.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); $fecOutErrorsCount = snmp_get($device, "fecOutErrorsCount.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); if (is_numeric($fecInErrorsCount) && is_numeric($fecOutErrorsCount)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:fecInErrorsCount:GAUGE:600:0:100000 DS:fecOutErrorsCount:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:fecInErrorsCount:GAUGE:600:0:100000', + 'DS:fecOutErrorsCount:GAUGE:600:0:100000' + ); + $fields = array( 'fecInErrorsCount' => $fecInErrorsCount, 'fecOutErrorsCount' => $fecOutErrorsCount, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-errorCount', $tags, $fields); $graphs['canopy_generic_errorCount'] = TRUE; - unset($rrd_filename,$fecInErrorsCount,$fecOutErrorsCount); + unset($rrd_filename, $fecInErrorsCount, $fecOutErrorsCount); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-crcErrors.rrd"; $crcErrors = snmp_get($device, "fecCRCError.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); if (is_numeric($crcErrors)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:crcErrors:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = 'DS:crcErrors:GAUGE:600:0:100000'; $fields = array( 'crcErrors' => $crcErrors, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-crcErrors', $tags, $fields); $graphs['canopy_generic_crcErrors'] = TRUE; } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-signalHV.rrd"; - $vertical = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.117.0", "-Ovqn", "")); - $horizontal = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.118.0", "-Ovqn", "")); + $vertical = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.117.0", "-Ovqn", "")); + $horizontal = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.2.2.118.0", "-Ovqn", "")); $combined = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.21.0", "-Ovqn", ""); if (is_numeric($vertical) && is_numeric($horizontal) && is_numeric($combined)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:vertical:GAUGE:600:-150:0 DS:horizontal:GAUGE:600:-150:0 DS:combined:GAUGE:600:-150:0".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:vertical:GAUGE:600:-150:0', + 'DS:horizontal:GAUGE:600:-150:0', + 'DS:combined:GAUGE:600:-150:0' + ); $fields = array( 'vertical' => floatval($vertical), 'horizontal' => floatval($horizontal), 'combined' => $combined, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-signalHV', $tags, $fields); $graphs['canopy_generic_signalHV'] = TRUE; - unset($rrd_filename,$vertical,$horizontal,$combined); + unset($rrd_filename, $vertical, $horizontal, $combined); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-rssi.rrd"; $rssi = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.2.0", "-Ovqn", ""); if (is_numeric($rssi)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:rssi:GAUGE:600:0:5000".$config['rrd_rra']); - } + $rrd_def = 'DS:rssi:GAUGE:600:0:5000'; $fields = array( 'rssi' => $rssi, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-rssi', $tags, $fields); $graphs['canopy_generic_rssi'] = TRUE; - unset($rrd_filename,$rssi); + unset($rrd_filename, $rssi); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-jitter.rrd"; $jitter = snmp_get($device, "jitter.0", "-Ovqn", "WHISP-SM-MIB"); if (is_numeric($jitter)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:jitter:GAUGE:600:0:20".$config['rrd_rra']); - } + $rrd_def = 'DS:jitter:GAUGE:600:0:20'; $fields = array( 'jitter' => $jitter, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-jitter', $tags, $fields); $graphs['canopy_generic_jitter'] = TRUE; - unset($rrd_filename,$jitter); + unset($rrd_filename, $jitter); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-slaveHV.rrd"; - $horizontal = str_replace('"',"",snmp_get($device, "radioDbmHorizontal.0", "-Ovqn", "WHISP-SM-MIB")); - $vertical = str_replace('"',"",snmp_get($device, "radioDbmVertical.0", "-Ovqn", "WHISP-SM-MIB")); + $horizontal = str_replace('"', "", snmp_get($device, "radioDbmHorizontal.0", "-Ovqn", "WHISP-SM-MIB")); + $vertical = str_replace('"', "", snmp_get($device, "radioDbmVertical.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:-100:100 DS:vertical:GAUGE:600:-100:100".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:-100:100', + 'DS:vertical:GAUGE:600:-100:100' + ); + $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-slaveHV', $tags, $fields); $graphs['canopy_generic_450_slaveHV'] = TRUE; - unset($rrd_filename,$horizontal,$vertical); + unset($rrd_filename, $horizontal, $vertical); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-slaveSSR.rrd"; - $ssr = str_replace('"',"",snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "WHISP-SM-MIB")); + $ssr = str_replace('"', "", snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($ssr)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:ssr:GAUGE:600:-150:150".$config['rrd_rra']); - } + $rrd_def = 'DS:ssr:GAUGE:600:-150:150'; $fields = array( 'ssr' => $ssr, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-slaveSSR', $tags, $fields); $graphs['canopy_generic_450_slaveSSR'] = TRUE; - unset($rrd_filename,$ssr); + unset($rrd_filename, $ssr); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-slaveSNR.rrd"; - $horizontal = str_replace('"',"",snmp_get($device, "signalToNoiseRatioSMHorizontal.0", "-Ovqn", "WHISP-SM-MIB")); - $vertical = str_replace('"',"",snmp_get($device, "signalToNoiseRatioSMVertical.0", "-Ovqn", "WHISP-SM-MIB")); + $horizontal = str_replace('"', "", snmp_get($device, "signalToNoiseRatioSMHorizontal.0", "-Ovqn", "WHISP-SM-MIB")); + $vertical = str_replace('"', "", snmp_get($device, "signalToNoiseRatioSMVertical.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:0:100 DS:vertical:GAUGE:600:0:100".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:0:100', + 'DS:vertical:GAUGE:600:0:100' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-slaveSNR', $tags, $fields); $graphs['canopy_generic_450_slaveSNR'] = TRUE; - unset($rrd_filename,$horizontal,$vertical); + unset($rrd_filename, $horizontal, $vertical); } } if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, 'CMM')) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-whispGPSStats.rrd"; $gpsStatus = snmp_get($device, "whispGPSStats.0", "-Ovqn", "WHISP-APS-MIB"); if ($gpsStatus == 'generatingSync') { $gpsStatus = 3; - } - else if ($gpsStatus == 'gpsLostSync') { + } else if ($gpsStatus == 'gpsLostSync') { $gpsStatus = 2; - } - else if ($gpsStatus == 'gpsSynchronized') { + } else if ($gpsStatus == 'gpsSynchronized') { $gpsStatus = 1; } if (is_numeric($gpsStatus)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:whispGPSStats:GAUGE:600:0:4".$config['rrd_rra']); - } + $rrd_def = 'DS:whispGPSStats:GAUGE:600:0:4'; $fields = array( 'whispGPSStats' => $gpsStatus, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-whispGPSStats', $tags, $fields); $graphs['canopy_generic_whispGPSStats'] = TRUE; - unset($rrd_filename,$gpsStatus); + unset($rrd_filename, $gpsStatus); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-gpsStats.rrd"; - $visible = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.7.0", "-Ovqn", "")); - $tracked = str_replace('"',"",snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.8.0", "-Ovqn", "")); + $visible = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.7.0", "-Ovqn", "")); + $tracked = str_replace('"', "", snmp_get($device, ".1.3.6.1.4.1.161.19.3.4.4.8.0", "-Ovqn", "")); if (is_numeric($visible) && is_numeric($tracked)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:visible:GAUGE:600:0:1000 DS:tracked:GAUGE:600:0:1000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:visible:GAUGE:600:0:1000', + 'DS:tracked:GAUGE:600:0:1000' + ); $fields = array( 'visible' => floatval($visible), 'tracked' => floatval($tracked), ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-gpsStats', $tags, $fields); $graphs['canopy_generic_gpsStats'] = TRUE; - unset($rrd_filename,$visible,$tracked); + unset($rrd_filename, $visible, $tracked); } } - + if (strstr($version, 'AP') == false) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-linkRadioDbm.rrd"; - $horizontal = str_replace('"',"",snmp_get($device, "linkRadioDbmHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); - $vertical = str_replace('"',"",snmp_get($device, "linkRadioDbmVertical.2", "-Ovqn", "WHISP-APS-MIB")); + $horizontal = str_replace('"', "", snmp_get($device, "linkRadioDbmHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); + $vertical = str_replace('"', "", snmp_get($device, "linkRadioDbmVertical.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:-100:0 DS:vertical:GAUGE:600:-100:0".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:-100:0', + 'DS:vertical:GAUGE:600:-100:0' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-linkRadioDbm', $tags, $fields); $graphs['canopy_generic_450_linkRadioDbm'] = TRUE; - unset($rrd_filename,$horizontal,$horizontal); + unset($rrd_filename, $horizontal, $horizontal); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-powerlevel.rrd"; - $lastLevel = str_replace('"',"",snmp_get($device, "lastPowerLevel.2", "-Ovqn", "WHISP-APS-MIB")); + $lastLevel = str_replace('"', "", snmp_get($device, "lastPowerLevel.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($lastLevel)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:last:GAUGE:600:-100:0".$config['rrd_rra']); - } + $rrd_def = 'DS:last:GAUGE:600:-100:0'; $fields = array( 'last' => $lastLevel, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-powerlevel', $tags, $fields); $graphs['canopy_generic_450_powerlevel'] = TRUE; unset($lastLevel); } - - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-ptpSNR.rrd"; - $horizontal = str_replace('"',"",snmp_get($device, "signalToNoiseRatioHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); - $vertical = str_replace('"',"",snmp_get($device, "signalToNoiseRatioVertical.2", "-Ovqn", "WHISP-APS-MIB")); + + $horizontal = str_replace('"', "", snmp_get($device, "signalToNoiseRatioHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); + $vertical = str_replace('"', "", snmp_get($device, "signalToNoiseRatioVertical.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($horizontal) && is_numeric($vertical)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:horizontal:GAUGE:600:0:100 DS:vertical:GAUGE:600:0:100".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:horizontal:GAUGE:600:0:100', + 'DS:vertical:GAUGE:600:0:100' + ); $fields = array( 'horizontal' => $horizontal, 'vertical' => $vertical, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-ptpSNR', $tags, $fields); $graphs['canopy_generic_450_ptpSNR'] = TRUE; - unset($rrd_filename,$horizontal,$horizontal); + unset($rrd_filename, $horizontal, $horizontal); } - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-450-masterSSR.rrd"; - $ssr = str_replace('"',"",snmp_get($device, "linkSignalStrengthRatio.2", "-Ovqn", "WHISP-APS-MIB")); + $ssr = str_replace('"', "", snmp_get($device, "linkSignalStrengthRatio.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($ssr)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:ssr:GAUGE:600:-150:150".$config['rrd_rra']); - } - $fields = array( - 'ssr' => $ssr, - ); - rrdtool_update($rrd_filename, $fields); - $graphs['canopy_generic_450_masterSSR'] = TRUE; - unset($rrd_filename,$ssr); + $rrd_def = 'DS:ssr:GAUGE:600:-150:150'; + $fields = array( + 'ssr' => $ssr, + ); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-450-masterSSR', $tags, $fields); + $graphs['canopy_generic_450_masterSSR'] = TRUE; + unset($rrd_filename, $ssr); } - if (strstr($hardware, 'PTP 230')) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-radioDbm.rrd"; - $dbmRadio = str_replace('"',"",snmp_get($device, "radioDbmInt.0", "-Ovqn", "WHISP-SM-MIB")); - $minRadio = str_replace('"',"",snmp_get($device, "minRadioDbm.0", "-Ovqn", "WHISP-SM-MIB")); - $maxRadio = str_replace('"',"",snmp_get($device, "maxRadioDbm.0", "-Ovqn", "WHISP-SM-MIB")); - $avgRadio = str_replace('"',"",snmp_get($device, "radioDbmAvg.0", "-Ovqn", "WHISP-SM-MIB")); + if (strstr($hardware, 'PTP 230')) { + $dbmRadio = str_replace('"', "", snmp_get($device, "radioDbmInt.0", "-Ovqn", "WHISP-SM-MIB")); + $minRadio = str_replace('"', "", snmp_get($device, "minRadioDbm.0", "-Ovqn", "WHISP-SM-MIB")); + $maxRadio = str_replace('"', "", snmp_get($device, "maxRadioDbm.0", "-Ovqn", "WHISP-SM-MIB")); + $avgRadio = str_replace('"', "", snmp_get($device, "radioDbmAvg.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($dbmRadio) && is_numeric($minRadio) && is_numeric($maxRadio) && is_numeric($avgRadio)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:dbm:GAUGE:600:-100:0 DS:min:GAUGE:600:-100:0 DS:max:GAUGE:600:-100:0 DS:avg:GAUGE:600:-100:0".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:dbm:GAUGE:600:-100:0', + 'DS:min:GAUGE:600:-100:0', + 'DS:max:GAUGE:600:-100:0', + 'DS:avg:GAUGE:600:-100:0' + ); + $fields = array( 'dbm' => $dbmRadio, 'min' => $minRadio, 'max' => $maxRadio, 'avg' => $avgRadio, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-radioDbm', $tags, $fields); $graphs['canopy_generic_radioDbm'] = TRUE; - unset($rrd_filename,$dbmRadio,$minRadio,$maxRadio,$avgRadio); + unset($rrd_filename, $dbmRadio, $minRadio, $maxRadio, $avgRadio); } } } //AP Equipment if (strstr($version, 'AP')) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-regCount.rrd"; - $registered = str_replace('"',"",snmp_get($device, "regCount.0", "-Ovqn", "WHISP-APS-MIB")); - $failed = str_replace('"',"",snmp_get($device, "regFailureCount.0", "-Ovqn", "WHISP-APS-MIB")); + $registered = str_replace('"', "", snmp_get($device, "regCount.0", "-Ovqn", "WHISP-APS-MIB")); + $failed = str_replace('"', "", snmp_get($device, "regFailureCount.0", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($registered) && is_numeric($failed)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:regCount:GAUGE:600:0:15000 DS:failed:GAUGE:600:0:15000".$config['rrd_rra']); - } + $rrd_def = array( + 'DS:regCount:GAUGE:600:0:15000', + 'DS:failed:GAUGE:600:0:15000' + ); $fields = array( 'regCount' => $registered, 'failed' => $failed, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-regCount', $tags, $fields); $graphs['canopy_generic_regCount'] = TRUE; - unset($rrd_filename,$registered,$failed); + unset($rrd_filename, $registered, $failed); } - - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/canopy-generic-freq.rrd"; - $freq = str_replace('"',"",snmp_get($device, "currentRadioFreqCarrier.0", "-Ovqn", "WHISP-APS-MIB")); + + $freq = str_replace('"', "", snmp_get($device, "currentRadioFreqCarrier.0", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($freq)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:freq:GAUGE:600:0:100000".$config['rrd_rra']); - } + $rrd_def = 'DS:freq:GAUGE:600:0:100000'; if ($freq > 99999) { $freq = $freq / 100000; - } - else { + } else { $freq = $freq / 10000; } $fields = array( 'freq' => $freq, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'canopy-generic-freq', $tags, $fields); $graphs['canopy_generic_freq'] = TRUE; - unset($rrd_filename,$freq); + unset($rrd_filename, $freq); } } \ No newline at end of file diff --git a/includes/polling/wireless/cisco-wwan.inc.php b/includes/polling/wireless/cisco-wwan.inc.php index 3bfb57b4ef..c11b9bb216 100644 --- a/includes/polling/wireless/cisco-wwan.inc.php +++ b/includes/polling/wireless/cisco-wwan.inc.php @@ -9,33 +9,25 @@ * the source code distribution for details. */ -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cisco-wwan-rssi.rrd"; $rssi = snmp_get($device, "CISCO-WAN-3G-MIB::c3gCurrentGsmRssi.13", "-Ovqn", "CISCO-WAN-3G-MIB"); - if (is_numeric($rssi)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:rssi:GAUGE:600:-150:5000".$config['rrd_rra']); - } + $rrd_def = 'DS:rssi:GAUGE:600:-150:5000'; $fields = array( 'rssi' => $rssi, ); - rrdtool_update($rrd_filename, $fields); + $tags = compact('rrd_def'); + data_update($device, 'cisco-wwan-rssi', $tags, $fields); $graphs['cisco_wwan_rssi'] = TRUE; - unset($rrd_filename,$rssi); } - -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cisco-wwan-mnc.rrd"; $mnc = snmp_get($device, "CISCO-WAN-3G-MIB::c3gGsmMnc.13", "-Ovqn", "CISCO-WAN-3G-MIB"); if (is_numeric($mnc)) { - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:mnc:GAUGE:600:0:U".$config['rrd_rra']); - } + $rrd_def = 'DS:mnc:GAUGE:600:0:U'; $fields = array( 'mnc' => $mnc, ); - rrdtool_update($rrd_filename, $fields); - $graphs['cisco_wwan_mnc'] = TRUE; - unset($rrd_filename,$mnc); + $tags = compact('rrd_def'); + data_update($device, 'cisco-wwan-rssi', $tags, $fields); + $graphs['cisco-wwan-mnc'] = TRUE; } - +unset($rrd_def, $rssi, $mnc, $fields, $tags); diff --git a/includes/polling/wireless/xirrus.inc.php b/includes/polling/wireless/xirrus.inc.php index ca7ccf9b47..6777fb8e67 100644 --- a/includes/polling/wireless/xirrus.inc.php +++ b/includes/polling/wireless/xirrus.inc.php @@ -1,5 +1,4 @@ $radio) { - $radioName = $radio['realtimeMonitorIfaceName']; - $associations[$radioName]=0; - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/xirrus_stats-$radioName.rrd"; - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:rssi:GAUGE:600:-150:0 DS:dataRate:GAUGE:600:0:1400 DS:noiseFloor:GAUGE:600:-150:0".$config['rrd_rra']); - } - rrdtool_update($rrd_filename, array( - 'rssi'=>$rssi[$idx]['realtimeMonitorAverageRSSI'], - 'dataRate'=>$dataRate[$idx]['realtimeMonitorAverageDataRate'], - 'noiseFloor'=>$noiseFloor[$idx]['realtimeMonitorNoiseFloor'] - )); + $associations[$radioName]=0; + $measurement = 'xirrus_stats'; + $rrd_name = array($measurement, $radioName); + $rrd_def = array( + 'DS:rssi:GAUGE:600:-150:0', + 'DS:dataRate:GAUGE:600:0:1400', + 'DS:noiseFloor:GAUGE:600:-150:0' + ); + $fields = array( + 'rssi' => $rssi[$idx]['realtimeMonitorAverageRSSI'], + 'dataRate' => $dataRate[$idx]['realtimeMonitorAverageDataRate'], + 'noiseFloor' => $noiseFloor[$idx]['realtimeMonitorNoiseFloor'] + ); + $tags = compact('radioName', 'rrd_name', 'rrd_def'); + data_update($device, $measurement, $tags, $fields); } -// cleanup -unset($rrd_filename); unset($radios); unset($rssi); unset($radioName); // if this config flag is true, don't poll for stations // this in case of large APs which may have many stations @@ -38,14 +39,15 @@ if ($config['xirrus_disable_stations']!=true) { unset($radio); unset($assoc); // write to rrds foreach($associations as $radio => $count) { - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/xirrus_users-$radio.rrd"; - if (!is_file($rrd_filename)) { - rrdtool_create($rrd_filename, " --step 300 DS:stations:GAUGE:600:0:3200".$config['rrd_rra']); - } - rrdtool_update($rrd_filename, array('stations'=>$count)); + $measurement = 'xirrus_users'; + $rrd_name = array($measurement, $radio); + $rrd_def = 'DS:stations:GAUGE:600:0:3200'; + $fields = array( + 'stations' => $count + ); + $tags = compact('radio', 'rrd_name', 'rrd_def'); + data_update($device, $measurement, $tags, $fields); } - // cleanup - unset($assocations); unset($rrd_filename); $graphs['xirrus_stations'] = TRUE; } else { $graphs['xirrus_stations'] = FALSE; @@ -55,3 +57,6 @@ $graphs['xirrus_rssi'] = TRUE; $graphs['xirrus_dataRates'] = TRUE; $graphs['xirrus_noiseFloor'] = TRUE; $graphs['xirrus_stations'] = TRUE; + +// cleanup +unset($rrd_def, $radios, $rssi, $radioName, $associations, $tags, $fields, $measurement); \ No newline at end of file diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 38949d3d98..9ea5a53725 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -127,6 +127,8 @@ function rrdtool_graph($graph_file, $options) fclose($rrd_pipes[0]); + $line = ""; + $data = ""; while (strlen($line) < 1) { $line = fgets($rrd_pipes[1], 1024); $data .= $line; @@ -208,33 +210,46 @@ function rrdtool($command, $filename, $options) /** * Generates an rrd database at $filename using $options * + * @internal * @param string filename * @param string options + * @return array|bool */ - - function rrdtool_create($filename, $options) { - global $config; - if( $config['rrdcached'] && $config['rrdtool_version'] >= 1.5 ) { - $chk = rrdtool('info', $filename, ''); - if (!empty($chk[0])) { - return true; - } + if (rrdtool_check_rrd_exists($filename)) { + return true; } - return rrdtool('create', $filename, str_replace(array("\r", "\n"), '', $options)); + return rrdtool('create', $filename, str_replace(array("\r", "\n"), '', $options)); } +/** + * Checks if the rrd file exists on the server + * This will perform a remote check if using rrdcached and rrdtool >= 1.5 + * + * @param $filename + * @return bool + */ +function rrdtool_check_rrd_exists($filename) +{ + global $config; + if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { + $chk = rrdtool('info', $filename, ''); + return !empty($chk[0]); + } else { + return is_file($filename); + } +} /** * Updates an rrd database at $filename using $options * Where $options is an array, each entry which is not a number is replaced with "U" * - * @param string filename - * @param array options + * @internal + * @param string $filename + * @param array $options + * @return array|string */ - - function rrdtool_update($filename, $options) { $values = array(); @@ -302,16 +317,19 @@ function rrdtool_escape($string, $maxlength=null){ } // rrdtool_escape -/* - * @return the name of the rrd file for $host's $extra component - * @param host Host name - * @param extra Components of RRD filename - will be separated with "-" +/** + * Generates a filename based on the hostname (or IP) and some extra items + * + * @param string $host Host name + * @param array|string $extra Components of RRD filename - will be separated with "-", or a pre-formed rrdname + * @param string $extension File extension (default is .rrd) + * @return string the name of the rrd file for $host's $extra component */ -function rrd_name($host, $extra, $exten = ".rrd") +function rrd_name($host, $extra, $extension = ".rrd") { global $config; $filename = safename(is_array($extra) ? implode("-", $extra) : $extra); - return implode("/", array($config['rrd_dir'], $host, $filename.$exten)); + return implode("/", array($config['rrd_dir'], $host, $filename.$extension)); } // rrd_name function rrdtool_tune($type, $filename, $max) { @@ -332,22 +350,27 @@ function rrdtool_tune($type, $filename, $max) { } // rrdtool_tune -/* +/** * rrdtool backend implementation of data_update + * + * @param $device + * @param $measurement + * @param $tags + * @param $fields */ function rrdtool_data_update($device, $measurement, $tags, $fields) { global $config; - $rrd_name = $tags['rrd_name'] ? $tags['rrd_name'] : $measurement; - $step = $tags['rrd_step'] ? $tags['rrd_step'] : 300; + $rrd_name = $tags['rrd_name'] ?: $measurement; + $step = $tags['rrd_step'] ?: 300; $oldname = $tags['rrd_oldname']; if (isset($oldname) && !empty($oldname)) { rrd_file_rename($device, $oldname, $rrd_name); } $rrd = rrd_name($device['hostname'], $rrd_name); - if (!is_file($rrd) && $tags['rrd_def']) { + if (!rrdtool_check_rrd_exists($rrd) && $tags['rrd_def']) { $rrd_def = is_array($tags['rrd_def']) ? $tags['rrd_def'] : array($tags['rrd_def']); // add the --step and the rra definitions to the command $newdef = "--step $step ".implode(' ', $rrd_def).$config['rrd_rra']; diff --git a/includes/services.inc.php b/includes/services.inc.php index fa40a33ffe..5e07dad182 100644 --- a/includes/services.inc.php +++ b/includes/services.inc.php @@ -110,6 +110,7 @@ function discover_service($device, $service) { function poll_service($service) { global $config; + $update = array(); $old_status = $service['service_status']; $check_cmd = ""; @@ -126,17 +127,17 @@ function poll_service($service) { $check_cmd .= " " . $service['service_param']; } + $service_id = $service['service_id']; // Some debugging - d_echo("\nNagios Service - ".$service['service_id']."\n"); - d_echo("Request: ".$check_cmd."\n"); + d_echo("\nNagios Service - $service_id\n"); + d_echo("Request: $check_cmd\n"); list($new_status, $msg, $perf) = check_service($check_cmd); - d_echo("Response: ".$msg."\n"); + d_echo("Response: $msg\n"); // If we have performance data we will store it. if (count($perf) > 0) { // Yes, We have perf data. - $filename = "services-".$service['service_id'].".rrd"; - $rrd_filename = $config['rrd_dir'] . "/" . $service['hostname'] . "/" . safename ($filename); + $rrd_name = array('services', $service_id); // Set the DS in the DB if it is blank. $DS = array(); @@ -148,28 +149,28 @@ function poll_service($service) { $update['service_ds'] = json_encode($DS); } - // Create the RRD - if (!file_exists ($rrd_filename)) { - $rra = ""; - foreach ($perf as $k => $v) { - if ($v['uom'] == 'c') { - // This is a counter, create the DS as such - $rra .= " DS:".$k.":COUNTER:600:0:U"; - } - else { - // Not a counter, must be a gauge - $rra .= " DS:".$k.":GAUGE:600:0:U"; - } + // rrd definition + $rrd_def = array(); + foreach ($perf as $k => $v) { + if ($v['uom'] == 'c') { + // This is a counter, create the DS as such + $rrd_def[] = "DS:".$k.":COUNTER:600:0:U"; + } + else { + // Not a counter, must be a gauge + $rrd_def[] = "DS:".$k.":GAUGE:600:0:U"; } - rrdtool_create ($rrd_filename, $rra . $config['rrd_rra']); } - // Update RRD - $rrd = array(); + // Update data + $fields = array(); foreach ($perf as $k => $v) { - $rrd[$k] = $v['value']; + $fields[$k] = $v['value']; } - rrdtool_update ($rrd_filename, $rrd); + + $tags = compact('service_id', 'rrd_name', 'rrd_def'); + //TODO not sure if we have $device at this point, if we do replace faked $device + data_update(array('hostname' => $service['hostname']), 'services', $tags, $fields); } if ($old_status != $new_status) { diff --git a/includes/snom-graphing.php b/includes/snom-graphing.php deleted file mode 100644 index 6108812d90..0000000000 --- a/includes/snom-graphing.php +++ /dev/null @@ -1,58 +0,0 @@ - Date: Thu, 7 Jul 2016 21:57:18 -0500 Subject: [PATCH 02/67] Fix scrut issues, pass by reference --- html/includes/graphs/application/shoutcast_multi_bits.inc.php | 3 ++- html/includes/graphs/application/shoutcast_multi_stats.inc.php | 3 ++- html/pages/device/apps/shoutcast.inc.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php index 5ee3c4c5e1..cd193c6bf9 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -23,7 +23,8 @@ $colour_area_out = 'C3D9FF'; $rrd_list = array(); $rrd_filenames = glob(rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], '*'))); foreach ($rrd_filenames as $file) { - $hostname = end(explode('-',basename($file, '.rrd'))); + $pieces = explode('-', basename($file, '.rrd')); + $hostname = end($pieces); list($host, $port) = explode('_', $hostname, 2); $rrd_list[] = array( 'filename' => $file, diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index 77d132c14c..3a72450623 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -10,7 +10,8 @@ $nototal = 0; $rrd_list = array(); $rrd_filenames = glob(rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], '*'))); foreach ($rrd_filenames as $file) { - $hostname = end(explode('-',basename($file, '.rrd'))); + $pieces = explode('-', basename($file, '.rrd')); + $hostname = end($pieces); list($host, $port) = explode('_', $hostname, 2); $rrd_list[] = array( 'filename' => $file, diff --git a/html/pages/device/apps/shoutcast.inc.php b/html/pages/device/apps/shoutcast.inc.php index dca8b5cca2..75f37d99e8 100644 --- a/html/pages/device/apps/shoutcast.inc.php +++ b/html/pages/device/apps/shoutcast.inc.php @@ -33,7 +33,8 @@ if (isset($total) && $total === true) { $files = glob(rrd_name($device['hostname'], array('app', 'shoutcast', $app['app_id'], '*'))); foreach ($files as $file) { - $hostname = end(explode('-',basename($file, '.rrd'))); + $pieces = explode('-', basename($file, '.rrd')); + $hostname = end($pieces); list($host, $port) = explode('_', $hostname, 2); $graphs = array( 'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')', From c5c546917988f22caeafb6bc0210415bdb66ee64 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 8 Jul 2016 14:35:00 -0500 Subject: [PATCH 03/67] Fix rrdtool_check_rrd_exists() --- includes/polling/functions.inc.php | 2 -- includes/rrdtool.inc.php | 52 +++++++++++++----------------- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index d021ddeb0b..aa1bc616db 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -359,8 +359,6 @@ function poll_device($device, $options) { 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; diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 9ea5a53725..fc5f651d34 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -51,17 +51,10 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) $rrd_process = proc_open($command, $descriptorspec, $rrd_pipes, $cwd, $env); - stream_set_blocking($rrd_pipes[1], 0); - stream_set_blocking($rrd_pipes[2], 0); - - if (is_resource($rrd_process)) { - // $pipes now looks like this: - // 0 => writeable handle connected to child stdin - // 1 => readable handle connected to child stdout - // Any error output will be appended to /tmp/error-output.txt - return true; - } + stream_set_blocking($rrd_pipes[1], false); + stream_set_blocking($rrd_pipes[2], false); + return is_resource($rrd_process); } @@ -159,23 +152,23 @@ function rrdtool_graph($graph_file, $options) /** * Generates and pipes a command to rrdtool * - * @param string command - * @param string filename - * @param string options + * @param $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached + * @param $filename The full patth to the rrd file + * @param $options rrdtool command options + * @param int $timeout seconds give up waiting for output, default 0 usually results in empty output + * @return array the output of stdout and stderr in an array * @global config * @global debug * @global rrd_pipes */ - - -function rrdtool($command, $filename, $options) +function rrdtool($command, $filename, $options, $timeout=0) { global $config, $debug, $rrd_pipes, $console_color; if ($config['rrdcached'] && - (version_compare($config['rrdtool_version'], '1.5.5', '>=') || - (version_compare($config['rrdtool_version'], '1.5', '>=') && $command != "tune") || - ($command != "create" && $command != "tune")) + (version_compare($config['rrdtool_version'], '1.5.5', '>=') || // 1.5.5+ supports all commands + (version_compare($config['rrdtool_version'], '1.5', '>=') && $command != "tune") || // 1.5+ supports all except tune + ($command != "create" && $command != "tune")) // older supports all except create and tune ) { if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { $filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename); @@ -183,27 +176,26 @@ function rrdtool($command, $filename, $options) } $cmd = "$command $filename $options --daemon ".$config['rrdcached']; - } - else { + } else { $cmd = "$command $filename $options"; } if ($config['norrd']) { print $console_color->convert('[%rRRD Disabled%n]'); - } - else { + } else { fwrite($rrd_pipes[0], $cmd."\n"); } + stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + $output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2])); + if ($debug) { - echo stream_get_contents($rrd_pipes[1]); - echo stream_get_contents($rrd_pipes[2]); + echo $output[0]; + echo $output[1]; print $console_color->convert('RRD[%g'.$cmd.'%n] '); } - else { - return array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2])); - } + return $output; } @@ -234,8 +226,8 @@ function rrdtool_check_rrd_exists($filename) { global $config; if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { - $chk = rrdtool('info', $filename, ''); - return !empty($chk[0]); + $chk = rrdtool('first', $filename, '', 5); // wait up to 5 seconds + return substr(rtrim($chk[0]), -25) !== 'No such file or directory'; } else { return is_file($filename); } From c01d8b7c4ef66d97729b2a4050426cebc793e516 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 8 Jul 2016 15:09:11 -0500 Subject: [PATCH 04/67] Eradicate is file checks for our rrds (leave them for nfsen and collectd) --- .../graphs/application/apache_bits.inc.php | 2 +- .../graphs/application/apache_cpu.inc.php | 2 +- .../graphs/application/apache_hits.inc.php | 2 +- .../application/apache_scoreboard.inc.php | 2 +- .../graphs/application/bind_queries.inc.php | 2 +- .../application/ceph_osd_performance.inc.php | 2 +- .../graphs/application/ceph_pool_df.inc.php | 2 +- .../graphs/application/ceph_pool_io.inc.php | 2 +- .../graphs/application/ceph_pool_iops.inc.php | 2 +- .../application/ceph_pool_objects.inc.php | 2 +- .../graphs/application/drbd_disk_bits.inc.php | 2 +- .../application/drbd_network_bits.inc.php | 2 +- .../graphs/application/drbd_queue.inc.php | 2 +- .../graphs/application/drbd_unsynced.inc.php | 2 +- .../application/mailscanner_reject.inc.php | 2 +- .../application/mailscanner_sent.inc.php | 2 +- .../application/mailscanner_spam.inc.php | 2 +- .../graphs/application/memcached.inc.php | 2 +- .../graphs/application/memcached_data.inc.php | 2 +- .../application/memcached_hitmiss.inc.php | 2 +- .../application/memcached_items.inc.php | 2 +- .../mysql_command_counters.inc.php | 2 +- .../application/mysql_connections.inc.php | 2 +- .../application/mysql_files_tables.inc.php | 2 +- .../mysql_innodb_buffer_pool.inc.php | 2 +- .../mysql_innodb_buffer_pool_activity.inc.php | 2 +- .../mysql_innodb_insert_buffer.inc.php | 2 +- .../application/mysql_innodb_io.inc.php | 2 +- .../mysql_innodb_io_pending.inc.php | 2 +- .../application/mysql_innodb_log.inc.php | 2 +- .../mysql_innodb_row_operations.inc.php | 2 +- .../mysql_innodb_semaphores.inc.php | 2 +- .../mysql_innodb_transactions.inc.php | 2 +- .../application/mysql_myisam_indexes.inc.php | 2 +- .../application/mysql_network_traffic.inc.php | 2 +- .../application/mysql_query_cache.inc.php | 64 +++++++++---------- .../mysql_query_cache_memory.inc.php | 2 +- .../application/mysql_select_types.inc.php | 2 +- .../application/mysql_slow_queries.inc.php | 2 +- .../graphs/application/mysql_sorts.inc.php | 2 +- .../graphs/application/mysql_status.inc.php | 2 +- .../application/mysql_table_locks.inc.php | 2 +- .../mysql_temporary_objects.inc.php | 2 +- .../application/nginx_connections.inc.php | 2 +- .../graphs/application/nginx_req.inc.php | 2 +- .../graphs/application/ntpclient_freq.inc.php | 2 +- .../application/ntpclient_stats.inc.php | 2 +- .../application/ntpdserver_bits.inc.php | 2 +- .../application/ntpdserver_buffer.inc.php | 2 +- .../application/ntpdserver_freq.inc.php | 2 +- .../application/ntpdserver_packets.inc.php | 2 +- .../application/ntpdserver_stats.inc.php | 2 +- .../application/ntpdserver_stratum.inc.php | 2 +- .../application/ntpdserver_uptime.inc.php | 2 +- .../graphs/application/powerdns_fail.inc.php | 2 +- .../application/powerdns_latency.inc.php | 2 +- .../application/powerdns_packetcache.inc.php | 2 +- .../application/powerdns_queries.inc.php | 2 +- .../application/powerdns_queries_udp.inc.php | 2 +- .../application/powerdns_querycache.inc.php | 2 +- .../application/powerdns_recursing.inc.php | 2 +- .../application/proxmox_traffic.inc.php | 2 +- .../graphs/application/rrdcached.inc.php | 2 +- .../graphs/application/tinydns_dnssec.inc.php | 2 +- .../graphs/application/tinydns_errors.inc.php | 2 +- .../graphs/application/tinydns_other.inc.php | 2 +- .../application/tinydns_queries.inc.php | 2 +- html/includes/graphs/bill/bits.inc.php | 2 +- .../graphs/cefswitching/graph.inc.php | 2 +- html/includes/graphs/customer/bits.inc.php | 2 +- html/includes/graphs/device/agent.inc.php | 2 +- html/includes/graphs/device/bits.inc.php | 2 +- .../graphs/device/diskio_common.inc.php | 2 +- html/includes/graphs/device/mempool.inc.php | 2 +- .../graphs/device/poller_modules_perf.inc.php | 2 +- .../graphs/device/processor_separate.inc.php | 2 +- .../graphs/device/processor_stack.inc.php | 2 +- html/includes/graphs/global/bits.inc.php | 2 +- .../graphs/global/processor_separate.inc.php | 2 +- .../graphs/global/processor_stack.inc.php | 2 +- html/includes/graphs/location/bits.inc.php | 2 +- html/includes/graphs/multiport/bits.inc.php | 2 +- .../graphs/multiport/bits_duo.inc.php | 4 +- .../graphs/multiport/bits_separate.inc.php | 2 +- .../graphs/multiport/bits_trio.inc.php | 6 +- html/includes/graphs/port/etherlike.inc.php | 2 +- .../graphs/port/mac_acc_total.inc.php | 2 +- html/includes/graphs/port/nupkts.inc.php | 2 +- html/includes/graphs/port/pagp_bits.inc.php | 2 +- html/pages/device/graphs/ipSytemStats.inc.php | 4 +- html/pages/device/graphs/memory.inc.php | 2 +- .../device/graphs/netstats_icmp_stat.inc.php | 2 +- html/pages/device/graphs/netstats_ip.inc.php | 2 +- .../device/graphs/netstats_ip_forward.inc.php | 2 +- html/pages/device/graphs/netstats_tcp.inc.php | 2 +- html/pages/device/graphs/netstats_udp.inc.php | 2 +- html/pages/device/graphs/screenos.inc.php | 2 +- html/pages/device/graphs/wireless.inc.php | 2 +- 98 files changed, 133 insertions(+), 133 deletions(-) diff --git a/html/includes/graphs/application/apache_bits.inc.php b/html/includes/graphs/application/apache_bits.inc.php index d74b5fb87f..651e1c022c 100644 --- a/html/includes/graphs/application/apache_bits.inc.php +++ b/html/includes/graphs/application/apache_bits.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $apache_rrd = rrd_name($device['hostname'], array('app', 'apache', $app['app_id'])); -if (is_file($apache_rrd)) { +if (rrdtool_check_rrd_exists($apache_rrd)) { $rrd_filename = $apache_rrd; } diff --git a/html/includes/graphs/application/apache_cpu.inc.php b/html/includes/graphs/application/apache_cpu.inc.php index e36b0fecbc..33c7561309 100644 --- a/html/includes/graphs/application/apache_cpu.inc.php +++ b/html/includes/graphs/application/apache_cpu.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $apache_rrd = rrd_name($device['hostname'], array('app', 'apache', $app['app_id'])); -if (is_file($apache_rrd)) { +if (rrdtool_check_rrd_exists($apache_rrd)) { $rrd_filename = $apache_rrd; } diff --git a/html/includes/graphs/application/apache_hits.inc.php b/html/includes/graphs/application/apache_hits.inc.php index b5a0636225..9b4eb012a6 100644 --- a/html/includes/graphs/application/apache_hits.inc.php +++ b/html/includes/graphs/application/apache_hits.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $apache_rrd = rrd_name($device['hostname'], array('app', 'apache', $app['app_id'])); -if (is_file($apache_rrd)) { +if (rrdtool_check_rrd_exists($apache_rrd)) { $rrd_filename = $apache_rrd; } diff --git a/html/includes/graphs/application/apache_scoreboard.inc.php b/html/includes/graphs/application/apache_scoreboard.inc.php index d8075c6978..aaf197ba04 100644 --- a/html/includes/graphs/application/apache_scoreboard.inc.php +++ b/html/includes/graphs/application/apache_scoreboard.inc.php @@ -50,7 +50,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/bind_queries.inc.php b/html/includes/graphs/application/bind_queries.inc.php index 94625bef2d..9f3d0b1d84 100644 --- a/html/includes/graphs/application/bind_queries.inc.php +++ b/html/includes/graphs/application/bind_queries.inc.php @@ -48,7 +48,7 @@ $rrd_list = array(); $config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = strtoupper($ds); diff --git a/html/includes/graphs/application/ceph_osd_performance.inc.php b/html/includes/graphs/application/ceph_osd_performance.inc.php index 58381a9781..3427725b10 100644 --- a/html/includes/graphs/application/ceph_osd_performance.inc.php +++ b/html/includes/graphs/application/ceph_osd_performance.inc.php @@ -8,7 +8,7 @@ $out_text = 'Commit'; $ceph_osd_rrd = ceph_rrd('osd'); -if (is_file($ceph_osd_rrd)) { +if (rrdtool_check_rrd_exists($ceph_osd_rrd)) { $rrd_filename = $ceph_osd_rrd; } diff --git a/html/includes/graphs/application/ceph_pool_df.inc.php b/html/includes/graphs/application/ceph_pool_df.inc.php index 4dbca16952..8b53d13523 100644 --- a/html/includes/graphs/application/ceph_pool_df.inc.php +++ b/html/includes/graphs/application/ceph_pool_df.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; $ceph_pool_rrd = ceph_rrd('df'); -if (is_file($ceph_pool_rrd)) { +if (rrdtool_check_rrd_exists($ceph_pool_rrd)) { $rrd_filename = $ceph_pool_rrd; } diff --git a/html/includes/graphs/application/ceph_pool_io.inc.php b/html/includes/graphs/application/ceph_pool_io.inc.php index 8b09856642..c33763d253 100644 --- a/html/includes/graphs/application/ceph_pool_io.inc.php +++ b/html/includes/graphs/application/ceph_pool_io.inc.php @@ -9,7 +9,7 @@ $format = 'bytes'; $ceph_pool_rrd = ceph_rrd('pool'); -if (is_file($ceph_pool_rrd)) { +if (rrdtool_check_rrd_exists($ceph_pool_rrd)) { $rrd_filename = $ceph_pool_rrd; } diff --git a/html/includes/graphs/application/ceph_pool_iops.inc.php b/html/includes/graphs/application/ceph_pool_iops.inc.php index 4ed81d3672..0f4e7b2324 100644 --- a/html/includes/graphs/application/ceph_pool_iops.inc.php +++ b/html/includes/graphs/application/ceph_pool_iops.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $ceph_pool_rrd = ceph_rrd('pool'); -if (is_file($ceph_pool_rrd)) { +if (rrdtool_check_rrd_exists($ceph_pool_rrd)) { $rrd_filename = $ceph_pool_rrd; } diff --git a/html/includes/graphs/application/ceph_pool_objects.inc.php b/html/includes/graphs/application/ceph_pool_objects.inc.php index c4f1389412..5d497869a4 100644 --- a/html/includes/graphs/application/ceph_pool_objects.inc.php +++ b/html/includes/graphs/application/ceph_pool_objects.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $ceph_pool_rrd = ceph_rrd('df'); -if (is_file($ceph_pool_rrd)) { +if (rrdtool_check_rrd_exists($ceph_pool_rrd)) { $rrd_filename = $ceph_pool_rrd; } diff --git a/html/includes/graphs/application/drbd_disk_bits.inc.php b/html/includes/graphs/application/drbd_disk_bits.inc.php index bc9961f51e..536cba013f 100644 --- a/html/includes/graphs/application/drbd_disk_bits.inc.php +++ b/html/includes/graphs/application/drbd_disk_bits.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $drbd_rrd = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); -if (is_file($drbd_rrd)) { +if (rrdtool_check_rrd_exists($drbd_rrd)) { $rrd_filename = $drbd_rrd; } diff --git a/html/includes/graphs/application/drbd_network_bits.inc.php b/html/includes/graphs/application/drbd_network_bits.inc.php index ebd6bce27f..b3d1c35394 100644 --- a/html/includes/graphs/application/drbd_network_bits.inc.php +++ b/html/includes/graphs/application/drbd_network_bits.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $drbd_rrd = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); -if (is_file($drbd_rrd)) { +if (rrdtool_check_rrd_exists($drbd_rrd)) { $rrd_filename = $drbd_rrd; } diff --git a/html/includes/graphs/application/drbd_queue.inc.php b/html/includes/graphs/application/drbd_queue.inc.php index 50237b4a12..3de7e66978 100644 --- a/html/includes/graphs/application/drbd_queue.inc.php +++ b/html/includes/graphs/application/drbd_queue.inc.php @@ -12,7 +12,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/drbd_unsynced.inc.php b/html/includes/graphs/application/drbd_unsynced.inc.php index dd16019c22..686d56c40c 100644 --- a/html/includes/graphs/application/drbd_unsynced.inc.php +++ b/html/includes/graphs/application/drbd_unsynced.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $drbd_rrd = rrd_name($device['hostname'], array('app', 'drbd', $app['app_instance'])); -if (is_file($drbd_rrd)) { +if (rrdtool_check_rrd_exists($drbd_rrd)) { $rrd_filename = $drbd_rrd; } diff --git a/html/includes/graphs/application/mailscanner_reject.inc.php b/html/includes/graphs/application/mailscanner_reject.inc.php index 4ab82707fa..a4fd6d258a 100644 --- a/html/includes/graphs/application/mailscanner_reject.inc.php +++ b/html/includes/graphs/application/mailscanner_reject.inc.php @@ -16,7 +16,7 @@ $array = array( $i = 0; $x = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { $max_colours = count($config['graph_colours'][$colours]); foreach ($array as $ds => $vars) { $x = (($x <= $max_colours) ? $x : 0); diff --git a/html/includes/graphs/application/mailscanner_sent.inc.php b/html/includes/graphs/application/mailscanner_sent.inc.php index 2a19397357..3e2728e1b9 100644 --- a/html/includes/graphs/application/mailscanner_sent.inc.php +++ b/html/includes/graphs/application/mailscanner_sent.inc.php @@ -17,7 +17,7 @@ $colour_area_out_max = 'FFEFAA'; $mailscanner_rrd = rrd_name($device['hostname'], array('app', 'mailscannerV2', $app['app_id'])); -if (is_file($mailscanner_rrd)) { +if (rrdtool_check_rrd_exists($mailscanner_rrd)) { $rrd_filename = $mailscanner_rrd; } diff --git a/html/includes/graphs/application/mailscanner_spam.inc.php b/html/includes/graphs/application/mailscanner_spam.inc.php index bb805addf2..ecad7e0948 100644 --- a/html/includes/graphs/application/mailscanner_spam.inc.php +++ b/html/includes/graphs/application/mailscanner_spam.inc.php @@ -19,7 +19,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/memcached.inc.php b/html/includes/graphs/application/memcached.inc.php index 5bd7e7bb27..880ea912d1 100644 --- a/html/includes/graphs/application/memcached.inc.php +++ b/html/includes/graphs/application/memcached.inc.php @@ -1,5 +1,5 @@ $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/memcached_hitmiss.inc.php b/html/includes/graphs/application/memcached_hitmiss.inc.php index f781224ee0..575a360819 100644 --- a/html/includes/graphs/application/memcached_hitmiss.inc.php +++ b/html/includes/graphs/application/memcached_hitmiss.inc.php @@ -20,7 +20,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/memcached_items.inc.php b/html/includes/graphs/application/memcached_items.inc.php index 067c6496ce..17352ab14d 100644 --- a/html/includes/graphs/application/memcached_items.inc.php +++ b/html/includes/graphs/application/memcached_items.inc.php @@ -16,7 +16,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/mysql_command_counters.inc.php b/html/includes/graphs/application/mysql_command_counters.inc.php index 258594fc98..7d3047e051 100644 --- a/html/includes/graphs/application/mysql_command_counters.inc.php +++ b/html/includes/graphs/application/mysql_command_counters.inc.php @@ -44,7 +44,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/mysql_connections.inc.php b/html/includes/graphs/application/mysql_connections.inc.php index b74234a676..45f577448f 100644 --- a/html/includes/graphs/application/mysql_connections.inc.php +++ b/html/includes/graphs/application/mysql_connections.inc.php @@ -34,7 +34,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/mysql_files_tables.inc.php b/html/includes/graphs/application/mysql_files_tables.inc.php index 40cc28578d..0fbe86de3f 100644 --- a/html/includes/graphs/application/mysql_files_tables.inc.php +++ b/html/includes/graphs/application/mysql_files_tables.inc.php @@ -12,7 +12,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php b/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php index 5b1478e9d7..9e35ca9664 100644 --- a/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php +++ b/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php @@ -12,7 +12,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php b/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php index ba6bc1af5e..19275feae3 100644 --- a/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php +++ b/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php @@ -11,7 +11,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php b/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php index 51256965e5..0d83b6633e 100644 --- a/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php +++ b/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php @@ -11,7 +11,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_innodb_io.inc.php b/html/includes/graphs/application/mysql_innodb_io.inc.php index 5f2ca64c58..cbc4f019ea 100644 --- a/html/includes/graphs/application/mysql_innodb_io.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; $mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); -if (is_file($mysql_rrd)) { +if (rrdtool_check_rrd_exists($mysql_rrd)) { $rrd_filename = $mysql_rrd; } diff --git a/html/includes/graphs/application/mysql_innodb_io_pending.inc.php b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php index 3cd0d7f325..f2ecc3d484 100644 --- a/html/includes/graphs/application/mysql_innodb_io_pending.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php @@ -15,7 +15,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_innodb_log.inc.php b/html/includes/graphs/application/mysql_innodb_log.inc.php index ade5e47f4a..cb20abebc3 100644 --- a/html/includes/graphs/application/mysql_innodb_log.inc.php +++ b/html/includes/graphs/application/mysql_innodb_log.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; $mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); -if (is_file($mysql_rrd)) { +if (rrdtool_check_rrd_exists($mysql_rrd)) { $rrd_filename = $mysql_rrd; } diff --git a/html/includes/graphs/application/mysql_innodb_row_operations.inc.php b/html/includes/graphs/application/mysql_innodb_row_operations.inc.php index c5ab9cda44..3aea791645 100644 --- a/html/includes/graphs/application/mysql_innodb_row_operations.inc.php +++ b/html/includes/graphs/application/mysql_innodb_row_operations.inc.php @@ -12,7 +12,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_innodb_semaphores.inc.php b/html/includes/graphs/application/mysql_innodb_semaphores.inc.php index 8a27ef1bc9..f8499e5728 100644 --- a/html/includes/graphs/application/mysql_innodb_semaphores.inc.php +++ b/html/includes/graphs/application/mysql_innodb_semaphores.inc.php @@ -11,7 +11,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_innodb_transactions.inc.php b/html/includes/graphs/application/mysql_innodb_transactions.inc.php index 04cde3a191..307c4e74cf 100644 --- a/html/includes/graphs/application/mysql_innodb_transactions.inc.php +++ b/html/includes/graphs/application/mysql_innodb_transactions.inc.php @@ -7,7 +7,7 @@ $rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id $array = array('IBTNx' => 'Transactions created'); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_myisam_indexes.inc.php b/html/includes/graphs/application/mysql_myisam_indexes.inc.php index c95b316dbc..5fdff1cee2 100644 --- a/html/includes/graphs/application/mysql_myisam_indexes.inc.php +++ b/html/includes/graphs/application/mysql_myisam_indexes.inc.php @@ -12,7 +12,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_network_traffic.inc.php b/html/includes/graphs/application/mysql_network_traffic.inc.php index afabd03cac..2674439a75 100644 --- a/html/includes/graphs/application/mysql_network_traffic.inc.php +++ b/html/includes/graphs/application/mysql_network_traffic.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; $mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); -if (is_file($mysql_rrd)) { +if (rrdtool_check_rrd_exists($mysql_rrd)) { $rrd_filename = $mysql_rrd; } diff --git a/html/includes/graphs/application/mysql_query_cache.inc.php b/html/includes/graphs/application/mysql_query_cache.inc.php index c1b76eeb36..9a70d720aa 100644 --- a/html/includes/graphs/application/mysql_query_cache.inc.php +++ b/html/includes/graphs/application/mysql_query_cache.inc.php @@ -4,45 +4,45 @@ require 'includes/graphs/common.inc.php'; $mysql_rrd = rrd_name($device['hostname'], array('app', mysql, $app['app_id'])); -if (is_file($mysql_rrd)) { +if (rrdtool_check_rrd_exists($mysql_rrd)) { $rrd_filename = $mysql_rrd; -} -$array = array( - 'QCQICe' => array( - 'descr' => 'Queries in cache', - 'colour' => '22FF22', - ), - 'QCHs' => array( - 'descr' => 'Cache hits', - 'colour' => '0022FF', - ), - 'QCIs' => array( - 'descr' => 'Inserts', - 'colour' => 'FF0000', - ), - 'QCNCd' => array( - 'descr' => 'Not cached', - 'colour' => '00AAAA', - ), - 'QCLMPs' => array( - 'descr' => 'Low-memory prunes', - 'colour' => 'FF00FF', - ), - ); + $array = array( + 'QCQICe' => array( + 'descr' => 'Queries in cache', + 'colour' => '22FF22', + ), + 'QCHs' => array( + 'descr' => 'Cache hits', + 'colour' => '0022FF', + ), + 'QCIs' => array( + 'descr' => 'Inserts', + 'colour' => 'FF0000', + ), + 'QCNCd' => array( + 'descr' => 'Not cached', + 'colour' => '00AAAA', + ), + 'QCLMPs' => array( + 'descr' => 'Low-memory prunes', + 'colour' => 'FF00FF', + ), + ); -$i = 0; -if (is_file($rrd_filename)) { + + $rrd_list = array(); foreach ($array as $ds => $vars) { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - // $rrd_list[$i]['colour'] = $vars['colour']; - $i++; + $rrd_list[] = array( + 'filename' => $rrd_filename, + 'descr' => $vars['descr'], + 'ds' => $ds, +// 'colour' => $vars['colour'] + ); } } else { - echo "file missing: $file"; + echo "data missing: $mysql_rrd"; } $colours = 'mixed'; diff --git a/html/includes/graphs/application/mysql_query_cache_memory.inc.php b/html/includes/graphs/application/mysql_query_cache_memory.inc.php index 6343ed214d..e003857307 100644 --- a/html/includes/graphs/application/mysql_query_cache_memory.inc.php +++ b/html/includes/graphs/application/mysql_query_cache_memory.inc.php @@ -10,7 +10,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_select_types.inc.php b/html/includes/graphs/application/mysql_select_types.inc.php index e7d81dab0b..b78e354937 100644 --- a/html/includes/graphs/application/mysql_select_types.inc.php +++ b/html/includes/graphs/application/mysql_select_types.inc.php @@ -13,7 +13,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_slow_queries.inc.php b/html/includes/graphs/application/mysql_slow_queries.inc.php index a70a28a369..2827a3c6dc 100644 --- a/html/includes/graphs/application/mysql_slow_queries.inc.php +++ b/html/includes/graphs/application/mysql_slow_queries.inc.php @@ -7,7 +7,7 @@ $rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id $array = array('SQs' => 'Slow queries'); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_sorts.inc.php b/html/includes/graphs/application/mysql_sorts.inc.php index c2df2b06a7..84abb295b8 100644 --- a/html/includes/graphs/application/mysql_sorts.inc.php +++ b/html/includes/graphs/application/mysql_sorts.inc.php @@ -12,7 +12,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_status.inc.php b/html/includes/graphs/application/mysql_status.inc.php index f74364d698..1bdd727c00 100644 --- a/html/includes/graphs/application/mysql_status.inc.php +++ b/html/includes/graphs/application/mysql_status.inc.php @@ -24,7 +24,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $vars => $ds) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_table_locks.inc.php b/html/includes/graphs/application/mysql_table_locks.inc.php index f2b7a7a136..d575e157ba 100644 --- a/html/includes/graphs/application/mysql_table_locks.inc.php +++ b/html/includes/graphs/application/mysql_table_locks.inc.php @@ -10,7 +10,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/mysql_temporary_objects.inc.php b/html/includes/graphs/application/mysql_temporary_objects.inc.php index fc1ef90f40..654e43bc1f 100644 --- a/html/includes/graphs/application/mysql_temporary_objects.inc.php +++ b/html/includes/graphs/application/mysql_temporary_objects.inc.php @@ -11,7 +11,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; if (is_array($vars)) { diff --git a/html/includes/graphs/application/nginx_connections.inc.php b/html/includes/graphs/application/nginx_connections.inc.php index 1339ec64f7..4926443c3d 100644 --- a/html/includes/graphs/application/nginx_connections.inc.php +++ b/html/includes/graphs/application/nginx_connections.inc.php @@ -26,7 +26,7 @@ $array = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/nginx_req.inc.php b/html/includes/graphs/application/nginx_req.inc.php index 7d3761380a..bb4d2502eb 100644 --- a/html/includes/graphs/application/nginx_req.inc.php +++ b/html/includes/graphs/application/nginx_req.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; $rrd_filename = rrd_name($device['hostname'], array('app', 'nginx', $app['app_id'])); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { $rrd_options .= ' -b 1000 '; $rrd_options .= ' -l 0 '; $rrd_options .= ' DEF:a='.$rrd_filename.':Requests:AVERAGE'; diff --git a/html/includes/graphs/application/ntpclient_freq.inc.php b/html/includes/graphs/application/ntpclient_freq.inc.php index 180dbc3c62..cfd0430b28 100644 --- a/html/includes/graphs/application/ntpclient_freq.inc.php +++ b/html/includes/graphs/application/ntpclient_freq.inc.php @@ -11,7 +11,7 @@ $graph_max = 100; $unit_text = 'Frequency'; $ntpclient_rrd = rrd_name($device['hostname'], array('app', 'ntpclient', $app['app_id'])); -if (is_file($ntpclient_rrd)) { +if (rrdtool_check_rrd_exists($ntpclient_rrd)) { $rrd_filename = $ntpclient_rrd; } diff --git a/html/includes/graphs/application/ntpclient_stats.inc.php b/html/includes/graphs/application/ntpclient_stats.inc.php index 6118f75cd9..1ee5672047 100644 --- a/html/includes/graphs/application/ntpclient_stats.inc.php +++ b/html/includes/graphs/application/ntpclient_stats.inc.php @@ -15,7 +15,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/ntpdserver_bits.inc.php b/html/includes/graphs/application/ntpdserver_bits.inc.php index 9b7996d7ab..f238dfd0f3 100644 --- a/html/includes/graphs/application/ntpdserver_bits.inc.php +++ b/html/includes/graphs/application/ntpdserver_bits.inc.php @@ -22,7 +22,7 @@ $colour_area_out_max = 'FFEFAA'; $ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); -if (is_file($ntpdserver_rrd)) { +if (rrdtool_check_rrd_exists($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; } diff --git a/html/includes/graphs/application/ntpdserver_buffer.inc.php b/html/includes/graphs/application/ntpdserver_buffer.inc.php index 7e10be0bda..b0e81ef713 100644 --- a/html/includes/graphs/application/ntpdserver_buffer.inc.php +++ b/html/includes/graphs/application/ntpdserver_buffer.inc.php @@ -15,7 +15,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/ntpdserver_freq.inc.php b/html/includes/graphs/application/ntpdserver_freq.inc.php index ac141364a8..59f6f12f86 100644 --- a/html/includes/graphs/application/ntpdserver_freq.inc.php +++ b/html/includes/graphs/application/ntpdserver_freq.inc.php @@ -11,7 +11,7 @@ $graph_max = 100; $unit_text = 'Frequency'; $ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); -if (is_file($ntpdserver_rrd)) { +if (rrdtool_check_rrd_exists($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; } diff --git a/html/includes/graphs/application/ntpdserver_packets.inc.php b/html/includes/graphs/application/ntpdserver_packets.inc.php index 55440924af..e884c5c3bd 100644 --- a/html/includes/graphs/application/ntpdserver_packets.inc.php +++ b/html/includes/graphs/application/ntpdserver_packets.inc.php @@ -19,7 +19,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/ntpdserver_stats.inc.php b/html/includes/graphs/application/ntpdserver_stats.inc.php index ec411bce06..362f19e06e 100644 --- a/html/includes/graphs/application/ntpdserver_stats.inc.php +++ b/html/includes/graphs/application/ntpdserver_stats.inc.php @@ -15,7 +15,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/ntpdserver_stratum.inc.php b/html/includes/graphs/application/ntpdserver_stratum.inc.php index 0016db50c5..aaf92c0287 100644 --- a/html/includes/graphs/application/ntpdserver_stratum.inc.php +++ b/html/includes/graphs/application/ntpdserver_stratum.inc.php @@ -11,7 +11,7 @@ $graph_max = 0; $unit_text = 'Stratum'; $ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); -if (is_file($ntpdserver_rrd)) { +if (rrdtool_check_rrd_exists($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; } diff --git a/html/includes/graphs/application/ntpdserver_uptime.inc.php b/html/includes/graphs/application/ntpdserver_uptime.inc.php index 8ea5f1cb73..a4baf8b03d 100644 --- a/html/includes/graphs/application/ntpdserver_uptime.inc.php +++ b/html/includes/graphs/application/ntpdserver_uptime.inc.php @@ -13,7 +13,7 @@ $graph_max = 0; $unit_text = 'Seconds'; $ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id'])); -if (is_file($ntpdserver_rrd)) { +if (rrdtool_check_rrd_exists($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; } diff --git a/html/includes/graphs/application/powerdns_fail.inc.php b/html/includes/graphs/application/powerdns_fail.inc.php index e9c623a283..87b886e3bf 100644 --- a/html/includes/graphs/application/powerdns_fail.inc.php +++ b/html/includes/graphs/application/powerdns_fail.inc.php @@ -24,7 +24,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/powerdns_latency.inc.php b/html/includes/graphs/application/powerdns_latency.inc.php index f8f1118808..5c22012f05 100644 --- a/html/includes/graphs/application/powerdns_latency.inc.php +++ b/html/includes/graphs/application/powerdns_latency.inc.php @@ -11,7 +11,7 @@ $graph_max = 100; $unit_text = 'Latency'; $powerdns_rrd = rrd_name($device['hostname'], array('app', 'powerdns', $app['app_id'])); -if (is_file($powerdns_rrd)) { +if (rrdtool_check_rrd_exists($powerdns_rrd)) { $rrd_filename = $powerdns_rrd; } diff --git a/html/includes/graphs/application/powerdns_packetcache.inc.php b/html/includes/graphs/application/powerdns_packetcache.inc.php index bfdf689da3..c0498748ea 100644 --- a/html/includes/graphs/application/powerdns_packetcache.inc.php +++ b/html/includes/graphs/application/powerdns_packetcache.inc.php @@ -24,7 +24,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/powerdns_queries.inc.php b/html/includes/graphs/application/powerdns_queries.inc.php index 27f65eb058..37cc95eb28 100644 --- a/html/includes/graphs/application/powerdns_queries.inc.php +++ b/html/includes/graphs/application/powerdns_queries.inc.php @@ -28,7 +28,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/powerdns_queries_udp.inc.php b/html/includes/graphs/application/powerdns_queries_udp.inc.php index a009ab60b6..a4cf32a0cb 100644 --- a/html/includes/graphs/application/powerdns_queries_udp.inc.php +++ b/html/includes/graphs/application/powerdns_queries_udp.inc.php @@ -28,7 +28,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/powerdns_querycache.inc.php b/html/includes/graphs/application/powerdns_querycache.inc.php index 03b424cefb..82f5dcd12e 100644 --- a/html/includes/graphs/application/powerdns_querycache.inc.php +++ b/html/includes/graphs/application/powerdns_querycache.inc.php @@ -20,7 +20,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/powerdns_recursing.inc.php b/html/includes/graphs/application/powerdns_recursing.inc.php index 47562e1ad6..ad0a33e7cd 100644 --- a/html/includes/graphs/application/powerdns_recursing.inc.php +++ b/html/includes/graphs/application/powerdns_recursing.inc.php @@ -20,7 +20,7 @@ $array = array( $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $vars['descr']; diff --git a/html/includes/graphs/application/proxmox_traffic.inc.php b/html/includes/graphs/application/proxmox_traffic.inc.php index 8d3b790fc7..09b7cdb084 100644 --- a/html/includes/graphs/application/proxmox_traffic.inc.php +++ b/html/includes/graphs/application/proxmox_traffic.inc.php @@ -20,7 +20,7 @@ require 'includes/graphs/common.inc.php'; $proxmox_rrd = config['rrd_dir'].'/proxmox/'.$vars['cluster'].'/'.$vars['vmid'].'_netif_'.$vars['port'].'.rrd'; -if (is_file($proxmox_rrd)) { +if (rrdtool_check_rrd_exists($proxmox_rrd)) { $rrd_filename = $proxmox_rrd; } diff --git a/html/includes/graphs/application/rrdcached.inc.php b/html/includes/graphs/application/rrdcached.inc.php index 8d16005b81..eda711768a 100644 --- a/html/includes/graphs/application/rrdcached.inc.php +++ b/html/includes/graphs/application/rrdcached.inc.php @@ -24,6 +24,6 @@ */ $rrd = rrd_name($device['hostname'], array('app', 'rrdcached', $app['app_id'])); -if (is_file($rrd)) { +if (rrdtool_check_rrd_exists($rrd)) { $rrd_filename = $rrd; } diff --git a/html/includes/graphs/application/tinydns_dnssec.inc.php b/html/includes/graphs/application/tinydns_dnssec.inc.php index cae12cae9f..43f96701f4 100644 --- a/html/includes/graphs/application/tinydns_dnssec.inc.php +++ b/html/includes/graphs/application/tinydns_dnssec.inc.php @@ -39,7 +39,7 @@ $array = array( $colours = 'mixed'; $rrd_list = array(); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = strtoupper($ds); diff --git a/html/includes/graphs/application/tinydns_errors.inc.php b/html/includes/graphs/application/tinydns_errors.inc.php index 04ffd5863e..e6a1be554b 100644 --- a/html/includes/graphs/application/tinydns_errors.inc.php +++ b/html/includes/graphs/application/tinydns_errors.inc.php @@ -40,7 +40,7 @@ $array = array( $colours = 'oranges'; $rrd_list = array(); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = strtoupper($ds); diff --git a/html/includes/graphs/application/tinydns_other.inc.php b/html/includes/graphs/application/tinydns_other.inc.php index 1525ab784b..c18cd6cbf2 100644 --- a/html/includes/graphs/application/tinydns_other.inc.php +++ b/html/includes/graphs/application/tinydns_other.inc.php @@ -40,7 +40,7 @@ $array = array( $colours = 'mixed'; $rrd_list = array(); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = strtoupper($ds); diff --git a/html/includes/graphs/application/tinydns_queries.inc.php b/html/includes/graphs/application/tinydns_queries.inc.php index 10a438fb99..a256bbb4e6 100644 --- a/html/includes/graphs/application/tinydns_queries.inc.php +++ b/html/includes/graphs/application/tinydns_queries.inc.php @@ -48,7 +48,7 @@ $rrd_list = array(); $config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($array as $ds) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = strtoupper($ds); diff --git a/html/includes/graphs/bill/bits.inc.php b/html/includes/graphs/bill/bits.inc.php index 266fa86a21..4feafc3ef5 100644 --- a/html/includes/graphs/bill/bits.inc.php +++ b/html/includes/graphs/bill/bits.inc.php @@ -5,7 +5,7 @@ $i = 0; foreach ($ports as $port) { $rrd_file = get_port_rrdfile_path ($port['hostname'], $port['port_id']); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $port['ifDescr']; $i++; diff --git a/html/includes/graphs/cefswitching/graph.inc.php b/html/includes/graphs/cefswitching/graph.inc.php index 5a1b31419d..28e1e81261 100644 --- a/html/includes/graphs/cefswitching/graph.inc.php +++ b/html/includes/graphs/cefswitching/graph.inc.php @@ -8,7 +8,7 @@ $oids = array( ); $i = 0; -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($oids as $oid) { $oid = str_replace('dot3Stats', '', $oid); $oid_ds = truncate($oid, 19, ''); diff --git a/html/includes/graphs/customer/bits.inc.php b/html/includes/graphs/customer/bits.inc.php index ee3d4a7411..46d3046ad2 100644 --- a/html/includes/graphs/customer/bits.inc.php +++ b/html/includes/graphs/customer/bits.inc.php @@ -11,7 +11,7 @@ $descr_type = "'".implode("', '", $config['customers_descr'])."'"; foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id', array(array($descr_type), $vars['id'])) as $port) { $rrd_filename = get_port_rrdfile_path ($port['hostname'], $port['port_id']); // FIXME: Unification OK? - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $port['hostname'].'-'.$port['ifDescr']; $rrd_list[$i]['descr_in'] = shorthost($port['hostname']); diff --git a/html/includes/graphs/device/agent.inc.php b/html/includes/graphs/device/agent.inc.php index d774097397..67fd78a275 100644 --- a/html/includes/graphs/device/agent.inc.php +++ b/html/includes/graphs/device/agent.inc.php @@ -6,7 +6,7 @@ require 'includes/graphs/common.inc.php'; $agent_rrd = rrd_name($device['hostname'], 'agent'); -if (is_file($agent_rrd)) { +if (rrdtool_check_rrd_exists($agent_rrd)) { $rrd_filename = $agent_rrd; } diff --git a/html/includes/graphs/device/bits.inc.php b/html/includes/graphs/device/bits.inc.php index f796490f2c..166743621e 100644 --- a/html/includes/graphs/device/bits.inc.php +++ b/html/includes/graphs/device/bits.inc.php @@ -23,7 +23,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($devic } $rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id']); - if ($ignore != 1 && is_file($rrd_filename)) { + if ($ignore != 1 && rrdtool_check_rrd_exists($rrd_filename)) { $port = ifLabel($port); // Fix Labels! ARGH. This needs to be in the bloody database! $rrd_filenames[] = $rrd_filename; diff --git a/html/includes/graphs/device/diskio_common.inc.php b/html/includes/graphs/device/diskio_common.inc.php index b5e503e07d..16f3d450ce 100644 --- a/html/includes/graphs/device/diskio_common.inc.php +++ b/html/includes/graphs/device/diskio_common.inc.php @@ -4,7 +4,7 @@ $i = 1; foreach (dbFetchRows('SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id', array($device['device_id'])) as $disk) { $rrd_filename = rrd_name($disk['hostname'], array('ucd_diskio', $disk['diskio_descr'])); - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $disk['diskio_descr']; $rrd_list[$i]['ds_in'] = $ds_in; diff --git a/html/includes/graphs/device/mempool.inc.php b/html/includes/graphs/device/mempool.inc.php index eeb86abe23..4b770b33c2 100644 --- a/html/includes/graphs/device/mempool.inc.php +++ b/html/includes/graphs/device/mempool.inc.php @@ -36,7 +36,7 @@ foreach (dbFetchRows('SELECT * FROM `mempools` where `device_id` = ?', array($de $descr = rrdtool_escape(short_hrDeviceDescr($mempool['mempool_descr']), 22); $rrd_filename = rrd_name($device['hostname'], array('mempool', $mempool['mempool_type'], $mempool['mempool_index'])); - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $rrd_options .= " DEF:mempoolfree$i=$rrd_filename:free:AVERAGE "; $rrd_options .= " DEF:mempoolused$i=$rrd_filename:used:AVERAGE "; $rrd_options .= " CDEF:mempooltotal$i=mempoolused$i,mempoolused$i,mempoolfree$i,+,/,100,* "; diff --git a/html/includes/graphs/device/poller_modules_perf.inc.php b/html/includes/graphs/device/poller_modules_perf.inc.php index 50ca7fcf4b..a83080b437 100644 --- a/html/includes/graphs/device/poller_modules_perf.inc.php +++ b/html/includes/graphs/device/poller_modules_perf.inc.php @@ -22,7 +22,7 @@ $count = 0; foreach ($config['poller_modules'] as $module => $module_status) { $rrd_filename = rrd_name($device['hostname'], array('poller-perf', $module)); if ($attribs['poll_'.$module] || ( $module_status && !isset($attribs['poll_'.$module]))) { - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $ds['ds'] = 'poller'; $ds['descr'] = $module; $ds['filename'] = $rrd_filename; diff --git a/html/includes/graphs/device/processor_separate.inc.php b/html/includes/graphs/device/processor_separate.inc.php index bf77508763..5607688699 100644 --- a/html/includes/graphs/device/processor_separate.inc.php +++ b/html/includes/graphs/device/processor_separate.inc.php @@ -5,7 +5,7 @@ $i = 0; foreach ($procs as $proc) { $rrd_filename = rrd_name($device['hostname'], array('processor', $proc['processor_type'], $proc['processor_index'])); - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $descr = short_hrDeviceDescr($proc['processor_descr']); $rrd_list[$i]['filename'] = $rrd_filename; diff --git a/html/includes/graphs/device/processor_stack.inc.php b/html/includes/graphs/device/processor_stack.inc.php index 6e3df921a6..5397b8fa10 100644 --- a/html/includes/graphs/device/processor_stack.inc.php +++ b/html/includes/graphs/device/processor_stack.inc.php @@ -5,7 +5,7 @@ $i = 0; foreach ($procs as $proc) { $rrd_filename = rrd_name($device['hostname'], array('processor', $proc['processor_type'], $proc['processor_index'])); - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $descr = short_hrDeviceDescr($proc['processor_descr']); $rrd_list[$i]['filename'] = $rrd_filename; diff --git a/html/includes/graphs/global/bits.inc.php b/html/includes/graphs/global/bits.inc.php index 350d96f870..3cb29a96ad 100644 --- a/html/includes/graphs/global/bits.inc.php +++ b/html/includes/graphs/global/bits.inc.php @@ -22,7 +22,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` AS D WHERE D.device_ } $rrd_filename = get_port_rrdfile_path ($port['hostname'], $port['port_id']); - if (!$ignore && $i < 1100 && is_file($rrd_filename)) { + if (!$ignore && $i < 1100 && rrdtool_check_rrd_exists($rrd_filename)) { $rrd_filenames[] = $rrd_filename; $rrd_list[$i]['filename'] = $rrd_filename; // $rrd_list[$i]['descr'] = $port['device_id'] . " " . $port['ifDescr']; diff --git a/html/includes/graphs/global/processor_separate.inc.php b/html/includes/graphs/global/processor_separate.inc.php index e68547523d..9c3003eeb8 100644 --- a/html/includes/graphs/global/processor_separate.inc.php +++ b/html/includes/graphs/global/processor_separate.inc.php @@ -5,7 +5,7 @@ $i = 0; foreach (dbFetchRows('SELECT * FROM `processors` AS P, devices AS D WHERE D.device_id = P.device_id') as $proc) { $rrd_filename = rrd_name($proc['hostname'], array('processor', $proc['processor_type'], $proc['processor_index'])); - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $descr = short_hrDeviceDescr($proc['processor_descr']); $rrd_list[$i]['filename'] = $rrd_filename; diff --git a/html/includes/graphs/global/processor_stack.inc.php b/html/includes/graphs/global/processor_stack.inc.php index da0919e984..9b73cc7f63 100644 --- a/html/includes/graphs/global/processor_stack.inc.php +++ b/html/includes/graphs/global/processor_stack.inc.php @@ -5,7 +5,7 @@ $i = 0; foreach (dbFetchRows('SELECT * FROM `processors` AS P, devices AS D WHERE D.device_id = P.device_id') as $proc) { $rrd_filename = rrd_name($proc['hostname'], array('processor', $proc['processor_type'], $proc['processor_index'])); - if (is_file($rrd_filename)) { + if (rrdtool_check_rrd_exists($rrd_filename)) { $descr = short_hrDeviceDescr($proc['processor_descr']); $rrd_list[$i]['filename'] = $rrd_filename; diff --git a/html/includes/graphs/location/bits.inc.php b/html/includes/graphs/location/bits.inc.php index 7f77108a92..100745630d 100644 --- a/html/includes/graphs/location/bits.inc.php +++ b/html/includes/graphs/location/bits.inc.php @@ -25,7 +25,7 @@ foreach ($devices as $device) { } $rrd_file = get_port_rrdfile_path ($device['hostname'], $int['port_id']); - if (is_file($rrd_file) && $ignore != 1) { + if (rrdtool_check_rrd_exists($rrd_file) && $ignore != 1) { $rrd_filename = $rrd_file; // FIXME: Can this be unified without side-effects? $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $port['label']; diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php index e64e39b314..06a8810397 100644 --- a/html/includes/graphs/multiport/bits.inc.php +++ b/html/includes/graphs/multiport/bits.inc.php @@ -10,7 +10,7 @@ foreach (explode(',', $vars['id']) as $ifid) { $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_filenames[$i] = $rrd_file; $i++; } diff --git a/html/includes/graphs/multiport/bits_duo.inc.php b/html/includes/graphs/multiport/bits_duo.inc.php index cc9892dde7..4d3b0817c0 100644 --- a/html/includes/graphs/multiport/bits_duo.inc.php +++ b/html/includes/graphs/multiport/bits_duo.inc.php @@ -15,7 +15,7 @@ $i = 1; foreach (explode(',', $_GET['id']) as $ifid) { $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_options .= ' DEF:inoctets'.$i.'='.$rrd_file.':INOCTETS:AVERAGE'; $rrd_options .= ' DEF:outoctets'.$i.'='.$rrd_file.':OUTOCTETS:AVERAGE'; $in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF'; @@ -33,7 +33,7 @@ unset($plus); foreach (explode(',', $_GET['idb']) as $ifid) { $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_options .= ' DEF:inoctetsb'.$i.'='.$rrd_file.':INOCTETS:AVERAGE'; $rrd_options .= ' DEF:outoctetsb'.$i.'='.$rrd_file.':OUTOCTETS:AVERAGE'; $in_thingb .= $seperator.'inoctetsb'.$i.',UN,0,'.'inoctetsb'.$i.',IF'; diff --git a/html/includes/graphs/multiport/bits_separate.inc.php b/html/includes/graphs/multiport/bits_separate.inc.php index 980386286b..12e1c78de4 100644 --- a/html/includes/graphs/multiport/bits_separate.inc.php +++ b/html/includes/graphs/multiport/bits_separate.inc.php @@ -5,7 +5,7 @@ $i = 0; foreach (explode(',', $vars['id']) as $ifid) { $port = dbFetchRow('SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($port['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { $port = ifLabel($port); $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $port['hostname'].' '.$port['ifDescr']; diff --git a/html/includes/graphs/multiport/bits_trio.inc.php b/html/includes/graphs/multiport/bits_trio.inc.php index 563ae1b9b0..8483ed1c87 100644 --- a/html/includes/graphs/multiport/bits_trio.inc.php +++ b/html/includes/graphs/multiport/bits_trio.inc.php @@ -16,7 +16,7 @@ $i = 1; foreach (explode(',', $_GET['id']) as $ifid) { $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { if (strstr($inverse, 'a')) { $in = 'OUT'; $out = 'IN'; @@ -43,7 +43,7 @@ unset($plus); foreach (explode(',', $_GET['idb']) as $ifid) { $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { if (strstr($inverse, 'b')) { $in = 'OUT'; $out = 'IN'; @@ -70,7 +70,7 @@ unset($plus); foreach (explode(',', $_GET['idc']) as $ifid) { $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { if (strstr($inverse, 'c')) { $in = 'OUT'; $out = 'IN'; diff --git a/html/includes/graphs/port/etherlike.inc.php b/html/includes/graphs/port/etherlike.inc.php index 86475f73f0..8c6643b189 100644 --- a/html/includes/graphs/port/etherlike.inc.php +++ b/html/includes/graphs/port/etherlike.inc.php @@ -20,7 +20,7 @@ $oids = array( $i = 0; $rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'dot3'); -if (is_file($rrd_filename)) { +if (rrdtool_check_rrd_exists($rrd_filename)) { foreach ($oids as $oid) { $oid = str_replace('dot3Stats', '', $oid); $oid_ds = truncate($oid, 19, ''); diff --git a/html/includes/graphs/port/mac_acc_total.inc.php b/html/includes/graphs/port/mac_acc_total.inc.php index e5ba5721d8..721955f3ab 100644 --- a/html/includes/graphs/port/mac_acc_total.inc.php +++ b/html/includes/graphs/port/mac_acc_total.inc.php @@ -65,7 +65,7 @@ $rrd_options .= " COMMENT:' In\: Current foreach ($accs as $acc) { $this_rrd = rrd_name($acc['hostname'], array('cip', $acc['ifIndex'], $acc['mac'])); - if (is_file($this_rrd)) { + if (rrdtool_check_rrd_exists($this_rrd)) { $mac = formatmac($acc['mac']); $name = $mac; $addy = dbFetchRow('SELECT * FROM ipv4_mac where mac_address = ? AND port_id = ?', array($acc['mac'], $acc['port_id'])); diff --git a/html/includes/graphs/port/nupkts.inc.php b/html/includes/graphs/port/nupkts.inc.php index a4c4296b10..dbbfebed8a 100644 --- a/html/includes/graphs/port/nupkts.inc.php +++ b/html/includes/graphs/port/nupkts.inc.php @@ -38,7 +38,7 @@ if (1) { include 'includes/graphs/generic_multi_seperated.inc.php'; } -else if (is_file($rrd_file)) { +else if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_filename = $rrd_file; $ds_in = 'INNUCASTPKTS'; diff --git a/html/includes/graphs/port/pagp_bits.inc.php b/html/includes/graphs/port/pagp_bits.inc.php index 7cce013217..979a6d96a8 100644 --- a/html/includes/graphs/port/pagp_bits.inc.php +++ b/html/includes/graphs/port/pagp_bits.inc.php @@ -4,7 +4,7 @@ $i = 0; foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? AND `pagpGroupIfIndex` = ?', array($port['device_id'], $port['ifIndex'])) as $int) { $rrd_file = get_port_rrdfile_path ($hostname, int['port_id']); - if (is_file($rrd_file)) { + if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $int['ifDescr']; $i++; diff --git a/html/pages/device/graphs/ipSytemStats.inc.php b/html/pages/device/graphs/ipSytemStats.inc.php index dc77999a22..f457d2de8d 100644 --- a/html/pages/device/graphs/ipSytemStats.inc.php +++ b/html/pages/device/graphs/ipSytemStats.inc.php @@ -1,6 +1,6 @@ Date: Fri, 8 Jul 2016 22:58:36 -0500 Subject: [PATCH 05/67] Fix sensors rrd name issue Use last instead of first, as last won't flush rrdcached Only stream_select if timeout > 0 Attempt to fix mysql --- .../application/mysql_connections.inc.php | 2 - .../application/mysql_innodb_io.inc.php | 44 +++++++++---------- html/pages/device/ports.inc.php | 5 ++- includes/common.php | 11 +++-- includes/polling/applications/mysql.inc.php | 19 ++++---- includes/polling/functions.inc.php | 2 +- includes/polling/ipmi.inc.php | 2 +- includes/rrdtool.inc.php | 6 ++- 8 files changed, 49 insertions(+), 42 deletions(-) diff --git a/html/includes/graphs/application/mysql_connections.inc.php b/html/includes/graphs/application/mysql_connections.inc.php index 45f577448f..5389690fbb 100644 --- a/html/includes/graphs/application/mysql_connections.inc.php +++ b/html/includes/graphs/application/mysql_connections.inc.php @@ -2,8 +2,6 @@ require 'includes/graphs/common.inc.php'; -require 'includes/graphs/common.inc.php'; - $rrd_filename = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id'])); $array = array( diff --git a/html/includes/graphs/application/mysql_innodb_io.inc.php b/html/includes/graphs/application/mysql_innodb_io.inc.php index cbc4f019ea..92efe35d99 100644 --- a/html/includes/graphs/application/mysql_innodb_io.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io.inc.php @@ -6,31 +6,31 @@ $mysql_rrd = rrd_name($device['hostname'], array('app', 'mysql', $app['app_id']) if (rrdtool_check_rrd_exists($mysql_rrd)) { $rrd_filename = $mysql_rrd; -} -$rrd_options .= ' DEF:a='.$rrd_filename.':IBIRd:AVERAGE '; -$rrd_options .= ' DEF:b='.$rrd_filename.':IBIWr:AVERAGE '; -$rrd_options .= ' DEF:c='.$rrd_filename.':IBILg:AVERAGE '; -$rrd_options .= ' DEF:d='.$rrd_filename.':IBIFSc:AVERAGE '; + $rrd_options .= ' DEF:a=' . $rrd_filename . ':IBIRd:AVERAGE '; + $rrd_options .= ' DEF:b=' . $rrd_filename . ':IBIWr:AVERAGE '; + $rrd_options .= ' DEF:c=' . $rrd_filename . ':IBILg:AVERAGE '; + $rrd_options .= ' DEF:d=' . $rrd_filename . ':IBIFSc:AVERAGE '; -$rrd_options .= 'COMMENT:" Current Average Maximum\n" '; + $rrd_options .= 'COMMENT:" Current Average Maximum\n" '; -$rrd_options .= 'LINE1:a#22FF22:"File Reads " '; -$rrd_options .= 'GPRINT:a:LAST:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:a:AVERAGE:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:a:MAX:"%6.2lf %s\\n" '; + $rrd_options .= 'LINE1:a#22FF22:"File Reads " '; + $rrd_options .= 'GPRINT:a:LAST:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:a:AVERAGE:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:a:MAX:"%6.2lf %s\\n" '; -$rrd_options .= 'LINE1:b#0022FF:"File Writes " '; -$rrd_options .= 'GPRINT:b:LAST:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:b:AVERAGE:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:b:MAX:"%6.2lf %s\\n" '; + $rrd_options .= 'LINE1:b#0022FF:"File Writes " '; + $rrd_options .= 'GPRINT:b:LAST:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:b:AVERAGE:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:b:MAX:"%6.2lf %s\\n" '; -$rrd_options .= 'LINE1:c#FF0000:"Log Writes " '; -$rrd_options .= 'GPRINT:c:LAST:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:c:AVERAGE:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:c:MAX:"%6.2lf %s\\n" '; + $rrd_options .= 'LINE1:c#FF0000:"Log Writes " '; + $rrd_options .= 'GPRINT:c:LAST:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:c:AVERAGE:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:c:MAX:"%6.2lf %s\\n" '; -$rrd_options .= 'LINE1:d#00AAAA:"File syncs " '; -$rrd_options .= 'GPRINT:d:LAST:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:d:AVERAGE:"%6.2lf %s" '; -$rrd_options .= 'GPRINT:d:MAX:"%6.2lf %s\\n" '; + $rrd_options .= 'LINE1:d#00AAAA:"File syncs " '; + $rrd_options .= 'GPRINT:d:LAST:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:d:AVERAGE:"%6.2lf %s" '; + $rrd_options .= 'GPRINT:d:MAX:"%6.2lf %s\\n" '; +} \ No newline at end of file diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index c038120292..cbc334e999 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -57,9 +57,12 @@ $graph_types = array( 'upkts' => 'Unicast Packets', 'nupkts' => 'Non-Unicast Packets', 'errors' => 'Errors', - 'etherlike' => 'Etherlike', ); +if ($config['enable_ports_etherlike']) { + $graph_types['etherlike'] = 'Etherlike'; +} + foreach ($graph_types as $type => $descr) { echo "$type_sep"; if ($vars['graph'] == $type && $vars['view'] == 'graphs') { diff --git a/includes/common.php b/includes/common.php index 6aa19c5735..a8075ebad5 100644 --- a/includes/common.php +++ b/includes/common.php @@ -129,14 +129,19 @@ function sgn($int) { } } -function get_sensor_rrd($device, $sensor) { +function get_sensor_rrd($device, $sensor) +{ + return rrd_name($device['hostname'], get_sensor_rrd_name($device, $sensor)); +} + +function get_sensor_rrd_name($device, $sensor) { global $config; # For IPMI, sensors tend to change order, and there is no index, so we prefer to use the description as key here. if ($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi") { - return "sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_descr']; + return array('sensor', $sensor['sensor_class'], $sensor['sensor_type'], $sensor['sensor_descr']); } else { - return "sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_index']; + return array('sensor', $sensor['sensor_class'], $sensor['sensor_type'], $sensor['sensor_index']); } } diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index 9402cd3de7..1d15efa560 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -15,15 +15,6 @@ else { echo ' mysql'; -$data = explode("\n", $mysql); - -$map = array(); -foreach ($data as $str) { - list($key, $value) = explode(':', $str); - $map[$key] = (float) trim($value); - // $nstring .= (float)trim($elements[1]).":"; -} - // General Stats $mapping = array( 'IDBLBSe' => 'cr', @@ -108,7 +99,15 @@ $mapping = array( 'CUMi' => 'c9', ); -unset($fields); +$data = explode("\n", $mysql); + +$map = array(); +foreach ($data as $str) { + list($key, $value) = explode(':', $str); + $map[$key] = (float) trim($value); +} + +$fields = array(); foreach ($mapping as $k => $v) { $fields[$k] = isset($map[$v]) ? $map[$v] : (-1); } diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index aa1bc616db..9c01b94b5a 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -107,7 +107,7 @@ function poll_sensor($device, $class, $unit) { $sensor_value = ($sensor_value * $sensor['sensor_multiplier']); } - $rrd_name = get_sensor_rrd($device, $sensor); + $rrd_name = get_sensor_rrd_name($device, $sensor); $rrd_def = 'DS:sensor:GAUGE:600:-20000:20000'; echo "$sensor_value $unit\n"; diff --git a/includes/polling/ipmi.inc.php b/includes/polling/ipmi.inc.php index 4d7c9f4734..d232d82381 100644 --- a/includes/polling/ipmi.inc.php +++ b/includes/polling/ipmi.inc.php @@ -29,7 +29,7 @@ if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) { echo $sensor." $unit\n"; - $rrd_name = get_sensor_rrd($device, $ipmisensors); + $rrd_name = get_sensor_rrd_name($device, $ipmisensors); $rrd_def = 'DS:sensor:GAUGE:600:-20000:20000'; $fields = array( diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index fc5f651d34..38ee7a3af6 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -186,7 +186,9 @@ function rrdtool($command, $filename, $options, $timeout=0) fwrite($rrd_pipes[0], $cmd."\n"); } - stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + if($timeout > 0) { + stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + } $output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2])); if ($debug) { @@ -226,7 +228,7 @@ function rrdtool_check_rrd_exists($filename) { global $config; if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { - $chk = rrdtool('first', $filename, '', 5); // wait up to 5 seconds + $chk = rrdtool('last', $filename, '', 5); // wait up to 5 seconds return substr(rtrim($chk[0]), -25) !== 'No such file or directory'; } else { return is_file($filename); From dd9e19d9edf96befee1559f89ca09db9f2fd7fda Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 15 Jul 2016 12:21:09 -0500 Subject: [PATCH 06/67] Fix slow poller debug (waiting for output) More robust rrdtool_check_rrd_exists() check Line return after outputting the rrd command for easier to read debug output Updated some phpdoc comments in rrdtool.inc.php --- includes/datastore.inc.php | 5 +- includes/rrdtool.inc.php | 94 ++++++++++++++++++++++---------------- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/includes/datastore.inc.php b/includes/datastore.inc.php index a214b3f39a..d6ee62fbcb 100644 --- a/includes/datastore.inc.php +++ b/includes/datastore.inc.php @@ -42,8 +42,9 @@ function rrd_array_filter($arr) * Datastore-independent function which should be used for all polled metrics. * * RRD Tags: - * rrd_name array|string: the rrd filename - * rrd_oldname array|string: old rrd filename to rename + * 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 diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 38ee7a3af6..8f4aab73c6 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -14,14 +14,11 @@ /** * Opens up a pipe to RRDTool using handles provided * + * @param $rrd_process + * @param $rrd_pipes + * @global $config * @return boolean - * @global config - * @global debug - * @param &rrd_process - * @param &rrd_pipes */ - - function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) { global $config; @@ -61,9 +58,9 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) /** * Closes the pipe to RRDTool * + * @param resource $rrd_process + * @param array $rrd_pipes * @return integer - * @param resource rrd_process - * @param array rrd_pipes */ @@ -89,9 +86,9 @@ function rrdtool_pipe_close($rrd_process, &$rrd_pipes) * Generates a graph file at $graph_file using $options * Opens its own rrdtool pipe. * + * @param string $graph_file + * @param string $options * @return integer - * @param string graph_file - * @param string options */ @@ -152,10 +149,10 @@ function rrdtool_graph($graph_file, $options) /** * Generates and pipes a command to rrdtool * - * @param $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached - * @param $filename The full patth to the rrd file - * @param $options rrdtool command options - * @param int $timeout seconds give up waiting for output, default 0 usually results in empty output + * @param string $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached + * @param string $filename The full patth to the rrd file + * @param string $options rrdtool command options + * @param integer $timeout seconds give up waiting for output, default 0 usually results in empty output * @return array the output of stdout and stderr in an array * @global config * @global debug @@ -180,21 +177,23 @@ function rrdtool($command, $filename, $options, $timeout=0) $cmd = "$command $filename $options"; } - if ($config['norrd']) { + // do not write rrd files, but allow read-only commands + if ($config['norrd'] && !in_array($command, array('graph', 'graphv', 'dump', 'fetch', 'first', 'last', 'lastupdate', 'info', 'xport'))) { print $console_color->convert('[%rRRD Disabled%n]'); + $output = array(null, null); } else { fwrite($rrd_pipes[0], $cmd."\n"); - } - if($timeout > 0) { - stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + if($timeout > 0) { + stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + } + $output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2])); } - $output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2])); if ($debug) { echo $output[0]; echo $output[1]; - print $console_color->convert('RRD[%g'.$cmd.'%n] '); + print $console_color->convert('RRD[%g'.$cmd."%n] \n"); } return $output; @@ -205,8 +204,8 @@ function rrdtool($command, $filename, $options, $timeout=0) * Generates an rrd database at $filename using $options * * @internal - * @param string filename - * @param string options + * @param string $filename + * @param string $options * @return array|bool */ function rrdtool_create($filename, $options) @@ -229,7 +228,7 @@ function rrdtool_check_rrd_exists($filename) global $config; if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { $chk = rrdtool('last', $filename, '', 5); // wait up to 5 seconds - return substr(rtrim($chk[0]), -25) !== 'No such file or directory'; + return substr(str_replace(array("\r", "\n"), '', $chk[0]), -25) !== 'No such file or directory'; } else { return is_file($filename); } @@ -287,20 +286,19 @@ function rrdtool_lastupdate($filename, $options) /** - * Escapes strings for RRDtool, - * + * Escapes strings for RRDtool + * + * @param string $string the string to escape + * @param integer $length if passed, string will be padded and trimmed to exactly this length (after rrdtool unescapes it) * @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){ +function rrdtool_escape($string, $length=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 (is_numeric($length)) { + $extra = substr_count($string, ':', 0, $length); + $result = substr(str_pad($result, $length), 0, ($length + $extra)); if ($extra > 0) { $result = substr($result, 0, (-1 * $extra)); } @@ -326,6 +324,14 @@ function rrd_name($host, $extra, $extension = ".rrd") return implode("/", array($config['rrd_dir'], $host, $filename.$extension)); } // rrd_name +/** + * Modify an rrd file's max value and trim the peaks as defined by rrdtool + * + * @param string $type only 'port' is supported at this time + * @param string $filename the path to the rrd file + * @param integer $max the new max value + * @return bool + */ function rrdtool_tune($type, $filename, $max) { $fields = array(); if ($type === 'port') { @@ -347,10 +353,16 @@ function rrdtool_tune($type, $filename, $max) { /** * rrdtool backend implementation of data_update * - * @param $device - * @param $measurement - * @param $tags - * @param $fields + * 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 device array + * @param string $measurement the name of this measurement (if no rrd_name tag is given, this will be used to name the file) + * @param array $tags tags to pass additional info to rrdtool + * @param array $fields data values to update */ function rrdtool_data_update($device, $measurement, $tags, $fields) { @@ -375,11 +387,13 @@ function rrdtool_data_update($device, $measurement, $tags, $fields) } // rrdtool_data_update -/* +/** + * rename an rrdfile, can only be done on the LibreNMS server hosting the rrd files + * + * @param array $device Device object + * @param string $oldname RRD name array as used with rrd_name() + * @param string $newname RRD name array as used with rrd_name() * @return bool indicating rename success or failure - * @param device Device object - * @param oldname RRD name array as used with rrd_name() - * @param newname RRD name array as used with rrd_name() */ function rrd_file_rename($device, $oldname, $newname) { From 969a08c2293ee89738e2c6deb02c06189e0b8731 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 18 Jul 2016 08:33:29 -0500 Subject: [PATCH 07/67] Fix extra data for TCP stats. --- includes/polling/netstats-tcp.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/polling/netstats-tcp.inc.php b/includes/polling/netstats-tcp.inc.php index 26f446243b..256ce11988 100644 --- a/includes/polling/netstats-tcp.inc.php +++ b/includes/polling/netstats-tcp.inc.php @@ -16,10 +16,6 @@ if ($device['os'] != 'Snom') { 'tcpOutRsts', ); - // $oids['tcp_collect'] = $oids['tcp']; - // $oids['tcp_collect'][] = 'tcpHCInSegs'; - // $oids['tcp_collect'][] = 'tcpHCOutSegs'; - $rrd_def = array(); $snmpstring = ''; foreach ($oids as $oid) { @@ -32,10 +28,14 @@ if ($device['os'] != 'Snom') { $snmpstring .= ' tcpHCOutSegs.0'; $data = snmp_get_multi($device, $snmpstring, '-OQUs', 'TCP-MIB'); - $fields = $data[0]; - unset($snmpstring); + // use HC Segs if we have them. + if (isset($fields['tcpHCInSegs']) && !empty($fields['tcpHCInSegs'])) { + $fields['tcpInSegs'] = $fields['tcpHCInSegs']; + $fields['tcpOutSegs'] = $fields['tcpHCOutSegs']; + unset($fields['tcpHCInSegs'], $fields['tcpHCOutSegs']); + } if (isset($fields['tcpInSegs']) && isset($fields['tcpOutSegs'])) { @@ -45,5 +45,5 @@ if ($device['os'] != 'Snom') { $graphs['netstat_tcp'] = true; } - unset($oids, $data, $data, $oid, $protos); + unset($oids, $data, $fields, $oid, $protos, $snmpstring); }//end if From 7c3ff521d8d4666d1b2dcd2d6e3d68fddc5e57cc Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 18 Jul 2016 09:07:54 -0500 Subject: [PATCH 08/67] Fix missing data fonetstats-snmp --- includes/polling/netstats-snmp.inc.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/polling/netstats-snmp.inc.php b/includes/polling/netstats-snmp.inc.php index 60ce024141..264f512a8b 100644 --- a/includes/polling/netstats-snmp.inc.php +++ b/includes/polling/netstats-snmp.inc.php @@ -38,14 +38,13 @@ if ($device['os'] != 'Snom') { $data = snmpwalk_cache_oid($device, 'snmp', array(), 'SNMPv2-MIB'); - $fields = $data[0]; - unset($fields['snmpEnableAuthenTraps']); - - if (isset($fields['snmpInPkts']) && isset($fields['snmpOutPkts'])) { + if (isset($data[0]['snmpInPkts'])) { $rrd_def = array(); + $fields = array(); foreach ($oids as $oid) { $oid_ds = truncate($oid, 19, ''); $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; + $fields[$oid] = isset($data[0][$oid]) ? $data[0][$oid] : 'U'; } $tags = compact('rrd_def'); @@ -55,5 +54,5 @@ if ($device['os'] != 'Snom') { $graphs['netstat_snmp_pkt'] = true; } - unset($oids, $data, $feilds, $oid, $rrd_def, $tags); + unset($oids, $data, $rrd_def, $fields, $tags); }//end if From 0a8acc7649c36d4fad4fa64bc522b556387f123f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 18 Jul 2016 13:30:39 -0500 Subject: [PATCH 09/67] Check for file missing string anywhere in stdout or stderr --- includes/rrdtool.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 8f4aab73c6..191237c22b 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -228,7 +228,7 @@ function rrdtool_check_rrd_exists($filename) global $config; if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { $chk = rrdtool('last', $filename, '', 5); // wait up to 5 seconds - return substr(str_replace(array("\r", "\n"), '', $chk[0]), -25) !== 'No such file or directory'; + return strpos(implode($chk), "$filename': No such file or directory") === false; } else { return is_file($filename); } From d7a7c5ef009d0337078db9c4af8627fc8fae9768 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 20 Jul 2016 09:09:19 -0500 Subject: [PATCH 10/67] Doc updates --- doc/Extensions/RRDCached.md | 11 ++++++----- doc/Support/Support-New-OS.md | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/Extensions/RRDCached.md b/doc/Extensions/RRDCached.md index 05244981ab..95a680e635 100644 --- a/doc/Extensions/RRDCached.md +++ b/doc/Extensions/RRDCached.md @@ -2,11 +2,12 @@ This document will explain how to setup RRDCached for LibreNMS. -> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. To -enable this set the following config: +> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. +If you have rrdcached 1.5.5 or above, we can also tune over rrdcached. +To enable this set the following config: ```php -$config['rrdtool_version'] = 1.5; +$config['rrdtool_version'] = 1.5.5; ``` ### RRDCached installation CentOS 6 @@ -29,7 +30,7 @@ vi /etc/yum.repos.d/rpmforge.repo vi /etc/sysconfig/rrdcached # Settings for rrdcached -OPTIONS="-w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/" +OPTIONS="-w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -B -R -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/" RRDC_USER=librenms mkdir /var/run/rrdcached @@ -77,7 +78,7 @@ After=network.service [Service] Type=forking PIDFile=/run/rrdcached.pid -ExecStart=/usr/bin/rrdcached -w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/ +ExecStart=/usr/bin/rrdcached -w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -B -R -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/ RRDC_USER=librenms [Install] diff --git a/doc/Support/Support-New-OS.md b/doc/Support/Support-New-OS.md index c7f2b2840e..1fc0339e45 100644 --- a/doc/Support/Support-New-OS.md +++ b/doc/Support/Support-New-OS.md @@ -316,7 +316,7 @@ $sessions = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv if (is_numeric($sessions)) { $rrd_def = array( - 'DS:sessions:GAUGE:600:0:U' + 'DS:sessions:GAUGE:600:0:U', } $fields = array( 'sessions' => $sessions From c43f533b55fd662d794234b686b569f487896078 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 21 Jul 2016 11:27:19 -0500 Subject: [PATCH 11/67] Sometimes the output streams already contain output, so we don't get the output we expect. Clear those output buffers, but only when we care about it. --- includes/rrdtool.inc.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 191237c22b..6acc2b64d5 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -182,12 +182,20 @@ function rrdtool($command, $filename, $options, $timeout=0) print $console_color->convert('[%rRRD Disabled%n]'); $output = array(null, null); } else { - fwrite($rrd_pipes[0], $cmd."\n"); - - if($timeout > 0) { - stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + if ($timeout > 0) { + // if we care about the output, indicated by the fact that we are waiting for it + // remove any previous output before sending the command + stream_get_contents($rrd_pipes[1]); + stream_get_contents($rrd_pipes[2]); } - $output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2])); + + fwrite($rrd_pipes[0], $cmd . "\n"); + + if ($timeout > 0) { + // this causes us to block until we receive output for up to $timeout seconds + stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); + } + $output = array(stream_get_contents($rrd_pipes[1]), stream_get_contents($rrd_pipes[2])); } if ($debug) { From e3772e265391d942e89be7917e742095f2488660 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 25 Jul 2016 16:24:09 -0500 Subject: [PATCH 12/67] Don't use $config['rrdcached_dir'] anymore, always use relative directories when using rrdcached. Wait for output on every command, this prevents input left in the buffer from messing up subsequent commands. It doesn't seem like there is a penalty, but I'd have to do more testing. --- doc/Extensions/Distributed-Poller.md | 4 ---- doc/Support/Configuration.md | 6 ++---- includes/defaults.inc.php | 3 +-- includes/rrdtool.inc.php | 31 +++++++++------------------- 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/doc/Extensions/Distributed-Poller.md b/doc/Extensions/Distributed-Poller.md index c4c7c7f03b..41ff72e91f 100644 --- a/doc/Extensions/Distributed-Poller.md +++ b/doc/Extensions/Distributed-Poller.md @@ -85,7 +85,6 @@ Running Apache and an install of LibreNMS in /opt/librenms ```php $config['distributed_poller'] = true; $config['rrdcached'] = "example.com:42217"; -$config['rrdcached_dir'] = "."; ``` Database Server: @@ -126,7 +125,6 @@ $config['distributed_poller_host'] = "example.com"; $config['distributed_poller_port'] = 11211; $config['distributed_poller'] = true; $config['rrdcached'] = "example.com:42217"; -$config['rrdcached_dir'] = "."; $config['update'] = 0; ``` @@ -153,7 +151,6 @@ $config['distributed_poller_host'] = "example.com"; $config['distributed_poller_port'] = 11211; $config['distributed_poller'] = true; $config['rrdcached'] = "example.com:42217"; -$config['rrdcached_dir'] = "."; $config['update'] = 0; ``` @@ -178,7 +175,6 @@ $config['distributed_poller_host'] = "example.com"; $config['distributed_poller_port'] = 11211; $config['distributed_poller'] = true; $config['rrdcached'] = "example.com:42217"; -$config['rrdcached_dir'] = "."; $config['update'] = 0; ``` diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index a2699620b4..465c9fa974 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -104,11 +104,9 @@ Settings to enable memcached - currently it's not recommended to run memcached u ```php $config['rrdcached'] = "unix:/var/run/rrdcached.sock"; // or a tcp connection 127.0.0.1:42217 -$config['rrdcached_dir'] = FALSE; ``` -To enable rrdcached you need to set at least the `rrdcached` option. If `rrdcached` is a tcp socket then you need to configure `rrdcached_dir` as well. -This should be set based on your base directory for running rrdcached. For instance if -b for rrdcached is set to /var/lib/rrd but you are expecting -LibreNMS to store them in /var/lib/rrd/librenms then you would need to set `rrdcached_dir` to librenms. +To enable rrdcached you need to set at least the `rrdcached` option. Make sure rrdcached is started with the `-b` option set to the correct directoy, +as configured in `$config['rrd_dir`]`. #### WebUI Settings diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a8121ded47..501891abc6 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -91,8 +91,7 @@ $config['rrd_rra'] .= ' RRA:LAST:0.5:1:1440 '; // RRDCacheD - Make sure it can write to your RRD dir! // $config['rrdcached'] = "unix:/var/run/rrdcached.sock"; -$config['rrdcached_dir'] = false; -// Set this if you are using tcp connections to rrdcached + // Web Interface Settings if (isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT'])) { if (strpos($_SERVER['SERVER_NAME'], ':')) { diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 6acc2b64d5..d0a973c5b2 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -104,10 +104,7 @@ function rrdtool_graph($graph_file, $options) // 1 => readable handle connected to child stdout // Any error output will be appended to /tmp/error-output.txt if ($config['rrdcached']) { - if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { - $options = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $options); - $options = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $options); - } + $options = str_replace(array($config['rrd_dir'].'/', $config['rrd_dir']), '', $options); fwrite($rrd_pipes[0], 'graph --daemon '.$config['rrdcached']." $graph_file $options"); } @@ -158,7 +155,7 @@ function rrdtool_graph($graph_file, $options) * @global debug * @global rrd_pipes */ -function rrdtool($command, $filename, $options, $timeout=0) +function rrdtool($command, $filename, $options, $timeout=1) { global $config, $debug, $rrd_pipes, $console_color; @@ -167,11 +164,11 @@ function rrdtool($command, $filename, $options, $timeout=0) (version_compare($config['rrdtool_version'], '1.5', '>=') && $command != "tune") || // 1.5+ supports all except tune ($command != "create" && $command != "tune")) // older supports all except create and tune ) { - if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { - $filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename); - $filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename); - } + // only relative paths if using rrdcached + $filename = str_replace(array($config['rrd_dir'].'/', $config['rrd_dir']), '', $filename); + + // using rrdcached, append --daemon $cmd = "$command $filename $options --daemon ".$config['rrdcached']; } else { $cmd = "$command $filename $options"; @@ -182,26 +179,18 @@ function rrdtool($command, $filename, $options, $timeout=0) print $console_color->convert('[%rRRD Disabled%n]'); $output = array(null, null); } else { - if ($timeout > 0) { - // if we care about the output, indicated by the fact that we are waiting for it - // remove any previous output before sending the command - stream_get_contents($rrd_pipes[1]); - stream_get_contents($rrd_pipes[2]); - } fwrite($rrd_pipes[0], $cmd . "\n"); - if ($timeout > 0) { - // this causes us to block until we receive output for up to $timeout seconds - stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); - } + // this causes us to block until we receive output for up to $timeout seconds + stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout); $output = array(stream_get_contents($rrd_pipes[1]), stream_get_contents($rrd_pipes[2])); } if ($debug) { - echo $output[0]; - echo $output[1]; print $console_color->convert('RRD[%g'.$cmd."%n] \n"); + echo 'rrdtool output: '; + var_dump($output); } return $output; From 8d950a4ed7d11993154e1c70fbb8e9dd6de4bb48 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 25 Jul 2016 20:12:40 -0500 Subject: [PATCH 13/67] More compact debug output. RRDC_USER is not used in the systemd unit file (this isn't how you set an environment variable), so remove it. --- doc/Extensions/RRDCached.md | 1 - includes/rrdtool.inc.php | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/Extensions/RRDCached.md b/doc/Extensions/RRDCached.md index 95a680e635..499a27aee2 100644 --- a/doc/Extensions/RRDCached.md +++ b/doc/Extensions/RRDCached.md @@ -79,7 +79,6 @@ After=network.service Type=forking PIDFile=/run/rrdcached.pid ExecStart=/usr/bin/rrdcached -w 1800 -z 1800 -f 3600 -s librenms -U librenms -G librenms -B -R -j /var/tmp -l unix:/var/run/rrdcached/rrdcached.sock -t 4 -F -b /opt/librenms/rrd/ -RRDC_USER=librenms [Install] WantedBy=default.target diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index d0a973c5b2..cdf1a8be5e 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -189,8 +189,9 @@ function rrdtool($command, $filename, $options, $timeout=1) if ($debug) { print $console_color->convert('RRD[%g'.$cmd."%n] \n"); - echo 'rrdtool output: '; - var_dump($output); + echo 'RRDtool Output: '; + echo $output[0]; + echo $output[1]; } return $output; From 76d5311647aaeaadaa590772415abe6f0fa1f62c Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 25 Jul 2016 20:42:37 -0500 Subject: [PATCH 14/67] Update nfs-stats.inc.php to use data_update filter tags in ports.inc.php, and update the phpdoc for rrd_array_filter() --- includes/datastore.inc.php | 7 +- .../polling/applications/nfs-stats.inc.php | 92 +++++++++---------- includes/polling/ports.inc.php | 4 +- 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/includes/datastore.inc.php b/includes/datastore.inc.php index d6ee62fbcb..756deb7b4f 100644 --- a/includes/datastore.inc.php +++ b/includes/datastore.inc.php @@ -22,8 +22,11 @@ require_once $config['install_dir'] . "/includes/rrdtool.inc.php"; require_once $config['install_dir'] . "/includes/influxdb.inc.php"; -/* - * @return Copy of $arr with all keys beginning with 'rrd_' removed. +/** + * Filter all elements with keys that start with 'rrd_' + * + * @param array $arr input array + * @return array Copy of $arr with all keys beginning with 'rrd_' removed. */ function rrd_array_filter($arr) { diff --git a/includes/polling/applications/nfs-stats.inc.php b/includes/polling/applications/nfs-stats.inc.php index 97a3d9881b..002275c3a1 100644 --- a/includes/polling/applications/nfs-stats.inc.php +++ b/includes/polling/applications/nfs-stats.inc.php @@ -1,55 +1,49 @@ $total, - 'null' => $null, - 'getattr' => $getattr, - 'setattr' => $setattr, - 'lookup' => $lookup, - 'access' => $access, - 'read' => $read, - 'write' => $write, - 'create' => $create, - 'mkdir' => $mkdir, - 'remove' => $remove, - 'rmdir' => $rmdir, - 'rename' => $rename, - 'readdirplus' => $readdirplus, - 'fsstat' => $fsstat, -); + 'total' => $data[0], + 'null' => $data[1], + 'getattr' => $data[2], + 'setattr' => $data[3], + 'lookup' => $data[4], + 'access' => $data[5], + 'read' => $data[6], + 'write' => $data[7], + 'create' => $data[8], + 'mkdir' => $data[9], + 'remove' => $data[10], + 'rmdir' => $data[11], + 'rename' => $data[12], + 'readdirplus' => $data[13], + 'fsstat' => $data[14], +); -rrdtool_update($rrd_filename, $fields); -$tags = array('name' => 'nfsstats', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index c54fc49d6d..cd140496d3 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -476,7 +476,7 @@ foreach ($ports as $port) { $port_tune = get_dev_attrib($device, 'ifName_tune:'.$port['ifName']); $device_tune = get_dev_attrib($device,'override_rrdtool_tune'); if ($port_tune == "true" || - ($device_tune == "true" && $port_tune != 'false') || + ($device_tune == "true" && $port_tune != 'false') || ($config['rrdtool_tune'] == "true" && $port_tune != 'false' && $device_tune != 'false')) { if ($oid == 'ifSpeed') { $tune_port = true; @@ -646,7 +646,7 @@ foreach ($ports as $port) { $fields['ifInOctets_rate'] = $port['ifInOctets_rate']; $fields['ifOutOctets_rate'] = $port['ifOutOctets_rate']; - influx_update($device,'ports',$tags,$fields); + influx_update($device, 'ports', rrd_array_filter($tags), $fields); // End Update IF-MIB // Update PAgP From 2f218e315fcec8893a2fcebc3a18781daee7bb93 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 26 Jul 2016 09:49:59 -0500 Subject: [PATCH 15/67] Correct missing/extra data issues netstats-icmp missing data netstats-tcp extra data --- includes/polling/netstats-icmp.inc.php | 6 ++++-- includes/polling/netstats-tcp.inc.php | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/polling/netstats-icmp.inc.php b/includes/polling/netstats-icmp.inc.php index 5e77ecc927..d18d4e53fe 100644 --- a/includes/polling/netstats-icmp.inc.php +++ b/includes/polling/netstats-icmp.inc.php @@ -34,13 +34,15 @@ if ($device['os'] != 'Snom') { ); $data = snmpwalk_cache_oid($device, 'icmp', array(), 'IP-MIB'); - $fields = $data[0]; + $data = $data[0]; - if (isset($fields['icmpInMsgs']) && isset($fields['icmpOutMsgs'])) { + if (isset($data['icmpInMsgs']) && isset($data['icmpOutMsgs'])) { $rrd_def = array(); + $fields = array(); foreach ($oids as $oid) { $oid_ds = truncate($oid, 19, ''); $rrd_def[] = "DS:$oid_ds:COUNTER:600:U:100000000000"; + $fields[$oid] = isset($data[$oid]) ? $data[$oid] : 'U'; } $tags = compact('rrd_def'); diff --git a/includes/polling/netstats-tcp.inc.php b/includes/polling/netstats-tcp.inc.php index 256ce11988..383e15cdcb 100644 --- a/includes/polling/netstats-tcp.inc.php +++ b/includes/polling/netstats-tcp.inc.php @@ -31,9 +31,11 @@ if ($device['os'] != 'Snom') { $fields = $data[0]; // use HC Segs if we have them. - if (isset($fields['tcpHCInSegs']) && !empty($fields['tcpHCInSegs'])) { - $fields['tcpInSegs'] = $fields['tcpHCInSegs']; - $fields['tcpOutSegs'] = $fields['tcpHCOutSegs']; + if (isset($fields['tcpHCInSegs'])) { + if (!empty($fields['tcpHCInSegs'])) { + $fields['tcpInSegs'] = $fields['tcpHCInSegs']; + $fields['tcpOutSegs'] = $fields['tcpHCOutSegs']; + } unset($fields['tcpHCInSegs'], $fields['tcpHCOutSegs']); } From 2d60ca9197fed70ff1e5326082df30ae6bbfc66b Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 1 Aug 2016 15:01:52 +0100 Subject: [PATCH 16/67] Updated multi_oid cache function --- includes/snmp.inc.php | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 13bf3de5d1..66b3f133ba 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -385,26 +385,10 @@ function snmpwalk_cache_multi_oid($device, $oid, $array, $mib=null, $mibdir=null $r_oid = trim($r_oid); $value = trim($value); $oid_parts = explode('.', $r_oid); - $r_oid = $oid_parts['0']; - $index = $oid_parts['1']; - if (isset($oid_parts['2'])) { - $index .= '.'.$oid_parts['2']; - } - - if (isset($oid_parts['3'])) { - $index .= '.'.$oid_parts['3']; - } - - if (isset($oid_parts['4'])) { - $index .= '.'.$oid_parts['4']; - } - - if (isset($oid_parts['5'])) { - $index .= '.'.$oid_parts['5']; - } - - if (isset($oid_parts['6'])) { - $index .= '.'.$oid_parts['6']; + $r_oid = array_shift($oid_parts); + $index = array_shift($oid_parts); + foreach ($oid_parts as $tmp_oid) { + $index .= '.'.$tmp_oid; } if (!strstr($value, 'at this OID') && isset($r_oid) && isset($index)) { From d4670d9a7b8f4b14efef283e56dcb2f63f4b0864 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 1 Aug 2016 11:51:06 -0500 Subject: [PATCH 17/67] update nfs-v3, minor cleanup nfs-stats to match. --- .../polling/applications/nfs-stats.inc.php | 10 +- .../polling/applications/nfs-v3-stats.inc.php | 245 +++++++++--------- 2 files changed, 126 insertions(+), 129 deletions(-) diff --git a/includes/polling/applications/nfs-stats.inc.php b/includes/polling/applications/nfs-stats.inc.php index 002275c3a1..95beeddd7c 100644 --- a/includes/polling/applications/nfs-stats.inc.php +++ b/includes/polling/applications/nfs-stats.inc.php @@ -1,12 +1,12 @@ $rc_hits, - 'rc_misses' => $rc_misses, - 'rc_nocache' => $rc_nocache, - 'fh_lookup' => $fh_lookup, - 'fh_anon' => $fh_anon, - 'fh_ncachedir' => $fh_ncachedir, - 'fh_ncachenondir' => $fh_ncachenondir, - 'fh_stale' => $fh_stale, - 'io_read' => $io_read, - 'io_write' => $io_write, - 'ra_size' => $ra_size, - 'ra_range01' => $ra_range01, - 'ra_range02' => $ra_range02, - 'ra_range03' => $ra_range03, - 'ra_range04' => $ra_range04, - 'ra_range05' => $ra_range05, - 'ra_range06' => $ra_range06, - 'ra_range07' => $ra_range07, - 'ra_range08' => $ra_range08, - 'ra_range09' => $ra_range09, - 'ra_range10' => $ra_range10, - 'ra_notfound'=> $ra_notfound, - 'net_all' => $net_all, - 'net_udp' => $net_udp, - 'net_tcp' => $net_tcp, - 'net_tcpconn' => $net_tcpconn, - 'rpc_calls' => $rpc_calls, - 'rpc_badcalls' => $rpc_badcalls, - 'rpc_badfmt' => $rpc_badfmt, - 'rpc_badauth' => $rpc_badauth, - 'rpc_badclnt' => $rpc_badclnt, - 'proc3_null' => $proc3_null, - 'proc3_getattr' => $proc3_getattr, - 'proc3_setattr' => $proc3_setattr, - 'proc3_lookup' => $proc3_lookup, - 'proc3_access' => $proc3_access, - 'proc3_readlink' => $proc3_readlink, - 'proc3_read' => $proc3_read, - 'proc3_write' => $proc3_write, - 'proc3_create' => $proc3_create, - 'proc3_mkdir' => $proc3_mkdir, - 'proc3_symlink' => $proc3_symlink, - 'proc3_mknod' => $proc3_mknod, - 'proc3_remove' => $proc3_remove, - 'proc3_rmdir' => $proc3_rmdir, - 'proc3_rename' => $proc3_rename, - 'proc3_link' => $proc3_link, - 'proc3_readdir' => $proc3_readdir, - 'proc3_readdirplus' => $proc3_readdirplus, - 'proc3_fsstat' => $proc3_fsstat, - 'proc3_fsinfo' => $proc3_fsinfo, - 'proc3_pathconf' => $proc3_pathconf, - 'proc3_commit' => $proc3_commit, -); + 'rc_hits' => $data[1], + 'rc_misses' => $data[2], + 'rc_nocache' => $data[3], + 'fh_lookup' => $data[4], + 'fh_anon' => $data[5], + 'fh_ncachedir' => $data[6], + 'fh_ncachenondir' => $data[7], + 'fh_stale' => $data[8], + 'io_read' => $data[9], + 'io_write' => $data[10], + 'ra_size' => $data[0], + 'ra_range01' => $data[11], + 'ra_range02' => $data[12], + 'ra_range03' => $data[13], + 'ra_range04' => $data[14], + 'ra_range05' => $data[15], + 'ra_range06' => $data[16], + 'ra_range07' => $data[17], + 'ra_range08' => $data[18], + 'ra_range09' => $data[19], + 'ra_range10' => $data[20], + 'ra_notfound' => $data[21], + 'net_all' => $data[22], + 'net_udp' => $data[23], + 'net_tcp' => $data[24], + 'net_tcpconn' => $data[25], + 'rpc_calls' => $data[26], + 'rpc_badcalls' => $data[27], + 'rpc_badfmt' => $data[28], + 'rpc_badauth' => $data[29], + 'rpc_badclnt' => $data[30], + 'proc3_null' => $data[31], + 'proc3_getattr' => $data[32], + 'proc3_setattr' => $data[33], + 'proc3_lookup' => $data[34], + 'proc3_access' => $data[35], + 'proc3_readlink' => $data[36], + 'proc3_read' => $data[37], + 'proc3_write' => $data[38], + 'proc3_create' => $data[39], + 'proc3_mkdir' => $data[40], + 'proc3_symlink' => $data[41], + 'proc3_mknod' => $data[42], + 'proc3_remove' => $data[43], + 'proc3_rmdir' => $data[44], + 'proc3_rename' => $data[45], + 'proc3_link' => $data[46], + 'proc3_readdir' => $data[47], + 'proc3_readdirplus' => $data[48], + 'proc3_fsstat' => $data[49], + 'proc3_fsinfo' => $data[50], + 'proc3_pathconf' => $data[51], + 'proc3_commit' => $data[52], +); -rrdtool_update($rrd_filename, $fields); -$tags = array('name' => 'nfs-v3-stats', 'app_id' => $app['app_id']); -influx_update($device,'app',$tags,$fields); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); + +unset($nfsstats, $rrd_name, $rrd_def, $data, $fields, $tags); \ No newline at end of file From e54881df14229ac458fbce5bfa10904ce7c07696 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Aug 2016 22:28:57 +0100 Subject: [PATCH 18/67] Improved junos BGP code + WebUI --- html/pages/device/routing/bgp.inc.php | 4 +- includes/discovery/bgp-peers.inc.php | 82 ++++++++------- includes/polling/bgp-peers.inc.php | 139 ++++++++++++-------------- includes/snmp.inc.php | 3 + 4 files changed, 114 insertions(+), 114 deletions(-) diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index e994313433..c3b10bc124 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -41,6 +41,7 @@ echo ' | Prefixes: '; if ($vars['view'] == 'prefixes_ipv4unicast') { echo ""; + $sql = " AND `bgpLocalAddr` NOT LIKE '%:%'"; } echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); @@ -63,6 +64,7 @@ echo ' | '; if ($vars['view'] == 'prefixes_ipv6unicast') { echo ""; + $sql = " AND `bgpLocalAddr` LIKE '%:%'"; } echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); @@ -98,7 +100,7 @@ echo 'Peer address $peer_ip, + 'as' => $peer_as, + 'ver' => $ver, + ); + } } - - if ($peer && $peer_ip != '0.0.0.0') { - d_echo("Found peer $peer_ip (AS$peer_as)\n"); - - $peerlist[] = array( - 'ip' => $peer_ip, - 'as' => $peer_as, - 'ver' => $ver, - ); - } - } - - if ($device['os'] == 'junos') { + } elseif ($device['os'] == 'junos') { // Juniper BGP4-V2 MIB // FIXME: needs a big cleanup! also see below. // FIXME: is .0.ipv6 the only possible value here? - $result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs.0.ipv6', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); - $peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.', '', $result)); + $result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.', '', $result)); foreach (explode("\n", $peers) as $peer) { list($peer_ip_snmp, $peer_as) = explode(' ', $peer); - // Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs. - $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16))))); + $octets = count(explode(".", $peer_ip_snmp)); + if ($octets > 11) { + // ipv6 + $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16))))); + } else { + // ipv4 + $peer_ip = implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 4))); + } if ($peer) { d_echo("Found peer $peer_ip (AS$peer_as)\n"); diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 34608f1ecc..22b712c91e 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -6,26 +6,29 @@ if ($config['enable_bgp']) { if (!empty($peers)) { - if ($device['os'] != 'junos') { + if ($device['os'] == 'junos') { + $peer_data_check = snmp_walk($device, 'jnxBgpM2PeerIndex', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_check = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.', '', $peer_data_check)); + } else { $peer_data_check = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', array(), 'CISCO-BGP4-MIB', $config['mibdir']); } foreach ($peers as $peer) { //add context if exist $device['context_name']= $peer['context_name']; + if (strstr(":", $peer['bgpPeerIdentifier'])) { + $peer_ip = ipv62snmp($peer['bgpPeerIdentifier']); + } else { + $peer_ip = $peer['bgpPeerIdentifier']; + } // Poll BGP Peer - $peer2 = false; echo 'Checking BGP peer '.$peer['bgpPeerIdentifier'].' '; if (!empty($peer['bgpPeerIdentifier'])) { - if (!strstr($peer['bgpPeerIdentifier'], ':') || $device['os'] != 'junos') { + if ($device['os'] != 'junos') { // v4 BGP4 MIB if (count($peer_data_check) > 0) { - $peer2 = true; - } - - if ($peer2 === true) { if (strstr($peer['bgpPeerIdentifier'], ':')) { $bgp_peer_ident = ipv62snmp($peer['bgpPeerIdentifier']); } @@ -82,58 +85,69 @@ if ($config['enable_bgp']) { list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data); $bgpLocalAddr = str_replace('"', '', str_replace(' ', '', $bgpLocalAddr)); } - else if ($device['os'] == 'junos') { - // v6 for JunOS via Juniper MIB - $peer_ip = ipv62snmp($peer['bgpPeerIdentifier']); + elseif ($device['os'] == 'junos') { - if (!isset($junos_v6)) { + if (!isset($junos)) { echo "\nCaching Oids..."; // FIXME - needs moved to function //$peer_cmd = $config['snmpwalk'].' -M '.$config['mibdir'].'/junos -m BGP4-V2-MIB-JUNIPER -OUnq -'.$device['snmpver'].' '.snmp_gen_auth($device).' '.$device['hostname'].':'.$device['port']; - $peer_cmd = $config['snmpwalk'].' -M '.$config['mibdir'].'/junos -m BGP4-V2-MIB-JUNIPER -OUnq -'.$device['snmpver'].' '.snmp_gen_auth($device).' '.$device['hostname'].':'.$device['port']; - $peer_cmd .= ' jnxBgpM2PeerStatus.0.ipv6'; - foreach (explode("\n", trim(`$peer_cmd`)) as $oid) { - list($peer_oid) = explode(' ', $oid); - $peer_id = explode('.', $peer_oid); - $junos_v6[implode('.', array_slice($peer_id, 35))] = implode('.', array_slice($peer_id, 18)); + foreach (explode("\n", $peer_data_check) as $tmp) { + list($peer_ip_snmp, $peer_index) = explode(' ', $tmp); + $octets = count(explode(".", $peer_ip_snmp)); + if ($octets > 11) { + // ipv6 + $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16))))); + } else { + // ipv4 + $peer_ip = implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 4))); + } + $junos[$peer_ip]['oid'] = $peer_ip_snmp; + $junos[$peer_ip]['index'] = $peer_index; } } - $peer_cmd = $config['snmpget'].' -M '.$config['mibdir'].'/junos -m BGP4-V2-MIB-JUNIPER -OUvq '.snmp_gen_auth($device); - $peer_cmd .= ' -M"'.$config['install_dir'].'/mibs/junos"'; - $peer_cmd .= ' '.$device['hostname'].':'.$device['port']; - $peer_cmd .= ' jnxBgpM2PeerState.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerStatus.0.ipv6.'.$junos_v6[$peer_ip]; - // Should be jnxBgpM2CfgPeerAdminStatus but doesn't seem to be implemented? - $peer_cmd .= ' jnxBgpM2PeerInUpdates.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerOutUpdates.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerInTotalMessages.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerOutTotalMessages.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerFsmEstablishedTime.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= ' jnxBgpM2PeerLocalAddr.0.ipv6.'.$junos_v6[$peer_ip]; - $peer_cmd .= '|grep -v "No Such Instance"'; - d_echo("\n$peer_cmd\n"); - $peer_data = trim(`$peer_cmd`); - list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data); + $peer_data_tmp = array_shift(snmp_get_multi( + $device, + array( + 'jnxBgpM2PeerState.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerStatus.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerInUpdates.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerOutUpdates.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerInTotalMessages.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerOutTotalMessages.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerFsmEstablishedTime.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerInUpdatesElapsedTime.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerLocalAddr.'.$junos[$peer_ip]['oid'], + 'jnxBgpM2PeerRemoteAddrType.'.$junos[$peer_ip]['oid'], + ), + '-OQnUs', + 'BGP4-V2-MIB-JUNIPER', + $config['mibdir'].'/junos' + )); + d_echo($peer_data_tmp); + $bgpPeerState = $peer_data_tmp['jnxBgpM2PeerState']; + $bgpPeerAdminStatus = $peer_data_tmp['jnxBgpM2PeerStatus']; + $bgpPeerInUpdates = $peer_data_tmp['jnxBgpM2PeerInUpdates']; + $bgpPeerOutUpdates = $peer_data_tmp['jnxBgpM2PeerOutUpdates']; + $bgpPeerInTotalMessages = $peer_data_tmp['jnxBgpM2PeerInTotalMessages']; + $bgpPeerOutTotalMessages = $peer_data_tmp['jnxBgpM2PeerOutTotalMessages']; + $bgpPeerFsmEstablishedTime = $peer_data_tmp['jnxBgpM2PeerFsmEstablishedTime']; + $bgpPeerInUpdateElapsedTime = $peer_data_tmp['jnxBgpM2PeerInUpdatesElapsedTime']; + if ($peer_data_tmp['jnxBgpM2PeerRemoteAddrType'] == 'ipv4') { + $bgpLocalAddr = long2ip(hexdec($peer_data_tmp['jnxBgpM2PeerLocalAddr'])); + } elseif ($peer_data_tmp['jnxBgpM2PeerRemoteAddrType'] == 'ipv6') { + $ip6 = trim(str_replace(' ', '', $peer_data_tmp['jnxBgpM2PeerLocalAddr']), '"'); + $ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4); + $bgpLocalAddr = Net_IPv6::compress($ip6); + } d_echo("State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"); - $bgpLocalAddr = str_replace('"', '', str_replace(' ', '', $bgpLocalAddr)); if ($bgpLocalAddr == '00000000000000000000000000000000') { $bgpLocalAddr = ''; // Unknown? } - else { - $bgpLocalAddr = strtolower($bgpLocalAddr); - for ($i = 0; $i < 32; $i += 4) { - $bgpLocalAddr6[] = substr($bgpLocalAddr, $i, 4); - } - - $bgpLocalAddr = Net_IPv6::compress(implode(':', $bgpLocalAddr6)); - unset($bgpLocalAddr6); - } }//end if }//end if @@ -186,7 +200,6 @@ if ($config['enable_bgp']) { if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') { // Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB) $peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); -print_r($peer_afis); foreach ($peer_afis as $peer_afi) { $afi = $peer_afi['afi']; $safi = $peer_afi['safi']; @@ -278,38 +291,15 @@ print_r($peer_afis); $safis['unicast'] = 1; $safis['multicast'] = 2; - if (!isset($peerIndexes)) { - $j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); - foreach ($j_bgp as $index => $entry) { - switch ($entry['jnxBgpM2PeerRemoteAddrType']) { - case 'ipv4': - $ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr'])); - $j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex']; - break; + if (!isset($j_prefixes)) { + $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + } - case 'ipv6': - $ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"'); - $ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4); - $ip6 = Net_IPv6::compress($ip6); - $j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex']; - break; - - default: - echo "PANIC: Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n"; - break; - } - } - }//end if - - $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); - - $cbgpPeerAcceptedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted']; - $cbgpPeerDeniedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected']; - $cbgpPeerAdvertisedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixOutPrefixes']; + $cbgpPeerAcceptedPrefixes = $j_prefixes[$junos[$peer_ip]['index'].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted']; + $cbgpPeerDeniedPrefixes = $j_prefixes[$junos[$peer_ip]['index'].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected']; + $cbgpPeerAdvertisedPrefixes = $j_prefixes[$junos[$peer_ip]['index'].".$afi.".$safis[$safi]]['jnxBgpM2PrefixOutPrefixes']; unset($j_prefixes); - unset($j_bgp); - unset($j_peerIndexes); }//end if // FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE! @@ -323,7 +313,6 @@ print_r($peer_afis); $peer['c_update']['SuppressedPrefixes'] = $cbgpPeerSuppressedPrefixes; $peer['c_update']['WithdrawnPrefixes'] = $cbgpPeerWithdrawnPrefixes; - $oids = array( 'AcceptedPrefixes', 'DeniedPrefixes', diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 66b3f133ba..dcc382e4d6 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -74,6 +74,9 @@ function snmp_get_multi($device, $oids, $options='-OQUs', $mib=null, $mibdir=nul $cmd .= isset($retries) ? ' -r '.$retries : ''; $cmd .= ' '.$device['transport'].':'.$device['hostname'].':'.$device['port']; + if (is_array($oids)) { + $oids = implode(' ', $oids); + } $cmd .= ' '.$oids; if (!$debug) { From 08c77862b9ed5bb770ee99a6213ffbf2905e70ac Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Aug 2016 23:38:08 +0100 Subject: [PATCH 19/67] Renamed variable for sql query --- html/pages/device/routing/bgp.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index c3b10bc124..3198589a2f 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -41,7 +41,7 @@ echo ' | Prefixes: '; if ($vars['view'] == 'prefixes_ipv4unicast') { echo ""; - $sql = " AND `bgpLocalAddr` NOT LIKE '%:%'"; + $extra_sql = " AND `bgpLocalAddr` NOT LIKE '%:%'"; } echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); @@ -64,7 +64,7 @@ echo ' | '; if ($vars['view'] == 'prefixes_ipv6unicast') { echo ""; - $sql = " AND `bgpLocalAddr` LIKE '%:%'"; + $extra_sql = " AND `bgpLocalAddr` LIKE '%:%'"; } echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); @@ -100,7 +100,7 @@ echo 'Peer address Date: Wed, 3 Aug 2016 00:01:55 +0100 Subject: [PATCH 20/67] Updated code to move array_shift --- includes/polling/bgp-peers.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 22b712c91e..b9d531a8ae 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -107,7 +107,7 @@ if ($config['enable_bgp']) { } } - $peer_data_tmp = array_shift(snmp_get_multi( + $peer_data_tmp = snmp_get_multi( $device, array( 'jnxBgpM2PeerState.'.$junos[$peer_ip]['oid'], @@ -124,7 +124,8 @@ if ($config['enable_bgp']) { '-OQnUs', 'BGP4-V2-MIB-JUNIPER', $config['mibdir'].'/junos' - )); + ); + $peer_data_tmp = array_shift($peer_data_tmp); d_echo($peer_data_tmp); $bgpPeerState = $peer_data_tmp['jnxBgpM2PeerState']; From d56ff8b87fe505acf0b3061c2b634c449ad55a5e Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 3 Aug 2016 16:49:41 +0100 Subject: [PATCH 21/67] More updates for junos bgp polling --- html/pages/routing/bgp.inc.php | 4 +- includes/discovery/bgp-peers.inc.php | 6 +- includes/polling/bgp-peers.inc.php | 93 ++++++++++++++-------------- includes/snmp.inc.php | 24 ++++++- 4 files changed, 73 insertions(+), 54 deletions(-) diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index e7450aac92..1e66c73f4c 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -111,6 +111,7 @@ else { echo ' | Prefixes: Unicast ('; if ($vars['graph'] == 'prefixes_ipv4unicast') { echo ""; + $extra_sql = " AND `bgpLocalAddr` NOT LIKE '%:%'"; } echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); @@ -122,6 +123,7 @@ else { if ($vars['graph'] == 'prefixes_ipv6unicast') { echo ""; + $extra_sql = " AND `bgpLocalAddr` LIKE '%:%'"; } echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); @@ -213,7 +215,7 @@ else { $where .= " AND (B.bgpPeerState != 'established')"; } - $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; + $peer_query = "SELECT * FROM `bgpPeers` AS `B`, `devices` AS `D` WHERE `B`.`device_id` = `D`.`device_id` $where $extra_sql ORDER BY `D`.`hostname`, `B`.`bgpPeerRemoteAs`, `B`.`bgpPeerIdentifier`"; foreach (dbFetchRows($peer_query) as $peer) { unset($alert, $bg_image); diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index fd76baed81..c312527a0f 100644 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -1,7 +1,7 @@ $entry) { switch ($entry['jnxBgpM2PeerRemoteAddrType']) { case 'ipv4': diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index b9d531a8ae..81c629b249 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -7,8 +7,7 @@ if ($config['enable_bgp']) { if (!empty($peers)) { if ($device['os'] == 'junos') { - $peer_data_check = snmp_walk($device, 'jnxBgpM2PeerIndex', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); - $peer_data_check = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.', '', $peer_data_check)); + $peer_data_check = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerIndex', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); } else { $peer_data_check = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', array(), 'CISCO-BGP4-MIB', $config['mibdir']); } @@ -92,54 +91,46 @@ if ($config['enable_bgp']) { // FIXME - needs moved to function //$peer_cmd = $config['snmpwalk'].' -M '.$config['mibdir'].'/junos -m BGP4-V2-MIB-JUNIPER -OUnq -'.$device['snmpver'].' '.snmp_gen_auth($device).' '.$device['hostname'].':'.$device['port']; - foreach (explode("\n", $peer_data_check) as $tmp) { - list($peer_ip_snmp, $peer_index) = explode(' ', $tmp); + foreach ($peer_data_check as $hash => $index) { + $peer_ip_snmp = ltrim($index['orig'], '.'); $octets = count(explode(".", $peer_ip_snmp)); if ($octets > 11) { // ipv6 - $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16))))); + $tmp_peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16))))); } else { // ipv4 - $peer_ip = implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 4))); + $tmp_peer_ip = implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 4))); } - $junos[$peer_ip]['oid'] = $peer_ip_snmp; - $junos[$peer_ip]['index'] = $peer_index; + $junos[$tmp_peer_ip]['hash'] = $hash; + $junos[$tmp_peer_ip]['index'] = $index['jnxBgpM2PeerIndex']; } } - $peer_data_tmp = snmp_get_multi( - $device, - array( - 'jnxBgpM2PeerState.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerStatus.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerInUpdates.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerOutUpdates.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerInTotalMessages.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerOutTotalMessages.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerFsmEstablishedTime.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerInUpdatesElapsedTime.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerLocalAddr.'.$junos[$peer_ip]['oid'], - 'jnxBgpM2PeerRemoteAddrType.'.$junos[$peer_ip]['oid'], - ), - '-OQnUs', - 'BGP4-V2-MIB-JUNIPER', - $config['mibdir'].'/junos' - ); - $peer_data_tmp = array_shift($peer_data_tmp); - d_echo($peer_data_tmp); - - $bgpPeerState = $peer_data_tmp['jnxBgpM2PeerState']; - $bgpPeerAdminStatus = $peer_data_tmp['jnxBgpM2PeerStatus']; - $bgpPeerInUpdates = $peer_data_tmp['jnxBgpM2PeerInUpdates']; - $bgpPeerOutUpdates = $peer_data_tmp['jnxBgpM2PeerOutUpdates']; - $bgpPeerInTotalMessages = $peer_data_tmp['jnxBgpM2PeerInTotalMessages']; - $bgpPeerOutTotalMessages = $peer_data_tmp['jnxBgpM2PeerOutTotalMessages']; - $bgpPeerFsmEstablishedTime = $peer_data_tmp['jnxBgpM2PeerFsmEstablishedTime']; - $bgpPeerInUpdateElapsedTime = $peer_data_tmp['jnxBgpM2PeerInUpdatesElapsedTime']; - if ($peer_data_tmp['jnxBgpM2PeerRemoteAddrType'] == 'ipv4') { - $bgpLocalAddr = long2ip(hexdec($peer_data_tmp['jnxBgpM2PeerLocalAddr'])); - } elseif ($peer_data_tmp['jnxBgpM2PeerRemoteAddrType'] == 'ipv6') { - $ip6 = trim(str_replace(' ', '', $peer_data_tmp['jnxBgpM2PeerLocalAddr']), '"'); + if (!isset($peer_data_tmp)) { + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerState', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerStatus', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerInUpdates', '.1.3.6.1.4.1.2636.5.1.1.2.6.1.1.1', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerOutUpdates', '.1.3.6.1.4.1.2636.5.1.1.2.6.1.1.2', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerInTotalMessages', '.1.3.6.1.4.1.2636.5.1.1.2.6.1.1.3', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerOutTotalMessages', '.1.3.6.1.4.1.2636.5.1.1.2.6.1.1.4', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerFsmEstablishedTime', '.1.3.6.1.4.1.2636.5.1.1.2.4.1.1.1', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerInUpdatesElapsedTime', '.1.3.6.1.4.1.2636.5.1.1.2.4.1.1.2', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerLocalAddr', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.7', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerRemoteAddrType', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.10', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + d_echo($peer_data_tmp); + } + $bgpPeerState = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerState']; + $bgpPeerAdminStatus = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerStatus']; + $bgpPeerInUpdates = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerInUpdates']; + $bgpPeerOutUpdates = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerOutUpdates']; + $bgpPeerInTotalMessages = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerInTotalMessages']; + $bgpPeerOutTotalMessages = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerOutTotalMessages']; + $bgpPeerFsmEstablishedTime = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerFsmEstablishedTime']; + $bgpPeerInUpdateElapsedTime = $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerInUpdatesElapsedTime']; + if ($peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerRemoteAddrType'] == 'ipv4') { + $bgpLocalAddr = long2ip(hexdec($peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerLocalAddr'])); + } elseif ($peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerRemoteAddrType'] == 'ipv6') { + $ip6 = trim(str_replace(' ', '', $peer_data_tmp[$junos[$peer_ip]['hash']]['jnxBgpM2PeerLocalAddr']), '"'); $ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4); $bgpLocalAddr = Net_IPv6::compress($ip6); } @@ -288,19 +279,22 @@ if ($config['enable_bgp']) { }//end if if ($device['os'] == 'junos') { - // Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes $safis['unicast'] = 1; $safis['multicast'] = 2; + $afis['ipv4'] = 1; + $afis['ipv6'] = 2; if (!isset($j_prefixes)) { - $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); + $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixInPrefixesAccepted', $j_prefixes, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos', '-OQnU'); + $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixInPrefixesRejected', $j_prefixes, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos', '-OQnU'); + $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixOutPrefixes', $j_prefixes, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos', '-OQnU'); + d_echo($j_prefixes); } + + $cbgpPeerAcceptedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.'.$junos[$peer_ip]['index'].".$afis[$afi].".$safis[$safi]]); + $cbgpPeerDeniedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9.'.$junos[$peer_ip]['index'].".$afis[$afi].".$safis[$safi]]); + $cbgpPeerAdvertisedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10.'.$junos[$peer_ip]['index'].".$afis[$afi].".$safis[$safi]]); - $cbgpPeerAcceptedPrefixes = $j_prefixes[$junos[$peer_ip]['index'].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted']; - $cbgpPeerDeniedPrefixes = $j_prefixes[$junos[$peer_ip]['index'].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected']; - $cbgpPeerAdvertisedPrefixes = $j_prefixes[$junos[$peer_ip]['index'].".$afi.".$safis[$safi]]['jnxBgpM2PrefixOutPrefixes']; - - unset($j_prefixes); }//end if // FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE! @@ -357,3 +351,6 @@ if ($config['enable_bgp']) { } //end foreach } //end if } //end if + +unset($$peer_data_tmp); +unset($j_prefixes); diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 2506ca935c..d15e5bc188 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -367,6 +367,26 @@ function snmpwalk_cache_oid($device, $oid, $array, $mib=null, $mibdir=null, $snm }//end snmpwalk_cache_oid() +function snmpwalk_cache_long_oid($device, $oid, $noid, $array, $mib=null, $mibdir=null, $snmpflags='-OQnU') { + $data = snmp_walk($device, $oid, $snmpflags, $mib, $mibdir); + foreach (explode("\n", $data) as $entry) { + list($tmp_oid,$value) = explode('=', $entry, 2); + $tmp_oid = trim($tmp_oid); + $value = trim($value); + $tmp_index = str_replace($noid, '', $tmp_oid); + $index = md5($tmp_index); + if (!empty($index) && !empty($oid)) { + $array[$index][$oid] = $value; + if (empty($array[$index]['orig'])) { + $array[$index]['orig'] = $tmp_index; + } + } + } + + return $array; + +}//end snmpwalk_cache_oid() + // just like snmpwalk_cache_oid except that it returns the numerical oid as the index // this is useful when the oid is indexed by the mac address and snmpwalk would @@ -378,11 +398,11 @@ function snmpwalk_cache_oid_num($device, $oid, $array, $mib=null, $mibdir=null) }//end snmpwalk_cache_oid_num() -function snmpwalk_cache_multi_oid($device, $oid, $array, $mib=null, $mibdir=null) { +function snmpwalk_cache_multi_oid($device, $oid, $array, $mib=null, $mibdir=null, $snmpflags='-OQUs') { global $cache; if (!(is_array($cache['snmp'][$device['device_id']]) && array_key_exists($oid, $cache['snmp'][$device['device_id']]))) { - $data = snmp_walk($device, $oid, '-OQUs', $mib, $mibdir); + $data = snmp_walk($device, $oid, $snmpflags, $mib, $mibdir); foreach (explode("\n", $data) as $entry) { list($r_oid,$value) = explode('=', $entry, 2); $r_oid = trim($r_oid); From ca89d7484ab31ded8d44e51940d539ef09cab52c Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 3 Aug 2016 16:05:28 -0500 Subject: [PATCH 22/67] Update the rrdtool timeout to 5 seconds. This should be adequate for most deployments. --- includes/rrdtool.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index cdf1a8be5e..c5c07939b3 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -149,13 +149,13 @@ function rrdtool_graph($graph_file, $options) * @param string $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached * @param string $filename The full patth to the rrd file * @param string $options rrdtool command options - * @param integer $timeout seconds give up waiting for output, default 0 usually results in empty output + * @param integer $timeout seconds give up waiting for output, default 5, setting this too low may disrupt subsequent rrdtool commands * @return array the output of stdout and stderr in an array * @global config * @global debug * @global rrd_pipes */ -function rrdtool($command, $filename, $options, $timeout=1) +function rrdtool($command, $filename, $options, $timeout=5) { global $config, $debug, $rrd_pipes, $console_color; From 668c08193e182ebf73da2b188a645a29cc7f759d Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 3 Aug 2016 16:40:31 -0500 Subject: [PATCH 23/67] Try to flush the output stream before we check it. --- includes/rrdtool.inc.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index c5c07939b3..4f3cbc6cb7 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -149,13 +149,13 @@ function rrdtool_graph($graph_file, $options) * @param string $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached * @param string $filename The full patth to the rrd file * @param string $options rrdtool command options - * @param integer $timeout seconds give up waiting for output, default 5, setting this too low may disrupt subsequent rrdtool commands + * @param integer $timeout seconds give up waiting for output, default 0 * @return array the output of stdout and stderr in an array * @global config * @global debug * @global rrd_pipes */ -function rrdtool($command, $filename, $options, $timeout=5) +function rrdtool($command, $filename, $options, $timeout=0) { global $config, $debug, $rrd_pipes, $console_color; @@ -179,6 +179,10 @@ function rrdtool($command, $filename, $options, $timeout=5) print $console_color->convert('[%rRRD Disabled%n]'); $output = array(null, null); } else { + if ( $timeout > 0 && stream_select($r = $rrd_pipes, $w = null, $x = null, 0) ) { + // dump existing data + stream_get_contents($rrd_pipes[1]); + } fwrite($rrd_pipes[0], $cmd . "\n"); @@ -208,10 +212,10 @@ function rrdtool($command, $filename, $options, $timeout=5) */ function rrdtool_create($filename, $options) { - if (rrdtool_check_rrd_exists($filename)) { - return true; - } - return rrdtool('create', $filename, str_replace(array("\r", "\n"), '', $options)); + $options = str_replace(array("\r", "\n"), '', $options); + $options .= ' -O'; // do not overwrite files with create + + return rrdtool('create', $filename, $options); } /** @@ -225,7 +229,7 @@ function rrdtool_check_rrd_exists($filename) { global $config; if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { - $chk = rrdtool('last', $filename, '', 5); // wait up to 5 seconds + $chk = rrdtool('last', $filename, '', 10); // wait up to 10 seconds return strpos(implode($chk), "$filename': No such file or directory") === false; } else { return is_file($filename); From 5c26586f89ac1486f036984e9312f9963e6f8741 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 4 Aug 2016 22:34:29 +0200 Subject: [PATCH 24/67] Comware Version Fix Be able to discover the version && features on older versions && newer. --- includes/polling/os/comware.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/polling/os/comware.inc.php b/includes/polling/os/comware.inc.php index c7b2195a27..556c46e31c 100644 --- a/includes/polling/os/comware.inc.php +++ b/includes/polling/os/comware.inc.php @@ -8,5 +8,6 @@ echo 'Comware OS...'; $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:HH3C-PRODUCT-ID-MIB'); -preg_match('/Software Version (.+), Release ([a-zA-Z0-9]+)/', $poll_device['sysDescr'], $match); -list(,$version,$features) = $match; +$data = str_replace(",","",$poll_device['sysDescr']); +$version = $data['6']; +$features = $data['8']; From e19a25f4cd45c6d150ff67115a42ea0d9789efc9 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 4 Aug 2016 23:11:10 +0200 Subject: [PATCH 25/67] Brain Fart --- includes/polling/os/comware.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/polling/os/comware.inc.php b/includes/polling/os/comware.inc.php index 556c46e31c..54010085ed 100644 --- a/includes/polling/os/comware.inc.php +++ b/includes/polling/os/comware.inc.php @@ -9,5 +9,6 @@ echo 'Comware OS...'; $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:HH3C-PRODUCT-ID-MIB'); $data = str_replace(",","",$poll_device['sysDescr']); -$version = $data['6']; -$features = $data['8']; +$explodeddata = explode(" ", $data); +$version = $explodeddata['6']; +$features = $explodeddata['8']; From 0eff6964c6a86ffd989326c5bf426fd41e886e46 Mon Sep 17 00:00:00 2001 From: Maxence POULAIN Date: Fri, 5 Aug 2016 12:46:32 +0200 Subject: [PATCH 26/67] Adding support for Brocade VDX sensors --- .../discovery/sensors/fanspeeds/nos.inc.php | 23 +++++++++++++++++++ .../sensors/temperatures/nos.inc.php | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 includes/discovery/sensors/fanspeeds/nos.inc.php create mode 100644 includes/discovery/sensors/temperatures/nos.inc.php diff --git a/includes/discovery/sensors/fanspeeds/nos.inc.php b/includes/discovery/sensors/fanspeeds/nos.inc.php new file mode 100644 index 0000000000..cbdbeceb9a --- /dev/null +++ b/includes/discovery/sensors/fanspeeds/nos.inc.php @@ -0,0 +1,23 @@ + Date: Fri, 5 Aug 2016 12:56:46 +0200 Subject: [PATCH 27/67] Update the current value when discovering the Brocade NOS sensors --- includes/discovery/sensors/fanspeeds/nos.inc.php | 2 +- includes/discovery/sensors/temperatures/nos.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/discovery/sensors/fanspeeds/nos.inc.php b/includes/discovery/sensors/fanspeeds/nos.inc.php index cbdbeceb9a..d2deb2ce21 100644 --- a/includes/discovery/sensors/fanspeeds/nos.inc.php +++ b/includes/discovery/sensors/fanspeeds/nos.inc.php @@ -16,7 +16,7 @@ if ($device['os'] == "nos") { { $descr = str_replace('"', '', $descr); $descr = trim($descr); - discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100'); + discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100', $value); } } } diff --git a/includes/discovery/sensors/temperatures/nos.inc.php b/includes/discovery/sensors/temperatures/nos.inc.php index 4eea893d37..ba0af0af29 100644 --- a/includes/discovery/sensors/temperatures/nos.inc.php +++ b/includes/discovery/sensors/temperatures/nos.inc.php @@ -16,7 +16,7 @@ if ($device['os'] == "nos") { { $descr = str_replace('"', '', $descr); $descr = trim($descr); - discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100'); + discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100', $value); } } } From 1d4db3d71819ebb1a5d9e2e5358a4b643b09f903 Mon Sep 17 00:00:00 2001 From: Maxence POULAIN Date: Fri, 5 Aug 2016 13:27:47 +0200 Subject: [PATCH 28/67] Updates to match the librenms coding guidelines --- includes/discovery/sensors/fanspeeds/nos.inc.php | 9 +++------ includes/discovery/sensors/temperatures/nos.inc.php | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/includes/discovery/sensors/fanspeeds/nos.inc.php b/includes/discovery/sensors/fanspeeds/nos.inc.php index d2deb2ce21..5ebd421c16 100644 --- a/includes/discovery/sensors/fanspeeds/nos.inc.php +++ b/includes/discovery/sensors/fanspeeds/nos.inc.php @@ -3,17 +3,14 @@ if ($device['os'] == "nos") { $oids = snmp_walk($device, '1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', '-Osqn'); $oids = trim($oids); - foreach (explode("\n", $oids) as $data) - { + foreach (explode("\n", $oids) as $data) { $data = trim($data); - if ($data AND $data[37] == "2") - { + if ($data AND $data[37] == "2") { $value_oid = ".1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4.".$data[35]; $descr_oid = ".1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5.".$data[35]; $value = snmp_get($device, $value_oid, '-Oqv'); $descr = snmp_get($device, $descr_oid, '-Oqv'); - if (!strstr($descr, 'No') AND !strstr($value, 'No')) - { + if (!strstr($descr, 'No') AND !strstr($value, 'No')) { $descr = str_replace('"', '', $descr); $descr = trim($descr); discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100', $value); diff --git a/includes/discovery/sensors/temperatures/nos.inc.php b/includes/discovery/sensors/temperatures/nos.inc.php index ba0af0af29..6d7f0c9169 100644 --- a/includes/discovery/sensors/temperatures/nos.inc.php +++ b/includes/discovery/sensors/temperatures/nos.inc.php @@ -3,17 +3,14 @@ if ($device['os'] == "nos") { $oids = snmp_walk($device, '1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', '-Osqn'); $oids = trim($oids); - foreach (explode("\n", $oids) as $data) - { + foreach (explode("\n", $oids) as $data) { $data = trim($data); - if ($data AND $data[37] == "1") - { + if ($data AND $data[37] == "1") { $value_oid = ".1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4.".$data[35]; $descr_oid = ".1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5.".$data[35]; $value = snmp_get($device, $value_oid, '-Oqv'); $descr = snmp_get($device, $descr_oid, '-Oqv'); - if (!strstr($descr, 'No') AND !strstr($value, 'No')) - { + if (!strstr($descr, 'No') AND !strstr($value, 'No')) { $descr = str_replace('"', '', $descr); $descr = trim($descr); discover_sensor($valid['sensor'], 'temperature', $device, $value_oid, $data[35], 'nos', $descr, '1', '1', null, null, '80', '100', $value); From 3f72a49dbfeefc097189b47eca4eaf18019f5123 Mon Sep 17 00:00:00 2001 From: Maxence POULAIN Date: Fri, 5 Aug 2016 13:31:00 +0200 Subject: [PATCH 29/67] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 4cb6240c8f..ae8f7a4985 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -114,6 +114,7 @@ LibreNMS contributors: - Cercel Valentin (crcro) - Ahmed Sajid (ahmedsajid) - Karsten Schmidt (guggemand) +- Maxence POULAIN (Linutux42) [1]: http://observium.org/ "Observium web site" Observium was written by: From 51e0e6c16211ab3f9b07f242f10f6a83ea4e1a47 Mon Sep 17 00:00:00 2001 From: Maxence POULAIN Date: Fri, 5 Aug 2016 13:40:56 +0200 Subject: [PATCH 30/67] Updates to add the copyright headers --- includes/discovery/sensors/fanspeeds/nos.inc.php | 12 ++++++++++++ includes/discovery/sensors/temperatures/nos.inc.php | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/includes/discovery/sensors/fanspeeds/nos.inc.php b/includes/discovery/sensors/fanspeeds/nos.inc.php index 5ebd421c16..110da51aad 100644 --- a/includes/discovery/sensors/fanspeeds/nos.inc.php +++ b/includes/discovery/sensors/fanspeeds/nos.inc.php @@ -1,4 +1,16 @@ + * + * 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'] == "nos") { $oids = snmp_walk($device, '1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', '-Osqn'); diff --git a/includes/discovery/sensors/temperatures/nos.inc.php b/includes/discovery/sensors/temperatures/nos.inc.php index 6d7f0c9169..ae2cb8571c 100644 --- a/includes/discovery/sensors/temperatures/nos.inc.php +++ b/includes/discovery/sensors/temperatures/nos.inc.php @@ -1,4 +1,15 @@ + * + * 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'] == "nos") { $oids = snmp_walk($device, '1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', '-Osqn'); From 71e97cd2c3666aaf4a0a412454e428ed3445527a Mon Sep 17 00:00:00 2001 From: crcro Date: Sun, 7 Aug 2016 04:50:31 +0300 Subject: [PATCH 31/67] rewrite of brocade switches models --- includes/polling/os/fabos.inc.php | 10 +- includes/rewrites.php | 212 ++++++++++++++++++++++++++++++ 2 files changed, 220 insertions(+), 2 deletions(-) diff --git a/includes/polling/os/fabos.inc.php b/includes/polling/os/fabos.inc.php index b4feb9abb8..4d7ae65cc3 100644 --- a/includes/polling/os/fabos.inc.php +++ b/includes/polling/os/fabos.inc.php @@ -1,4 +1,10 @@ Date: Sun, 7 Aug 2016 06:24:34 +0300 Subject: [PATCH 32/67] fixes for general apps page --- .../{dhcp-stats.inc.php => dhcp-stats_stats.inc.php} | 0 .../{os-updates.inc.php => os-updates_packages.inc.php} | 0 html/pages/apps.inc.php | 8 ++++++-- html/pages/device/apps/dhcp-stats.inc.php | 2 +- html/pages/device/apps/os-updates.inc.php | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) rename html/includes/graphs/application/{dhcp-stats.inc.php => dhcp-stats_stats.inc.php} (100%) rename html/includes/graphs/application/{os-updates.inc.php => os-updates_packages.inc.php} (100%) diff --git a/html/includes/graphs/application/dhcp-stats.inc.php b/html/includes/graphs/application/dhcp-stats_stats.inc.php similarity index 100% rename from html/includes/graphs/application/dhcp-stats.inc.php rename to html/includes/graphs/application/dhcp-stats_stats.inc.php diff --git a/html/includes/graphs/application/os-updates.inc.php b/html/includes/graphs/application/os-updates_packages.inc.php similarity index 100% rename from html/includes/graphs/application/os-updates.inc.php rename to html/includes/graphs/application/os-updates_packages.inc.php diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 0a48bd432a..04c4cc21ed 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -76,8 +76,12 @@ $graphs['nfs-v3-stats'] = array( 'rpc', ); -$graphs['os-updates'] = array(''); -$graphs['dhcp-stats'] = array(''); +$graphs['os-updates'] = array( + 'packages', +); +$graphs['dhcp-stats'] = array( + 'stats', +); print_optionbar_start(); diff --git a/html/pages/device/apps/dhcp-stats.inc.php b/html/pages/device/apps/dhcp-stats.inc.php index debe352ffc..707d55c95a 100644 --- a/html/pages/device/apps/dhcp-stats.inc.php +++ b/html/pages/device/apps/dhcp-stats.inc.php @@ -3,7 +3,7 @@ global $config; $graphs = array( - 'dhcp-stats' => 'DHCP Stats', + 'dhcp-stats_stats' => 'DHCP Stats', ); foreach ($graphs as $key => $text) { diff --git a/html/pages/device/apps/os-updates.inc.php b/html/pages/device/apps/os-updates.inc.php index 31ba45b92a..772dc85d1e 100644 --- a/html/pages/device/apps/os-updates.inc.php +++ b/html/pages/device/apps/os-updates.inc.php @@ -3,7 +3,7 @@ global $config; $graphs = array( - 'os-updates' => 'OS updates', + 'os-updates_packages' => 'OS updates', ); foreach ($graphs as $key => $text) { From 837e360d5f7f9590ec07da04eaef9f689177940d Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 6 Aug 2016 23:53:26 -0500 Subject: [PATCH 33/67] Always send rrd create --- includes/rrdtool.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 4f3cbc6cb7..4d6ce50c81 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -229,7 +229,7 @@ function rrdtool_check_rrd_exists($filename) { global $config; if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { - $chk = rrdtool('last', $filename, '', 10); // wait up to 10 seconds + $chk = rrdtool('last', $filename, '', 30); // wait up to 30 seconds return strpos(implode($chk), "$filename': No such file or directory") === false; } else { return is_file($filename); @@ -378,7 +378,7 @@ function rrdtool_data_update($device, $measurement, $tags, $fields) } $rrd = rrd_name($device['hostname'], $rrd_name); - if (!rrdtool_check_rrd_exists($rrd) && $tags['rrd_def']) { + if ($tags['rrd_def']) { $rrd_def = is_array($tags['rrd_def']) ? $tags['rrd_def'] : array($tags['rrd_def']); // add the --step and the rra definitions to the command $newdef = "--step $step ".implode(' ', $rrd_def).$config['rrd_rra']; From 850c4a2f92c1d5bd6d8514239320d5eb92202417 Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sun, 7 Aug 2016 11:40:37 +0200 Subject: [PATCH 34/67] move pbn mibs to subdirectory --- .../discovery/discovery-protocols.inc.php | 3 ++- includes/discovery/mempools/pbn.inc.php | 3 ++- includes/discovery/processors/pbn.inc.php | 3 ++- includes/polling/functions.inc.php | 20 +++++++++++++------ includes/polling/mempools/pbn-mem.inc.php | 5 +++-- includes/polling/processors/pbn-cpu.inc.php | 3 ++- mibs/{ => pbn}/NMS-IF-MIB.MIB | 0 mibs/{ => pbn}/NMS-LLDP | 0 mibs/{ => pbn}/NMS-MEMORY-POOL-MIB.MIB | 0 mibs/{ => pbn}/NMS-PROCESS-MIB.MIB | 0 mibs/{ => pbn}/NMS-QOS-PIB-MIB.MIB | 0 mibs/{ => pbn}/NMS-SMI | 0 mibs/{ => pbn}/NMS-TC.MIB | 0 mibs/{ => pbn}/PBN-MIB | 0 mibs/{ => pbn}/PBN-ROOT | 0 15 files changed, 25 insertions(+), 12 deletions(-) rename mibs/{ => pbn}/NMS-IF-MIB.MIB (100%) rename mibs/{ => pbn}/NMS-LLDP (100%) rename mibs/{ => pbn}/NMS-MEMORY-POOL-MIB.MIB (100%) rename mibs/{ => pbn}/NMS-PROCESS-MIB.MIB (100%) rename mibs/{ => pbn}/NMS-QOS-PIB-MIB.MIB (100%) rename mibs/{ => pbn}/NMS-SMI (100%) rename mibs/{ => pbn}/NMS-TC.MIB (100%) rename mibs/{ => pbn}/PBN-MIB (100%) rename mibs/{ => pbn}/PBN-ROOT (100%) diff --git a/includes/discovery/discovery-protocols.inc.php b/includes/discovery/discovery-protocols.inc.php index 343cf9f0aa..17dbfe4623 100644 --- a/includes/discovery/discovery-protocols.inc.php +++ b/includes/discovery/discovery-protocols.inc.php @@ -96,7 +96,8 @@ unset($lldp_array); if ($device['os'] == 'pbn' && $config['autodiscovery']['xdp'] === true) { echo ' NMS-LLDP-MIB: '; - $lldp_array = snmpwalk_cache_oid($device, 'lldpRemoteSystemsData', array(), 'NMS-LLDP-MIB'); + $mibdir = $config['mibdir'].'/pbn'.':'.$config['mibdir']; + $lldp_array = snmpwalk_cache_oid($device, 'lldpRemoteSystemsData', array(), 'NMS-LLDP-MIB', $mibdir); d_echo($lldp_array); if ($lldp_array) { unset($lldp_links); diff --git a/includes/discovery/mempools/pbn.inc.php b/includes/discovery/mempools/pbn.inc.php index 1a95b81148..1737cc7957 100644 --- a/includes/discovery/mempools/pbn.inc.php +++ b/includes/discovery/mempools/pbn.inc.php @@ -10,7 +10,8 @@ if ($device['os'] == 'pbn') { // specified MIB supported since build 16607 if ($version[build] >= 16607) { - $usage = snmp_get($device, 'NMS-MEMORY-POOL-MIB::nmsMemoryPoolUtilization.0', '-OUvQ'); + $mibdir = $config['mibdir'].'/pbn'.':'.$config['mibdir']; + $usage = snmp_get($device, 'nmsMemoryPoolUtilization.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', $mibdir); if (is_numeric($usage)) { discover_mempool($valid_mempool, $device, 0, 'pbn-mem', 'Main Memory', '100', null, null); diff --git a/includes/discovery/processors/pbn.inc.php b/includes/discovery/processors/pbn.inc.php index ada6c6cbdd..ada86365b1 100644 --- a/includes/discovery/processors/pbn.inc.php +++ b/includes/discovery/processors/pbn.inc.php @@ -11,7 +11,8 @@ if ($device['os'] == 'pbn') { echo 'PBN : '; $descr = 'Processor'; - $usage = snmp_get($device, 'NMS-PROCESS-MIB::nmspmCPUTotal5min.1', '-OUvQ'); + $mibdir = $config['mibdir'].'/pbn'.':'.$config['mibdir']; + $usage = snmp_get($device, 'nmspmCPUTotal5min.1', '-OUvQ', 'NMS-PROCESS-MIB', $mibdir); if (is_numeric($usage)) { discover_processor($valid['processor'], $device, 'NMS-PROCESS-MIB::nmspmCPUTotal5min', '0', 'pbn-cpu', $descr, '100', $usage, null, null); diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index a6fbfa4594..e917a7cf6f 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -10,6 +10,13 @@ function poll_sensor($device, $class, $unit) { $sensor_value = ''; if ($sensor['poller_type'] == 'snmp') { + if ($device['os'] == 'pbn') { + $mibdir = $config['mibdir'].'/pbn'.':'.$config['mibdir']; + } + else { + $mibdir = $config['mibdir']; + } + if ($device['os'] == 'siklu') { $mib = ':RADIO-BRIDGE-MIB'; } @@ -29,7 +36,7 @@ function poll_sensor($device, $class, $unit) { for ($i = 0; $i < 5; $i++) { d_echo("Attempt $i "); - $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); + $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib", $mibdir))); preg_match('/[\d\.]+/', $sensor_value, $temp_response); if (!empty($temp_response[0])) { $sensor_value = $temp_response[0]; @@ -44,7 +51,7 @@ function poll_sensor($device, $class, $unit) { }//end if } else if ($class == 'state') { - $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB'))); + $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB', $mibdir))); if (!is_numeric($sensor_value)) { $state_value = dbFetchCell('SELECT `state_value` FROM `state_translations` LEFT JOIN `sensors_to_state_indexes` ON `state_translations`.`state_index_id` = `sensors_to_state_indexes`.`state_index_id` WHERE `sensors_to_state_indexes`.`sensor_id` = ? AND `state_translations`.`state_descr` LIKE ?', array($sensor['sensor_id'], $sensor_value)); d_echo('State value of ' . $sensor_value . ' is ' . $state_value . "\n"); @@ -56,10 +63,10 @@ function poll_sensor($device, $class, $unit) { else if ($class == 'signal') { $currentOS = $device['os']; include "includes/polling/signal/$currentOS.inc.php"; - $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); + $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib", $mibdir))); } else if ($class == 'dbm') { - $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); + $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib", $mibdir))); //iosxr does not expose dbm values through SNMP so we convert Watts to dbm to have a nice graph to show if ($device['os'] == "iosxr") { $sensor_value = round(10*log10($sensor_value/1000),3); @@ -67,13 +74,14 @@ function poll_sensor($device, $class, $unit) { } else { if ($sensor['sensor_type'] == 'apc') { - $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB:PowerNet-MIB$mib"))); + $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB:PowerNet-MIB$mib", $mibdir))); } else { - $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); + $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib", $mibdir))); } }//end if unset($mib); + unset($mibdir); } else if ($sensor['poller_type'] == 'agent') { if (isset($agent_sensors)) { diff --git a/includes/polling/mempools/pbn-mem.inc.php b/includes/polling/mempools/pbn-mem.inc.php index c078426725..1947efd364 100644 --- a/includes/polling/mempools/pbn-mem.inc.php +++ b/includes/polling/mempools/pbn-mem.inc.php @@ -10,8 +10,9 @@ if ($device['os'] == 'pbn') { // specified MIB supported since build 16607 if ($version[build] >= 16607) { - $perc = snmp_get($device, "NMS-MEMORY-POOL-MIB::nmsMemoryPoolUtilization.0", '-OUvQ'); - $memory_available = snmp_get($device, "NMS-MEMORY-POOL-MIB::nmsMemoryPoolTotalMemorySize.0", '-OUvQ'); + $mibdir = $config['mibdir'].'/pbn'.':'.$config['mibdir']; + $perc = snmp_get($device, 'nmsMemoryPoolUtilization.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', $mibdir); + $memory_available = snmp_get($device, 'nmsMemoryPoolTotalMemorySize.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', $mibdir); $mempool['total'] = $memory_available; if (is_numeric($perc)) { diff --git a/includes/polling/processors/pbn-cpu.inc.php b/includes/polling/processors/pbn-cpu.inc.php index d97d86fa6a..bbe42892b1 100644 --- a/includes/polling/processors/pbn-cpu.inc.php +++ b/includes/polling/processors/pbn-cpu.inc.php @@ -11,7 +11,8 @@ if ($device['os'] == 'pbn') { // specified MIB supported since build 16607 if ($version[build] >= 16607) { - $usage = snmp_get($device, 'NMS-PROCESS-MIB::nmspmCPUTotal5min.1', '-OUvQ'); + $mibdir = $config['mibdir'].'/pbn'.':'.$config['mibdir']; + $usage = snmp_get($device, 'nmspmCPUTotal5min.1', '-OUvQ', 'NMS-PROCESS-MIB', $mibdir); if (is_numeric($usage)) { $proc = ($usage * 100); diff --git a/mibs/NMS-IF-MIB.MIB b/mibs/pbn/NMS-IF-MIB.MIB similarity index 100% rename from mibs/NMS-IF-MIB.MIB rename to mibs/pbn/NMS-IF-MIB.MIB diff --git a/mibs/NMS-LLDP b/mibs/pbn/NMS-LLDP similarity index 100% rename from mibs/NMS-LLDP rename to mibs/pbn/NMS-LLDP diff --git a/mibs/NMS-MEMORY-POOL-MIB.MIB b/mibs/pbn/NMS-MEMORY-POOL-MIB.MIB similarity index 100% rename from mibs/NMS-MEMORY-POOL-MIB.MIB rename to mibs/pbn/NMS-MEMORY-POOL-MIB.MIB diff --git a/mibs/NMS-PROCESS-MIB.MIB b/mibs/pbn/NMS-PROCESS-MIB.MIB similarity index 100% rename from mibs/NMS-PROCESS-MIB.MIB rename to mibs/pbn/NMS-PROCESS-MIB.MIB diff --git a/mibs/NMS-QOS-PIB-MIB.MIB b/mibs/pbn/NMS-QOS-PIB-MIB.MIB similarity index 100% rename from mibs/NMS-QOS-PIB-MIB.MIB rename to mibs/pbn/NMS-QOS-PIB-MIB.MIB diff --git a/mibs/NMS-SMI b/mibs/pbn/NMS-SMI similarity index 100% rename from mibs/NMS-SMI rename to mibs/pbn/NMS-SMI diff --git a/mibs/NMS-TC.MIB b/mibs/pbn/NMS-TC.MIB similarity index 100% rename from mibs/NMS-TC.MIB rename to mibs/pbn/NMS-TC.MIB diff --git a/mibs/PBN-MIB b/mibs/pbn/PBN-MIB similarity index 100% rename from mibs/PBN-MIB rename to mibs/pbn/PBN-MIB diff --git a/mibs/PBN-ROOT b/mibs/pbn/PBN-ROOT similarity index 100% rename from mibs/PBN-ROOT rename to mibs/pbn/PBN-ROOT From 22ef18793bb3dff1780800c5e05df9b51c2a5eba Mon Sep 17 00:00:00 2001 From: Florian Beer Date: Sun, 7 Aug 2016 15:39:03 +0200 Subject: [PATCH 35/67] Fix: Use of undefined constant yes - assumed 'yes' --- html/includes/vars.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 369a13a74a..bca2c2577c 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -28,7 +28,7 @@ foreach ($segments as $pos => $segment) { else { list($name, $value) = explode('=', $segment); if ($value == '' || !isset($value)) { - $vars[$name] = yes; + $vars[$name] = 'yes'; } else { $vars[$name] = $value; From 84f695e372924e50feaa8637c464dc67dc99202b Mon Sep 17 00:00:00 2001 From: Florian Beer Date: Sun, 7 Aug 2016 15:39:30 +0200 Subject: [PATCH 36/67] Fix: Failed opening file for inclusion --- includes/device-groups.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/device-groups.inc.php b/includes/device-groups.inc.php index fc010d62bc..adab6b2a44 100644 --- a/includes/device-groups.inc.php +++ b/includes/device-groups.inc.php @@ -25,7 +25,7 @@ * @subpackage Devices */ -include_once($config['install_dir'].'/includes/common.inc.php'); +include_once($config['install_dir'].'/includes/common.php'); /** * Add a new device group From 330910b4e39ebe20fd3f363f4417d9b2a5ac7f9d Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sun, 7 Aug 2016 17:47:25 +0200 Subject: [PATCH 37/67] Fix a bug in syslog since PR #3812 syslog writes to wrong device id in syslog table. this happens on all devices where inet_pton() returns false. --- includes/syslog.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/syslog.php b/includes/syslog.php index ab4d1e2a12..fa0eacacae 100644 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -13,7 +13,12 @@ function get_cache($host, $value) { case 'device_id': // Try by hostname $ip = inet_pton($host); - $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ? OR `ip` = ?', array($host, $host, $ip)); + if (var_export(inet_ntop($ip),1) == 'false') { + $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host)); + } + else { + $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ? OR `ip` = ?', array($host, $host, $ip)); + } // If failed, try by IP if (!is_numeric($dev_cache[$host]['device_id'])) { $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `ipv4_addresses` AS A, `ports` AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id', array($host)); From f3fc6f2906a6792e20790334906ea2cd69a7b26e Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 7 Aug 2016 12:16:40 -0500 Subject: [PATCH 38/67] Use Exceptions Use exceptions for addHost() Gets rid of silly mixed return and only returns the device_id. Throwing an exception if we run into any issues. Slightly modifies api add host output again to include device_id --- addhost.php | 30 +++++++++++++---------- html/includes/api_functions.inc.php | 11 ++++----- html/pages/addhost.inc.php | 15 ++++++++---- includes/discovery/functions.inc.php | 13 +++++----- includes/functions.php | 36 +++++++++++++++++----------- snmp-scan.php | 27 +++++++++++++-------- 6 files changed, 77 insertions(+), 55 deletions(-) diff --git a/addhost.php b/addhost.php index 8e799174df..d82b03241e 100755 --- a/addhost.php +++ b/addhost.php @@ -49,7 +49,7 @@ if (isset ($options['p'])) { if (! in_array ($port_assoc_mode, $valid_assoc_modes)) { echo "Invalid port association mode '" . $port_assoc_mode . "'\n"; echo 'Valid modes: ' . join (', ', $valid_assoc_modes) . "\n"; - exit(2); + exit(1); } $cmd = array_shift($argv); @@ -115,7 +115,7 @@ if (!empty($argv[1])) { $v3['authalgo'] = $arg; } else { echo 'Invalid argument: '.$arg."\n"; - exit(2); + exit(1); } } @@ -139,7 +139,7 @@ if (!empty($argv[1])) { $v3['cryptoalgo'] = $arg; } else { echo 'Invalid argument: '.$arg."\n"; - exit(2); + exit(1); } }//end while @@ -165,16 +165,20 @@ if (!empty($argv[1])) { } }//end if - $result = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); - - if (is_numeric($result)) { - $device = device_by_id_cache($result); - echo 'Added device '.$device['hostname'].' ('.$result.")\n"; + try { + $device_id = addHost($host, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode); + $device = device_by_id_cache($device_id); + echo "Added device {$device['hostname']} ($device_id)\n"; exit(0); - } - else { - print $console_color->convert("%rWe couldn't add this device:\n " . $result . "%n\n"); - exit(1); + } catch (HostUnreachableException $e) { + print_error($e->getMessage()); + foreach ($e->getReasons() as $reason) { + echo " $reason\n"; + } + exit(2); + } catch (Exception $e){ + print_error($e->getMessage()); + exit(3); } } else { @@ -197,5 +201,5 @@ if (!empty($argv[1])) { %rRemember to run discovery for the host afterwards.%n ' ); - exit(2); + exit(1); } diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index d06d625f5b..11b6132c01 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -289,14 +289,13 @@ function add_device() { $message = "You haven't specified an SNMP version to use"; } if (empty($message)) { - $result = addHost($hostname, $snmpver, $port, $transport, 1, $poller_group, $force_add); - if (is_numeric($result)) { + try { + $device_id = addHost($hostname, $snmpver, $port, $transport, $poller_group, $force_add); $code = 201; $status = 'ok'; - $message = "Device $hostname has been added successfully"; - } - else { - $message = $result; + $message = "Device $hostname ($device_id) has been added successfully"; + } catch (Exception $e) { + $message = $e->getMessage(); } } diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index f2bf274e6d..947478ee62 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -66,11 +66,16 @@ if ($_POST['hostname']) { } $port_assoc_mode = $_POST['port_assoc_mode']; - $result = addHost($hostname, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); - if (is_numeric($result)) { - print_message("Device added ($result)"); - } else { - print_error('Error: ' . $result); + try { + $device_id = addHost($hostname, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode); + print_message("Device added ($device_id)"); + } catch (HostUnreachableException $e) { + print_error($e->getMessage()); + foreach ($e->getReasons() as $reason) { + print_error($reason); + } + } catch (Exception $e){ + print_error($e->getMessage()); } } else { diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 460ef4cc2c..4e1a3ff603 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -53,9 +53,8 @@ function discover_new_device($hostname, $device = '', $method = '', $interface = } if (match_network($config['nets'], $ip)) { - $result = addHost($dst_host, '', '161', 'udp', '0', $config['distributed_poller_group']); - if (is_numeric($result)) { - $remote_device_id = $result; + try { + $remote_device_id = addHost($dst_host, '', '161', 'udp', $config['distributed_poller_group']); $remote_device = device_by_id_cache($remote_device_id, 1); echo '+[' . $remote_device['hostname'] . '(' . $remote_device['device_id'] . ')]'; discover_device($remote_device); @@ -73,10 +72,10 @@ function discover_new_device($hostname, $device = '', $method = '', $interface = } return $remote_device_id; - } else { - if(substr($result, 0, 12) !== 'Already have') { - log_event("$method discovery of " . $dst_host . " ($ip) failed - " . $result); - } + } catch (HostExistsException $e) { + // already have this device + } catch (Exception $e) { + log_event("$method discovery of " . $dst_host . " ($ip) failed - " . $e->getMessage()); } } else { d_echo("$ip not in a matched network - skipping\n"); diff --git a/includes/functions.php b/includes/functions.php index b7ce3b20f1..819511f7fb 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -17,7 +17,8 @@ include_once("Net/IPv4.php"); include_once("Net/IPv6.php"); -// Observium Includes +// Includes +include_once($config['install_dir'] . "/includes/exceptions.inc.php"); include_once($config['install_dir'] . "/includes/dbFacile.php"); include_once($config['install_dir'] . "/includes/common.php"); @@ -253,23 +254,30 @@ function delete_device($id) { * @param string $snmp_version If this is empty, try v2c,v3,v1. Otherwise, use this specific version. * @param string $port the port to connect to for snmp * @param string $transport udp or tcp - * @param int $quiet don't output anything * @param string $poller_group the poller group this device will belong to * @param string $force_add add even if the device isn't pingable * @param string $port_assoc_mode snmp field to use to determine unique ports - * @return int|string returns the id of the added device, otherwise an error message + * + * @return int returns the device_id of the added device + * + * @throws HostExistsException This hostname already exists + * @throws HostIpExistsException We already have a host with this IP + * @throws HostUnreachableException We could not reach this device is some way + * @throws HostUnreachablePingException We could not ping the device + * @throws InvalidPortAssocModeException The given port association mode was invalid + * @throws SnmpVersionUnsupportedException The given snmp version was invalid */ -function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $quiet = 0, $poller_group = '0', $force_add = '0', $port_assoc_mode = 'ifIndex') { +function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $poller_group = '0', $force_add = '0', $port_assoc_mode = 'ifIndex') { global $config; // Test Database Exists if (host_exists($host) === true) { - return "Already have host $host"; + throw new HostExistsException("Already have host $host"); } // Valid port assoc mode if (!is_valid_port_assoc_mode($port_assoc_mode)) { - return "Invalid port association_mode '$port_assoc_mode'. Valid modes are: " . join(', ', get_port_assoc_modes()); + throw new InvalidPortAssocModeException("Invalid port association_mode '$port_assoc_mode'. Valid modes are: " . join(', ', get_port_assoc_modes())); } // check if we have the host by IP @@ -279,14 +287,14 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ $ip = $host; } if (ip_exists($ip)) { - return "Already have host with this IP $host"; + throw new HostIpExistsException("Already have host with this IP $host"); } // Test reachability $address_family = snmpTransportToAddressFamily($transport); $ping_result = isPingable($host, $address_family); if ($force_add == 1 || !$ping_result['result']) { - return "Could not ping $host"; + throw new HostUnreachablePingException("Could not ping $host"); } // if $snmpver isn't set, try each version of snmp @@ -296,13 +304,13 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ $snmpvers = array($snmp_version); } + $host_unreachable_exception = new HostUnreachableException("Could not connect, please check the snmp details and snmp reachability"); // try different snmp variables to add the device foreach ($snmpvers as $snmpver) { if ($snmpver === "v3") { // Try each set of parameters from config foreach ($config['snmp']['v3'] as $v3) { $device = deviceArray($host, null, $snmpver, $port, $transport, $v3, $port_assoc_mode); - print_message("Trying v3 parameters " . $v3['authname'] . "/" . $v3['authlevel'] . " ... ", $quiet); if ($force_add == 1 || isSNMPable($device)) { $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB"); $result = createHost($host, null, $snmpver, $port, $transport, $v3, $poller_group, $port_assoc_mode, $snmphost); @@ -310,14 +318,14 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ return $result; } } else { - print_error("No reply on credentials " . $v3['authname'] . "/" . $v3['authlevel'] . " using $snmpver", $quiet); + $host_unreachable_exception->addReason("SNMP $snmpver: No reply with credentials " . $v3['authname'] . "/" . $v3['authlevel']); } } } elseif ($snmpver === "v2c" || $snmpver === "v1") { // try each community from config foreach ($config['snmp']['community'] as $community) { $device = deviceArray($host, $community, $snmpver, $port, $transport, null, $port_assoc_mode); - print_message("Trying community $community ...", $quiet); + if ($force_add == 1 || isSNMPable($device)) { $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB"); $result = createHost($host, $community, $snmpver, $port, $transport, array(), $poller_group, $port_assoc_mode, $snmphost); @@ -325,15 +333,15 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ return $result; } } else { - print_error("No reply on community $community using $snmpver", $quiet); + $host_unreachable_exception->addReason("SNMP $snmpver: No reply with community $community"); } } } else { - return "Unsupported SNMP Version \"$snmpver\", must be v1, v2c, or v3"; + throw new SnmpVersionUnsupportedException("Unsupported SNMP Version \"$snmpver\", must be v1, v2c, or v3"); } } - return "Could not connect, please check the snmp details and snmp reachability"; + throw $host_unreachable_exception; } function deviceArray($host, $community, $snmpver, $port = 161, $transport = 'udp', $v3, $port_assoc_mode = 'ifIndex') { diff --git a/snmp-scan.php b/snmp-scan.php index 4f38f69750..fb864f9492 100755 --- a/snmp-scan.php +++ b/snmp-scan.php @@ -42,7 +42,7 @@ require 'includes/functions.php'; require 'includes/discovery/functions.inc.php'; function perform_snmp_scan($net) { - global $stats, $config, $quiet; + global $stats, $config, $debug; echo 'Range: '.$net->network.'/'.$net->bitmask.PHP_EOL; $config['snmp']['timeout'] = 1; $config['snmp']['retries'] = 0; @@ -63,22 +63,30 @@ function perform_snmp_scan($net) { continue; } foreach (array('udp','tcp') as $transport) { - $result = addHost(gethostbyaddr($host), '', $config['snmp']['port'], $transport, $quiet, $config['distributed_poller_group'], 0); - if (is_numeric($result)) { + try { + addHost(gethostbyaddr($host), '', $config['snmp']['port'], $transport, $config['distributed_poller_group']); $stats['added']++; echo '+'; break; - } elseif (substr($result, 0, 12) === 'Already have') { + } catch (HostExistsException $e) { $stats['known']++; echo '*'; break; - } elseif (substr($result, 0 , 14) === 'Could not ping') { + } catch (HostUnreachablePingException $e) { echo '.'; break; - } elseif ($transport == 'tcp') { - // tried both udp and tcp without success - $stats['failed']++; - echo '-'; + } catch (HostUnreachableException $e) { + if ($debug) { + print_error($e->getMessage() . " over $transport"); + foreach ($e->getReasons() as $reason) { + echo " $reason\n"; + } + } + if ($transport == 'tcp') { + // tried both udp and tcp without success + $stats['failed']++; + echo '-'; + } } } } @@ -104,7 +112,6 @@ if (isset($opts['h']) || (empty($opts) && (!isset($config['nets']) || empty($con } if (isset($opts['d'])) { $debug = true; - $quiet = 0; } if (isset($opts['l'])) { echo ' * = Known Device; . = Unpingable Device; + = Added Device; - = Failed To Add Device;'.PHP_EOL; From d65364c8efab5d387b521245a9106efec0bf3329 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sun, 7 Aug 2016 23:40:12 +0200 Subject: [PATCH 39/67] Fix Dell PowerConnect Discovery #3995 --- includes/discovery/os/radlan.inc.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/includes/discovery/os/radlan.inc.php b/includes/discovery/os/radlan.inc.php index da34ae5223..1474289736 100644 --- a/includes/discovery/os/radlan.inc.php +++ b/includes/discovery/os/radlan.inc.php @@ -1,10 +1,6 @@ Date: Sun, 7 Aug 2016 20:28:53 -0500 Subject: [PATCH 40/67] Update docs --- doc/API/API-Docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/API/API-Docs.md b/doc/API/API-Docs.md index fed298f941..445fd6e22e 100644 --- a/doc/API/API-Docs.md +++ b/doc/API/API-Docs.md @@ -629,7 +629,7 @@ Output: ```text { "status": "ok", - "message": "Device localhost.localdomain has been added successfully" + "message": "Device localhost.localdomain (57) has been added successfully" } ``` From b438e94771800ad72ecce5de3a1b2b70f888949b Mon Sep 17 00:00:00 2001 From: vitalisator Date: Mon, 8 Aug 2016 17:36:19 +0200 Subject: [PATCH 41/67] reduction, thx an @murrant --- includes/syslog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/syslog.php b/includes/syslog.php index fa0eacacae..26b7ba7901 100644 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -13,7 +13,7 @@ function get_cache($host, $value) { case 'device_id': // Try by hostname $ip = inet_pton($host); - if (var_export(inet_ntop($ip),1) == 'false') { + if (inet_ntop($ip) === false) { $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host)); } else { From 057d78aab792b49a1a7743c82059d4c97f43ad60 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Mon, 8 Aug 2016 18:34:30 +0200 Subject: [PATCH 42/67] Remove more code --- includes/polling/os/radlan.inc.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/includes/polling/os/radlan.inc.php b/includes/polling/os/radlan.inc.php index aa0da3818a..2935cc92df 100644 --- a/includes/polling/os/radlan.inc.php +++ b/includes/polling/os/radlan.inc.php @@ -1,16 +1,8 @@ Date: Mon, 8 Aug 2016 19:53:04 +0100 Subject: [PATCH 43/67] Added php lint checking for travis --- .travis.yml | 26 +++++++++++++-------- html/includes/graphs/port/pagp_bits.inc.php | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36f9fbddea..16a2eb9a55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,19 @@ language: php - -php: - - '5.3' - - '5.4' - - '5.5' - - '5.6' - - '7.0' - - hhvm - matrix: + fast_finish: true + include: + - php: 5.3 + script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + - php: 5.4 + script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + - php: 5.5 + script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + - php: 5.6 + script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + - php: 7.0 + script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + - php: hhvm + script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 allow_failures: - - php: 7.0 + - php: 7.0 + - php: hhvm diff --git a/html/includes/graphs/port/pagp_bits.inc.php b/html/includes/graphs/port/pagp_bits.inc.php index 7cce013217..450edde0f9 100644 --- a/html/includes/graphs/port/pagp_bits.inc.php +++ b/html/includes/graphs/port/pagp_bits.inc.php @@ -3,7 +3,7 @@ // Generate a list of ports and then call the multi_bits grapher to generate from the list $i = 0; foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? AND `pagpGroupIfIndex` = ?', array($port['device_id'], $port['ifIndex'])) as $int) { - $rrd_file = get_port_rrdfile_path ($hostname, int['port_id']); + $rrd_file = get_port_rrdfile_path ($hostname, $int['port_id']); if (is_file($rrd_file)) { $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $int['ifDescr']; From 544fd95a635d3166f572145bbc4de9df4cf7d4f5 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 8 Aug 2016 20:03:40 +0100 Subject: [PATCH 44/67] Updated to support php 5.3 --- includes/polling/applications/proxmox.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/applications/proxmox.inc.php b/includes/polling/applications/proxmox.inc.php index c1e366b362..c86a6e5a92 100644 --- a/includes/polling/applications/proxmox.inc.php +++ b/includes/polling/applications/proxmox.inc.php @@ -51,7 +51,7 @@ if (!is_dir($pmxcdir)) { dbUpdate(array('device_id' => $device['device_id'], 'app_type' => 'proxmox', 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], 'proxmox')); if (count($pmxlines) > 0) { - $pmxcache = []; + $pmxcache = array(); foreach ($pmxlines as $vm) { list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5); From bcd2476f321295256e80e5dd67248491c9918ac1 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 8 Aug 2016 20:13:33 +0100 Subject: [PATCH 45/67] Updated travis + added build icons --- .travis.yml | 2 +- README.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16a2eb9a55..a3ea97cf9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: - php: 7.0 script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 - php: hhvm - script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 allow_failures: - php: 7.0 - php: hhvm diff --git a/README.md b/README.md index 2d3555809b..926658660a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://scrutinizer-ci.com/g/librenms/librenms/badges/build.png?b=master)](https://scrutinizer-ci.com/g/librenms/librenms/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/librenms/librenms/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/librenms/librenms/?branch=master) [![Build Status](https://travis-ci.org/librenms/librenms.svg?branch=master)](https://travis-ci.org/librenms/librenms) + Introduction ------------ From 34feda861370ec961c7161303d70bf85aea55d4c Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 8 Aug 2016 20:20:18 +0100 Subject: [PATCH 46/67] Fixed ./includes/polling/applications/rrdcached.inc.php for php 53 --- includes/polling/applications/rrdcached.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/polling/applications/rrdcached.inc.php b/includes/polling/applications/rrdcached.inc.php index 21bb5e4684..f37136402b 100644 --- a/includes/polling/applications/rrdcached.inc.php +++ b/includes/polling/applications/rrdcached.inc.php @@ -53,7 +53,8 @@ if ($agent_data['app']['rrdcached']) { while ($max == -1 || $count < $max) { $data .= fgets($sock, 128); if ($max == -1) { - $max = explode(' ', $data)[0] + 1; + $tmp_max = explode(' ', $data); + $max = $tmp_max[0]+1; } $count++; } From 09eb5ca1e94d4c9e970b174f817225331f6199c9 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 8 Aug 2016 20:26:44 +0100 Subject: [PATCH 47/67] Fixed ./includes/polling/os/infinity.inc.php for php 53 --- includes/polling/os/infinity.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/polling/os/infinity.inc.php b/includes/polling/os/infinity.inc.php index bf4d70981c..61c11edec7 100644 --- a/includes/polling/os/infinity.inc.php +++ b/includes/polling/os/infinity.inc.php @@ -10,6 +10,6 @@ * the source code distribution for details. */ -$version = $poll_device['sysDescr']; -$version = explode(' ', $version)[2]; +$version = explode(' ', $poll_device['sysDescr']); +$version = $version[2]; $hardware = snmp_get($device, 'IEEE802dot11-MIB::dot11manufacturerProductName.5', '-Ovq'); From 5643d3710d42f3efdd15d936fe7ed3f9a555a60f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Aug 2016 15:47:35 -0500 Subject: [PATCH 48/67] Actually add the exceptions --- includes/exceptions.inc.php | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 includes/exceptions.inc.php diff --git a/includes/exceptions.inc.php b/includes/exceptions.inc.php new file mode 100644 index 0000000000..4964c3683b --- /dev/null +++ b/includes/exceptions.inc.php @@ -0,0 +1,70 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + + +// ---- addHost Excpetions ---- +class HostExistsException extends Exception {} + +class HostIpExistsException extends HostExistsException {} + +class InvalidPortAssocModeException extends Exception {} + +class SnmpVersionUnsupportedException extends Exception {} + +class HostUnreachableException extends Exception +{ + protected $reasons = array(); + + public function __toString() + { + $string = __CLASS__ . ": [{$this->code}]: {$this->message}\n"; + foreach ($this->reasons as $reason) { + $string .= " $reason\n"; + } + return $string; + } + + /** + * Add additional reasons + * @param $message + */ + public function addReason($message) + { + $this->reasons[] = $message; + } + + /** + * Get the reasons + * @return array + */ + public function getReasons() + { + return $this->reasons; + } +} + +class HostUnreachablePingException extends HostUnreachableException {} + +class HostUnreachableSnmpException extends HostUnreachableException {} From a50bb344edf34a4b25a5497a01c4821dba411888 Mon Sep 17 00:00:00 2001 From: Florian Beer Date: Tue, 9 Aug 2016 02:57:45 +0200 Subject: [PATCH 49/67] This probably can be deleted since it was wrong --- includes/device-groups.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/device-groups.inc.php b/includes/device-groups.inc.php index adab6b2a44..e023a96376 100644 --- a/includes/device-groups.inc.php +++ b/includes/device-groups.inc.php @@ -25,8 +25,6 @@ * @subpackage Devices */ -include_once($config['install_dir'].'/includes/common.php'); - /** * Add a new device group * @param $pattern From aa859fe5c48c4b059cb32f8b333d365df6f60ec4 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Aug 2016 20:33:41 -0500 Subject: [PATCH 50/67] Fix php lint error --- html/includes/graphs/vserver/auth.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/graphs/vserver/auth.inc.php b/html/includes/graphs/vserver/auth.inc.php index 38eef28a0a..2be7893b95 100644 --- a/html/includes/graphs/vserver/auth.inc.php +++ b/html/includes/graphs/vserver/auth.inc.php @@ -7,7 +7,7 @@ if (is_numeric($vars['id'])) { if (is_numeric($vserver['device_id']) && ($auth || device_permitted($vserver['device_id']))) { $device = device_by_id_cache($vserver['device_id']); - $rrd_filename = rrd_name(device['hostname'], array('vserver', $vserver['classmap_id'])); + $rrd_filename = rrd_name($device['hostname'], array('vserver', $vserver['classmap_id'])); $title = generate_device_link($device); $title .= ' :: Serverfarm :: '.htmlentities($vserver['classmap_id']); From 1182cb3f6d8b032b5c0ba9f3e583bcfddd8d80c3 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Aug 2016 22:46:58 -0500 Subject: [PATCH 51/67] One more lint error --- html/includes/graphs/application/proxmox_traffic.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/graphs/application/proxmox_traffic.inc.php b/html/includes/graphs/application/proxmox_traffic.inc.php index 09b7cdb084..ea7f75c63e 100644 --- a/html/includes/graphs/application/proxmox_traffic.inc.php +++ b/html/includes/graphs/application/proxmox_traffic.inc.php @@ -18,7 +18,7 @@ require 'includes/graphs/common.inc.php'; -$proxmox_rrd = config['rrd_dir'].'/proxmox/'.$vars['cluster'].'/'.$vars['vmid'].'_netif_'.$vars['port'].'.rrd'; +$proxmox_rrd = $config['rrd_dir'].'/proxmox/'.$vars['cluster'].'/'.$vars['vmid'].'_netif_'.$vars['port'].'.rrd'; if (rrdtool_check_rrd_exists($proxmox_rrd)) { $rrd_filename = $proxmox_rrd; From 7c7c6159515a0ca1599a10bf15c5d229bc07644c Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Aug 2016 23:05:30 -0500 Subject: [PATCH 52/67] Detect PowerConnect 5324 as powerconnect os --- includes/discovery/os/powerconnect.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/discovery/os/powerconnect.inc.php b/includes/discovery/os/powerconnect.inc.php index f13f00cc7d..2c43bfa572 100644 --- a/includes/discovery/os/powerconnect.inc.php +++ b/includes/discovery/os/powerconnect.inc.php @@ -1,14 +1,14 @@ Date: Tue, 9 Aug 2016 09:31:26 -0500 Subject: [PATCH 53/67] rrdtool.inc.php: Remove unused functions Always force -O with create Mark rrdtool() as internal A little PSR-2 and whitespace cleanup --- includes/rrdtool.inc.php | 139 +++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 80 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 4d6ce50c81..6030782052 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -62,8 +62,6 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) * @param array $rrd_pipes * @return integer */ - - function rrdtool_pipe_close($rrd_process, &$rrd_pipes) { d_echo(stream_get_contents($rrd_pipes[1])); @@ -78,7 +76,6 @@ function rrdtool_pipe_close($rrd_process, &$rrd_pipes) $return_value = proc_close($rrd_process); return $return_value; - } @@ -90,8 +87,6 @@ function rrdtool_pipe_close($rrd_process, &$rrd_pipes) * @param string $options * @return integer */ - - function rrdtool_graph($graph_file, $options) { global $config, $debug; @@ -106,9 +101,8 @@ function rrdtool_graph($graph_file, $options) if ($config['rrdcached']) { $options = str_replace(array($config['rrd_dir'].'/', $config['rrd_dir']), '', $options); - fwrite($rrd_pipes[0], 'graph --daemon '.$config['rrdcached']." $graph_file $options"); - } - else { + fwrite($rrd_pipes[0], 'graph --daemon ' . $config['rrdcached'] . " $graph_file $options"); + } else { fwrite($rrd_pipes[0], "graph $graph_file $options"); } @@ -117,7 +111,7 @@ function rrdtool_graph($graph_file, $options) $line = ""; $data = ""; while (strlen($line) < 1) { - $line = fgets($rrd_pipes[1], 1024); + $line = fgets($rrd_pipes[1], 1024); $data .= $line; } @@ -135,34 +129,39 @@ function rrdtool_graph($graph_file, $options) } return $data; - } - else { + } else { return 0; } - } /** * Generates and pipes a command to rrdtool * + * @internal * @param string $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached * @param string $filename The full patth to the rrd file * @param string $options rrdtool command options * @param integer $timeout seconds give up waiting for output, default 0 * @return array the output of stdout and stderr in an array - * @global config - * @global debug - * @global rrd_pipes + * @global $config + * @global $debug + * @global $rrd_pipes + * @global $console_color */ -function rrdtool($command, $filename, $options, $timeout=0) +function rrdtool($command, $filename, $options, $timeout = 0) { global $config, $debug, $rrd_pipes, $console_color; + // do not ovewrite files when creating + if ($command == 'create') { + $options .= ' -O'; + } + // rrdcached commands: >=1.5.5: all, >=1.5 all: except tune, <1.5: all except tune and create if ($config['rrdcached'] && - (version_compare($config['rrdtool_version'], '1.5.5', '>=') || // 1.5.5+ supports all commands - (version_compare($config['rrdtool_version'], '1.5', '>=') && $command != "tune") || // 1.5+ supports all except tune - ($command != "create" && $command != "tune")) // older supports all except create and tune + (version_compare($config['rrdtool_version'], '1.5.5', '>=') || + (version_compare($config['rrdtool_version'], '1.5', '>=') && $command != "tune") || + ($command != "create" && $command != "tune")) ) { // only relative paths if using rrdcached @@ -175,11 +174,13 @@ function rrdtool($command, $filename, $options, $timeout=0) } // do not write rrd files, but allow read-only commands - if ($config['norrd'] && !in_array($command, array('graph', 'graphv', 'dump', 'fetch', 'first', 'last', 'lastupdate', 'info', 'xport'))) { + if ($config['norrd'] && !in_array($command, + array('graph', 'graphv', 'dump', 'fetch', 'first', 'last', 'lastupdate', 'info', 'xport')) + ) { print $console_color->convert('[%rRRD Disabled%n]'); $output = array(null, null); } else { - if ( $timeout > 0 && stream_select($r = $rrd_pipes, $w = null, $x = null, 0) ) { + if ($timeout > 0 && stream_select($r = $rrd_pipes, $w = null, $x = null, 0)) { // dump existing data stream_get_contents($rrd_pipes[1]); } @@ -201,23 +202,6 @@ function rrdtool($command, $filename, $options, $timeout=0) return $output; } - -/** - * Generates an rrd database at $filename using $options - * - * @internal - * @param string $filename - * @param string $options - * @return array|bool - */ -function rrdtool_create($filename, $options) -{ - $options = str_replace(array("\r", "\n"), '', $options); - $options .= ' -O'; // do not overwrite files with create - - return rrdtool('create', $filename, $options); -} - /** * Checks if the rrd file exists on the server * This will perform a remote check if using rrdcached and rrdtool >= 1.5 @@ -242,64 +226,46 @@ function rrdtool_check_rrd_exists($filename) * * @internal * @param string $filename - * @param array $options + * @param array $data * @return array|string */ -function rrdtool_update($filename, $options) +function rrdtool_update($filename, $data) { $values = array(); - // Do some sanitisation on the data if passed as an array. + // Do some sanitation on the data if passed as an array. - if (is_array($options)) { + if (is_array($data)) { $values[] = 'N'; - foreach ($options as $k => $v) { + foreach ($data as $v) { if (!is_numeric($v)) { - $v = U; + $v = 'U'; } $values[] = $v; } - $options = implode(':', $values); - return rrdtool('update', $filename, $options); - } - else { + $data = implode(':', $values); + return rrdtool('update', $filename, $data); + } else { return 'Bad options passed to rrdtool_update'; } } // rrdtool_update -function rrdtool_fetch($filename, $options) -{ - return rrdtool('fetch', $filename, $options); -} // rrdtool_fetch - - -function rrdtool_last($filename, $options) -{ - return rrdtool('last', $filename, $options); -} // rrdtool_last - - -function rrdtool_lastupdate($filename, $options) -{ - return rrdtool('lastupdate', $filename, $options); -} // rrdtool_lastupdate - - /** * Escapes strings for RRDtool - * + * * @param string $string the string to escape * @param integer $length if passed, string will be padded and trimmed to exactly this length (after rrdtool unescapes it) * @return string */ -function rrdtool_escape($string, $length=null){ +function rrdtool_escape($string, $length = null) +{ $result = shorten_interface_type($string); $result = str_replace("'", '', $result); # remove quotes $result = str_replace('%', '%%', $result); # double percent signs if (is_numeric($length)) { - $extra = substr_count($string, ':', 0, $length); + $extra = substr_count($string, ':', 0, $length); $result = substr(str_pad($result, $length), 0, ($length + $extra)); if ($extra > 0) { $result = substr($result, 0, (-1 * $extra)); @@ -313,7 +279,7 @@ function rrdtool_escape($string, $length=null){ /** * Generates a filename based on the hostname (or IP) and some extra items - * + * * @param string $host Host name * @param array|string $extra Components of RRD filename - will be separated with "-", or a pre-formed rrdname * @param string $extension File extension (default is .rrd) @@ -328,13 +294,14 @@ function rrd_name($host, $extra, $extension = ".rrd") /** * Modify an rrd file's max value and trim the peaks as defined by rrdtool - * + * * @param string $type only 'port' is supported at this time * @param string $filename the path to the rrd file * @param integer $max the new max value * @return bool */ -function rrdtool_tune($type, $filename, $max) { +function rrdtool_tune($type, $filename, $max) +{ $fields = array(); if ($type === 'port') { if ($max < 10000000) { @@ -342,11 +309,25 @@ function rrdtool_tune($type, $filename, $max) { } $max = $max / 8; $fields = array( -'INOCTETS','OUTOCTETS','INERRORS','OUTERRORS','INUCASTPKTS','OUTUCASTPKTS','INNUCASTPKTS','OUTNUCASTPKTS','INDISCARDS','OUTDISCARDS','INUNKNOWNPROTOS','INBROADCASTPKTS','OUTBROADCASTPKTS','INMULTICASTPKTS','OUTMULTICASTPKTS' + 'INOCTETS', + 'OUTOCTETS', + 'INERRORS', + 'OUTERRORS', + 'INUCASTPKTS', + 'OUTUCASTPKTS', + 'INNUCASTPKTS', + 'OUTNUCASTPKTS', + 'INDISCARDS', + 'OUTDISCARDS', + 'INUNKNOWNPROTOS', + 'INBROADCASTPKTS', + 'OUTBROADCASTPKTS', + 'INMULTICASTPKTS', + 'OUTMULTICASTPKTS' ); } if (count($fields) > 0) { - $options = "--maximum " . implode(":$max --maximum ", $fields). ":$max"; + $options = "--maximum " . implode(":$max --maximum ", $fields) . ":$max"; rrdtool('tune', $filename, $options); } } // rrdtool_tune @@ -381,8 +362,8 @@ function rrdtool_data_update($device, $measurement, $tags, $fields) if ($tags['rrd_def']) { $rrd_def = is_array($tags['rrd_def']) ? $tags['rrd_def'] : array($tags['rrd_def']); // add the --step and the rra definitions to the command - $newdef = "--step $step ".implode(' ', $rrd_def).$config['rrd_rra']; - rrdtool_create($rrd, $newdef); + $newdef = "--step $step " . implode(' ', $rrd_def) . $config['rrd_rra']; + rrdtool('create', $rrd, $newdef); } rrdtool_update($rrd, $fields); @@ -405,13 +386,11 @@ function rrd_file_rename($device, $oldname, $newname) if (rename($oldrrd, $newrrd)) { log_event("Renamed $oldrrd to $newrrd", $device, "poller"); return true; - } - else { + } else { log_event("Failed to rename $oldrrd to $newrrd", $device, "poller"); return false; } - } - else { + } else { // we don't need to rename the file return true; } From 21ad9c2a8b014e6e21a98cfc3b1833e72a9342d2 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Aug 2016 14:03:16 -0500 Subject: [PATCH 54/67] generic_v3_multiline: extra colin breaks the graph --- html/includes/graphs/generic_v3_multiline.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/html/includes/graphs/generic_v3_multiline.inc.php b/html/includes/graphs/generic_v3_multiline.inc.php index 92773ba01d..9a0f8a80a0 100644 --- a/html/includes/graphs/generic_v3_multiline.inc.php +++ b/html/includes/graphs/generic_v3_multiline.inc.php @@ -89,11 +89,10 @@ foreach ($rrd_list as $rrd) { if ($i && ($dostack === 1)) { $stack = ':STACK'; } - + $rrd_options .= ' LINE2:'.$g_defname.$i.'#'.$colour.":'".$descr."'$stack"; if ($addarea === 1) { - $descr = ":"; $rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.$transparency.":'".$descr."'$stack"; } $rrd_options .= ' GPRINT:'.$t_defname.$i.':LAST:%8.0lf%s GPRINT:'.$t_defname.$i.'min:MIN:%8.0lf%s'; From 97877e38ec995483930ef2155c6c5c126874836a Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Aug 2016 14:06:01 -0500 Subject: [PATCH 55/67] Remove the var_dump of the poller stats update array It doesn't add any useful info and takes up several lines --- includes/polling/functions.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index a6fbfa4594..fe575df2ca 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -346,7 +346,6 @@ function poll_device($device, $options) { echo "Polled in $device_time seconds\n"; d_echo('Updating '.$device['hostname']."\n"); - d_echo($update_array); $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id'])); if ($updated) { From 0105d8cac739a6fb869914f1702adc3a2d43c0b0 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Aug 2016 14:32:07 -0500 Subject: [PATCH 56/67] Delete distro script, it has moved to librenms-agent snmp directory. --- scripts/distro | 96 -------------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100755 scripts/distro diff --git a/scripts/distro b/scripts/distro deleted file mode 100755 index 11fc5d5076..0000000000 --- a/scripts/distro +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -# Detects which OS and if it is Linux then it will detect which Linux Distribution. - -OS=`uname -s` -REV=`uname -r` -MACH=`uname -m` - -if [ "${OS}" = "SunOS" ] ; then - OS=Solaris - ARCH=`uname -p` - OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" - -elif [ "${OS}" = "AIX" ] ; then - OSSTR="${OS} `oslevel` (`oslevel -r`)" - -elif [ "${OS}" = "Linux" ] ; then - KERNEL=`uname -r` - - if [ -f /etc/redhat-release ] ; then - DIST=$(cat /etc/redhat-release | awk '{print $1}') - if [ "${DIST}" = "CentOS" ]; then - DIST="CentOS" - elif [ "${DIST}" = "Mandriva" ]; then - DIST="Mandriva" - PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//` - REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//` - else - DIST="RedHat" - fi - - PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` - REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` - - elif [ -f /etc/mandrake-release ] ; then - DIST='Mandrake' - PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//` - REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//` - - elif [ -f /etc/debian_version ] ; then - DIST="Debian `cat /etc/debian_version`" - REV="" - - elif [ -f /etc/gentoo-release ] ; then - DIST="Gentoo" - REV=$(tr -d '[[:alpha:]]' Date: Tue, 9 Aug 2016 22:07:34 +0200 Subject: [PATCH 57/67] Cisco ASA HA State Discovery #3784 --- includes/discovery/sensors/states/asa.inc.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 includes/discovery/sensors/states/asa.inc.php diff --git a/includes/discovery/sensors/states/asa.inc.php b/includes/discovery/sensors/states/asa.inc.php new file mode 100644 index 0000000000..e3443ba18f --- /dev/null +++ b/includes/discovery/sensors/states/asa.inc.php @@ -0,0 +1,70 @@ + + * 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' && $device['os'] == 'asa') { + + $temp = snmpwalk_cache_multi_oid($device, 'cfwHardwareStatusTable', array(), 'CISCO-FIREWALL-MIB'); + $cur_oid = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.'; + + if (is_array($temp)) { + //Create State Index + if (strpos($temp['primaryUnit']['cfwHardwareStatusDetail'], 'Failover Off') == false || strpos($temp['primaryUnit']['cfwHardwareStatusDetail'], 'not Configured') == false) { + + $state_name = 'cfwHardwareStatus'; + $state_index_id = create_state_index($state_name); + + //Create State Translation + if ($state_index_id !== null) { + $states = array( + array($state_index_id,'other',0,1,2) , + array($state_index_id,'up',0,2,0) , + array($state_index_id,'down',0,3,2) , + array($state_index_id,'error',0,4,2) , + array($state_index_id,'overTemp',0,5,2) , + array($state_index_id,'busy',0,6,2) , + array($state_index_id,'noMedia',0,7,2) , + array($state_index_id,'backup',0,8,2) , + array($state_index_id,'active',0,9,0) , + array($state_index_id,'standby',0,10,0) + ); + foreach($states as $value){ + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } + } + + foreach ($temp as $index => $entry) { + $descr = ucwords($temp[$index]['cfwHardwareStatusDetail']); + if ($index == 'netInterface') { + $index = 4; + } + elseif ($index == 'primaryUnit') { + $index = 6; + } + elseif ($index == 'secondaryUnit') { + $index = 7; + } + //Discover Sensors + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][' cfwHardwareStatusValue'], 'snmp', $index); + + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); + } + } + } +} From eadeeb94095975b5436ee19660596b5f29452d04 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Aug 2016 15:00:12 -0500 Subject: [PATCH 58/67] Fix addHost force_add logic Use boolean where we can Fixes #4001 --- addhost.php | 4 ++-- html/pages/addhost.inc.php | 8 +------- includes/functions.php | 18 ++++++++++-------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/addhost.php b/addhost.php index d82b03241e..d510256011 100755 --- a/addhost.php +++ b/addhost.php @@ -37,9 +37,9 @@ if (isset($options['f']) && $options['f'] == 0) { $cmd = array_shift($argv); array_shift($argv); array_unshift($argv, $cmd); - $force_add = 1; + $force_add = true; } else { - $force_add = 0; + $force_add = false; } $port_assoc_mode = $config['default_port_association_mode']; diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index 947478ee62..76a5a0ce66 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -57,13 +57,7 @@ if ($_POST['hostname']) { print_error('Unsupported SNMP Version. There was a dropdown menu, how did you reach this error ?'); }//end if $poller_group = $_POST['poller_group']; - $force_add = $_POST['force_add']; - if ($force_add == 'on') { - $force_add = 1; - } - else { - $force_add = 0; - } + $force_add = ($_POST['force_add'] == 'on'); $port_assoc_mode = $_POST['port_assoc_mode']; try { diff --git a/includes/functions.php b/includes/functions.php index 819511f7fb..3700bc917a 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -255,7 +255,7 @@ function delete_device($id) { * @param string $port the port to connect to for snmp * @param string $transport udp or tcp * @param string $poller_group the poller group this device will belong to - * @param string $force_add add even if the device isn't pingable + * @param boolean $force_add add even if the device isn't reachable * @param string $port_assoc_mode snmp field to use to determine unique ports * * @return int returns the device_id of the added device @@ -267,7 +267,7 @@ function delete_device($id) { * @throws InvalidPortAssocModeException The given port association mode was invalid * @throws SnmpVersionUnsupportedException The given snmp version was invalid */ -function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $poller_group = '0', $force_add = '0', $port_assoc_mode = 'ifIndex') { +function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $poller_group = '0', $force_add = false, $port_assoc_mode = 'ifIndex') { global $config; // Test Database Exists @@ -291,10 +291,12 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ } // Test reachability - $address_family = snmpTransportToAddressFamily($transport); - $ping_result = isPingable($host, $address_family); - if ($force_add == 1 || !$ping_result['result']) { - throw new HostUnreachablePingException("Could not ping $host"); + if (!$force_add) { + $address_family = snmpTransportToAddressFamily($transport); + $ping_result = isPingable($host, $address_family); + if (!$ping_result['result']) { + throw new HostUnreachablePingException("Could not ping $host"); + } } // if $snmpver isn't set, try each version of snmp @@ -311,7 +313,7 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ // Try each set of parameters from config foreach ($config['snmp']['v3'] as $v3) { $device = deviceArray($host, null, $snmpver, $port, $transport, $v3, $port_assoc_mode); - if ($force_add == 1 || isSNMPable($device)) { + if ($force_add || isSNMPable($device)) { $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB"); $result = createHost($host, null, $snmpver, $port, $transport, $v3, $poller_group, $port_assoc_mode, $snmphost); if ($result !== false) { @@ -326,7 +328,7 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $ foreach ($config['snmp']['community'] as $community) { $device = deviceArray($host, $community, $snmpver, $port, $transport, null, $port_assoc_mode); - if ($force_add == 1 || isSNMPable($device)) { + if ($force_add || isSNMPable($device)) { $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB"); $result = createHost($host, $community, $snmpver, $port, $transport, array(), $poller_group, $port_assoc_mode, $snmphost); if ($result !== false) { From a296a27adffb19d9d133cddc7b7aa0cb0bc6ced4 Mon Sep 17 00:00:00 2001 From: crcro Date: Wed, 10 Aug 2016 04:28:08 +0300 Subject: [PATCH 59/67] duplicate description field when area was used --- html/includes/graphs/generic_v3_multiline.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/graphs/generic_v3_multiline.inc.php b/html/includes/graphs/generic_v3_multiline.inc.php index 9a0f8a80a0..908caa42c6 100644 --- a/html/includes/graphs/generic_v3_multiline.inc.php +++ b/html/includes/graphs/generic_v3_multiline.inc.php @@ -93,7 +93,7 @@ foreach ($rrd_list as $rrd) { $rrd_options .= ' LINE2:'.$g_defname.$i.'#'.$colour.":'".$descr."'$stack"; if ($addarea === 1) { - $rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.$transparency.":'".$descr."'$stack"; + $rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.$transparency.":''$stack"; } $rrd_options .= ' GPRINT:'.$t_defname.$i.':LAST:%8.0lf%s GPRINT:'.$t_defname.$i.'min:MIN:%8.0lf%s'; $rrd_options .= ' GPRINT:'.$t_defname.$i.'max:MAX:%8.0lf%s GPRINT:'.$t_defname.$i.":AVERAGE:'%8.0lf%s\\n'"; From f3a6d6e12a567d906da5146d6da8aeb444623f32 Mon Sep 17 00:00:00 2001 From: crcro Date: Wed, 10 Aug 2016 06:12:03 +0300 Subject: [PATCH 60/67] ubuntu os icon --- html/images/os/ubuntu.png | Bin 4606 -> 1897 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/html/images/os/ubuntu.png b/html/images/os/ubuntu.png index 2b1a99b18876fc83eb2542cc8b72dce273a2c8d0..92be4b5a150d39aa82fa2993e86522e83253ab22 100644 GIT binary patch delta 1883 zcmV-h2c-D^Bk2y1BYy`lNkluou&w)%qUpPw2Fm)Xa#D(iRj=90}5yvB?=B{D*{!FP9;HL$|Dev zEOB4=ar)i6*}eNnx{GIWH+#>XbH3mCe!uTK-y!7LnkqbnzkeuFrWbfSdr)`|zKA8X#4}*ZoUrnLMbgcg9 zq`tIrS1g=2fPe74nqQHnEs9J5DBK~Z?wb0BEqXo@-Z1%#!GES`HB75odpUf#b*7gB zO;OP&fNy4MWg`ovow74ES) zKEJBSdu0Vfp;Efb^D*pW!}DJUT~iLx!PLJ{1L|mxQ-7i}2m@zz!z|ZcadnYg`i)7d zR{bM&pQ5tcZR0lQbcs8^Wf7?ADffNDh;{3Wgl8-$^Y)?NQKCR8@ZHIcLsnxn1M zeA1#^#>M3$fbx03s0!eUs{vI5zB>N$2l`uW&x;Ep60ufko5GJK z0UW6G_DXo&qYESTQ<3%oQRSoA(;hv5*>ZeY!wptcrw zP>&ugUFdD+%)sdF(Zdda@NC}(pHF%qzWeN*i~d7^hns+}_kfz7gqZsmQ2G7Y<33mo z?EEuOGzRGS8tCo>iHt#}NO<8z?bS#fHQuNc-hbm)Psv^?aCT4WVI~w0uy7}+;z7I1q?0*S~h~-TamI@4;6M)L`7)(F{6l1 z-0qz{e1N^X?12SW7|A^~=yPg4!{<+&{G3hHRK*tZJ zgMYBK5ED4xZO)-kjkiJ5q+j>ue$j6b@Tadp-hMqgViFtXfevixU7*C``PF*R4K*o3 z{5$CRyLzV~Y^|qgt@l%pCjBHXz6=1PCV?J#m;2+Y6uWuxO$+eYP+K{V> zTNi_>fA7Apo6BC?noa`)(8Ja_(rdkj;^X*IB#4qS;E9h}OL0#K+t`Xs@c;8>?e zuF7fLnKx(zC~&j;-u?;b(EILAD0AU6YyW6IK20H+}KK1~|`iMY$+;$G3_J4tX*ThFFA8Ykj zf+F3yJuq<&P}krDlw-Q_VbI5oSpf8~I7g8?J)e3V5lV3l*diLs?hCR8E}Y`5$LVxP zaeSV=(4NNJ02aOt8k<7F(-T3*K7Y%iz!72h?Vg5y{fNU*%FY4BrJ$!;lI|22PP4*! zG5ddC#wW}KJ@~Ra=gc?2lChi-MLGbT%chW6Pe*Q1W|v$pZ6Xi#dhUzGoOlA0-S;m( z0IjUb9%oN2p9{?UD@gUZ{Tu5+%?;^;ISd6SqK=@LL+eWA!n$kZQ%WKgXMZkSG>UiK z;wGcD_W_@S$wx=jsVXc0u30J{(Dyk@Z^m^ zB`2}*w{dN^pA*>vP&k+lz;q5G{qu8HVEk_5aMD!QbaiF_0%;N1MX1zw;VH&c0KeJ5 zsdjjJ|Mrzk$r1L<8n^HLwV;g)UE?yMM1(-sk0_HCcl9 z(S%LYa863YxHz%H_PcMH9^UZ`PQlX`y5m0Q;^es*N#WV2U^FUP-#KYbsM%+vmt=Me z&h+?wCibdcu80$5*(H>PqGTMf>_d>p$5gYyHTQ#B-bj{XdQ_YZ6Uql{jb#_5iT3ZC zl(I1crJW9l)RH{k%7567n(L;p2KYq$&p+Zjx8lazgVxj^e`NGsmLIG2Qt|6i(N*p7 zdrh&0Z$$x0y%AkXOK{FRk8vd&m8ja@dCrSTQWK@Jc6X7qyuTOqvcl1kk2ey__Uzg; zgx(#+>TPGNrS~2%^S_#D45jJAd^A~=QN~452|LBPp7Ule@QwJWZsK5PR5b7E6g%c0GV{8g{||!= V2dvt*j@bYJ002ovPDHLkV1ho}ujK#$ literal 4606 zcmVKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}000LWNkl;b4!-o@$Rz+!n450d@wQ>jNIq_KA28* z;?O!}tFi6BD0;tj)8@UAFAi)V>FdMpz#LG=ON!-dpnMT@K3`o+61uB>c63=bBM$`` zdvcN$TQ}`$blE5!nFB@^-9-7vU%$^-$4qK#iat~QguV04O3Fme4LhLQ8y=Ti2U8Y; zatkQ87}U*G-zN#xRP(fMZdgJ)aT~Q7qdP9)#e*1KdNU&neGJb4 zWm(ZDH|oGpr|i*F@?}uI;mOZHXa94DNs6A7bflYFR-`+{GVQWoej2&obgv~JjLZWg zj|``7YhIkZXTKn1Tg?)l{M|R;WgjFUZlBw3%>3~x00il#Exa_)$|Wf!JN=8-JsNnb zunZb5Y54%Qb->y4!PD2LVqpNLzlX5cUOyAI>SeuvAI7~~ejHurxY3w0 z<1!N7v>$K|{eCvIx~)$K7`-x8?%KM`etW|qRa5o6F>(2GM&5V-1{;6_h@AT`iqTU` zQ#TXI766|gFig+7amJs&`ZIO`i~vjk>O^Bmx15}IO)a1mo|bt1v2v$s&uEx{*jbbp zeEAP)zB#XK)F(<0ptBt!EAJ?QPT1ijmedf2>BiX?a2?XhbHIc-ZNbjK`WL;m7JDMU?5~K#T>Wf4A zl^#!o&y>OtE=>vm8bDe`+^Yrdy7=WxSC=UfAWR6u2Wkx=k|@|Ppe|p&CtP0s6i5rE zsRadry#Z6;(d)~VxH3^8662k8X3o&tTgkO4=nd0^2n1jq zKK#su)vKRRHf;t17`kG`hhNk&jJ(aoJ@M<_FF33f0CZQ^bdWj1?-u}Iq@{&a zXXl*u!orHP3l{ube)(lDRsm$LT6Hvi>eL-6G}6-%X$9H|_fUqJ+!bZ$ec$`DKDaFx z1|TLBTr`(dOrmWMKR0jQQGMl#k)E4-QiMWryQyhx{K%24L|dBy0D&PxAVML?)>foX zo*WyuZ(qJSY}moRdqU+vThZSBE~Q8%#yOuqQ7;QY-TK$HB+*e+RGN(LEZtSfqop&+JUwsCsNluzCI?KZ0-duFG({NO|Ym#+UX8R!tAGkC`xAE!;6_%XFM5s!xu z2$(R8sPOqDI~te5@BvEpmU1&7-5ynYbZ`C-Pcsr!$|amcLTSqi)3UBmN(lgB_?;ET zx4!dtNC0sFX#p71H+}@5-EB2Qe`z?ND?sme8jQtU`V9tQcn=O}`xc(5*ueJV6U6vM o6=KxgJKV0~KZ5yx|2qEn0Na(?dMS-9kpKVy07*qoM6N<$f)+f8hyVZp From bc16925f252e912d112cc6c598841e1b72493d9a Mon Sep 17 00:00:00 2001 From: Rosiak Date: Wed, 10 Aug 2016 18:27:42 +0200 Subject: [PATCH 61/67] Last fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t add states for non ha setups. --- includes/discovery/sensors/states/asa.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/discovery/sensors/states/asa.inc.php b/includes/discovery/sensors/states/asa.inc.php index e3443ba18f..321849ea18 100644 --- a/includes/discovery/sensors/states/asa.inc.php +++ b/includes/discovery/sensors/states/asa.inc.php @@ -17,8 +17,8 @@ if ($device['os_group'] == 'cisco' && $device['os'] == 'asa') { if (is_array($temp)) { //Create State Index - if (strpos($temp['primaryUnit']['cfwHardwareStatusDetail'], 'Failover Off') == false || strpos($temp['primaryUnit']['cfwHardwareStatusDetail'], 'not Configured') == false) { - + if (strstr($temp['netInterface']['cfwHardwareStatusDetail'], 'not Configured') == false) { + $state_name = 'cfwHardwareStatus'; $state_index_id = create_state_index($state_name); @@ -49,7 +49,7 @@ if ($device['os_group'] == 'cisco' && $device['os'] == 'asa') { } foreach ($temp as $index => $entry) { - $descr = ucwords($temp[$index]['cfwHardwareStatusDetail']); + $descr = ucwords(trim(preg_replace('/\s*\([^)]*\)/', '', $temp[$index]['cfwHardwareInformation']))); if ($index == 'netInterface') { $index = 4; } @@ -68,3 +68,4 @@ if ($device['os_group'] == 'cisco' && $device['os'] == 'asa') { } } } + From 7fecb5169bbcc7c492d3994eaeac90902ab71dd0 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Wed, 10 Aug 2016 21:46:06 +0200 Subject: [PATCH 62/67] Device Page UI Changes #4008 --- html/pages/device.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index b6682eeb2e..e1777178f6 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -412,9 +412,9 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {