add a linebreak convenience function
[php-utility-classes.git] / examples / rrd / rrd-update.php
CommitLineData
4a778b7e 1<?php
880bcb60
RK
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
1759d73b 6date_default_timezone_set("Europe/Vienna");
4a778b7e 7$myfile = $_SERVER['SCRIPT_FILENAME'];
8while (is_link($myfile)) { $myfile = readlink($myfile); }
9if (getcwd() != dirname($myfile)) {
10 // change to directory of the script if called from different directory
11 $orig_workingdir = getcwd();
12 chdir(dirname($myfile));
13}
14
15include_once('rrdstat.php-class');
4d8d65db
RK
16
17$rrd_config_file = 'rrd-config/'.php_uname('n').'.inc.php';
18if (!file_exists($rrd_config_file)) { $rrd_config_file = 'rrd-config.inc.php'; }
19include_once($rrd_config_file);
4a778b7e 20
21if (php_sapi_name() == 'cli') {
22 // automated updates
23 $autoupdate = array();
24 foreach ($rrd_info as $iname=>$rinfo) {
25 if (isset($rinfo['auto-update']) && $rinfo['auto-update']) {
26 $autoupdate[] = $iname;
27 }
28 }
29 $autoupdate[] = 'rrdup';
30 foreach ($autoupdate as $rrdname) {
31 $rrd = new rrdstat($rrd_info, $rrdname);
32 $rrd->update();
33 }
34}
35else {
36 print('this is a commandline app.');
37}
38?>