# 2 Monitoring of Specific Applications

#### AS/400

IBM AS/400 platform can be monitored using SNMP. More information is
available at
<http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg244504.html?Open>.

#### MySQL

Configuration file misc/conf/zabbix\_agentd.conf contains list of
parameters that can be used for monitoring of MySQL.

    ### Set of parameter for monitoring MySQL server (v3.23.42 and later)
    ### Change -u and add -p if required
    #UserParameter=mysql[ping],mysqladmin -uroot ping|grep alive|wc -l
    #UserParameter=mysql[uptime],mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
    #UserParameter=mysql[threads],mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
    #UserParameter=mysql[questions],mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
    #UserParameter=mysql[slowqueries],mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
    #UserParameter=mysql[qps],mysqladmin -uroot status|cut -f9 -d":"
    #UserParameter=version[mysql],mysql -V

##### mysql\[ping\]

Check whether MySQL is alive

        Result: 0 - not started 1 - alive

##### mysql\[uptime\]

Number of seconds MySQL is running

##### mysql\[threads\]

Number of MySQL threads

##### mysql\[questions\]

Number of processed queries

##### mysql\[slowqueries\]

Number of slow queries

##### mysql\[qps\]

Queries per second

##### mysql\[version\]

Version of MySQL Example: mysql Ver 11.16 Distrib 3.23.49, for
pc-linux-gnu (i686)

#### Mikrotik routers

Use SNMP agent provided by Mikrotik. See <http://www.mikrotik.com> for
more information.

#### WIN32

Use Zabbix W32 agent included (pre-compiled) into Zabbix distribution.

#### Novell

Use MRTG Extension Program for NetWare Server (MRTGEXT.NLM) agent for
Novell. The agent is compatible with protocol used by Zabbix. It is
available from <http://forge.novell.com/modules/xfmod/project/?mrtgext>.

Items have to be configured of type Zabbix Agent and must have keys
according to the MRTGEXT documentation.

For example:

\*\* UTIL1 \*\*

1 minute average CPU utilization

\*\* CONNMAX \*\*

Max licensed connections used

\*\* VFKSys \*\*

bytes free on volume Sys:

Full list of parameters supported by the agent can be found in
readme.txt, which is part of the software.

#### Tuxedo

Tuxedo command line utilities tmadmin and qmadmin can be used in
definition of a UserParameter in order to return per
server/service/queue performance counters and availability of Tuxedo
resources.

#### Informix

Standard Informix utility **onstat** can be used for monitoring of
virtually every aspect of Informix database. Also, Zabbix can retrieve
information provided by Informix SNMP agent.

#### JMX

First of all, you need to configure your jvm to allow jmx monitoring.
How do you know if you can do this? You can use the sun jconsole utility
that comes with the jdk and point it at your machine running the jvm. If
you can connect, you are good.

In my tomcat environment, I enable it by setting the following options
for the jvm:

    -Dcom.sun.management.jmxremote \
    -Dcom.sun.management.jmxremote.port=xxxxx \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=true \
    -Dcom.sun.management.jmxremote.password.file=/path/java/jre/lib/management/jmxremote. password"

This tells the jmx server to run on port XXXXX, to use password
authentication, and to refer to the passwords stored in the
jmxremote.password file. See the sun docs on jconsole for details. (You
might consider enabling ssl to make the connection more secure.)

Once that is done, I can then run jconsole and see everything that is
currently exposed (and to verify that I can connect properly). jconsole
will also provide you the information you need to query specific jmx
attributes from the information tab.

Now, since I use Tomcat, there are two ways that I can grab the jmx
attribute values (or effect a jmx operation). The first way is I can use
the servlet provided by Tomcat. (Don't know what jboss has). The second
way is I can send well formatted requests via a jmx command line tool.

Let's say I am interested in peak threads used by the system. I browse
down through the jmx objects via jconsole, find it under java.lang,
Threading. After selecting Threading, I click on the info tab, and I can
see the name of the mbean is "java.lang:type=Threading"

With tomcat, I can do the following:

    curl -s -u<jmxusername>:<jmxpassword> 'http://<tomcat_hostname>/manager/jmxproxy/?qry=java.lang:type=Threading'

where the jmx username and password are the ones defined in the file
defined in the jvm options above, the qry string is the one obtained
from jconsole.

The output from this will be all the metrics from this jmx key. Parse
the output and grab the number of your choice.

If you don't have a servlet that will allow you to make a http request
to the jmx interface, you can use the command line tool like this

    /<pathTo>/java -jar /<pathTo>/cmdline-jmxclient.jar <jmxusername>:<jmxpassword> <jvmhostname>:<jmxport> java.lang:type=Threading PeakThreadCount

The difference with the command line client is you need to specify the
attribute you are interested in specifically. Leaving it out will give
you a list of all the attributes available under Threading.

Again, parse the output for the data of your choice.

Once you can reliably grab the data you are interested in, you can then
turn that command into a zabbix userparm. e.g.

    UserParameter=jvm.maxthreads, /usr/bin/curl -s -u<jmxusername>:<jmxpassword> 'http://<tomcat_hostname>/manager/jmxproxy/?qry=java.lang:type=Threading' | /bin/awk '/^PeakThreadCount\:/ { gsub( /[^0123456789]/, "" ); print $1 }'

or

    UserParameter=jvm.maxthreads, /<pathTo>/java -jar /<pathTo>/cmdline-jmxclient.jar <jmxusername>:<jmxhostname> <jvmhostname>:<jmxport> java.lang:type=Threading PeakThreadCount | <some filter to grab just the number you need - left as an exercise to the reader>

That's it.

I prefer getting my stats from the servlet via http rather than using
the java command line client as it is much "lighter" to start up and
grab the information.

Need a command line jmx client? I use the one from here:
<http://crawler.archive.org/cmdline-jmxclient/>

Information on setting up jmx monitoring for your jvms
<http://java.sun.com/j2se/1.5.0/docs>...ment/agent.html

General Information on JMX
<http://java.sun.com/j2se/1.5.0/docs>...verviewTOC.html

::: notetip
Apparently the 1.5 jvm also supports SNMP which provides
another option.
:::
