Check_sybase_databases

CMK version:
OMD - Open Monitoring Distribution Version 2.1.0p2.cee

OS version:
4.18.0-348.23.1.el8_5.x86_64 #1 SMP Tue Apr 12 11:20:32 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
Error message:
Traceback (most recent call last):
File “/omd/sites/RS5/bin/cmk”, line 98, in
exit_status = modes.call(“–check”, None, opts, args)
File “/omd/sites/RS5/lib/python3/cmk/base/modes/init.py”, line 69, in call
return handler(*handler_args)
File “/omd/sites/RS5/lib/python3/cmk/base/modes/check_mk.py”, line 1804, in mode_check
checking.commandline_checking(
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/decorator.py”, line 43, in wrapped_check_func
status, output_text = _combine_texts(check_func(hostname, *args, **kwargs))
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 121, in commandline_checking
return _execute_checkmk_checks(
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 174, in _execute_checkmk_checks
num_success, plugins_missing_data = check_host_services(
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 322, in check_host_services
success = _execute_check(
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 382, in _execute_check
submittable = get_aggregated_result(
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 469, in get_aggregated_result
result = _aggregate_results(
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 577, in _aggregate_results
perfdata, results = _consume_and_dispatch_result_types(subresults)
File “/omd/sites/RS5/lib/python3/cmk/base/agent_based/checking/init.py”, line 621, in _consume_and_dispatch_result_types
for subr in subresults:
File “/omd/sites/RS5/lib/python3/cmk/base/api/agent_based/register/check_plugins.py”, line 94, in filtered_generator
for element in generator(*args, **kwargs):
File “/omd/sites/RS5/lib/python3/cmk/base/api/agent_based/register/check_plugins_legacy.py”, line 176, in check_result_generator
subresults = sig_function(**kwargs)
File “/omd/sites/RS5/lib/python3/cmk/base/api/agent_based/register/check_plugins_legacy.py”, line 294, in check_migration_wrapper
return original_function(None, params, section)
File “/omd/sites/RS5/local/share/check_mk/checks/sybase_databases.py”, line 63, in check_sybase_databases
return 3, item + “not found”
TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘str’

script:sybase_databases.py
factory_settings[“sybase_database_default_values”] = {
“levels” : (80.0, 90.0, 75.0, 85.0)
}

def inventory_sybase_databases(info):
for line in info:
yield line[0] + line[1], “sybase_database_default_values”

def check_sybase_databases(item, params, info):
warndata, critdata, warnlog, critlog = params[“levels”]
for line in info:
server=line[0]
database=line[1]
if item == server + database:
status=int(line[6])
status2=int(line[7])
status3=int(line[8])
status4=int(line[9])
databasestatus=“”
if status & 256:
databasestatus=“Database suspect, "
if status2 & 16:
databasestatus+=“Database is offline, "
datasize=float(line[2])
dataused=float(line[3])
datausedpct=100*(dataused/datasize)
try:
logsize=float(line[4])
logused=float(line[5])
logusedpct=100*(logused/logsize)
except:
logsize=0.0
logused=0.0
logusedpct=0.0
outstring=”%sData used: %.2f%% Log used: %.2f%%” % (databasestatus, datausedpct, logusedpct)
perfdata=[(“data”, dataused, datasizewarndata/100, datasizecritdata/100, 0.0, datasize),
(“log”, logused, logsizewarnlog/100, logsizecritlog/100, 0.0, logsize)]
if datausedpct > critdata or logusedpct > critlog or databasestatus:
return 2, outstring, perfdata
if datausedpct > warndata or logusedpct > warnlog:
return 1, outstring, perfdata
return 0, outstring, perfdata
return 3, item + “not found”

check_info[“sybase_databases”] = {
“service_description” : “Sybase ASE Databases”,
“check_function” : check_sybase_databases,
“inventory_function” : inventory_sybase_databases,
‘has_perfdata’ : True,
“group” : “sybase_databases”,
“default_levels_variable” : “sybase_database_default_values”,
}

Agent local output
<<<sybase_databases:sep(44)>>>
SYB_REC_F
* ,master , 99.99996928, 11.20114688, 0, 0, 1, -32768, 131072, 16384,
.. truncated
<<<sybase_users:sep(44)>>>
SYB_REC_*** , 6,running ,
… Truncated

any idea ?
regards

This check is not part of CheckMK. Is it possible that this is a own made check?

Hi Andreas,
Thanks for your replay,
is true, but is used by CMK
this issue is occured by Python 3. ( OMD version

Any Hint?

AZARUS

As the code is not readable, i cannot say what you all need to change.
Please use the “Preformatted text” tag.
Inside the code you need to make sure that the variable “item” is not None. This must be a string.

Andreas,
bellow code used


#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# Sybase Database Usage

# columns in output of sybase_databases:
# 0: Servername
# 1: Databasename
# 2: total size of data segments in MB
# 3: used size of data segments in MB
# 4: total size of log segments in MB, may be NULL
# 5: used size of log segments in MB, may be NULL
# 6-9: status - flags

# default: data used warn, critical, log used warn, critical
factory_settings["sybase_database_default_values"] = {
    "levels" : (80.0, 90.0, 75.0, 85.0)
}

def inventory_sybase_databases(info):
    for line in info:
        yield line[0] + line[1], "sybase_database_default_values"

def check_sybase_databases(item, params, info):
    warndata, critdata, warnlog, critlog = params["levels"]
    for line in info:
        server=line[0]
        database=line[1]
        if item == server + database:
            # check status flags
            status=int(line[6])
            status2=int(line[7])
            status3=int(line[8])
            status4=int(line[9])
            # see http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36274.1550/html/tables/X42615.htm
            databasestatus=""
            if status & 256:
                databasestatus="Database suspect, "
            if status2 & 16:
                databasestatus+="Database is offline, "
            # usage
            datasize=float(line[2])*1048576
            dataused=float(line[3])*1048576
            datausedpct=100*(dataused/datasize)
            try:
                logsize=float(line[4])*1048576
                logused=float(line[5])*1048576
                logusedpct=100*(logused/logsize)
            except:
                logsize=0.0
                logused=0.0
                logusedpct=0.0
            outstring="%sData used: %.2f%% Log used: %.2f%%" % (databasestatus, datausedpct, logusedpct)
            perfdata=[("sybase_data", dataused, datasize*warndata/100, datasize*critdata/100, 0.0, datasize),
                      ("sybase_log", logused, logsize*warnlog/100, logsize*critlog/100, 0.0, logsize)]
            if datausedpct > critdata or logusedpct > critlog or databasestatus:
                return 2, outstring, perfdata
            if datausedpct > warndata or logusedpct > warnlog:
                return 1, outstring, perfdata
            return 0, outstring, perfdata
    **return 3, str(item) + "not found"**


# check declaration
check_info["sybase_databases"] = {
    "service_description"     : "Sybase ASE Databases",
    "check_function"          : check_sybase_databases,
    "inventory_function"      : inventory_sybase_databases,
    'has_perfdata'            : True,
    "group"                   : "sybase_databases",
    "default_levels_variable" : "sybase_database_default_values",
}

i use str (item) vs item and now i got
Sybase ASE Databases SYB_REC_** tempdb_user3 Nonenot found
Sybase ASE Databases SYB_REC_** tempdb_xlarge Nonenot found
Sybase ASE Databases SYB_REC_** tempdbsa Nonenot found

regards

output from Agent

SYB_REC_DB1 ,master                        ,                                    99.99996928,                                    11.20114688,                                           0,                                            0,     1, -32768,     131072,      16384,
SYB_REC_DB1 ,tempdb                        ,                                  4099.99998976,                                   367.96481536,                                           0,                                            0,    13, -32767,     131072,     540672,
SYB_REC_DB1 ,model                         ,                                     3.99998976,                                     1.82028288,                                           0,                                            0,     1, -32768,     131072,      16384,
SYB_REC_DB1 ,PRIX                          ,                                 22528.00000000,                                  1156.75189248,                                  2047.99997952,                                      8.00194560,    12,      1,     917504,      16384,
SYB_REC_DB1 ,tempdbsa                      ,                                  1024.00000000,                                     5.81834752,                                           0,                                            0,    13, -32767,     131328,     540672,
SYB_REC_DB1 ,PUSH                          ,                                  4096.00000000,                                    17.86718208,                                   499.99998976,                                      1.96874240,    13,      1,     131072,      16384,
SYB_REC_DB1 ,FPLOS                         ,                                 98304.00000000,                                   828.28314624,                                  3071.99997952,                                     12.14257152,    13,      1,     131072,      16384,
SYB_REC_DB1 ,LOCAL                         ,                                  7607.99995904,                                  6239.28504320,                                   599.99997952,                                      2.36521472,  8204,      1,    1179648,      16384,
SYB_REC_DB1 ,CDV                           ,                                 17384.00000000,                                  5050.83201536,                                   599.99997952,                                      2.36132352,  8205,      1,     131072,      16384,
SYB_REC_DB1 ,CENTRAL                       ,                                228115.99998976,                                 35319.04479232,                                  1799.99997952,                                      7.04882688,  8205,      1,     131072,      16384,
SYB_REC_DB1 ,GEO                           ,                                  1023.99997952,                                   386.66207232,                                    99.99998976,                                      0.40624128,    13,      1,    1179648,      16384,
SYB_REC_DB1 ,tempdb_user1                  ,                                  4096.00000000,                                    18.07810560,                                           0,                                            0,    13, -32767,     131328,     540672,
SYB_REC_DB1 ,tempdb_user2                  ,                                  4096.00000000,                                    34.74802688,                                           0,                                            0,    13, -32767,     131328,     540672,
SYB_REC_DB1 ,tempdb_user3                  ,                                  4096.00000000,                                    22.85350912,                                           0,                                            0,    13, -32767,     131328,     540672,
SYB_REC_DB1 ,WORKFPLOS                     ,                                 32768.00000000,                                   202.68163072,                                  1024.00000000,                                    138.04101632,    13,      1,     131072,      16384,
SYB_REC_DB1 ,tempdb_xlarge                 ,                                  8192.00000000,                                    33.80076544,                                           0,                                            0,    13, -32767,     131328,     540672,
SYB_REC_DB1 ,sybsystemdb                   ,                                   202.99999232,                                     2.69137920,                                           0,                                            0,     1, -32768,     131072,      16384,
SYB_REC_DB1 ,sybsystemprocs                ,                                   200.00000000,                                   140.60937216,                                           0,                                            0,     9, -32768,     131072,      16384,
<<<sybase_users:sep(44)>>>
SYB_REC_DB1 ,          3,running     ,
SYB_REC_DB1 ,          1,runnable    ,
SYB_REC_DB1 ,          3,alarm sleep ,
SYB_REC_DB1 ,         15,sleeping    ,
SYB_REC_DB1 ,          6,recv sleep  ,
SYB_REC_DB1 ,         10,max online engines                                                                                                                                                                                                                                             ,
SYB_REC_DB1 ,        500,number of user connections                                                                                                                                                                                                                                     ,
<<<sybase_locks:sep(44)>>>
SYB_REC_DB1 ,     4,          1,
SYB_REC_DB1 ,     1,          3,
SYB_REC_DB1 ,     6,          1,
SYB_REC_DB1 ,     3,          1,
<<<sybase_cache:sep(44)>>>
SYB_REC_DB1 ,default data cache            ,          99.9,
SYB_REC_DB1 ,DFT_TEMPDB                    ,          98.7,

Now i see the real problem - your check expects an item but your “check_info” section has no item.
change the line

"service_description"     : "Sybase ASE Databases",

to

"service_description"     : "Sybase ASE Databases %s",

and rediscover the host. Then your checks should work again.

Hello Andreas

Good Job .
its running as expected.
thanks .

I share here the code

OMD[RS5]:~$ cat "/omd/sites/RS5/local/share/check_mk/checks/sybase_databases.py"
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# Sybase Database Usage

# columns in output of sybase_databases:
# 0: Servername
# 1: Databasename
# 2: total size of data segments in MB
# 3: used size of data segments in MB
# 4: total size of log segments in MB, may be NULL
# 5: used size of log segments in MB, may be NULL
# 6-9: status - flags

# default: data used warn, critical, log used warn, critical
factory_settings["sybase_database_default_values"] = {
    "levels" : (80.0, 90.0, 75.0, 85.0)
}

def inventory_sybase_databases(info):
    for line in info:
        yield line[0] + line[1], "sybase_database_default_values"

def check_sybase_databases(item, params, info):
    warndata, critdata, warnlog, critlog = params["levels"]
    for line in info:
        server=line[0]
        database=line[1]
        if item == server + database:
            # check status flags
            status=int(line[6])
            status2=int(line[7])
            status3=int(line[8])
            status4=int(line[9])
            # see http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36274.1550/html/tables/X42615.htm
            databasestatus=""
            if status & 256:
                databasestatus="Database suspect, "
            if status2 & 16:
                databasestatus+="Database is offline, "
            # usage
            datasize=float(line[2])*1048576
            dataused=float(line[3])*1048576
            datausedpct=100*(dataused/datasize)
            try:
                logsize=float(line[4])*1048576
                logused=float(line[5])*1048576
                logusedpct=100*(logused/logsize)
            except:
                logsize=0.0
                logused=0.0
                logusedpct=0.0
            outstring="%sData used: %.2f%% Log used: %.2f%%" % (databasestatus, datausedpct, logusedpct)
            perfdata=[("sybase_data", dataused, datasize*warndata/100, datasize*critdata/100, 0.0, datasize),
                      ("sybase_log", logused, logsize*warnlog/100, logsize*critlog/100, 0.0, logsize)]
            if datausedpct > critdata or logusedpct > critlog or databasestatus:
                return 2, outstring, perfdata
            if datausedpct > warndata or logusedpct > warnlog:
                return 1, outstring, perfdata
            return 0, outstring, perfdata
    return 3, str(item) + "not found"


# check declaration
check_info["sybase_databases"] = {
    "service_description"     : "Sybase ASE Databases %s",
    "check_function"          : check_sybase_databases,
    "inventory_function"      : inventory_sybase_databases,
    'has_perfdata'            : True,
    "group"                   : "sybase_databases",
    "default_levels_variable" : "sybase_database_default_values",
}

CMK CAPTURE.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.