]>
Commit | Line | Data |
---|---|---|
5c2a6547 ER |
1 | #!/usr/bin/php |
2 | <?php | |
3 | /* | |
4 | +---------------------------------------------------------------------------+ | |
5 | | This script import cacti xml template files by command line | | |
6 | | Author : Jean Francois Masure <jean-francois.masure@arche.fr> | | |
7 | | Version : 0.1 8 Aug 2005 | | |
8 | +---------------------------------------------------------------------------+ | |
9 | */ | |
10 | include_once("/usr/share/cacti/include/global.php"); | |
11 | include_once("/usr/share/cacti/lib/import.php"); | |
12 | ||
13 | // check if we have good number of argument | |
52084463 ER |
14 | if ($argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) { |
15 | echo "Usage: $argv[0] FILE.xml [FILE.xml]\n"; | |
16 | echo "This script will import FILE.xml template into cacti\n"; | |
17 | exit(0); | |
5c2a6547 | 18 | } |
52084463 | 19 | array_shift($argv); |
5c2a6547 | 20 | |
52084463 ER |
21 | foreach ($argv as $xml_file) { |
22 | $xml_data = file_get_contents($xml_file); | |
23 | if ($xml_data === false) { | |
24 | echo "ERROR: cannot open $xml_file, exiting\n"; | |
25 | exit(1); | |
26 | } | |
5c2a6547 | 27 | |
52084463 ER |
28 | // import data into cacti. $info_array will contain debugging info. |
29 | echo "cacti-add_template: importing $xml_file\n"; | |
30 | $info_array = import_xml_data($xml_data, false); | |
31 | } | |
5c2a6547 | 32 | |
52084463 | 33 | exit(0); |