]> git.pld-linux.org Git - packages/cacti-add_template.git/blob - cacti-add_template.php
- add to SOURCES
[packages/cacti-add_template.git] / cacti-add_template.php
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
14 if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?')))
15 {
16   echo "usage : $argv[0] file.xml\n";
17   echo "this script will import file.xml template into cacti\n";
18   return 0;
19 }
20
21 // open the .xml file
22 $xml_file = $argv[1];
23 $fp = fopen($xml_file, "r");
24 if ($fp == FALSE) 
25 {
26   echo "cannot open $xml_file, exiting\n";
27   return -1;
28 }
29 $xml_data = fread($fp,filesize($xml_file));
30
31 // import data into cacti. $info_array will contain debugging info.
32 $info_array = import_xml_data($xml_data,false);
33
34 return 0;
35 ?>
This page took 0.129465 seconds and 3 git commands to generate.