import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.io.FileInputStream; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.DocumentBuilder; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.w3c.dom.Document; import org.w3c.dom.DOMException; import msglog; /** * read a hosts xml doc in and pick out the necessary bits of info */ public class hostinfo { protected static String hostname; protected static String label; protected static String mapname; protected static String hosttype; protected static String pollenabled; protected static String polltype; protected static String logging; protected static String notify; protected static String dependencyup; protected static String dependencydown; protected static String schedulestart; protected static String scheduleend; protected static String scheduledays; protected static String servicegroup; protected static String snmpenabled; protected static String snmpread; protected static String snmpwrite; protected static String snmpobjectid; msglog mlog = new msglog(); String getDataFromNode( org.w3c.dom.Node nod ) { org.w3c.dom.NodeList nodes = nod.getChildNodes(); for ( int i=0; i< nodes.getLength(); i++ ) { org.w3c.dom.Node node = nodes.item(i); int type = node.getNodeType(); String val = node.getNodeValue(); String name = node.getNodeName(); if ( type == 3 ) { if ( val != null ) { return( val ); } } } return( null ); } String getDataFromNode( org.w3c.dom.Node nod, String str ) { org.w3c.dom.NodeList nodes = nod.getChildNodes(); for ( int i=0; i< nodes.getLength(); i++ ) { org.w3c.dom.Node node = nodes.item(i); int type = node.getNodeType(); String val = node.getNodeValue(); String name = node.getNodeName(); // mlog.write( "type: " + type + " nodename: " + name + " value: " + val ); if ( type == 1 && name != null ) { if ( name.equals( str )) { if ( node.hasChildNodes() ) { org.w3c.dom.NodeList nads = node.getChildNodes(); for ( int j = 0; j < nads.getLength(); j++ ) { node = nads.item(j); type = node.getNodeType(); val = node.getNodeValue(); name = node.getNodeName(); if ( type == 3 && val != null ) { return( val ); } } } } } } return( null ); } void recurseNodes( org.w3c.dom.NodeList nodes ) throws IOException { for (int i=0; i