Error in Nagios script of check

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Error in Nagios script of check

Postby CedricF » Wed Dec 05, 2018 11:18 am

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.
CedricF
 
Posts: 12
Joined: Thu Nov 15, 2018 4:37 am

Re: Error in Nagios script of check

Postby scottwilkerson » Wed Dec 05, 2018 12:36 pm

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Error in Nagios script of check

Postby CedricF » Wed Dec 05, 2018 12:57 pm

the $ is sticking to EXPIRY. Problem of copying / pasting.
CedricF
 
Posts: 12
Joined: Thu Nov 15, 2018 4:37 am

Re: Error in Nagios script of check

Postby scottwilkerson » Wed Dec 05, 2018 1:31 pm

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12594
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot], mouli449 and 30 guests