]> git.pld-linux.org Git - packages/cacti-add_template.git/blob - cacti-add_template.php
- cacti can do it by itself now:
[packages/cacti-add_template.git] / cacti-add_template.php
1 #!/usr/bin/php
2 <?php
3 /*
4  * $Id$
5  */
6
7 /*
8 +---------------------------------------------------------------------------+
9 | This script import cacti xml template files by command line               |
10 | Author : Jean Francois Masure <jean-francois.masure@arche.fr>             |
11 | Version : 0.1 8 Aug 2005                                                  |
12 | Modified by PLD Linux Team <http://www.pld-linux.org>                     |
13 +---------------------------------------------------------------------------+
14
15 */
16
17 require_once '/usr/share/cacti/include/global.php';
18 require_once '/usr/share/cacti/lib/import.php';
19
20 // check if we have good number of argument
21 if ($argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
22         echo "Usage: $argv[0] FILE.xml [FILE.xml]\n";
23         echo "This script will import FILE.xml template into cacti\n";
24         exit(0);
25 }
26 array_shift($argv);
27
28 foreach ($argv as $xml_file) {
29         $xml_data = file_get_contents($xml_file);
30         if ($xml_data === false) {
31                 fprintf(STDERR, "ERROR: cannot open $xml_file, exiting\n");
32                 exit(1);
33         }
34
35         // import data into cacti. $info_array will contain debugging info.
36         echo "cacti-add_template: importing $xml_file\n";
37         $info_array = import_xml_data($xml_data, false);
38 }
39
40 exit(0);
This page took 0.083352 seconds and 3 git commands to generate.