From 32cb8c651e6ded997d511b7d8e1f689b59b976d8 Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Thu, 24 Mar 2016 09:59:29 +0100 Subject: [PATCH] Added first plugin --- README.md | 3 +- process-info/README.md | 8 ++ process-info/control | 17 +++ process-info/cpu-get.sh | 6 + process-info/proc-discovery.sh | 4 + process-info/template.xml | 204 +++++++++++++++++++++++++++++++++ 6 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 process-info/README.md create mode 100644 process-info/control create mode 100755 process-info/cpu-get.sh create mode 100755 process-info/proc-discovery.sh create mode 100644 process-info/template.xml diff --git a/README.md b/README.md index 39069e4..3c56e0e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # zaf-plugins -Zabbix Agent Framework plugins repository +Zabbix Agent Framework plugins repository. It contains working set of default plugins. Feel free to contribute. Or write your public and maintain control file on your site. + diff --git a/process-info/README.md b/process-info/README.md new file mode 100644 index 0000000..0a5b2f2 --- /dev/null +++ b/process-info/README.md @@ -0,0 +1,8 @@ +# Zaf plugin for detailed process info +This plugin is used to monitor process activity on linux based systems. It supports autodiscovery of processes and next to this it will show CPU and memory usage of each process. +Please note that this plugin is very simple plugin for domonstrating possibilities. It cannot catch all processes because it discovers processes in regular intervals and if process will start and end between this time, it will not be autodiscovered. + +## Usage + +zaf intall process-list + diff --git a/process-info/control b/process-info/control new file mode 100644 index 0000000..0ac27f0 --- /dev/null +++ b/process-info/control @@ -0,0 +1,17 @@ +Plugin: process-info + +Maintainer: Lukas Macura + +Item: cpu[*] + This item will return cpu usage of given process. In zabbix, it will be prefixed automaticaly by plugin name (processlist.cpu) +Item-cmd-cpu[*]: {PLUGINDIR}/cpu-get.sh + +Item: discovery + Discovery of runing processes +Item-cmd-discovery: {PLUGINDIR}/cpu-get.sh + +Binary-Depends: echo ps awk sort uniq sed + +Install-bin: cpu-get.sh proc-discovery.sh + + diff --git a/process-info/cpu-get.sh b/process-info/cpu-get.sh new file mode 100755 index 0000000..33cf9fe --- /dev/null +++ b/process-info/cpu-get.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +TOTAL=0 +for PROC in $(/bin/ps u -C $1 | /bin/grep -e '^$2' | /usr/bin/awk '{ print $$3 }'); do TOTAL=$(echo "$TOTAL $PROC" | /usr/bin/awk '{print $$1 + $$2}') ; done; +echo $TOTAL + diff --git a/process-info/proc-discovery.sh b/process-info/proc-discovery.sh new file mode 100755 index 0000000..80c6086 --- /dev/null +++ b/process-info/proc-discovery.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "{\n \"data\":[" ; /bin/ps --no-headers caux | /usr/bin/awk '{ print " { \"{#PSUSER}\":\"" $1 "\", \"{#PSNAME}\":\"" $11 "\" },"}' | /usr/bin/sort | /usr/bin/uniq | /bin/sed -e 's/\//\\\//g' -e '$s/.$//' ; echo " ]\n}" + diff --git a/process-info/template.xml b/process-info/template.xml new file mode 100644 index 0000000..7ddb186 --- /dev/null +++ b/process-info/template.xml @@ -0,0 +1,204 @@ + + + 3.0 + 2016-03-23T09:37:42Z + + + Templates + + + + + +