@Override public Property newProperty(String key, Object val) { return new Property(key, val); }
@Override public Property newProperty(String key, Object val, String valType) { return new Property(key, val, valType); }
/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @param transient_ * flag indicating whether property is transient * @return reference to this snapshot */ @Override public PropertySnapshot add(Object key, Object value, boolean transient_) { this.add(new Property(String.valueOf(key), value, transient_)); return this; }
/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @param valType * value type such as (currency, percent). See {@link ValueTypes}. * @return reference to this snapshot */ @Override public PropertySnapshot add(Object key, Object value, String valType) { this.add(new Property(key.toString(), value, valType)); return this; }
return new Property(getKey(key), pValue, getValueType(key));
throw new SAXParseException("<" + SIM_XML_PROP + ">: invalid type: " + type, saxLocator); return new Property(name, propValue, valType);
private boolean isDuplicate(TrackingEvent event, String msg) { if (msgTracker != null) { String key = dupUseSoundex? soundex.soundex(msg): msg; long hitCount = msgTracker.hitAndGetCount(key); if ((hitCount > 1) && (msgTracker.getHitAge(msg, TimeUnit.SECONDS) < dupTimeoutSec)) { msgTracker.missAndGetCount(key); return true; } else if (dupAppendStats && (event != null && hitCount > 1)) { event.getOperation().addProperty(new Property("_hitCount", hitCount, ValueTypes.VALUE_TYPE_COUNTER)); event.getOperation().addProperty(new Property("_missCount", msgTracker.getMissCount(key), ValueTypes.VALUE_TYPE_COUNTER)); event.getOperation().addProperty(new Property("_hit_last_age_ms", msgTracker.getHitAge(msg, TimeUnit.MILLISECONDS), ValueTypes.VALUE_TYPE_AGE_MSEC)); event.getOperation().addProperty(new Property("_miss_last_age_ms", msgTracker.getMissAge(msg, TimeUnit.MILLISECONDS), ValueTypes.VALUE_TYPE_AGE_MSEC)); } } return false; } }
double load = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); if (load >= 0) { cpu.add(new Property(DEFAULT_PROPERTY_LOAD_AVG, load, ValueTypes.VALUE_TYPE_GAUGE)); cpu.add(new Property(DEFAULT_PROPERTY_CPU_TIME, ((double) tmbean.getThreadCpuTime(ctx.ownerThread.getThreadId()) / 1000.0d), ValueTypes.VALUE_TYPE_AGE_USEC)); cpu.add(new Property(DEFAULT_PROPERTY_TOTAL_USER_TIME, ((double) tmbean.getThreadUserTime(ctx.ownerThread.getThreadId()) / 1000.0d), ValueTypes.VALUE_TYPE_AGE_USEC)); thread.add(new Property(DEFAULT_PROPERTY_COUNT, tmbean.getThreadCount(), ValueTypes.VALUE_TYPE_GAUGE)); thread.add(new Property(DEFAULT_PROPERTY_DAEMON_COUNT, tmbean.getDaemonThreadCount(), ValueTypes.VALUE_TYPE_GAUGE)); thread.add(new Property(DEFAULT_PROPERTY_STARTED_COUNT, tmbean.getTotalStartedThreadCount(), ValueTypes.VALUE_TYPE_COUNTER)); thread.add(new Property(DEFAULT_PROPERTY_PEAK_COUNT, tmbean.getPeakThreadCount(), ValueTypes.VALUE_TYPE_GAUGE)); if (ctx != null) { thread.add(new Property(DEFAULT_PROPERTY_BLOCKED_COUNT, ctx.ownerThread.getBlockedCount(), ValueTypes.VALUE_TYPE_COUNTER)); thread.add(new Property(DEFAULT_PROPERTY_WAITED_COUNT, ctx.ownerThread.getWaitedCount(), ValueTypes.VALUE_TYPE_COUNTER)); thread.add(new Property(DEFAULT_PROPERTY_BLOCKED_TIME, ctx.ownerThread.getBlockedTime() * 1000, ValueTypes.VALUE_TYPE_AGE_USEC)); thread.add(new Property(DEFAULT_PROPERTY_WAITED_TIME, ctx.ownerThread.getWaitedTime() * 1000, ValueTypes.VALUE_TYPE_AGE_USEC)); long usedMem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
@Override public void event(Object arg0, SyslogServerIF config, SocketAddress arg2, SyslogServerEventIF event) { Date date = (event.getDate() == null ? new Date() : event.getDate()); String facility = getFacilityString(event.getFacility()); OpLevel level = getOpLevel(event.getLevel()); TrackingEvent tevent = logger.newEvent(facility, event.getMessage()); tevent.getOperation().setSeverity(level); tevent.getOperation().addProperty(new Property("facility", facility)); tevent.getOperation().addProperty(new Property("hostname", event.getHost())); tevent.getOperation().addProperty(new Property("level", event.getLevel(), ValueTypes.VALUE_TYPE_ID)); if (arg2 instanceof InetSocketAddress) { InetSocketAddress from = (InetSocketAddress) arg2; tevent.getOperation().addProperty(new Property("hostaddr", from.getAddress().getHostAddress())); tevent.setLocation(from.getAddress().getHostAddress()); } else { tevent.setLocation(event.getHost()); } tevent.setCharset(config.getConfig().getCharSet()); if (event instanceof StructuredSyslogServerEvent) { processRFC5424(facility, (StructuredSyslogServerEvent) event, tevent); } else { processRFC3164(facility, event, tevent); } // extract name=value pairs if available extractVariables(event, tevent); String locationKey = tevent.getLocation() + "/" + tevent.getOperation().getResource(); tevent.stop(date.getTime() * 1000, getUsecSinceLastEvent(locationKey)); logger.tnt(tevent); }