diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index d20e24ac61..3f21363130 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,10 +2,7 @@ > Please read this information carefully. -[ ] Is your install up to date? [Updating your install](http://docs.librenms.org/General/Updating/) - -[ ] Please include all of the information between the `====================================` section of `./validate.php`. - -[ ] If you would like us to add a new device then please provide the information asked for [here](http://docs.librenms.org/Support/FAQ/#faq20) - -[ ] Please provide as much detail as possible. +- [ ] Is your install up to date? [Updating your install](http://docs.librenms.org/General/Updating/) +- [ ] Please include all of the information between the `====================================` section of `./validate.php`. +- [ ] If you would like us to add a new device then please provide the information asked for [here](http://docs.librenms.org/Support/FAQ/#faq20) +- [ ] Please provide as much detail as possible. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5e473ff58e..8cc3ea1d2a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,6 +2,5 @@ > Please read this information carefully. -[ ] Have you signed the [Contributors agreement](http://docs.librenms.org/General/Contributing/) - -[ ] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) +- [ ] Have you signed the [Contributors agreement](http://docs.librenms.org/General/Contributing/) +- [ ] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) diff --git a/.gitignore b/.gitignore index 05af5ba56f..fe34379a88 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ !/.editorconfig !/.scrutinizer.yml !/.travis.yml +!/.php_cs !/.github/ # Others # diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000000..131e3896e1 --- /dev/null +++ b/.php_cs @@ -0,0 +1,18 @@ +exclude('html/includes/geshi') + ->exclude('html/includes/jpgraph') + ->exclude('html/includes/Slim') + ->exclude('html/lib') + ->exclude('lib') + ->exclude('logs') + ->exclude('mibs') + ->exclude('rrd') + ->in(__DIR__); + +return Symfony\CS\Config\Config::create() + ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->finder($finder); diff --git a/.travis.yml b/.travis.yml index 36f9fbddea..a3ea97cf9e 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 . -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: 7.0 + - php: hhvm diff --git a/AUTHORS.md b/AUTHORS.md index 3ccf67d0bc..87d40e61b5 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) - Florian Beer (florianbeer) [1]: http://observium.org/ "Observium web site" 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 ------------ diff --git a/addhost.php b/addhost.php index 8e799174df..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']; @@ -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/check-services.php b/check-services.php index dcee38ae85..fd408e7852 100755 --- a/check-services.php +++ b/check-services.php @@ -28,8 +28,7 @@ if (isset($options['d'])) { ini_set('display_startup_errors', 1); ini_set('log_errors', 1); ini_set('error_reporting', 1); -} -else { +} else { $debug = false; // ini_set('display_errors', 0); ini_set('display_startup_errors', 0); @@ -37,6 +36,16 @@ else { // ini_set('error_reporting', 0); } +if (isset($options['f'])) { + $config['noinfluxdb'] = true; +} + +if ($config['noinfluxdb'] !== true && $config['influxdb']['enable'] === true) { + $influxdb = influxdb_connect(); +} else { + $influxdb = false; +} + rrdtool_pipe_open($rrd_process, $rrd_pipes); foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC') as $service) { 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" } ``` 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/Extensions/RRDCached.md b/doc/Extensions/RRDCached.md index 05244981ab..499a27aee2 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,8 +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/ -RRDC_USER=librenms +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/ [Install] WantedBy=default.target diff --git a/doc/General/Updating.md b/doc/General/Updating.md index 1c49b21a1f..444b44e335 100644 --- a/doc/General/Updating.md +++ b/doc/General/Updating.md @@ -1,14 +1,23 @@ ## Updating your install ## -LibreNMS by default performs updates on a daily basis. This can be disabled -by ensuring: - - $config['update'] = 0; - -is no longer commented out. If you would like to perform a manual update -then you can do this by running the following command as the librenms user: +If you would like to perform a manual update +then you can do this by running the following command as the **librenms** user: ./daily.sh This will update both the core LibreNMS files but also update the database structure if updates are available. + +## Configuring the update channel ## +LibreNMS follows the master branch on github for daily updates. +You can change to the monthly releases by setting: + + $config['update_channel'] == 'release'; + +## Disabling automatic updates ## +LibreNMS by default performs updates on a daily basis. This can be disabled +by ensuring: + + $config['update'] = 0; + +is no longer commented out. \ No newline at end of file diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 323aa319cb..c44fc9e9cc 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/doc/Support/Support-New-OS.md b/doc/Support/Support-New-OS.md index be2bec7c96..1fc0339e45 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 getMessage(); } } diff --git a/html/includes/graphs/XXX_device_memory_windows.inc.php b/html/includes/graphs/XXX_device_memory_windows.inc.php index 731250de9a..9a8e4bd34e 100644 --- a/html/includes/graphs/XXX_device_memory_windows.inc.php +++ b/html/includes/graphs/XXX_device_memory_windows.inc.php @@ -4,7 +4,7 @@ require 'includes/graphs/common.inc.php'; $device = device_by_id_cache($id); -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/mem.rrd'; +$rrd_filename = rrd_name($device['hostname'], 'mem'); $rrd_options .= ' -b 1024'; diff --git a/html/includes/graphs/accesspoints/channel.inc.php b/html/includes/graphs/accesspoints/channel.inc.php index d68824fa16..29ca8c8eaf 100644 --- a/html/includes/graphs/accesspoints/channel.inc.php +++ b/html/includes/graphs/accesspoints/channel.inc.php @@ -1,6 +1,6 @@ array( @@ -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 3df1abf45a..9f3d0b1d84 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', @@ -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/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/drbd_disk_bits.inc.php b/html/includes/graphs/application/drbd_disk_bits.inc.php index d3458c72a6..536cba013f 100644 --- a/html/includes/graphs/application/drbd_disk_bits.inc.php +++ b/html/includes/graphs/application/drbd_disk_bits.inc.php @@ -4,9 +4,9 @@ $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)) { +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 d20c1b3043..b3d1c35394 100644 --- a/html/includes/graphs/application/drbd_network_bits.inc.php +++ b/html/includes/graphs/application/drbd_network_bits.inc.php @@ -4,9 +4,9 @@ $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)) { +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 a04a4080b6..3de7e66978 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', @@ -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 f2a551ba8c..686d56c40c 100644 --- a/html/includes/graphs/application/drbd_unsynced.inc.php +++ b/html/includes/graphs/application/drbd_unsynced.inc.php @@ -4,9 +4,9 @@ $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)) { +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 9298460db4..a4fd6d258a 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'), @@ -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 f9cb4c4a67..3e2728e1b9 100644 --- a/html/includes/graphs/application/mailscanner_sent.inc.php +++ b/html/includes/graphs/application/mailscanner_sent.inc.php @@ -15,9 +15,9 @@ $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)) { +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 f68b5200b7..ecad7e0948 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', @@ -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 6bd8d58824..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 19182d0a6d..7d3047e051 100644 --- a/html/includes/graphs/application/mysql_command_counters.inc.php +++ b/html/includes/graphs/application/mysql_command_counters.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( 'CDe' => array( @@ -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 d8024a9ed4..5389690fbb 100644 --- a/html/includes/graphs/application/mysql_connections.inc.php +++ b/html/includes/graphs/application/mysql_connections.inc.php @@ -2,9 +2,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( @@ -34,7 +32,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 f02593e607..0fbe86de3f 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'), @@ -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 6f9255ffac..9e35ca9664 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', @@ -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 e2e3f84418..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 @@ -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', @@ -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 9cbde97ff6..0d83b6633e 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', @@ -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 0140303705..92efe35d99 100644 --- a/html/includes/graphs/application/mysql_innodb_io.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io.inc.php @@ -2,35 +2,35 @@ 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)) { +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/includes/graphs/application/mysql_innodb_io_pending.inc.php b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php index 7b578e0522..f2ecc3d484 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', @@ -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 b68890b844..cb20abebc3 100644 --- a/html/includes/graphs/application/mysql_innodb_log.inc.php +++ b/html/includes/graphs/application/mysql_innodb_log.inc.php @@ -2,9 +2,9 @@ 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)) { +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 f3b74a58b4..3aea791645 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', @@ -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 4b259ed7a4..f8499e5728 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', @@ -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 87e64f73e7..307c4e74cf 100644 --- a/html/includes/graphs/application/mysql_innodb_transactions.inc.php +++ b/html/includes/graphs/application/mysql_innodb_transactions.inc.php @@ -2,12 +2,12 @@ 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'); $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 a4d8a36e33..5fdff1cee2 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', @@ -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 c37372eeea..2674439a75 100644 --- a/html/includes/graphs/application/mysql_network_traffic.inc.php +++ b/html/includes/graphs/application/mysql_network_traffic.inc.php @@ -2,9 +2,9 @@ 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)) { +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 1de0634367..9a70d720aa 100644 --- a/html/includes/graphs/application/mysql_query_cache.inc.php +++ b/html/includes/graphs/application/mysql_query_cache.inc.php @@ -2,47 +2,47 @@ 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)) { +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 f4dcf4737e..e003857307 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', @@ -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 77f15948fe..b78e354937 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', @@ -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 c8304c678b..2827a3c6dc 100644 --- a/html/includes/graphs/application/mysql_slow_queries.inc.php +++ b/html/includes/graphs/application/mysql_slow_queries.inc.php @@ -2,12 +2,12 @@ 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'); $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 15396df980..84abb295b8 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', @@ -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 9e8b1fa06f..1bdd727c00 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', @@ -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 7a7b0ed0a5..d575e157ba 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', @@ -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 149ec713eb..654e43bc1f 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', @@ -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 44e2e3a5d9..4926443c3d 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( @@ -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 97bff73aef..bb4d2502eb 100644 --- a/html/includes/graphs/application/nginx_req.inc.php +++ b/html/includes/graphs/application/nginx_req.inc.php @@ -2,9 +2,9 @@ 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)) { +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 36d580a507..cfd0430b28 100644 --- a/html/includes/graphs/application/ntpclient_freq.inc.php +++ b/html/includes/graphs/application/ntpclient_freq.inc.php @@ -9,9 +9,9 @@ $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)) { +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 b7c6680544..1ee5672047 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'), @@ -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 b96f3c5a57..f238dfd0f3 100644 --- a/html/includes/graphs/application/ntpdserver_bits.inc.php +++ b/html/includes/graphs/application/ntpdserver_bits.inc.php @@ -20,9 +20,9 @@ $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)) { +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 3e47555f94..b0e81ef713 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'), @@ -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 13f64c2950..59f6f12f86 100644 --- a/html/includes/graphs/application/ntpdserver_freq.inc.php +++ b/html/includes/graphs/application/ntpdserver_freq.inc.php @@ -9,9 +9,9 @@ $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)) { +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 b3d906aa3c..e884c5c3bd 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', @@ -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 e6d79d292b..362f19e06e 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'), @@ -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 debff062ea..aaf92c0287 100644 --- a/html/includes/graphs/application/ntpdserver_stratum.inc.php +++ b/html/includes/graphs/application/ntpdserver_stratum.inc.php @@ -9,9 +9,9 @@ $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)) { +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 e1b007f3d6..a4baf8b03d 100644 --- a/html/includes/graphs/application/ntpdserver_uptime.inc.php +++ b/html/includes/graphs/application/ntpdserver_uptime.inc.php @@ -11,9 +11,9 @@ $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)) { +if (rrdtool_check_rrd_exists($ntpdserver_rrd)) { $rrd_filename = $ntpdserver_rrd; } 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/includes/graphs/application/powerdns_fail.inc.php b/html/includes/graphs/application/powerdns_fail.inc.php index 469b633ac1..87b886e3bf 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', @@ -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 5e716a8dc1..5c22012f05 100644 --- a/html/includes/graphs/application/powerdns_latency.inc.php +++ b/html/includes/graphs/application/powerdns_latency.inc.php @@ -9,9 +9,9 @@ $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)) { +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 abd3297cc7..c0498748ea 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', @@ -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 49f5b8d200..37cc95eb28 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', @@ -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 e680f72dae..a4cf32a0cb 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', @@ -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 694bb88f79..82f5dcd12e 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', @@ -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 32a94799a2..ad0a33e7cd 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', @@ -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 26d6e66823..ea7f75c63e 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/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..cd193c6bf9 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -20,30 +20,18 @@ $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) { + $pieces = explode('-', basename($file, '.rrd')); + $hostname = end($pieces); + 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..3a72450623 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -7,30 +7,17 @@ $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) { + $pieces = explode('-', basename($file, '.rrd')); + $hostname = end($pieces); + 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 @@ $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/poller_perf.inc.php b/html/includes/graphs/device/poller_perf.inc.php index f69e7690e3..03b78401e5 100644 --- a/html/includes/graphs/device/poller_perf.inc.php +++ b/html/includes/graphs/device/poller_perf.inc.php @@ -16,7 +16,7 @@ $scale_min = '0'; require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/poller-perf.rrd'; +$rrd_filename = rrd_name($device['hostname'], 'poller-perf'); $rrd_options .= ' DEF:poller='.$rrd_filename.':poller:AVERAGE'; $rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'"; diff --git a/html/includes/graphs/device/processor_separate.inc.php b/html/includes/graphs/device/processor_separate.inc.php index de0760ac68..5607688699 100644 --- a/html/includes/graphs/device/processor_separate.inc.php +++ b/html/includes/graphs/device/processor_separate.inc.php @@ -3,9 +3,9 @@ $i = 0; foreach ($procs as $proc) { - $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'])); - 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 dfbd4b3558..5397b8fa10 100644 --- a/html/includes/graphs/device/processor_stack.inc.php +++ b/html/includes/graphs/device/processor_stack.inc.php @@ -3,9 +3,9 @@ $i = 0; foreach ($procs as $proc) { - $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'])); - 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/pulse_sessions.inc.php b/html/includes/graphs/device/pulse_sessions.inc.php index bedbdb0cc7..76967a39bc 100644 --- a/html/includes/graphs/device/pulse_sessions.inc.php +++ b/html/includes/graphs/device/pulse_sessions.inc.php @@ -1,6 +1,6 @@ $array) { // We only care about children of the selected policy. if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { - // Are we trying to only graph a single class? if (isset($vars['class'])) { // Yes, is this the selected class @@ -62,7 +61,7 @@ foreach ($components as $id => $array) { // Add the class map to the graph if ($addtograph === true) { d_echo("\n Class: ".$components[$id]['label']."\t+ added to the graph"); - $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 850ae866bf..95e8332072 100644 --- a/html/includes/graphs/port/cbqos_qosdrops.inc.php +++ b/html/includes/graphs/port/cbqos_qosdrops.inc.php @@ -46,7 +46,6 @@ foreach ($components as $id => $array) { // We only care about children of the selected policy. if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { - // Are we trying to only graph a single class? if (isset($vars['class'])) { // Yes, is this the selected class @@ -62,7 +61,7 @@ foreach ($components as $id => $array) { // Add the class map to the graph if ($addtograph === true) { d_echo("\n Class: ".$components[$id]['label']."\t+ added to the graph"); - $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 995a077311..85419457a8 100644 --- a/html/includes/graphs/port/cbqos_traffic.inc.php +++ b/html/includes/graphs/port/cbqos_traffic.inc.php @@ -46,7 +46,6 @@ foreach ($components as $id => $array) { // We only care about children of the selected policy. if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { - // Are we trying to only graph a single class? if (isset($vars['class'])) { // Yes, is this the selected class @@ -62,7 +61,7 @@ foreach ($components as $id => $array) { // Add the class map to the graph if ($addtograph === true) { d_echo("\n Class: ".$components[$id]['label']."\t+ added to the graph"); - $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/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 eb9f0622a4..721955f3ab 100644 --- a/html/includes/graphs/port/mac_acc_total.inc.php +++ b/html/includes/graphs/port/mac_acc_total.inc.php @@ -64,8 +64,8 @@ $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'); - if (is_file($this_rrd)) { + $this_rrd = rrd_name($acc['hostname'], array('cip', $acc['ifIndex'], $acc['mac'])); + 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..46d5e8de80 100644 --- a/html/includes/graphs/port/pagp_bits.inc.php +++ b/html/includes/graphs/port/pagp_bits.inc.php @@ -3,8 +3,8 @@ // 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']); - if (is_file($rrd_file)) { + $rrd_file = get_port_rrdfile_path ($hostname, $int['port_id']); + if (rrdtool_check_rrd_exists($rrd_file)) { $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $int['ifDescr']; $i++; 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..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 = $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/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; diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index f2bf274e6d..76a5a0ce66 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -57,20 +57,19 @@ 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']; - $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/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.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']) {