Security

CheckSSLCertExpiry

Description:

A simple bash script to check if the ssl certificate is getting expire. If getting expired in 10 days then it will alert.

Syntax:

script :

Feel free to change, as per need, example for -c and -w.

For now I just made it simple.

Current Version

V1

Last Release Date

2015-09-01

Compatible With

  • Nagios 1.x
  • Nagios 2.x
  • Nagios 3.x
  • Nagios 4.x
  • Nagios XI

License

GPL


Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Project Files
Project Notes
A simple bash script to check if the ssl certificate is getting expire. If getting expired in 10 days then it will alert. Syntax: script : Feel free to change, as per need, example for -c and -w. For now I just made it simple. example: ./CheckSSL.sh www.google.com:443 output: Certificate will expire on Jun 7 00:00:00 2016 GMT
Reviews (1) Add a Review
Works well, but needed configuration
by jkegaly, April 30, 2018
This was a good starter script. It works as it should after modification. I ended up modifying it to say...
#######################################
#!/bin/bash
SitePort=$1

OutDate=$(echo | openssl s_client -connect ${SitePort}:443 2>/dev/null | openssl x509 -noout -endda$

OutputDate=$(date -d "${OutDate}" "+%s")
SystemDate=$(date '+%s')

DiffTime=$(expr "${OutputDate}" - "${SystemDate}")

if [ "${DiffTime}" -ge 864000 ]
then
echo "Certificate will expire on ${OutDate}"
exit 0

elif [ "${DiffTime}" -le 863999 -a -ge 5 ]
then
echo "Certificate is going to expire in less then 10 days on ( ${OutDate} ). Please Renew!"
exit 1
elif [ "${DiffTime}" -le 4 ]
then
echo "Certificate has EXPIRED on ( ${OutDate} )! Please replace!"
exit 2
else
echo "ERROR! Certificate NOT found!"
exit 2
fi
#######################################
Helpful? Yes  No 
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4 (1)
Favorites
0
Views
9,139