albinbatman / zabbix-ssl-monitor-template

Web monitoring steps from Zabbix into an LLD to also monitor them for certificate expiration
MIT License
8 stars 1 forks source link

Problem with discovery rule #1

Closed proovek closed 3 years ago

proovek commented 3 years ago

Hello, I did every step you say it's need to do. After this i've got a problem with the discovery rule, it's look like some script problem..

Invalid discovery rule value: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'PHP Fatal error: Uncaught exception 'ErrorException' with message 'mysqli::mysqli(): Headers and client library minor version mismatch. Headers:50564 And the rule shown as unsupported status..

albinbatman commented 3 years ago

Hi @proovek,

Can you run the following and redact any sensitive information before dumping into this issue? Run the following on the host that is executing the php script.

OS Information egrep '^(VERSION|NAME)=' /etc/os-release

If Ubuntu: apt list --installed | grep mysql

If CentOS: yum list installed | grep mysql

proovek commented 3 years ago

[r00tek@zabbix ~]# yum list installed | grep mysql

php-mysql.x86_64 5.4.16-48.el7 @base rh-php72-php-mysqlnd.x86_64 7.2.24-1.el7 @centos-sclo-rh zabbix-server-mysql.x86_64 5.0.5-1.el7 @zabbix zabbix-web-mysql-scl.noarch 5.0.5-1.el7 @zabbix-frontend

It's look like this. :)

albinbatman commented 3 years ago

Hi again @proovek,

It looks as if the mismatch is due to you having php-mysql at version 5.4 and a seperate client at version 7.2. I would recommend removing this package:

php-mysql.x86_64 5.4.16-48.el7

proovek commented 3 years ago

Hello After i removed the package which you suggest to remove im getting similar error: Invalid discovery rule value: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'PHP Fatal error: Class 'mysqli' not found in /etc/zabbix/scripts/zabbix-ssl-monitor-template/scripts/SQL.php on line 23'

albinbatman commented 3 years ago

Hi again @proovek,

Can you run php -v in your SSH and see what your php version is? If it is below <7.x, I would recommend updating asap either way.

I am assuming you are on the 5.x version and the only thing I can find is the following php - mysql_connect(): Headers and client library minor version mismatch Library:100005 - Stack Overflow.

proovek commented 3 years ago

Hello, PHP was updated to 7.4, ill check the issue again and ill back with informations :)

albinbatman commented 3 years ago

Hello, PHP was updated to 7.4, ill check the issue again and ill back with informations :)

Hi again @proovek,

Alright! Hopefully that resolves it, I developed the php functions on 7.4 as well. :smile:

proovek commented 3 years ago

Hello again, it's true.. 😄

Anyway, why you template not receiving the problem alerts?? In another case the zabbix pollers was dramatically drowned by your template :(

albinbatman commented 3 years ago

Hi again @proovek,

I am unsure what you mean. Problem alerts are only fired if the certificate is expiring within the macro variable. How many pollers do you have and how many items is the template discovering? It works fine on my zabbix 4.4 with >100 certificate checks.

proovek commented 3 years ago

I have like 70 certificates and 100 pollers. Ummm i mean that, one of my certificates will expire in 3 days and this is not showing up as alert in the zabbix

albinbatman commented 3 years ago

Hi again @proovek,

Can you please run the following and dump the ouput you get from it in this issue?

php /path/to/SSL.php hostname days

example: php /path/to/SSL.php github.com 90

crashoverburn commented 3 years ago

Hello,

Any updates, I am also can't get this running properly and the item is unsupported in the discovery rule.

ZabbixServer running on Linux

added a Single host with web scenario with test URL https://www.github.com with URL on the name like you recommend.

php -v PHP 7.2.24-0ubuntu0.18.04.7 (cli) (built: Oct 7 2020 15:24:25) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.24-0ubuntu0.18.04.7, Copyright (c) 1999-2018, by Zend Technologies

/etc/zabbix/scripts/zabbix-ssl-monitor-template/scripts# php SSL.php github.com 90 {"hostname":"github.com","validFrom":"2020-05-05","validTo":"2022-05-10","expiresWithin":false,"error":null}

NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)"

/etc/zabbix/scripts/zabbix-ssl-monitor-template/scripts# apt list --installed | grep mysql

libdbd-mysql-perl/bionic,now 4.046-1 amd64 [instaled, automatic] libmysqlclient20/bionic-updates,bionic-security,now 5.7.32-0ubuntu0.18.04.1 amd64 [instaled, automatic] mysql-common/desconocido,desconocido,desconocido,now 1:10.5.8+maria~focal all[instaled, automatic] php-mysql/bionic,now 1:7.2+60ubuntu1 all [instaled, automatic] php7.2-mysql/bionic-updates,bionic-security,now 7.2.24-0ubuntu0.18.04.7 amd64 [instaled, automatic] zabbix-server-mysql/desconocido,now 1:5.2.3-1+ubuntu18.04 amd64 [instaled]

any guess?

albinbatman commented 3 years ago

Hmm... can you take a screenshot of the host and the items?

albinbatman commented 3 years ago

@crashoverburn See above