More verbose messages.
authorLadislav Láska <ladislav.laska@gmail.com>
Mon, 11 Oct 2010 14:42:31 +0000 (16:42 +0200)
committerLadislav Láska <ladislav.laska@gmail.com>
Mon, 11 Oct 2010 14:42:31 +0000 (16:42 +0200)
Makefile
main.c
tags

index aa1daef72886fe5952f78948b6c784b7a7594579..cfd0894c29b191696c6bd6d959483006dcd1a0e4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 CFLAGS=-Wall -pedantic --std=c99 -lgnutls
 
 
-all:   cert-checker test
+all:   cert-checker
 
 cert-checker: main.o
        gcc $(CFLAGS) -o $@ $^
@@ -11,9 +11,6 @@ depend:
 
 -include: Makefile.depend
 
-test:
-       ./cert-checker localhost:5556
-
 .PHONY: clean
 
 clean:
diff --git a/main.c b/main.c
index 11b689643b35a144988345e9d00bbbc1377674e6..fcbd79a9c4658f36c2bea81c79d6942c3cd4533a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -140,13 +140,20 @@ int check( char * hostname, char *service ) {
                gnutls_x509_crt_import( cert, &cert_list[0], GNUTLS_X509_FMT_DER );
                expiration_time = gnutls_x509_crt_get_expiration_time( cert );
                int expires_in = (expiration_time - today) / 86400;
+               struct tm * t = gmtime( &expiration_time );
                if ((state == S_OK) && (expires_in <= warning_after)) {
                        state = S_WARNING;
-                       sprintf(errmsg, "Certificate will expire in %i days.", expires_in);
+                       sprintf(errmsg, "Warning - Will expire in %i days (%i-%02i-%02i).", expires_in, 
+                               t->tm_year+1900, t->tm_mon+1, t->tm_mday );
                }
                if ((state <= S_WARNING) && (expires_in <= error_after)) {
                        state = S_ERROR;
-                       sprintf(errmsg, "Certificate will expire in %i days.", expires_in);
+                       sprintf(errmsg, "Critical - Will expire in %i days (%i-%02i-%02i).", expires_in,
+                               t->tm_year+1900, t->tm_mon+1, t->tm_mday );
+               }
+               if (state == S_OK) {
+                       sprintf(errmsg, "OK - Will expire in %i days (%i-%02i-%02i).", expires_in,
+                               t->tm_year+1900, t->tm_mon+1, t->tm_mday );
                }
        }
 
diff --git a/tags b/tags
index 4c916a10d199a9fafc2e76e1553763dfbee1dab2..4b68797a9a047c54dac29b9a606a3029629c8b71 100644 (file)
--- a/tags
+++ b/tags
@@ -5,8 +5,23 @@
 !_TAG_PROGRAM_URL      http://ctags.sourceforge.net    /official site/
 !_TAG_PROGRAM_VERSION  5.8     //
 CFLAGS Makefile        /^CFLAGS=-Wall -pedantic --std=c99 -lgnutls$/;" m
+LOG_LEVEL      main.c  38;"    d       file:
+S_ERROR        main.c  32;"    d       file:
+S_NO_X509      main.c  29;"    d       file:
+S_OK   main.c  30;"    d       file:
+S_UNKNOWN      main.c  33;"    d       file:
+S_UNREACHABLE  main.c  28;"    d       file:
+S_WARNING      main.c  31;"    d       file:
 _XOPEN_SOURCE  main.c  14;"    d       file:
-check  main.c  /^int check( char * hostname, int port ) {$/;"  f       signature:( char * hostname, int port )
-die    main.c  25;"    d       file:
+check  main.c  /^int check( char * hostname, char *service ) {$/;"     f       signature:( char * hostname, char *service )
+die    main.c  40;"    d       file:
+errmsg main.c  /^char errmsg[256];$/;" v
+error_after    main.c  /^int error_after = 7;$/;"      v
+gnutls_die     main.c  41;"    d       file:
+log_func       main.c  /^void log_func( int level, char *msg ) {$/;"   f       signature:( int level, char *msg )
 main   main.c  /^int main(int argc, char **argv) {$/;" f       signature:(int argc, char **argv)
-tcp_open       main.c  /^int tcp_open( char *hostname, int port ) {$/;"        f       signature:( char *hostname, int port )
+print_help     main.c  /^void print_help() {$/;"       f
+print_help     main.c  /^void print_help();$/;"        p       file:
+sig_handler    main.c  /^void sig_handler(int k) {$/;" f       signature:(int k)
+tcp_open       main.c  /^int tcp_open( char *hostname, char *service ) {$/;"   f       signature:( char *hostname, char *service )
+warning_after  main.c  /^int warning_after = 30;$/;"   v