]>
Commit | Line | Data |
---|---|---|
5c2a6547 ER |
1 | #!/usr/bin/php |
2 | <?php | |
11105d00 ER |
3 | /* |
4 | * $Id$ | |
5 | */ | |
6 | ||
5c2a6547 ER |
7 | /* |
8 | +---------------------------------------------------------------------------+ | |
9adb5270 ER |
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> | | |
5c2a6547 | 13 | +---------------------------------------------------------------------------+ |
11105d00 | 14 | |
5c2a6547 | 15 | */ |
9adb5270 ER |
16 | |
17 | require_once '/usr/share/cacti/include/global.php'; | |
18 | require_once '/usr/share/cacti/lib/import.php'; | |
5c2a6547 ER |
19 | |
20 | // check if we have good number of argument | |
52084463 ER |
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); | |
5c2a6547 | 25 | } |
52084463 | 26 | array_shift($argv); |
5c2a6547 | 27 | |
52084463 ER |
28 | foreach ($argv as $xml_file) { |
29 | $xml_data = file_get_contents($xml_file); | |
30 | if ($xml_data === false) { | |
11105d00 | 31 | fprintf(STDERR, "ERROR: cannot open $xml_file, exiting\n"); |
52084463 ER |
32 | exit(1); |
33 | } | |
5c2a6547 | 34 | |
52084463 ER |
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 | } | |
5c2a6547 | 39 | |
52084463 | 40 | exit(0); |