diff options
author | Bala.FA <barumuga@redhat.com> | 2014-03-13 17:01:12 +0530 |
---|---|---|
committer | Bala.FA <barumuga@redhat.com> | 2014-04-29 10:21:36 +0530 |
commit | 940eef887f5142d980c91e95193e102c41d18808 (patch) | |
tree | 512ce98580612d9d48964776b263c5c7c0a9f949 /templates | |
parent | 981d905fd08d4565f306344c11c560a8479cbf75 (diff) |
all: import plugins/templates/config from githubv0.1.0
All plugins/templates/config are imported from
https://github.com/gluster-rhsc/nagios-plugin.git
Change-Id: Icbbf23c0595e2b36548015489341d9ff823bac50
Signed-off-by: Bala.FA <barumuga@redhat.com>
Reviewed-on: https://cuckoo.blr.redhat.com:8443/6
Diffstat (limited to 'templates')
-rw-r--r-- | templates/Makefile.am | 12 | ||||
-rw-r--r-- | templates/check_cpu_multicore.php | 102 | ||||
-rw-r--r-- | templates/check_disk_and_inode.php | 69 | ||||
-rw-r--r-- | templates/check_interfaces.php | 53 | ||||
-rw-r--r-- | templates/check_memory.php | 59 | ||||
-rw-r--r-- | templates/check_swap_usage.php | 41 |
6 files changed, 336 insertions, 0 deletions
diff --git a/templates/Makefile.am b/templates/Makefile.am new file mode 100644 index 0000000..ccd3006 --- /dev/null +++ b/templates/Makefile.am @@ -0,0 +1,12 @@ +pnp4nagiostemplatedir = $(datarootdir)/nagios/html/pnp4nagios/templates.dist +pnp4nagiostemplate_DATA = \ + check_cpu_multicore.php \ + check_disk_and_inode.php \ + check_interfaces.php \ + check_memory.php \ + check_swap_usage.php \ + $(NULL) + +EXTRA_DIST = \ + $(pnp4nagiostemplate_DATA) \ + $(NULL) diff --git a/templates/check_cpu_multicore.php b/templates/check_cpu_multicore.php new file mode 100644 index 0000000..0cb3942 --- /dev/null +++ b/templates/check_cpu_multicore.php @@ -0,0 +1,102 @@ +<?php +############################################################################ +# Author: Nishanth Thomas e-mail: nthomas@redhat.com # +############################################################################ +# PNP4Nagios Template: check_cpu_multicore.php (this file) # +# For Nagios Plugin: check_cpu_multicore.py # +# # +# This will plot graphs for: # +# A graph for average CPU utilization across all cores # +# Separate graphs for CPU utilization for each cores # +# # +############################################################################ +# +# check_interfaces -- template to generate RRD graph +# Copyright (C) 2014 Red Hat Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# Graph Total CPU usage (average across all cpu cores) +$def[1]=""; $opt[1]=""; $ds_name[1]=""; +$opt[1] = "--vertical-label \"% Usage\" -r --lower-limit 0 --upper-limit 100 --title \"CPU for $hostname / $servicedesc\" --slope-mode -u 100 -N"; +$ds_name[1] = "CPU Utilization - Average across all cores"; + +$def[1] = "DEF:total_cpu_in=$RRDFILE[1]:$DS[2]:AVERAGE " ; +$def[1] .= "DEF:system_cpu_in=$RRDFILE[1]:$DS[3]:AVERAGE " ; +$def[1] .= "DEF:user_cpu_in=$RRDFILE[1]:$DS[4]:AVERAGE " ; + +$def[1] .= "CDEF:user_cpu_out=user_cpu_in "; +$def[1] .= "LINE1:user_cpu_out#0000FF:\"User\t\t\" "; +$def[1] .= rrd::gprint("user_cpu_out", array("LAST", "AVERAGE", "MAX"), "%6.2lf%%"); + +$def[1] .= rrd::cdef("system_cpu_out", "system_cpu_in"); +$def[1] .= "LINE1:system_cpu_out#008000:\"System\t\" "; +$def[1] .= rrd::gprint("system_cpu_in", array("LAST", "AVERAGE", "MAX"), "%6.2lf%%"); + +$def[1] .= rrd::cdef("total_cpu_out", "total_cpu_in"); +$def[1] .= "LINE1:total_cpu_out#800080:\"Total\t\t\" "; +$def[1] .= rrd::gprint("total_cpu_in", array("LAST", "AVERAGE", "MAX"), "%6.2lf%%"); + +if ($WARN[2] != ""){ + $def[1] .= "LINE2:$WARN[2]#FFA500:\"Warning\\n\" "; +} +if ($CRIT[2] != ""){ + $def[1] .= "LINE2:$CRIT[2]#FF0000:\"Critical\\n\" "; +} + +# Graph Per-Core CPU usage +$def_n=2; +$index = 6; +$no_cpu=$ACT[1]; + +if($no_cpu>1) + +for( $cpu_n=0; $cpu_n<$no_cpu; $cpu_n++) { + $def[$def_n]=''; + $ds_name[$def_n] = "CPU Utlilization for core: $cpu_n"; + $opt[$def_n] = "--vertical-label \"% Usage\" --lower-limit 0 --upper-limit 100 --title \"CPU for $hostname / $servicedesc\" --slope-mode -N"; + + $index_of_threshold_val = $index; + $def[$def_n] = "DEF:total_cpu_in=$RRDFILE[$index]:$DS[$index]:AVERAGE " ; + $index += 1; + $def[$def_n] .= "DEF:system_cpu_in=$RRDFILE[$index]:$DS[$index]:AVERAGE " ; + $index += 1; + $def[$def_n] .= "DEF:user_cpu_in=$RRDFILE[$index]:$DS[$index]:AVERAGE " ; + $index += 1; + $def[$def_n] .= "DEF:idle_cpu_in=$RRDFILE[$index]:$DS[$index]:AVERAGE " ; + $index += 1; + + $def[$def_n] .= "CDEF:user_cpu_out=user_cpu_in "; + $def[$def_n] .= "LINE1:user_cpu_out#0000FF:\"User\t\t\" "; + $def[$def_n] .= rrd::gprint("user_cpu_out", array("LAST", "AVERAGE", "MAX"), "%6.2lf%%"); + + $def[$def_n] .= rrd::cdef("system_cpu_out", "system_cpu_in"); + $def[$def_n] .= "LINE1:system_cpu_out#008000:\"System\t\" "; + $def[$def_n] .= rrd::gprint("system_cpu_in", array("LAST", "AVERAGE", "MAX"), "%6.2lf%%"); + + $def[$def_n] .= rrd::cdef("total_cpu_out", "total_cpu_in"); + $def[$def_n] .= "LINE1:total_cpu_out#800079:\"Total\t\t\" "; + $def[$def_n] .= rrd::gprint("total_cpu_in", array("LAST", "AVERAGE", "MAX"), "%6.2lf%%"); + + if ($WARN[$index_of_threshold_val] != ""){ + $def[$def_n] .= "LINE2:$WARN[$index_of_threshold_val]#FFFF00:\"Warning\\n\" "; + } + if ($CRIT[$index_of_threshold_val] != ""){ + $def[$def_n] .= "LINE2:$CRIT[$index_of_threshold_val]#FF0000:\"Critical\\n\" "; + } + $def_n++; +} +?> diff --git a/templates/check_disk_and_inode.php b/templates/check_disk_and_inode.php new file mode 100644 index 0000000..3185544 --- /dev/null +++ b/templates/check_disk_and_inode.php @@ -0,0 +1,69 @@ +<?php +# +# check_interfaces -- template to generate RRD graph +# Copyright (C) 2014 Red Hat Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# set graph labels +$i = 0; +$k = 0; +foreach ($this->DS as $KEY=>$VAL) { + if ($i == 0) { + $VAL['NAME'] = str_replace("_","/",$VAL['NAME']); + $ds_name[$KEY] = "Disk Utilization"; + $name[$KEY] = "Disk Utilization for mount: " . $VAL['NAME']; + + # set graph labels + $opt[$KEY] = "--vertical-label \"% Usage\" --lower-limit 0 --upper-limit 100 --title \"$name[$KEY]\" "; + # Graph Definitions + $def[$KEY] = rrd::def( "var1", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE" ); + + # disk graph rendering + if ($VAL['ACT'] >= $VAL['CRIT']) { + $def[$KEY] .= rrd::line1( "var1", "#008000", "Disk Usage" ); + } elseif ($VAL['ACT'] >= $VAL['WARN']) { + $def[$KEY] .= rrd::line1( "var1", "#008000", "Disk Usage" ); + }else { + $def[$KEY] .= rrd::line1( "var1", "#008000", "Disk Usage" ); + } + $def[$KEY] .= rrd::gprint ("var1", array("LAST","MAX","AVERAGE"), "%3.4lf %S%%"); + $i = 1; + $k = $KEY; + } + else { + # inode graph rendering + $def[$k] .= rrd::def( "var2", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE" ); + if ($VAL['ACT'] >= $VAL['CRIT']) { + $def[$k] .= rrd::line1( "var2", "#0000FF", "Inode Usage" ); + } elseif ($VAL['ACT'] >= $VAL['WARN']) { + $def[$k] .= rrd::line1( "var2", "#0000FF", "Inode Usage" ); + }else { + $def[$k] .= rrd::line1( "var2", "#0000FF", "Inode Usage" ); + } + $def[$k] .= rrd::gprint ("var2", array("LAST","MAX","AVERAGE"), "%3.4lf %S%%"); + $i = 0; + + # create warning line and legend + $def[$k] .= rrd::line2( $VAL['WARN'], "#FFA500", "Warning\\n"); + + # create critical line and legend + $def[$k] .= rrd::line2( $VAL['CRIT'], "#FF0000", "Critical\\n"); + + } +} +?> diff --git a/templates/check_interfaces.php b/templates/check_interfaces.php new file mode 100644 index 0000000..96226e9 --- /dev/null +++ b/templates/check_interfaces.php @@ -0,0 +1,53 @@ +<?php +# +# check_interfaces -- template to generate RRD graph +# Copyright (C) 2014 Red Hat Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +$VALUE_COUNT = 4; + +$name = $NAME; +asort($name); +$c = count($name); +if ($c % $VALUE_COUNT != 0) { + exit; +} + +$interface_count = $c / $VALUE_COUNT; + +for ($i = 0; $i < $interface_count; $i++) { + $index = ($i * $VALUE_COUNT) + 1; + + list ($interface, $data_type) = explode (".", $name[$index+2]); + $interface = str_replace(";","",$interface); + $opt[$index+1] = "--vertical-label \"Speed in Gbps\" -X 0 -l 0 -u 1 --title \"Network Interface Load for $hostname / $interface\" "; + + $ds_name[$index+1] = "$interface:: Receiving and "; + $def[$index+1] = rrd::def("value1", $RRDFILE[$index+2], $DS[$index+2], "AVERAGE"); + $def[$index+1] .= rrd::cdef ("value2","value1,125000,/"); + $def[$index+1] .= rrd::line1("value2", "#008000", $data_type); + $def[$index+1] .= rrd::gprint ("value2", array("LAST", "AVERAGE", "MAX"), "%10.4lf Gbps"); + + list ($interface, $data_type) = explode (".", $name[$index+3]); + $interface = str_replace(";","",$interface); + $ds_name[$index+1] .= "Transmission speed"; + $def[$index+1] .= rrd::def ("value3", $RRDFILE[$index+3], $DS[$index+3], "AVERAGE"); + $def[$index+1] .= rrd::cdef ("value4","value3,125000,/"); + $def[$index+1] .= rrd::line1 ("value4", "#0000ff", $data_type) ; + $def[$index+1] .= rrd::gprint ("value4", array("LAST", "AVERAGE", "MAX"), "%10.4lf Gbps"); + } +?> diff --git a/templates/check_memory.php b/templates/check_memory.php new file mode 100644 index 0000000..d620b66 --- /dev/null +++ b/templates/check_memory.php @@ -0,0 +1,59 @@ +<?php +# +# check_interfaces -- template to generate RRD graph +# Copyright (C) 2014 Red Hat Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +$def[1]=""; $opt[1]=""; $ds_name[1]=""; +$upper_limit = round($MAX[1] / (1048576),2) +$opt[1] = "--vertical-label \"$UNIT[1](Total:$upper_limit GB)\" -l 0 -u $upper_limit -r --title \"Memory usage for $hostname / $servicedesc\" --slope-mode -N"; +$ds_name[1] = "Memory Usage"; + + + +$def[1] = "DEF:total_mem_in=$RRDFILE[1]:$DS[1]:AVERAGE " ; +$def[1] .= "DEF:used_mem_in=$RRDFILE[1]:$DS[2]:AVERAGE " ; +$def[1] .= "DEF:buffer_mem_in=$RRDFILE[1]:$DS[3]:AVERAGE " ; +$def[1] .= "DEF:cached_mem_in=$RRDFILE[1]:$DS[4]:AVERAGE " ; + +$def[1] .= rrd::cdef("used_mem_out","used_mem_in,1048576,/"); +$def[1] .= "LINE1:used_mem_out#0000ff:\"Used \" "; +$def[1] .= "GPRINT:used_mem_in:LAST:\"%8.2lf GB LAST \" "; +$def[1] .= "GPRINT:used_mem_in:MAX:\"%8.2lf GB MAX \" "; +$def[1] .= "GPRINT:used_mem_in" . ':AVERAGE:"%8.2lf GB AVERAGE \j" '; + +$def[1] .= rrd::cdef("buffer_mem_out","buffer_mem_in,1048576,/"); +$def[1] .= "LINE1:buffer_mem_out#800080:\"Buffer \" "; +$def[1] .= "GPRINT:buffer_mem_in:LAST:\"%8.2lf GB LAST \" "; +$def[1] .= "GPRINT:buffer_mem_in:MAX:\"%8.2lf GB MAX \" "; +$def[1] .= "GPRINT:buffer_mem_in" . ':AVERAGE:"%8.2lf GB AVERAGE \j" '; + +$def[1] .= rrd::cdef("cached_mem_out","cached_mem_in,1048576,/"); +$def[1] .= "LINE1:cached_mem_out#008000:\"Cached \" "; +$def[1] .= "GPRINT:cached_mem_in:LAST:\"%8.2lf GB LAST \" "; +$def[1] .= "GPRINT:cached_mem_in:MAX:\"%8.2lf GB MAX \" "; +$def[1] .= "GPRINT:cached_mem_in" . ':AVERAGE:"%8.2lf GB AVERAGE \j" '; + +if ($WARN[1] != ""){ + $WAR = $WARN[1] / 1048576 ; + $def[1] .= "LINE2:$WAR#FFA500:\"Warning \\n\" "; +} +if ($CRIT[1] != "") { + $CRT = $CRIT[1] / 1048576 ; + $def[1] .= "LINE2:$CRT#FF0000:\"Critical \\n\" "; + } + +?>
\ No newline at end of file diff --git a/templates/check_swap_usage.php b/templates/check_swap_usage.php new file mode 100644 index 0000000..4d1c0ff --- /dev/null +++ b/templates/check_swap_usage.php @@ -0,0 +1,41 @@ +1;3406;0c<?php +# +# check_interfaces -- template to generate RRD graph +# Copyright (C) 2014 Red Hat Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +$upper_limit = round($MAX[1] / (1048576),2); +$opt[1] = "-X 0 --vertical-label \"$UNIT[1](Total:$upper_limit GB)\" -l 0 -r -u $upper_limit --title \"Swap usage $hostname / $servicedesc\" "; +$ds_name[1] = "Swap Usage"; +$def[1] = "DEF:used_swap_in=$RRDFILE[1]:$DS[1]:AVERAGE " ; + +$def[1] .= rrd::cdef("used_swap_out","used_swap_in,1048576,/"); +$def[1] .= "AREA:used_swap_out#3D1AA8:\"Used \" "; +$def[1] .= "GPRINT:used_swap_out:LAST:\"%3.2lf GB LAST \" "; +$def[1] .= "GPRINT:used_swap_out:MAX:\"%3.2lf GB MAX \" "; +$def[1] .= "GPRINT:used_swap_out" . ':AVERAGE:"%3.2lf GB AVERAGE \j" '; + +if ($WARN[1] != ""){ + $WAR = $WARN[1] / 1048576 ; + $def[1] .= "LINE2:$WAR#FFA500:\"Warning \\n\" "; +} +if ($CRIT[1] != "") { + $CRT = $CRIT[1] / 1048576 ; + $def[1] .= "LINE2:$CRT#FF0000:\"Critical \\n\" "; +} + + +?>
\ No newline at end of file |