Registry Expiry Date – Мониторинг оплаты домена

Print Friendly, PDF & Email

Задача:

В системе Zabbix, настроить мониторинг Registry Expiry Date (Срок действия или регистрации домена). Иначе говоря, настроить отслеживание времени регистрации домена.

---------------------------------------------------------------

Мониторить будем с самого сервера zabbix, поэтому проверяем наличие необходимых утилиты на сервере и при отсутствии устанавливаем.

[root@s18393 ~]# whois yandex.ru
-bash: whois: command not found
[root@appliance ~]# yum install whois
Last metadata expiration check: 1:53:46 ago on Thu 03 Jun 2021 12:16:16 PM UTC.
Dependencies resolved.
======================================================================================================================================================================================================
 Package                                         Architecture                                 Version                                           Repository                                       Size
======================================================================================================================================================================================================
Installing:
 whois                                           x86_64                                       5.5.1-2.el8                                       appstream                                        78 k
Installing dependencies:
 whois-nls                                       noarch                                       5.5.1-2.el8                                       appstream                                        38 k

Transaction Summary
======================================================================================================================================================================================================
Install  2 Packages

Total download size: 116 k
Installed size: 341 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): whois-5.5.1-2.el8.x86_64.rpm                                                                                                                                   731 kB/s |  78 kB     00:00
(2/2): whois-nls-5.5.1-2.el8.noarch.rpm                                                                                                                               115 kB/s |  38 kB     00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                  98 kB/s | 116 kB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                              1/1
  Installing       : whois-nls-5.5.1-2.el8.noarch                                                                                                                                                 1/2
  Installing       : whois-5.5.1-2.el8.x86_64                                                                                                                                                     2/2
  Running scriptlet: whois-5.5.1-2.el8.x86_64                                                                                                                                                     2/2
  Verifying        : whois-5.5.1-2.el8.x86_64                                                                                                                                                     1/2
  Verifying        : whois-nls-5.5.1-2.el8.noarch                                                                                                                                                 2/2

Installed:
  whois-5.5.1-2.el8.x86_64                                                                        whois-nls-5.5.1-2.el8.noarch

Complete!
[root@s18393 ~]#

Стандартный вывод команды whois для домена yandex.com из консоли linux.

[root@s18393 ~]# whois yandex.com
   Domain Name: YANDEX.COM
   Registry Domain ID: 2028456_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.safenames.net
   Registrar URL: http://www.safenames.net
   Updated Date: 2019-10-01T04:32:14Z
   Creation Date: 1998-09-24T04:00:00Z
   Registry Expiry Date: 2021-09-23T04:00:00Z
   Registrar: SafeNames Ltd.
   Registrar IANA ID: 447
   Registrar Abuse Contact Email: abuse@safenames.net
   Registrar Abuse Contact Phone: +44.1908200022
   Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
   Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
   Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
   Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
   Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
   Name Server: NS1.YANDEX.RU
   Name Server: NS2.YANDEX.RU
   Name Server: NS9.Z5H64Q92X9.NET
   DNSSEC: signedDelegation
   DNSSEC DS Data: 31456 5 1 593F529E8942948DE9D6646AC5F9E2208F49D606
   DNSSEC DS Data: 31456 5 2 EF1EA343AD7B49AC7F44283858A764FCD16539B3C7A5993EE470526213B26343
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2021-06-04T20:16:47Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
Domain Name: YANDEX.COM
Registry Domain ID: 2028456_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.safenames.net
Registrar URL: http://www.safenames.net
Updated Date: 2019-10-01T05:32:15Z
Creation Date: 1998-09-24T04:00:00Z
Registrar Registration Expiration Date: 2021-09-23T04:00:00Z
Registrar: Safenames Ltd
Registrar IANA ID: 447
Registrar Abuse Contact Email: abuse@safenames.net
Registrar Abuse Contact Phone: +44.1908200022
Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Registry Registrant ID: Not Available From Registry
Registrant Name: Data protected, not disclosed
Registrant Organisation: Yandex Europe AG
Registrant Street: Werftestrasse 4
Registrant Street:
Registrant City: Luzern
Registrant State/Province:
Registrant Postal Code: 6005
Registrant Country: CH
Registrant Phone: Data protected, not disclosed
Registrant Fax: Data protected, not disclosed
Registrant Email: eiaarrllaegm@idp.email
Registry Admin ID: Not Available From Registry
Admin Name: International Domain Administrator
Admin Organisation: Safenames Ltd
Admin Street: Safenames House, Sunrise Parkway
Admin Street: Linford Wood
Admin City: Milton Keynes
Admin State/Province: Bucks
Admin Postal Code: MK14 6LS
Admin Country: UK
Admin Phone: +44.1908200022
Admin Fax: +44.1908325192
Admin Email: hostmaster@safenames.net
Registry Tech ID: Not Available From Registry
Tech Name: International Domain Tech
Tech Organisation: Safenames Ltd
Tech Street: Safenames House, Sunrise Parkway
Tech Street: Linford Wood
Tech City: Milton Keynes
Tech State/Province: Bucks
Tech Postal Code: MK14 6LS
Tech Country: UK
Tech Phone: +44.1908200022
Tech Fax: +44.1908325192
Tech Email: hostmaster@safenames.net
Name Server: ns1.yandex.ru
Name Server: ns2.yandex.ru
Name Server: ns9.z5h64q92x9.net
DNSSEC: unsigned
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
>>> Last update of WHOIS database: 2019-10-01T05:32:15Z <<<

"For more information on Whois status codes, please visit https://icann.org/epp"

Safenames - Experts in Global Domain Management and Online Brand Protection

Domain Registration in over 760 different extensions
Enterprise Domain Management since 1999
Mark Protect™ Online Brand Monitoring and Enforcement
Domain Consulting and Strategy
Domain Name Acquisition
Domain Disputes and Recovery

Visit Safenames at www.safenames.net
+1 703 574 5313 in the US/Canada
+44 1908 200022 in Europe

The Data in the Safenames Registrar WHOIS database is provided by Safenames for
information purposes only, and to assist persons in obtaining information about
or related to a domain name registration record.  Safenames does not guarantee
its accuracy.  Additionally, the data may not reflect updates to billing
contact information.

By submitting a WHOIS query, you agree to use this Data only for lawful purposes
and that under no circumstances will you use this Data to:

(1) allow, enable, or otherwise support the transmission of mass unsolicited,
commercial advertising or solicitations via e-mail, telephone, or facsimile; or
(2) enable high volume, automated, electronic processes that apply to Safenames
(or its computer systems).  The compilation, repackaging, dissemination or
other use of this Data is expressly prohibited without the prior written
consent of Safenames.  Safenames reserves the right to terminate your access to
the Safenames Registrar WHOIS database in its sole discretion, including
without limitation, for excessive querying of the WHOIS database or for failure
to otherwise abide by this policy.  Safenames reserves the right to modify
these terms at any time. By submitting this query, you agree to abide by this
policy.


[root@s18393 ~]#

Для мониторинга оплаты домена важна строка “Registry Expiry Date“, её и будем выделять из всего текста.

[root@s18393 ~]# whois yandex.com | grep 'Registry Expiry Date'
   Registry Expiry Date: 2021-09-23T04:00:00Z
[root@s18393 ~]#

Чтобы вывести только дату и время, можно использовать awk. Выведем начиная с четвертого элемента строки.

[root@s18393 ~]# whois yandex.com | grep 'Registry Expiry Date'| awk '{print $4}'
2021-09-23T04:00:00Z
[root@s18393 ~]#

Для удобства вычисления переведём время Unix формат. Это формат определяет количество секунд, прошедших по UTC с полуночи 00:00:00 1 января 1970 года. Этот момент называют «эпохой Unix» (англ. Unix Epoch).

[root@s18393 scripts]# date --date=`whois yandex.com | grep 'Registry Expiry Date'| awk '{print $4}'` +%s
1632369600
[root@s18393 scripts]#

Также нам необходимо знать текущую дату в unix формате

[root@s18393 scripts]# date +%s
1622842391
[root@s18393 scripts]#

Для удобства будем использовать переменные. Затем нам необходимо вычислить разницу между текущей датой и полученным значением и перевести в сутки (Делим на 86400, именно столько секунд в сутках).

d_date=`whois yandex.com | grep 'Registry Expiry Date'| awk '{print $4}'`
d_checkdate=`date --date=$d_date +%s`
d_currentdate=`date +%s `
echo $(( ($d_checkdate-$d_currentdate)/86400 ))

Проверяем работу. Получается, у нас есть ровно сто дней для оплаты домена.

[root@appliance scripts]# d_date=`whois yandex.com | grep 'Registry Expiry Date'| awk '{print $4}'`
[root@appliance scripts]# d_checkdate=`date --date=$d_date +%s`
[root@appliance scripts]# d_currentdate=`date +%s `
[root@appliance scripts]# echo $(( ($d_checkdate-$d_currentdate)/86400 ))
100
[root@appliance scripts]#

Создаём файл для скрипта, и делаем его исполняемым

[root@s18393 ~]# cd /etc/zabbix/scripts/
[root@s18393 scripts]# touch checkdomainexpire.sh
[root@s18393 scripts]# chown zabbix:zabbix checkdomainexpire.sh
[root@s18393 scripts]# chmod +x checkdomainexpire.sh
[root@s18393 scripts]#

содержимое файла checkdomainexpire.sh

d_domain=$1
d_date=`whois $d_domain | grep 'Registry Expiry Date' | awk '{print $4}'`
d_checkdate=`date --date="$d_date" +%s`
d_currentdate=`date +%s`
echo $(( ($d_checkdate-$d_currentdate)/86400 ))

Проверяем работу

[root@appliance scripts]# ./checkdomainexpire.sh yandex.com
100
[root@appliance scripts]#

Переходим к настройке zabbix. Открываем, веб-интерфейс переходим в настройки, выбираем заббикс сервер и добавляем item

Вставляем ключ для проверки и заполняем согласно картинки ниже

system.run[/etc/zabbix/scripts/checkdomainexpire.sh yandex.com]

Интервал проверки (Update interval) устанавливаем один день, этого более чем достаточно.

В завершении необходимо настроит тригер

также можно почитать:

Помогла статья? Есть возможность отблагодарить автора

QR Link:

QR Code

Вам может также понравиться...

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *