Page 1 of 1

Error in Nagios script of check

Posted: Wed Dec 05, 2018 11:18 am
by CedricF
Hi,

We have a license check script for Nagios that makes us go wrong during testing.

Here is the piece in error:

Code: Select all

if ["$EXPIRY" = "UNKNOWN"]; Then
                 STATE = "UNKNOWN"
         elif ["$EXPIRY" = "∞"] || ["$ EXPIRY" -gt "7"];
                 STATE = "OK"
         elif ["$EXPIRY" = "7"] && ["$ EXPIRY" -gt "1"]; Then
                 STATE = "WARNING"
         elif ["$EXPIRY" = "1"]; Then
                 STATE = "CRITICAL"
fi
 
echo $ STATE - "License expires in $EXPIRY days"
and the error return when testing the script:

Code: Select all

./check_zend_license: line 50: [: <span ng-if = "loginData.license.daysToExpired === 0"> Your license expires today </ span>
                                                        <span ng-if = "loginData.license.daysToExpired> 0"> Your license will expire in {{loginData.license.daysToExpired}} day {{loginData.license.daysToExpired> 1? 's': ''}} </ span>
                                        <div ng-if = "! (loginData.license.isOk && loginData.license.daysToExpired === false)"> <a href = "http://www.zend.com/go/trial/server-6- upgrade-login "target =" _ blank "> Contact us to get a license </a> </ div>: integer expected as expression
- The license expires in <span ng-if = "loginData.license.daysToExpired === 0"> Your license expires today </ span>
                                                        <span ng-if = "loginData.license.daysToExpired> 0"> Your license will expire in {{loginData.license.daysToExpired}} day {{loginData.license.daysToExpired> 1? 's': ''}} </ span>
                                        <div ng-if = "! (loginData.license.isOk && loginData.license.daysToExpired === false)"> <a href = "http://www.zend.com/go/trial/server-6- upgrade-login "target =" _ blank "> Contact us to get a license </a> </ div> days
Line 50 corresponds to:

Code: Select all

elif ["$EXPIRY" = "∞"] || ["$EXPIRY" -gt "7"];
I tried with just:

Code: Select all

["$EXPIRY" -gt "7"]
but I get the same result.

Thank you for any feedback on this subject.

Re: Error in Nagios script of check

Posted: Wed Dec 05, 2018 12:36 pm
by scottwilkerson
I'm not familiar with your script, however it looks like you have a space between the $ and EXPIRY in everything you posted

Code: Select all

$ EXPIRY
should likely be

Code: Select all

$EXPIRY
But this is not a script that we produced so I cannot say for sure that is the problem, you will likely want to contact the author.

Re: Error in Nagios script of check

Posted: Wed Dec 05, 2018 12:57 pm
by CedricF
the $ is sticking to EXPIRY. Problem of copying / pasting.

Re: Error in Nagios script of check

Posted: Wed Dec 05, 2018 1:31 pm
by scottwilkerson
CedricF wrote:the $ is sticking to EXPIRY. Problem of copying / pasting.
Then I really don't know anything about this plugin, you will likely want to contact the author.