New self-made script to check warranty on xen and san Dell hosts

This commit is contained in:
Tommaso Piccioli 2016-07-22 14:23:00 +02:00
parent b92af6a7da
commit 6a2efe3c03
2 changed files with 54 additions and 1 deletions

View File

@ -65,7 +65,8 @@ nagios_dell_omsa_pkgs:
# We need a more recent version of the check_openmanage executable
nagios_dell_standalone_checks:
- check_dell_warranty.py
# - check_dell_warranty.py
- dell_warranty_lifetime.sh
- check_openmanage
nagios_openmanage_additional_opts: ''

View File

@ -0,0 +1,52 @@
#!/bin/bash
#Nagios plug-in to check Dell Warranty and Support Service Level
#Version: 1.0
#Created: 2016-07-22
#Author: Tommaso piccioli
apikey=849e027f476027a394edd656eaef4842
baseurl='https://apidp.dell.com/support/assetinfo/v4/getassetwarranty/'
ServiceTag=`dmidecode -t system | grep -m 1 'Serial Number' | awk '{print $3}'`
requrl="${baseurl}${ServiceTag}?apikey=${apikey}"
#echo $requrl
reqresp=`wget -q -O - $requrl | sed 's/}/\n/g' | grep -m 1 AssetEntitlementData`
ServiceLevelDescription=`echo $reqresp | sed 's/{/\n/g' | sed 's/,/\n/g' | grep ServiceLevelDescription | awk -F '"' '{print $4}'`
StartDate=`echo $reqresp | sed 's/{/\n/g' | sed 's/,/\n/g' | grep StartDate | awk -F '"' '{print $4}'`
EndDate=`echo $reqresp | sed 's/{/\n/g' | sed 's/,/\n/g' | grep EndDate | awk -F '"' '{print $4}'`
EndDay=`echo $EndDate | awk -F 'T' '{print $1}'`
#TodayDate=`date +'%Y-%m-%d'`
SecsLeft=$(( `date -d $EndDay +%s`-`date +%s`))
DaysLeft=$(( $SecsLeft/86400 ))
#echo $DaysLeft
##output="OK: Service Tag: FNV4H92, Warranty: Next Business Day, Start: 01/03/2016, End: 01/04/2019, Days left: 905"
output="Service Tag: $ServiceTag, Warranty: $ServiceLevelDescription, Start: $StartDate, End: $EndDate, Days left: $DaysLeft"
#echo $output
if [ $DaysLeft -gt 60 ]
then
echo "OK - $output"
exit 0
elif [ $DaysLeft -gt 30 ]
then
echo "WARNING - $output"
exit 1
elif [ $DaysLeft -gt 15 ]
then
echo "CRITICAL - $output"
exit 2
else
echo "UNKNOWN - $output"
exit 3
fi