I recently needed to understand actually how the ordering for the oids in an SNMP table need to be arranged for commands like snmpwalk and snmptable to correctly traverse a table.
So here is a MIB fragment for a table:
jmxTable OBJECT-TYPE
SYNTAX SEQUENCE OF jmxEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
::= { monMIB 2 }
jmxEntry OBJECT-TYPE
SYNTAX JmxEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
""
INDEX { routeIndex }
::= { jmxTable 1 }
JmxEntry ::= SEQUENCE {
routeIndex INTEGER,
routeName DisplayString,
contextName DisplayString,
exchangesFailed INTEGER
}
routeIndex OBJECT-TYPE
SYNTAX INTEGER
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
routeName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { jmxEntry 2 }
contextName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { jmxEntry 3 }
exchangesFailed OBJECT-TYPE
SYNTAX INTEGER
MAX-ACCESS read-only
STATUS current
DESCRIPTION
""
::= { jmxEntry 4 }
We've got a four column table with a visible integer index, two text columns and a numeric column.
It turns out the important thing is that getnext on jmxEntry.0 must return jmxEntry.1.1.
Of course jmxEntry.0 doesn't exist in the MIB, except for its ability to respond to getnext.
Sunday, 4 March 2012
command line xslt transforms
Just putting this here because I was asked to. How to transform a file using XSLT on the command line.
Here is a really simple xsl stylesheet to remove some elements from an xml file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="book[@name='X']"/>
</xsl:stylesheet>
</xsl:stylesheet>
Here is an xml file:
<?xml version="1.0" encoding="UTF-8"?>
<a>
<book name="X">
<title>A book</title>
</book>
<book name="Y">
<title>Another book</title>
</book>
</a>
Here is a command:
xsltproc x.xsl x.xml
And here is the output;
<?xml version="1.0"?>
<a>
<book name="Y">
<title>Another book</title>
</book>
</a>
Here is a really simple xsl stylesheet to remove some elements from an xml file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="book[@name='X']"/>
</xsl:stylesheet>
</xsl:stylesheet>
Here is an xml file:
<?xml version="1.0" encoding="UTF-8"?>
<a>
<book name="X">
<title>A book</title>
</book>
<book name="Y">
<title>Another book</title>
</book>
</a>
Here is a command:
xsltproc x.xsl x.xml
And here is the output;
<?xml version="1.0"?>
<a>
<book name="Y">
<title>Another book</title>
</book>
</a>
securing jmx
JMX is cool. Lots of Java stuff has fantastic management beans that work really well.
Too well.
I have Apache ActiveMQ and Apache Camel running under Tomcat and anyone can fire up a jconsole and do what they like to it.
Now I need to mediate this stuff to SNMP because that's what our management tool uses. I could setup all the JMX security with ssl and certificates, but I really just want it so only my SNMP sub-agent can talk to it. Now you'd think telling the socket to just listen on the loopback interface would be easy.
It is.
-Djava.rmi.server.hostname=127.0.0.1
Finding that out took ages. I got it from here. But the usually reliable stackoverflow gives a way overcomplicated answer.
Too well.
I have Apache ActiveMQ and Apache Camel running under Tomcat and anyone can fire up a jconsole and do what they like to it.
Now I need to mediate this stuff to SNMP because that's what our management tool uses. I could setup all the JMX security with ssl and certificates, but I really just want it so only my SNMP sub-agent can talk to it. Now you'd think telling the socket to just listen on the loopback interface would be easy.
It is.
-Djava.rmi.server.hostname=127.0.0.1
Finding that out took ages. I got it from here. But the usually reliable stackoverflow gives a way overcomplicated answer.
Subscribe to:
Posts (Atom)