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
+ Plantilla_Apache_Estado
+
+
+ App Templates
+
+
+ Templates
+
+
+
+
+ Apache - Estadísticas
+
+
+ Apache - Workers
+
+
+
+ -
+ Apache - Bytes Por Petición
+ 2
+
+ 0
+
+ apache[BytesPerReq]
+ 0
+ 30
+ 365
+ 0
+ 0
+
+ B
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Bytes Por Segundo
+ 2
+
+ 0
+
+ apache[BytesPerSec]
+ 0
+ 30
+ 365
+ 0
+ 0
+
+ Bps
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Carga CPU
+ 2
+
+ 0
+
+ apache[CPULoad]
+ 0
+ 30
+ 365
+ 0
+ 0
+
+
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Peticiones Por Segundo
+ 2
+
+ 0
+
+ apache[ReqPerSec]
+ 60
+ 30
+ 365
+ 0
+ 0
+
+ r/s
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Accesos Totales
+ 2
+
+ 0
+
+ apache[TotalAccesses]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Transferencia de Datos Total
+ 2
+
+ 1
+
+ apache[TotalkBytes]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ B
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1024
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Uptime
+ 2
+
+ 0
+
+ apache[Uptime]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ s
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+
+ -
+ Apache - Estado
+ 0
+
+ 0
+
+ apache.status
+ 60
+ 30
+ 365
+ 0
+ 3
+
+
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+ Item usado para recopilar información a través de zabbix trappers.
+ 0
+
+
+ Apache - Estadísticas
+
+
+
+ Service state
+
+
+ -
+ Apache - Workers - Ocupados
+ 2
+
+ 0
+
+ apache[BusyWorkers]
+ 0
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workerss - Cerrando Conexión
+ 2
+
+ 0
+
+ apache[Closingconnection]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workerss - Búsqueda DNS
+ 2
+
+ 0
+
+ apache[DNSLookup]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workerss - Finalizando Normalmente
+ 2
+
+ 0
+
+ apache[Gracefullyfinishing]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workerss - Ocioso
+ 2
+
+ 0
+
+ apache[IdleWorkers]
+ 0
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workers - Idle cleanup of worker
+ 2
+
+ 0
+
+ apache[Idlecleanupofworker]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workers - Keepalive (lectura)
+ 2
+
+ 0
+
+ apache[Keepaliveread]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workers - Logueo
+ 2
+
+ 0
+
+ apache[Logging]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workers - Slots abiertos sin procesar actualmente
+ 2
+
+ 0
+
+ apache[Openslotwithnocurrentprocess]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workers - Leyendo Peticiones
+ 2
+
+ 0
+
+ apache[ReadingRequest]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workers - Enviando Respuesta
+ 2
+
+ 0
+
+ apache[SendingReply]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workerss - Inicializándose
+ 2
+
+ 0
+
+ apache[Startingup]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ Workers
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+ -
+ Apache - Workerss - Esperando Para Conexión
+ 2
+
+ 0
+
+ apache[WaitingforConnection]
+ 60
+ 30
+ 365
+ 0
+ 3
+
+ s
+ 0
+
+
+ 0
+ 0
+
+ 0
+
+ 1
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Apache - Workers
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {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 @@
+