<commit_before><?xml version="1.0"?>
<scriptd-configuration>
	<engine language="beanshell" className="bsh.util.BeanShellBSFEngine" extensions="bsh"/>

	<start-script language="beanshell">

		import org.opennms.netmgt.snmp.SnmpTrapBuilder;
		import org.opennms.netmgt.config.DatabaseConnectionFactory;
		import org.opennms.netmgt.utils.SingleResultQuerier;

		log = bsf.lookupBean("log");
		snmpTrapHelper = new org.opennms.netmgt.scriptd.helper.SnmpTrapHelper();

	</start-script>

	<stop-script language="beanshell">

		snmpTrapHelper.stop();

		log.debug("executing a stop script");

	</stop-script>

	<event-script language="beanshell">

	event = bsf.lookupBean("event");

	if ((event.uei.equals("uei.opennms.org/nodes/nodeUp")) 
		|| (event.uei.equals("uei.opennms.org/nodes/nodeDown"))
		|| (event.uei.equals("uei.opennms.org/nodes/interfaceDown")) 
		|| (event.uei.equals("uei.opennms.org/nodes/interfaceUp")) 
		|| (event.uei.equals("uei.opennms.org/nodes/nodeLostService")) 
		|| (event.uei.equals("uei.opennms.org/nodes/nodeRegainedService")))
	{

		try {

		log.debug("Forwarding an OpenNMS event.");

		SnmpTrapBuilder trap = snmpTrapHelper.createV1Trap(".1.3.6.1.4.1.5813.1", "10.88.2.18", 6, 1, 0);

		t_dbid = new Integer(event.dbid).toString();
		if (t_dbid != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.1", "OctetString", "text", t_dbid);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.1", "OctetString", "text", "null");
		if (event.distPoller != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.2", "OctetString", "text", event.distPoller);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.2", "OctetString", "text", "null");
		if (event.creationTime != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.3", "OctetString", "text", event.creationTime);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.3", "OctetString", "text", "null");
		if (event.masterStation != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.4", "OctetString", "text", event.masterStation);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.4", "OctetString", "text", "null");
		if (event.uei != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.6", "OctetString", "text", event.uei);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.6", "OctetString", "text", "null");
		if (event.source != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.7", "OctetString", "text", event.source);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.7", "OctetString", "text", "null");
		t_nodeid = new Long(event.nodeid).toString();
		if (t_nodeid != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.8", "OctetString", "text", t_nodeid);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.8", "OctetString", "text", "null");
		if (event.time != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.9", "OctetString", "text", event.time);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.9", "OctetString", "text", "null");
		if (event.host != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.10", "OctetString", "text", event.host);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.10", "OctetString", "text", "null");
		t_interface = event.getInterface();
		if (t_interface != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.11", "OctetString", "text", t_interface);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.11", "OctetString", "text", "null");
		if (event.snmphost != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.12", "OctetString", "text", event.snmphost);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.12", "OctetString", "text", "einstein.ntrs.com");
		if (event.service != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.13", "OctetString", "text", event.service);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.13", "OctetString", "text", "null");
		if (event.descr != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.16", "OctetString", "text", event.descr);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.16", "OctetString", "text", "null");
		if (event.severity != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.18", "OctetString", "text", event.severity);
		else<commit_msg>Added logmsg to scriptd OpenNMS trap example.<commit_after><?xml version="1.0"?>
<scriptd-configuration>
	<engine language="beanshell" className="bsh.util.BeanShellBSFEngine" extensions="bsh"/>

	<start-script language="beanshell">

		import org.opennms.netmgt.snmp.SnmpTrapBuilder;
		import org.opennms.netmgt.config.DatabaseConnectionFactory;
		import org.opennms.netmgt.utils.SingleResultQuerier;

		log = bsf.lookupBean("log");
		snmpTrapHelper = new org.opennms.netmgt.scriptd.helper.SnmpTrapHelper();

	</start-script>

	<stop-script language="beanshell">

		snmpTrapHelper.stop();

		log.debug("executing a stop script");

	</stop-script>

	<event-script language="beanshell">

	event = bsf.lookupBean("event");

	if ((event.uei.equals("uei.opennms.org/nodes/nodeUp")) 
		|| (event.uei.equals("uei.opennms.org/nodes/nodeDown"))
		|| (event.uei.equals("uei.opennms.org/nodes/interfaceDown")) 
		|| (event.uei.equals("uei.opennms.org/nodes/interfaceUp")) 
		|| (event.uei.equals("uei.opennms.org/nodes/nodeLostService")) 
		|| (event.uei.equals("uei.opennms.org/nodes/nodeRegainedService")))
	{

		try {

		log.debug("Forwarding an OpenNMS event.");

		SnmpTrapBuilder trap = snmpTrapHelper.createV1Trap(".1.3.6.1.4.1.5813.1", "10.88.2.18", 6, 1, 0);

		t_dbid = new Integer(event.dbid).toString();
		if (t_dbid != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.1", "OctetString", "text", t_dbid);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.1", "OctetString", "text", "null");
		if (event.distPoller != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.2", "OctetString", "text", event.distPoller);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.2", "OctetString", "text", "null");
		if (event.creationTime != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.3", "OctetString", "text", event.creationTime);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.3", "OctetString", "text", "null");
		if (event.masterStation != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.4", "OctetString", "text", event.masterStation);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.4", "OctetString", "text", "null");
		if (event.uei != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.6", "OctetString", "text", event.uei);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.6", "OctetString", "text", "null");
		if (event.source != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.7", "OctetString", "text", event.source);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.7", "OctetString", "text", "null");
		t_nodeid = new Long(event.nodeid).toString();
		if (t_nodeid != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.8", "OctetString", "text", t_nodeid);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.8", "OctetString", "text", "null");
		if (event.time != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.9", "OctetString", "text", event.time);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.9", "OctetString", "text", "null");
		if (event.host != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.10", "OctetString", "text", event.host);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.10", "OctetString", "text", "null");
		t_interface = event.getInterface();
		if (t_interface != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.11", "OctetString", "text", t_interface);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.11", "OctetString", "text", "null");
		if (event.snmphost != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.12", "OctetString", "text", event.snmphost);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.12", "OctetString", "text", "einstein.ntrs.com");
		if (event.service != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.13", "OctetString", "text", event.service);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.13", "OctetString", "text", "null");
		if (event.descr != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.16", "OctetString", "text", event.descr);
		else
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.16", "OctetString", "text", "null");
                if (event.logmsg != null)
                        snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.17", "OctetString", "text", event.logmsg);
                else
                        snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.17", "OctetString", "text", "null");
		if (event.severity != null)
			snmpTrapHelper.addVarBinding(trap, ".1.3.6.1.4.1.5813.2.18", "OctetString", "text", event.severity);
		else
{'fraction_non_alphanumeric': 0.21188878235858102, 'fraction_numerical': 0.07925854905720678, 'mean_word_length': 4.08283703302653, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 2, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 60, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5380531', 'n_tokens_mistral': 4485, 'n_tokens_neox': 4072, 'n_words': 521}