diff --git a/bin/check_apache b/bin/check_apache index c4e6dbd..063dbaf 100755 --- a/bin/check_apache +++ b/bin/check_apache @@ -1,4 +1,5 @@ #!/usr/bin/python +# https://github.com/gpmidi/zabbix-apache-stats/blob/master/bin/check_apache """ Fetch Apache stats via mod_status and send to Zabbix By Paulson McIntyre @@ -43,7 +44,7 @@ def setLogLevel(loglevel): logger.setLevel(numeric_loglevel) log_handler = logging.handlers.SysLogHandler( address = '/dev/log' ) - #log_handler = logging.StreamHandler(sys.stdout) + # log_handler = logging.StreamHandler(sys.stdout) logger.addHandler( log_handler ) return logger @@ -94,14 +95,15 @@ def zabbix_sender(payload, agentconfig = None, zabbixserver = None, zabbixport = logger.error('must specify agent configuration or server name to call zabbix_sender with') try: - p = Popen(sender_command, stdout = PIPE, stdin = PIPE, stderr = PIPE) - out, err = p.communicate( input = payload ) - ret = p.wait() + try: + p = Popen(sender_command, stdout = PIPE, stdin = PIPE, stderr = PIPE) + out, err = p.communicate( input = payload ) + ret = p.wait() + except Exception: + t, e = sys.exc_info()[:2] + err = "%s\nFailed to execute: '%s'" % (e, " ".join(sender_command)) result = 1 - except Exception, e: - err = "%s\nFailed to execute: '%s'" % (e, " ".join(sender_command)) - finally: if ret != 0: raise Exception("error returned from %s! ret: %d, out: '%s', err: '%s'" % (sender_command[0], ret, out.strip('\n'), err.strip('\n'))) @@ -313,12 +315,14 @@ def main(): try: server_status = fetchURL(opts.url, user = opts.user, passwd = opts.passwd) - except Exception as e: + except Exception: + t, e = sys.exc_info()[:2] zbx_fail('failed to read server-status: %s' % e) try: data = parse( data = server_status, version = opts.statusvers ) - except Exception as e: + except Exception: + t, e = sys.exc_info()[:2] zbx_fail('failed to parse server-status: %s' % e) payload = "" @@ -333,7 +337,8 @@ def main(): payload = payload, agentconfig = opts.agentconfig, senderloc = opts.senderloc ) - except Exception as e: + except Exception: + t, e = sys.exc_info()[:2] zbx_fail('failed to send parsed data: %s' % e) else: # return value for apache.status item @@ -350,10 +355,12 @@ def main(): zabbixserver = opts.zabbixserver, zabbixport = opts.zabbixport, senderloc = opts.senderloc ) - except Exception as e: + except Exception: + t, e = sys.exc_info()[:2] zbx_fail('failed to send parsed data: %s' % e) if __name__ == "__main__": loglevel = 'debug' logger = setLogLevel(loglevel) main() + diff --git a/conf/Template_App_Apache_Status-3.0.es.xml b/conf/Template_App_Apache_Status-3.0.es.xml new file mode 100644 index 0000000..081c28c --- /dev/null +++ b/conf/Template_App_Apache_Status-3.0.es.xml @@ -0,0 +1,1190 @@ + + + 3.0 + 2016-11-14T14:03:53Z + + + App Templates + + + Templates + + + + + + + + {Plantilla_Apache_Estado:apache.status.last()}=0 + 0 + + {HOST.NAME} Apache - Apache Caido + 0 + + + 0 + 2 + + 0 + 0 + + + + + + + Apache - Estadísticas + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 2 + 0 + 0000C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[BytesPerSec] + + + + 3 + 0 + C800C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[CPULoad] + + + + 0 + 0 + C80000 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[BusyWorkers] + + + + 4 + 0 + 00C8C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[ReqPerSec] + + + + 1 + 0 + 00C800 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[BytesPerReq] + + + + + + Apache - Workers + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 1 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 2 + 0 + 0000C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Gracefullyfinishing] + + + + 1 + 0 + 00C800 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[DNSLookup] + + + + 3 + 0 + C800C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Idlecleanupofworker] + + + + 11 + 0 + 009696 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[IdleWorkers] + + + + 0 + 0 + C80000 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Closingconnection] + + + + 9 + 0 + 000096 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Startingup] + + + + 4 + 0 + 00C8C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Keepaliveread] + + + + 5 + 0 + C8C800 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Logging] + + + + 10 + 0 + 960096 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[WaitingforConnection] + + + + 8 + 0 + 009600 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[SendingReply] + + + + 7 + 0 + 960000 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[ReadingRequest] + + + + 6 + 0 + C8C8C8 + 0 + 2 + 0 + + Plantilla_Apache_Estado + apache[Openslotwithnocurrentprocess] + + + + + + + diff --git a/conf/Template_App_Apache_Status-3.0.xml b/conf/Template_App_Apache_Status-3.0.xml index 4ea16e2..102b5e3 100644 --- a/conf/Template_App_Apache_Status-3.0.xml +++ b/conf/Template_App_Apache_Status-3.0.xml @@ -922,6 +922,24 @@ + + + {Template_App_Apache_Status:apache.status.last()}=0 + 0 + + {HOST.NAME} Apache - Apache is Down + 0 + + + 0 + 2 + + 0 + 0 + + + + Apache Stats @@ -1169,3 +1187,4 @@ +