Ad Widget

Collapse

Monitoring of SSL certificate expiration time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jpawlowski
    Member
    • May 2005
    • 45

    #1

    Monitoring of SSL certificate expiration time

    I wrote this script for me :-)

    Code:
    #!/bin/sh
    DATE="/bin/date"
    OPENSSL="/usr/local/openssl/current/bin/openssl"
    HOST=$1
    PORT=$2
    
    if [ "$HOST" == "" ]; then
        exit
    fi
    
    if [ "$PORT" == "" ]; then
        PORT="443"
    fi
    
    CMD=`echo "" | $OPENSSL s_client -connect $HOST:$PORT 2>/dev/null | $OPENSSL x509 -enddate -noout 2>/dev/null|  sed 's/notAfter\=//'`
    
    if [ "$CMD" != "" ]; then
        EXPIRE_DATE=`$DATE -d "$CMD" +%s`
        TIME=`$DATE +%s`
        EXPIRE_TIME=`expr $EXPIRE_DATE - $TIME`
        echo $EXPIRE_TIME
    fi
    It returns the time in seconds to the expiration.
    (it does NOT check if the certificate is valid!)
    Last edited by jpawlowski; 15-05-2005, 15:49.
  • dorgan
    Junior Member
    • Dec 2005
    • 5

    #2
    This is awsome!!!

    Comment

    • pattieja
      Junior Member
      • Mar 2005
      • 14

      #3
      Returning string instead of integer or float

      I implemented this script exactly as posted in ZABBIX 1.1beta8, and I cannot seem to get zabbix_agentd to return anything other than a string. Is there something special I need to do in order to make zabbix_agentd think the return value is an integer? I added a ".0" onto the end of the return value, but I'm still getting values like "[s|42510876.0]" when I check the value with 'zabbix_agentd -p'.

      Comment

      Working...