net-snmp: how do I register for a new enterprise trap? - c

I'm working with net-snmp and agentx. I have to register my enterprise OIDs for scalars and tables. For example:
netsnmp_register_read_only_scalar(...); // register my scalars
netsnmp_tdata_register(...); // register my table
Until I make those calls in my agentx code, my OIDs don't show up in snmpd.
My MIB file also has NOTIFICATION-TYPE definitions, such as:
myTrapTest NOTIFICATION-TYPE
STATUS current
DESCRIPTION "A sample trap."
::= { myNotifications 1 }
I took a look at #include <net-snmp/agent/agent_trap.h> but this file seems to be about sending traps, not registering custom ones.
My question: What do I call to register my trap definitions?

Turns out there is no registration required for traps. When I asked on the NET-SNMP mailing list, the answer I received was:
You need to 'register' variables/tables so that the master
agent knows which sub-agent to call/invoke (you versus the other guy)
when a particular OID is get/set, but...
You don't have to 'register' trap definitions, you simply have to
'send' the (correctly composed) notification (agentx-Notify-PDU).
(Source: http://permalink.gmane.org/gmane.network.net-snmp.user/35320 )

Related

action.devices.commands.OpenClose trait in Google Smart Home actions does not work properly

When I give command "Open the device 30 percent", the data received by intent fulfillment is
{
"command": "action.devices.commands.OpenClose",
"params": {
"followUpToken": "00f38e7b45edbc12fafce49c23568896b7feea58a8a4ba873f31abad7db96de28a25389a2987c7f8deff41afcb25fdffb2b81fe2",
"openPercent": 100
}
}
As shown above, the "openPercent" is not correctly interpreted. But if I give command "Close the device 70 percent", the data received by intent fulfillment is
{
"command": "action.devices.commands.OpenClose",
"params": {
"followUpToken": "00f38e7b4588ad650859efe30a46d7dcb565e3a7eea257919678d5cda32fd769f290298ec8c9d40d0eb3a1b52b0063921823a39d",
"openPercent": 30
}
}
So we can see that the "openPercent" is correctly interpreted for this command.
Just wondering what caused the action.devices.commands.OpenClose trait only works partially.
There are two main possibilities of what might be going wrong with the device trait on this one: Your execution might not be interpreted correctly by the Google systems, or your device definition might be in a way such that Google sends you a discrete fully open intent.
To check if the issue is with the interpretation, you can try typing out the command as well as speaking it via voice, to see if Google sends you different values with the execution intent. Please also try our different grammar, such as “Open the device 30 percent”, “Open the device”, “Set the device to 50 open”, “Partially open the device 60 percent” to see if any of these would help. It might be possible that your intent to open might be always recognized as “100%”.
The second possibility is that your device definition might lead Google to send you discrete states of fully open & fully close (or one of these, as in your case). To troubleshoot, please check your Sync response for any potential issues on how you define the trait attributes.

Using LDAP template to find certificate

Our organization stores signing certificates in Active Directory. We are using anonymous bind to search for them at a base DN (e.g. OU=MY ORG,dc=mydc,dc=org). I have been trying to use the Spring LdapTemplate to look them up, but no matter what method I use, I get the cryptic InterruptedNamingException.
Assuming a cert subject of cn=mycert.myorg.com
My code looks like this
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(String.format(LDAP_URL_FORMAT, ldapCertStoreParameters.getServerName(),
ldapCertStoreParameters.getPort()));
contextSource.setBase(ldapCertStoreParameters.getBaseDn());
contextSource.setAnonymousReadOnly(true);
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setIgnorePartialResultException(true);
ldapTemplate.afterPropertiesSet();
X500Principal principal = x509CertSelector.getSubject();
Object obj = ldapTemplate.lookup(new LdapName(principal.getName()));
The X500 principal's name is the whole dn. cn=mycert.myorg.com,OU=MY ORG,dc=mydc,dc=org
I have also tried the search using just the cn.
We have verified that the DN exists on the server using Apache Directory Studio.
• I would suggest you to please remove the call altogether or set the ‘userSearchBase’ either to an empty String (“”) as per the given example in the below community thread: -
Configure Spring security for Ldap connection
As in the ‘AbstractContextSource’, set the base suffix from which all operations should origin. If a base suffix is set, you will not have to (and, indeed, must not) specify the full distinguished names in any operations performed. Since you specified the full DN for the userDN/filter, you must not specify the base.
AD servers are apparently unable to handle referrals automatically, which causes a ‘PartialResultException’ to be thrown whenever a referral is encountered in a search. To avoid this, set the ‘ignorePartialResultException’ property to true. There is currently no way of manually handling these referrals in the form of ‘ReferralException’, i.e., either you get the exception (and your results are lost) or all referrals are ignored (if the server is unable to handle them properly). Neither is there any simple way to get notified that a ‘PartialResultException’ has been ignored.
For more details regarding the LDAP template search for Active Directory stored certificates, kindly refer to the link below: -
https://docs.spring.io/spring-ldap/docs/current/apidocs/org/springframework/ldap/core/LdapTemplate.html
• Also, please try to refer to the below documentation for configuration of Springboot LDAP template configuration through certificates stored in Active Directory: -
https://www.baeldung.com/x-509-authentication-in-spring-security

Parameter subscription must conform to pattern ^projects/[^/]+subscriptions/[^/]+$

.I am trying to create a data fusion pipeline which fetches data from pub sub and the used projection to convert message into string (as told by you) and thens ave it to GCS.
howeer,its giving me error: Parameter subscription must conform to pattern ^projects/[^/]+subscriptions/[^/]+$
I am using correct topic and subsctiption name projects/test/subscriptions/dataFusionSubscribe projects/test/topics/DataFusionTopic
You don't need to include the full subscription and topic name in the config, you only need to provide project id as test, subscription id as dataFusionSubscribe, and topic as DataFusionTopic
Attached is a screenshot showing the config for the Pubsub

Getting more info from snmp traps

I have some Windows PCs sending snmpt traps to a linux server. On the server a snmptt trap handler, that works fine except for one issue.
Windows sends out traps with a description (say "Adobe Flash player update service stopped"). My problem is I don't know how to receive this description. Using snmptt (link to doc page), I only get the trapoid,community, category, uptime, hostname, etc, but no description.
Problem is that the Windows trapOID only states that "a service has been stopped". You understand that this is not a very useful info.
With tcpdump I can see the trap coming:
> { SNMPv1 C=dst0pc10 { Trap(298)
> E:311.1.13.1.23.83.101.114.118.105.99.101.32.67.111.110.116.114.111.108.32.77.97.110.97.103.101.114 78.168.1.161 enterpriseSpecific s=1073748860 1213932 E:311.1.13.1.9999.1.0=49_6c_20_73_65_72_76_69_7a_69_6f_20_48_50_20_50_6f_72_74_20_52_65_73_6f_6c_76_65_72_20_e8_20_6f_72_61_20_69_6e_20_6d_6f_64_61_6c_69_74_e0_20_61_72_72_65_73_74_61_74_6f_2e_0d_0a
> E:311.1.13.1.9999.2.0="Unknown" E:311.1.13.1.9999.3.0="PCMAGA"
> E:311.1.13.1.9999.4.0="4" E:311.1.13.1.9999.5.0="0"
> E:311.1.13.1.9999.6.0="HP Port Resolver"
> E:311.1.13.1.9999.7.0="stopped" } }
I have big difficulties in understanding how to receive and log those descriptions. Any clue?
Ok, posting a question here usually boost my luck. I've found this simple answer:
In snmptt.conf file, the FORMAT directive could be set as
FORMAT $*
to put all the description in the "formatline" field of the database generated by snmptt.
Another problem arise, hope I can work it out soon: some descrption are in HEX format. Got to find a way to convert them.

using default exchange in rabbitmq-c

I am trying to connect to rabbitmq-c in centos 5.6 and test its function in c client following the steps of the website: http://www.rabbitmq.com/tutorials/tutorial-one-java.html.
However, it fails when I use the default exchange.
For example, I want to send a message, "Hello world", to a queue named "myqueue" via the default exchange whose name is "(AMQP default)".
In java, here is the code:
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
But in c, when I run rmq_new_task.c (almost the same as amqp_sendstring.c) as the examples on https://github.com/liuhaobupt/rabbitmq_work_queues_demo-with-rabbit-c-client-lib.
queuename="myqueue";
......
die_on_error(amqp_basic_publish(conn, amqp_cstring_bytes(exchange),
amqp_cstring_bytes(routingkey), &props, amqp_cstring_bytes("Hello world")),
"Publishing");
In the java client, we just set the parameter "exchange" to "" to tell the server that we'd send the message to a specified queue named the same as routingkey via the default exchange.
So what value should I give the second parameter "exchange" in c client (using the default exchange)? I tried to set it to "" or "amq.direct". It didnot show any error while running and seemed working well.
However, when I checked in the rabbitmq-management(http://localhost:55672/#/queues), the queue named "myqueue" did not exist!
Would someone please point me to the right direction? I'd really appreciate!
Take a look at http://www.rabbitmq.com/tutorials/amqp-concepts.html and specifically look for the section entitled Default Exchange.
The usage of the default exchange is very simple.
In java you would do:
channel.basicPublish("", "hello", null, message.getBytes());
By specifying "" in says to use the default exchange. (There should be no need to use amq.direct)
As per the article above it states:
The default exchange is a direct exchange with no name (empty string)
pre-declared by the broker. It has one special property that makes it
very useful for simple applications: every queue that is created is
automatically bound to it with a routing key which is the same as the
queue name.
So that means publishing to the default exchange will only work if you have already created the queue that you want to publish to.
So you will need to create your queue before you can publish to the default exchange. Once you've done that you will start seeing your messages.

Resources