SOURCES: cacti-add_template.php (NEW) - add to SOURCES

glen glen at pld-linux.org
Sun Oct 5 14:12:03 CEST 2008


Author: glen                         Date: Sun Oct  5 12:12:03 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- add to SOURCES

---- Files affected:
SOURCES:
   cacti-add_template.php (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/cacti-add_template.php
diff -u /dev/null SOURCES/cacti-add_template.php:1.1
--- /dev/null	Sun Oct  5 14:12:03 2008
+++ SOURCES/cacti-add_template.php	Sun Oct  5 14:11:57 2008
@@ -0,0 +1,35 @@
+#!/usr/bin/php
+<?php
+/*
++---------------------------------------------------------------------------+
+| This script import cacti xml template files by command line		    |
+| Author : Jean Francois Masure <jean-francois.masure at arche.fr>		    |
+| Version : 0.1 8 Aug 2005						    |
++---------------------------------------------------------------------------+
+*/
+include_once("/usr/share/cacti/include/global.php");
+include_once("/usr/share/cacti/lib/import.php"); 
+
+// check if we have good number of argument
+if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?')))
+{
+  echo "usage : $argv[0] file.xml\n";
+  echo "this script will import file.xml template into cacti\n";
+  return 0;
+}
+
+// open the .xml file
+$xml_file = $argv[1];
+$fp = fopen($xml_file, "r");
+if ($fp == FALSE) 
+{
+  echo "cannot open $xml_file, exiting\n";
+  return -1;
+}
+$xml_data = fread($fp,filesize($xml_file));
+
+// import data into cacti. $info_array will contain debugging info.
+$info_array = import_xml_data($xml_data,false);
+
+return 0;
+?>
================================================================


More information about the pld-cvs-commit mailing list