[Check_mk (english)] Apache Status Plugin Help

I’m having trouble getting the apache_status check to show up in my inventory.

I have the plugin copied to the apache server with the config file. I can run it locally on the apache server and get the expected output…

$ /usr/share/check-mk-agent/plugins/apache_status

<<<apache_status>>>

localhost 90 Total Accesses: 1102337

localhost 90 Total kBytes: 14460075

localhost 90 CPULoad: .0463671

localhost 90 Uptime: 330040

localhost 90 ReqPerSec: 3.34001

localhost 90 BytesPerSec: 44864.6

localhost 90 BytesPerReq: 13432.5

localhost 90 BusyWorkers: 2

localhost 90 IdleWorkers: 11

localhost 90 Scoreboard: __W______W…._…

But when I telnet to the agent port or run an inventory against the host I get nothing…

$ telnet localhost 6556

<<>>

<<>>

<<<apache_status>>>

<<>>

[[[/var/log/messages]]]

Anyone have ideas about what I am missing here?

The apache status plugin:

https://mathias-kettner.de/checkmk_check_apache_status.html

You may transfer plugin apache_status in
/usr/lib/check_mk_agent/plugins that the content:

#!/usr/bin/python
# encoding: utf-8

# Check_MK-Agent-Plugin - Apache Server Status

···

2014-08-07 5:24 GMT+02:00 John Zimmerman <john.zimm@gmail.com>:

I'm having trouble getting the apache_status check to show up in my
inventory.

I have the plugin copied to the apache server with the config file. I can
run it locally on the apache server and get the expected output...

$ /usr/share/check-mk-agent/plugins/apache_status
<<<apache_status>>>
localhost 90 Total Accesses: 1102337
localhost 90 Total kBytes: 14460075
localhost 90 CPULoad: .0463671
localhost 90 Uptime: 330040
localhost 90 ReqPerSec: 3.34001
localhost 90 BytesPerSec: 44864.6
localhost 90 BytesPerReq: 13432.5
localhost 90 BusyWorkers: 2
localhost 90 IdleWorkers: 11
localhost 90 Scoreboard:
__W______W.._..._._.............................................................................................................................................................................................................................................

But when I telnet to the agent port or run an inventory against the host I
get nothing....

$ telnet localhost 6556
....
<<<job>>>
<<<local>>>
<<<apache_status>>>
<<<logwatch>>>
[[[/var/log/messages]]]
....

Anyone have ideas about what I am missing here?

_______________________________________________
checkmk-en mailing list
checkmk-en@lists.mathias-kettner.de
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

#
# Fetches the server-status page from detected or configured apache
# processes to gather status information about this apache process.
#
# To make this agent plugin work you have to load the status_module
# into your apache process. It is also needed to enable the "server-status"
# handler below the URL "/server-status".
#
# By default this plugin tries to detect all locally running apache processes
# and to monitor them. If this is not good for your environment you might
# create an apache_status.cfg file in MK_CONFDIR and populate the servers
# list to prevent executing the detection mechanism.
#
# It is also possible to override or extend the ssl_ports variable to make the
# check contact other ports than 443 with HTTPS requests.

import os, sys, urllib2, re

config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
config_file = config_dir + "/apache_status.conf"
if not os.path.exists(config_file):
    config_file = config_dir + "/apache_status.cfg"

# None or list of (proto, ipaddress, port) tuples.
# proto is 'http' or 'https'
servers = None
ssl_ports = [ 443, ]

if os.path.exists(config_file):
    execfile(config_file)

def try_detect_servers():
    pids =
    results =
    for line in os.popen('netstat -tlnp 2>/dev/null').readlines():
        parts = line.split()
        # Skip lines with wrong format
        if len(parts) < 7 or '/' not in parts[6]:
            continue

        pid, proc = parts[6].split('/', 1)
        to_replace = re.compile('^.*/')
        proc = to_replace.sub('', proc)

        procs = [ 'apache2', 'httpd', 'httpd2-prefork',
'httpd2-worker', 'httpd.worker' ]
        # the pid/proc field length is limited to 19 chars. Thus in case of
        # long PIDs, the process names are stripped of by that length.
        # Workaround this problem here
        procs = [ p[:19 - len(pid) - 1] for p in procs ]

        # Skip unwanted processes
        if proc not in procs:
            continue

        # Add only the first found port of a single server process
        if pid in pids:
            continue
        pids.append(pid)

        proto = 'http'
        address, port = parts[3].rsplit(':', 1)
        port = int(port)

        # Use localhost when listening globally
        if address == '0.0.0.0':
            address = '127.0.0.1'
        elif address == '::':
            address = '::1'

        # Switch protocol if port is SSL port. In case you use SSL on another
        # port you would have to change/extend the ssl_port list
        if port in ssl_ports:
            proto = 'https'

        results.append((proto, address, port))

    return results

if servers is None:
    servers = try_detect_servers()

if not servers:
    sys.exit(0)

print '<<<apache_status>>>'
for server in servers:
    if isinstance(server, tuple):
        proto, address, port = server
        page = 'server-status'
    else:
        proto = server['protocol']
        address = server['address']
        port = server['port']
        page = server.get('page', 'server-status')

    try:
        url = '%s://%s:%s/%s?auto' % (proto, address, port, page)
        # Try to fetch the status page for each server
        try:
            fd = urllib2.urlopen(url)
        except urllib2.URLError, e:
            if 'SSL23_GET_SERVER_HELLO:unknown protocol' in str(e):
                # HACK: workaround misconfigurations where port 443 is used for
                # serving non ssl secured http
                url = 'http://%s:%s/server-status?auto' % (address, port)
                fd = urllib2.urlopen(url)
            else:
                raise

        for line in fd.read().split('\n'):
            if not line.strip():
                continue
            if line.lstrip()[0] == '<':
                # seems to be html output. Skip this server.
                break
            print address, port, line
    except urllib2.HTTPError, e:
        sys.stderr.write('HTTP-Error (%s:%d): %s %s\n' % (address,
port, e.code, e))

    except Exception, e:
        sys.stderr.write('Exception (%s:%d): %s\n' % (address, port, e))

And:

You may create file apache_status.cfg in /etc/check_mk/ , with the
permission 400 with the content:

servers = [
{
'protocol' : 'http',
'address' : 'localhost',
'port' : 80 ,
},
{
'protocol' : 'https',
'address' : 'localhost',
'port' : 443 ,
},
]

And then discovery services from system monitoring...With web gui
check_mk or check_mk -II host

Regards

Hi John,

If you did not change anything in agent script your plugins folder should be /use/lib/check_mk_agent/plugins - but this should also be reported in the first lines of agent output.

When you put the plugin in the right folder and it’s executable you should get what you want.

HTH,
Marcel

​Thanks for looking…

My plugins directory is actually /usr/share/check-mk-agent/plugins. I’ve installed from the EPEL repository on CentOS 6.​ I also truncated the output…

The truncated output from telnet that includes the version/directories is as follows…

$ telnet localhost 6556

Trying ::1…

Connected to localhost.

Escape character is ‘^]’.

<<<check_mk>>>

Version: 1.2.4p2

AgentOS: linux

PluginsDirectory: /usr/share/check-mk-agent/plugins

LocalDirectory: /usr/share/check-mk-agent/local

SpoolDirectory: /etc/check-mk-agent/spool

AgentDirectory: /etc/check-mk-agent

…truncated output…

<<<postfix_mailq>>>

Mail queue is empty

<<>>

<<>>

<<<apache_status>>>

<<>>

[[[/var/log/messages]]]

[[[/var/log/auth.log:missing]]]

[[[/var/log/syslog:missing]]]

[[[/var/log/kern.log:missing]]]

Connection closed by foreign host.

The apache_status section shows up when I drop the plugin in the folder, but it isn’t actually sending any output via the client. I can execute it directly and get the expected output.

···

On Thu, Aug 7, 2014 at 1:58 AM, Marcel Schulte schulte.marcel@gmail.com wrote:

Hi John,

If you did not change anything in agent script your plugins folder should be /use/lib/check_mk_agent/plugins - but this should also be reported in the first lines of agent output.

When you put the plugin in the right folder and it’s executable you should get what you want.

HTH,
Marcel


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

Ok - figured it out. Thanks for looking everyone. Suggestions to check my paths helped.

When executing directly having the config apache_status.cfg file in the /etc/check_mk directory worked just fine. I think because I am installing the agent via the EPEL repository it wants the config files in /etc/check-mk-agent/. I copied the config files in there and now when the agent executes the plugin I get the expected output and the check is discovered on an inventory.

···

On Thu, Aug 7, 2014 at 5:09 PM, John Zimmerman john.zimm@gmail.com wrote:

​Thanks for looking…

My plugins directory is actually /usr/share/check-mk-agent/plugins. I’ve installed from the EPEL repository on CentOS 6.​ I also truncated the output…

The truncated output from telnet that includes the version/directories is as follows…

$ telnet localhost 6556

Trying ::1…

Connected to localhost.

Escape character is ‘^]’.

<<<check_mk>>>

Version: 1.2.4p2

AgentOS: linux

PluginsDirectory: /usr/share/check-mk-agent/plugins

LocalDirectory: /usr/share/check-mk-agent/local

SpoolDirectory: /etc/check-mk-agent/spool

AgentDirectory: /etc/check-mk-agent

…truncated output…

<<<postfix_mailq>>>

Mail queue is empty

<<>>

<<>>

<<<apache_status>>>

<<>>

[[[/var/log/messages]]]

[[[/var/log/auth.log:missing]]]

[[[/var/log/syslog:missing]]]

[[[/var/log/kern.log:missing]]]

Connection closed by foreign host.

The apache_status section shows up when I drop the plugin in the folder, but it isn’t actually sending any output via the client. I can execute it directly and get the expected output.

On Thu, Aug 7, 2014 at 1:58 AM, Marcel Schulte schulte.marcel@gmail.com wrote:

Hi John,

If you did not change anything in agent script your plugins folder should be /use/lib/check_mk_agent/plugins - but this should also be reported in the first lines of agent output.

When you put the plugin in the right folder and it’s executable you should get what you want.

HTH,
Marcel


checkmk-en mailing list

checkmk-en@lists.mathias-kettner.de

http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en

I’ve modified ldap.py to allow our OpenLDAP groups to control user roles for
userids matching ldap groups nagiosadmin and nagiosusers. This will have
to be manually changed after any updated OMD/Check_MK packages are installed.

I’ve submitted a bug report, but it could be months/years (if ever) before
the changes are accepted or rejected, so any feedback would be appreciated.

/omd/versions/1.11.20140718/share/check_mk/web/plugins/userdb/ldap.py

from:

    # if group could be found and user is a member, add the role
    if dn in ldap_groups and ldap_user['dn'] in ldap_groups[dn]['members']:
        roles.add(role_id)

to:

    # if group could be found and user is a member, add the role
    if dn in ldap_groups and user_id in ldap_groups[dn]['members']:
        roles.add(role_id)
        ldap_log('ROLE_SYNC -  added role ' + role_id + ' to user ' + user_id)