forked from simondeziel/custom-nagios-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check_qemu_overcommit: libvirt passes -smp 1,sockets=1... so trim aft…
…er the , Signed-off-by: Simon Deziel <[email protected]>
- Loading branch information
1 parent
d6e1e19
commit 7029292
Showing
1 changed file
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
#!/bin/sh | ||
|
||
# Nagios plugin to check if QEMU VMs use too much resources for what's available | ||
|
||
# Copyright (c) 2016 Simon Deziel <[email protected]> | ||
|
||
# Permission to use, copy, modify, and distribute this software for any | ||
# purpose with or without fee is hereby granted, provided that the above | ||
# copyright notice and this permission notice appear in all copies. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
# Copyright (C) 2016-2017 Simon Deziel <[email protected]> | ||
|
||
# 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. | ||
|
||
# Explicitly set the PATH to that of ENV_SUPATH in /etc/login.defs and unset | ||
# various other variables. For details, see: | ||
|
@@ -31,7 +32,7 @@ MSG_OK="OK" | |
MSG_WARNING="WARNING" | ||
MSG_CRITICAL="CRITICAL" | ||
MSG_UNKNOWN="UNKNOWN" | ||
SCRIPT_NAME="$(basename $0)" | ||
SCRIPT_NAME="$(basename "$0")" | ||
GETOPT="/usr/bin/getopt" | ||
perf_data="|" | ||
|
||
|
@@ -55,7 +56,7 @@ p_unknown () { | |
usage () { | ||
cat << EOF | ||
Usage: | ||
$SCRIPT_NAME [-h] -m <warning>,<critical> -p <warning>,<critical> | ||
$SCRIPT_NAME [-h] -m <warning> -M <critical> -p <warning> -P <critical> | ||
Options: | ||
-h | ||
|
@@ -90,7 +91,7 @@ fi | |
# Note that we use `"$@"' to let each command-line parameter expand to a | ||
# separate word. The quotes around `$@' are essential! | ||
# We need TEMP as the `eval set --' would nuke the return value of getopt. | ||
TEMP=`$GETOPT -q -s sh -n $SCRIPT_NAME -o +hm:M:p:P: -- "$@"` | ||
TEMP=$($GETOPT -q -s sh -n "$SCRIPT_NAME" -o +hm:M:p:P: -- "$@") | ||
if [ $? != 0 ]; then | ||
p_unknown "Unknown/invalid argument, see $SCRIPT_NAME -h for help" | ||
fi | ||
|
@@ -118,7 +119,7 @@ parse_qemu_cmdline() { | |
while [ "$#" -ge 1 ]; do | ||
case $1 in | ||
-m) t_m=$((t_m+$2));shift 2;; | ||
-smp) t_p=$((t_p+$2));shift 2;; | ||
-smp) t_p=$((t_p+$(echo "$2" | cut -d, -f1)));shift 2;; | ||
*) shift;; | ||
esac | ||
done | ||
|
@@ -129,9 +130,8 @@ t_p=0 | |
OIFS="$IFS" | ||
IFS=" | ||
" | ||
for vm in $(pgrep -a -f ^qemu-system-); do | ||
IFS=' ' | ||
parse_qemu_cmdline $vm | ||
for qemu_args in $(pgrep -a ^qemu-system-.+); do | ||
IFS=' ' parse_qemu_cmdline $qemu_args | ||
done | ||
IFS="$OIFS" | ||
|
||
|