/** * <p>errorf</p> * * @param format a {@link java.lang.String} object. * @param args a {@link java.lang.Object} object. */ protected void errorf(final String format, final Object... args) { log().error(String.format(format, args)); }
/** * <p>errorf</p> * * @param t a {@link java.lang.Throwable} object. * @param format a {@link java.lang.String} object. * @param args a {@link java.lang.Object} object. */ protected void errorf(final Throwable t, final String format, final Object... args) { log().error(String.format(format, args), t); }
/** * <p>shutdownAndWaitForCompletion</p> * * @param executorService a {@link java.util.concurrent.ExecutorService} object. * @param msg a {@link java.lang.String} object. */ public void shutdownAndWaitForCompletion(ExecutorService executorService, String msg) { executorService.shutdown(); try { while (!executorService.awaitTermination(10, TimeUnit.SECONDS)) { // loop util the await returns false } } catch (InterruptedException e) { log().error(msg, e); } }
private OnmsNode findNodeByNodeLabel(String label) { Collection<OnmsNode> nodes = getNodeDao().findByLabel(label); if (nodes.size() == 1) { return nodes.iterator().next(); } log().error("Unable to locate a unique node using label "+label+" "+nodes.size()+" nodes found. Ignoring relationship."); return null; }
private void closeQuietly(Snmp session) { if (session == null) { return; } try { session.close(); } catch (IOException e) { ThreadCategory.getInstance(Snmp4JStrategy.class).error("error closing SNMP connection: " + e, e); } } }
private void finish() { signal(); try { close(); } catch (IOException e) { log().error(getName()+": Unexpected Error occured closing snmp session for: "+m_address, e); } }
session = agentConfig.createSnmpSession(); } catch (IOException e) { log().error("send: Could not create SNMP session for agent " + agentConfig + ": " + e, e); return new SnmpValue[] { null }; session.listen(); } catch (IOException e) { log().error("send: error setting up listener for SNMP responses: " + e, e); return new SnmpValue[] { null }; log().error("send: error during SNMP operation: " + e, e); return new SnmpValue[] { null }; } catch (Throwable e) { log().error("send: unexpected error during SNMP operation: " + e, e); return new SnmpValue[] { null };
/** * <p>start</p> */ public final void start() { setLoggingCategory(); setStatus(Fiber.STARTING); SpringServiceDaemon daemon = getDaemon(); try { daemon.start(); } catch (Throwable t) { log().error("Could not start daemon: " + t, t); try { stop(); } catch (Throwable tt) { log().error("Could not stop daemon after it failed to start: " + tt, tt); } if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new UndeclaredThrowableException(t); } } setStatus(Fiber.RUNNING); }
parms[k] = getArgument(args[k]); } catch (Throwable t) { log().error("An error occurred building argument " + k + " for operation "+ invoke.getMethod() + " on MBean " + mbean.getObjectName() + ": " + t, log().error("An error occurred invoking operation " + invoke.getMethod() + " on MBean " + mbean.getObjectName() + ": " + t, t);
intOperand = new BigInteger(valueOperand); } catch (NumberFormatException nfe) { log.error("Failed to parse operand " + valueOperand + " or observed value " + replyVar.getValue() + " as a BigInteger, giving up"); log.info(nfe.getMessage()); throw new XmpUtilException("Operand '" + valueOperand + "' or observed value '" + replyVar.getValue() + "' is a malformed integer"); return (intValue.compareTo(intOperand) != 0); } else { log.error("Unknown value operator '" + valueOperator + "', giving up"); throw new XmpUtilException("Operator '" + valueOperator + "' unknown"); floatOperand = Float.parseFloat(valueOperand); } catch (NumberFormatException nfe) { log.error("Failed to parse operand " + valueOperand + " or observed value " + replyVar.getValue() + " as a Float, giving up"); log.info(nfe.getMessage()); throw new XmpUtilException("Operand '" + valueOperand + "' or observed value '" + replyVar.getValue() + "' is a malformed floating-point number"); return (floatValue != floatOperand); } else { log.error("Unknown value operator '" + valueOperator + "', giving up"); throw new XmpUtilException("Value operator '" + valueOperator + "' unknown"); log.debug("valueMeetsCriteria: operand " + valueOperand + " looks non-numeric, treating with String"); if (!EQUALS.equals(valueOperator)) { log.error("Value operator '" + valueOperator + "' does not apply for non-numeric value operand '" + valueOperand + "', giving up"); throw new XmpUtilException("Value operator '" + valueOperator + "' does not apply for non-numeric value operand '" + valueOperand + "'");
/** * Begins importing from resource specified in model-importer.properties file or * in event parameter: url. Import Resources are managed with a "key" called * "foreignSource" specified in the XML retreived by the resource and can be overridden * as a parameter of an event. * @param event */ private void doImport(Event event) { Resource resource = null; try { m_stats = new ImporterStats(); resource = ((event != null && getEventUrl(event) != null) ? new UrlResource(getEventUrl(event)) : m_importResource); sendImportStarted(resource); importModelFromResource(resource, m_stats, event); log().info("Finished Importing: "+m_stats); sendImportSuccessful(m_stats, resource); } catch (IOException e) { String msg = "IOException importing "+resource; log().error(msg, e); sendImportFailed(msg+": "+e.getMessage(), resource); } catch (ModelImportException e) { String msg = "Error parsing import data from "+resource; log().error(msg, e); sendImportFailed(msg+": "+e.getMessage(), resource); } }
protected PDU buildPdu(Snmp4JAgentConfig agentConfig, int pduType, SnmpObjId[] oids, SnmpValue[] values) { PDU pdu = agentConfig.createPdu(pduType); if (values == null) { for (SnmpObjId oid : oids) { pdu.add(new VariableBinding(new OID(oid.toString()))); } } else { // TODO should this throw an exception? This situation is fairly bogus and probably signifies a coding error. if (oids.length != values.length) { Exception e = new Exception("This is a bogus exception so we can get a stack backtrace"); log().error("PDU to prepare has object values but not the same number as there are OIDs. There are " + oids.length + " OIDs and " + values.length + " object values.", e); return null; } for (int i = 0; i < oids.length; i++) { pdu.add(new VariableBinding(new OID(oids[i].toString()), new Snmp4JValue(values[i].getType(), values[i].getBytes()).getVariable())); } } // TODO should this throw an exception? This situation is fairly bogus. if (pdu.getVariableBindings().size() != oids.length) { Exception e = new Exception("This is a bogus exception so we can get a stack backtrace"); log().error("Prepared PDU does not have as many variable bindings as there are OIDs. There are " + oids.length + " OIDs and " + pdu.getVariableBindings() + " variable bindings.", e); return null; } return pdu; }
/** {@inheritDoc} */ public void foundInterface(final String ipAddr, final Object descr, final InterfaceSnmpPrimaryType snmpPrimary, final boolean managed, final int status) { if ("".equals(ipAddr)) { log().error("Found interface on node "+m_node.getLabel()+" with an empty ipaddr! Ignoring!"); // create a bogus OnmsIpInterface and set it to current to services we run across get ignored as well m_currentInterface = new OnmsIpInterface(); return; } m_currentInterface = new OnmsIpInterface(ipAddr, m_node); m_currentInterface.setIsManaged(status == 3 ? "U" : "M"); m_currentInterface.setIsSnmpPrimary(PrimaryType.get(snmpPrimary.toString())); //m_currentInterface.setIpStatus(status == 3 ? new Integer(3) : new Integer(1)); if (InterfaceSnmpPrimaryType.P.equals(snmpPrimary)) { final InetAddress addr = InetAddressUtils.addr(ipAddr); if (addr == null) { LogUtils.errorf(this, "Unable to resolve address of snmpPrimary interface for node %s", m_node.getLabel()); } m_collector = new IfSnmpCollector(addr); } //FIXME: verify this doesn't conflict with constructor. The constructor already adds this //interface to the node. m_node.addIpInterface(m_currentInterface); }
XmpCollectionFactory.init(); } catch (Throwable e) { log().error("initialize: XmpCollectionFactory failed to initialize"); throw new UndeclaredThrowableException(e); XmpPeerFactory.init(); } catch (Throwable e) { log().error("initialize: XmpPeerFactory failed to initialize"); throw new UndeclaredThrowableException(e); XmpConfigFactory.init(); } catch (Throwable e) { log().error("initialize: config factory failed to initialize"); throw new UndeclaredThrowableException(e);
/** * <p>getObjectInstances</p> */ public void getObjectInstances() { for (InvokerService invokerService : getServices()) { Service service = invokerService.getService(); try { // find the mbean if (log().isDebugEnabled()) { log().debug("finding mbean instance " + service.getName()); } ObjectName name = new ObjectName(service.getName()); invokerService.setMbean(getServer().getObjectInstance(name)); } catch (Throwable t) { log().error("An error occurred loading the mbean " + service.getName() + " of type " + service.getClassName() + " it will be skipped", t); invokerService.setBadThrowable(t); } } }
return valueMeetsCriteria(replyVars[0], valueOperator, valueOperand, log, caseSensitive); } else { log.error("Observed MIB name (" + replyVars[0].getMibName() + ") or object name (" + replyVars[0].getObjName() + ") does not match specified MIB name (" + mib + ") or object name (" + object + "), giving up"); throw new XmpUtilException("Received unexpected response (MIB: " + replyVars[0].getMibName() + " Object: " + replyVars[0].getObjName());
log().error("Error while sending RESPONSE PDU to peer " + addr + ": " + ex.getMessage() + "acknowledging receipt of INFORM (reqId=" + command.getRequestID() + ")");
protected void doInTransactionWithoutResult(TransactionStatus status) { OnmsNode dbNode = findNodeByForeignId(m_foreignSource, node.getForeignId()); if (dbNode == null) { log().error("Error setting parent on node: "+node.getForeignId()+" node not in database"); return; } OnmsNode parent = findParent(node); OnmsIpInterface critIface = null; if (parent != null) { critIface = getCriticalInterface(parent); } log().info("Setting parent of node: "+dbNode+" to: "+parent); dbNode.setParent(parent); log().info("Setting criticalInterface of node: "+dbNode+" to: "+critIface); if (critIface == null) { dbNode.setPathElement(null); } else { final String ipAddress = InetAddressUtils.str(critIface.getIpAddress()); dbNode.setPathElement(new PathElement(ipAddress, "ICMP")); } getNodeDao().update(dbNode); }
log().error("An error occurred loading the mbean " + service.getName() + " of type " + service.getClassName() + ": " + t,