Ejemplo n.º 1
0
 public static final NagiosObj getObject(
     String firstLine, String cfgLines, String filename, PrintStream _debugOut)
     throws NagiosParserException, NagiosTypeNotSupportedException, UnknownHostException {
   NagiosObj rtn;
   int objType = getObjectType(firstLine);
   switch (objType) {
     case HOST_TYPE:
       rtn = getHostObj(cfgLines, filename, _debugOut);
       break;
     case SERVICE_TYPE:
       rtn = new NagiosServiceObj();
       rtn.setDebugInfo(filename, _debugOut);
       rtn.parseCfg(cfgLines);
       break;
     case COMMAND_TYPE:
       rtn = new NagiosCommandObj();
       rtn.setDebugInfo(filename, _debugOut);
       rtn.parseCfg(cfgLines);
       break;
     case HOSTGROUP_TYPE:
       rtn = new NagiosHostGroupObj();
       rtn.setDebugInfo(filename, _debugOut);
       rtn.parseCfg(cfgLines);
       break;
     case RESOURCE_TYPE:
       rtn = new NagiosResourceObj();
       rtn.setDebugInfo(filename, _debugOut);
       rtn.parseCfg(cfgLines);
       break;
     default:
       throw new NagiosTypeNotSupportedException();
   }
   return rtn;
 }
Ejemplo n.º 2
0
 private static NagiosObj getHostObj(String cfgLines, String filename, PrintStream _debugOut)
     throws NagiosParserException {
   NagiosObj rtn;
   try {
     rtn = new NagiosHostObj();
     rtn.setDebugInfo(filename, _debugOut);
     rtn.parseCfg(cfgLines);
   } catch (NagiosParserException e) {
     rtn = new NagiosTemplateHostObj();
     rtn.setDebugInfo(filename, _debugOut);
     rtn.parseCfg(cfgLines);
   }
   return rtn;
 }