Error in Nagios script of check

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
CedricF
Posts: 12
Joined: Thu Nov 15, 2018 4:37 am

Error in Nagios script of check

Post 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.
Last edited by CedricF on Wed Dec 05, 2018 12:58 pm, edited 1 time in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error in Nagios script of check

Post 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.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
CedricF
Posts: 12
Joined: Thu Nov 15, 2018 4:37 am

Re: Error in Nagios script of check

Post by CedricF »

the $ is sticking to EXPIRY. Problem of copying / pasting.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error in Nagios script of check

Post 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.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked