Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 25 additions and 34 deletions. Show diff stats Hide diff stats

  1. +25 34 libexec/check_whois_status
59 libexec/check_whois_status
@@ -72,17 +72,17 @@ sub grok {
72 72 $registrar = $1 if (/Registrar Handle\.*:\s*(.*)/i);
73 73
74 74 if (/expiration date:\s*(\d\d-\w\w\w-\d\d\d\d)/i) {
75   - $expires = $1;
  75 + $expires = $1;
76 76 } elsif (/record expires on (.*)/i) {
77   - $expires = $1;
  77 + $expires = $1;
78 78 } elsif (/^expires:\s+([-\w]+)/i) {
79   - $expires = $1;
  79 + $expires = $1;
80 80 } elsif (/^domain expiration date:\s+(.*)/i) {
81   - $expires = $1;
  81 + $expires = $1;
82 82 } elsif (/Renewal date:\s+(.*)/i) {
83   - $expires = $1;
  83 + $expires = $1;
84 84 } elsif (/Expiration Date:\s+(.*)/i) {
85   - $expires = $1;
  85 + $expires = $1;
86 86 }
87 87
88 88 $status = $1 if (/Status:\s*(.*)/i);
@@ -98,48 +98,39 @@ sub grok {
98 98 $registrar = 'UNKNOWN';
99 99 } else {
100 100 $registrar = 'UNKNOWN';
101   - #critical("Didn't find Registrar");
  101 +#critical("Didn't find Registrar");
102 102 }
103 103
104 104 my $t;
105   - #if (defined $status) {
106   - # success("$name registered by $registrar and is $status") unless ($status =~ /ok/i);
107   - #}
  105 + if (defined $expires) {
  106 + $t = UnixDate($expires, "%s");
  107 + critical("Invalid expiration time '$expires'") unless defined $t;
  108 + critical("Unknown expiration time '$expires'") if ($t < 0);
  109 + $expires = strftime("%Y-%m-%d", localtime($t));
  110 + }
  111 +
  112 + critical("$name registered by $registrar is $status and expires $expires") if ($t - time < (86400*7));
  113 + warning ("$name registered by $registrar is $status and expires $expires") if ($t - time < (86400*28));
108 114 success("$name registered by $registrar is $status and expires $expires");
109   - #} elsif (defined $expires) {
110   - # $t = UnixDate($expires, "%s");
111   - # critical("Invalid expiration time '$expires'") unless defined $t;
112   - # critical("Invalid expiration time '$expires'") if ($t < 0);
113   - # $expires = strftime("%Y-%m-%d", localtime($t));
114   - #} elsif (defined $opts{x}) {
115   - # $t = time + (86400 * 90);
116   - # $expires = 'UNKNOWN';
117   - #} else {
118   - # critical("Didn't find expiration timestamp");
119   - #}
120   -
121   - #critical("Expires $expires at $registrar") if ($t - time < (86400*7));
122   - #warning ("Expires $expires at $registrar") if ($t - time < (86400*28));
123   - #success ("Expires $expires at $registrar");
124 115 }
125 116
126 117 sub success {
127   - output('OK', shift);
128   - exit(0);
  118 + output('OK', shift);
  119 + exit(0);
129 120 }
130 121
131 122 sub warning {
132   - output('WARNING', shift);
133   - exit(1);
  123 + output('WARNING', shift);
  124 + exit(1);
134 125 }
135 126
136 127 sub critical {
137   - output('CRITICAL', shift);
138   - exit(2);
  128 + output('CRITICAL', shift);
  129 + exit(2);
139 130 }
140 131
141 132 sub output {
142   - my $state = shift;
143   - my $msg = shift;
144   - printf "WHOIS %s: %s\n", $state, $msg;
  133 + my $state = shift;
  134 + my $msg = shift;
  135 + printf "WHOIS %s: %s\n", $state, $msg;
145 136 }

No commit comments for this range

Something went wrong with that request. Please try again.