/** * Print out a message and stack trace and then exit. * This method does not return. * * @param message message to print to System.err * @param t Throwable for which to print a stack trace */ private void die(String message, Throwable t) { LogUtils.errorf(this, t, message); System.exit(1); }
public void run() { try { processPackets(replyQueue); } catch (Throwable t) { LogUtils.errorf(this, t, "Unexpected exception on Thread %s!", this); } } };
int invokeOperation(String operation) { Authenticator.setDefault(getAuthenticator()); String urlString = getInvokeUrl() + "&operation=" + operation; try { URL invoke = new URL(urlString); HttpURLConnection connection = (HttpURLConnection) invoke.openConnection(); connection.setReadTimeout(getHttpRequestReadTimeout()); InputStream in = connection.getInputStream(); int ch; while ((ch = in.read()) != -1) { System.out.write((char) ch); } in.close(); System.out.println(""); System.out.flush(); } catch (final ConnectException e) { LogUtils.errorf(this, e, "error when attempting to fetch URL \"%s\"", urlString); if (isVerbose()) { System.out.println(e.getMessage() + " when attempting to fetch URL \"" + urlString + "\""); } return 1; } catch (final Throwable t) { LogUtils.errorf(this, t, "error invoking %s operation", operation); System.out.println("error invoking " + operation + " operation"); return 1; } return 0; }
/** * <p>check</p> * * @return a int. */ public int check() { try { new DatabaseChecker().check(); } catch (final Throwable t) { LogUtils.errorf(this, t, "error invoking check command"); return 1; } return 0; }
void processPackets(Queue<PingReply> pendingReplies) { while (true) { try { DatagramPacket packet = m_socket.receive(); PingReply reply = IcmpMessenger.createPingReply(packet); if (reply.isEchoReply() && reply.getIdentity() == FILTER_ID) { LogUtils.debugf(this, "Found an echo packet addr = %s, port = %d, length = %d, created reply %s", packet.getAddress(), packet.getPort(), packet.getLength(), reply); pendingReplies.offer(reply); } } catch (IOException e) { LogUtils.errorf(this, e, "I/O Error occurred reading from ICMP Socket"); } catch (IllegalArgumentException e) { // this is not an EchoReply so ignore it } catch (IndexOutOfBoundsException e) { // this packet is not a valid EchoReply ignore it } catch (Throwable e) { LogUtils.errorf(this, e, "Unexpected Exception processing reply packet!"); } } }
String message = "Error creating URL object for invoke URL: '" + url + "'"; System.err.println(message); LogUtils.errorf(this, e, message); String message = "Error invoking status command"; System.err.println(message); LogUtils.errorf(this, t, message); return 1; LogUtils.errorf(this, "Unknown status returned from statusGetter.getStatus(): %s", statusGetter.getStatus()); return 1;
for (final String dataSource : m_required) { if (!m_dataSources.containsKey(dataSource)) { LogUtils.errorf(this, "Required data source '%s' is missing from opennms-datasources.xml", dataSource); dataSourcesFound = false; final String errorMessage = "Unable to connect to data source '%s' at URL '%s' with username '%s', check opennms-datasources.xml and your database permissions."; if (m_required.contains(name)) { LogUtils.errorf(this, errorMessage, name, dataSource.getUrl(), dataSource.getUserName()); throw new InvalidDataSourceException("Data source '" + name + "' failed.", t); } else {
public void run() { try { while (true) { DatagramPacket pkt = m_socket.receive(); PingReply reply; try { reply = org.opennms.netmgt.ping.IcmpMessenger.createPingReply(pkt); } catch (Throwable t) { // do nothing but skip this packet continue; } if (reply.isEchoReply() && reply.getIdentity() == m_icmpId) { float rtt = reply.getPacket().elapsedTime(TimeUnit.MILLISECONDS); System.out.println(ICMPEchoPacket.getNetworkSize() + " bytes from " + InetAddressUtils.str(pkt.getAddress()) + ": icmp_seq=" + reply.getPacket().getIdentifier() + ". time=" + rtt + " ms"); } } } catch (final Throwable t) { LogUtils.errorf(this, t, "An exception occured processing the datagram, thread exiting."); System.exit(1); } } }
/** {@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); }
if (attrib.getName().equals("AuthenticationMethod")) { if (!attrib.getValue().getContent().equals("basic")) { LogUtils.errorf(this, "AuthenticationMethod is \"%s\", but only \"basic\" is supported", attrib.getValue()); return null;