Code Monkey home page Code Monkey logo

nagios-nrpe-check_glusterfs's Issues

check_glusterfs: line 162: [: ==: unary operator expected

If you have an error like "unsynched entries" none of the cases that set ex_stat are hit. This means that you then have an unquoted ${ex_stat} as there is on line 162 (the last line shown here):

# exit with warning if errors
if [ -n "$errors" ]; then
	sep='; '
	msg=$(printf "${sep}%s" "${errors[@]}")
	msg=${msg:${#sep}}
	if [ ${ex_stat} == "CRITICAL_stat" ]; then

then the variable is just empty and the warning is produced. I think it just needs to be quoted to fix this to stop the warning from being produced, e.g.:

	if [ "${ex_stat}" == "CRITICAL_stat" ]; then

Modifications for pnp4nagios

--- check_glusterfs 2014-10-11 23:33:14.000000000 +0200
+++ check_glusterfs.new 2015-04-20 10:37:23.961066897 +0200
@@ -85,7 +85,7 @@

get volume heal status

heal=0
-for entries in $(sudo gluster volume heal ${VOLUME} info | awk '/^Number of entries: /{print $4}'); do
+for entries in $(sudo gluster volume heal ${VOLUME} info heal-failed | awk '/^Number of entries: /{print $4}'); do
if [ "$entries" -gt 0 ]; then
let $((heal+=entries))
fi
@@ -97,6 +97,7 @@

get volume status

bricksfound=0
freegb=9999999
+ex_stat=UNKNOWN
shopt -s nullglob
while read -r line; do
field=($(echo $line))
@@ -146,10 +147,10 @@
if [ $CRIT -ge $WARN ]; then
Exit UNKNOWN "critical threshold below warning"
elif [ $freegb -lt $CRIT ]; then

  •   errors=("${errors[@]}" "free space ${freegb}GB")
    
  •   errors=("${errors[@]}" "free_space_gb=${freegb} | free_space_gb=${freegb};;;;")
        ex_stat="CRITICAL_stat"
    

    elif [ $freegb -lt $WARN ]; then

  •   errors=("${errors[@]}" "free space ${freegb}GB")
    
  •   errors=("${errors[@]}" "free_space_gb=${freegb} | free_space_gb=${freegb};;;;")
    ex_stat="WARNING_stat"
    

    fi
    fi
    @@ -167,4 +168,4 @@
    fi

    exit with no errors

    -Exit OK "${bricksfound} bricks; free space ${freegb}GB"
    +Exit OK " bricks=${bricksfound} free_space_gb=${freegb} | bricks=${bricksfound};;;; free_space_gb=${freegb};;;;"

utils.sh ?

Guys, what is $PROGPATH/utils.sh and where does it come from?

Script not fully compatible with Bash < 4.2

Hi,
My environment is RHEL6 (with Bash 4.1.2) and i've got this error:

line 111:  -2: substring expression < 0

This syntax is not valid in Bash < 4.2:

free=${freeunit:0:-2}

(negative length is working since Bash 4.2 only)

To make it work:

free=${freeunit:0:${#freeunit}-2}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.