ParrotSecurity 4.2: Install Zabbix for web base system monitor

This article will describe installing Zabbix which is a web-base system monitor tool.

1 Install Zabbix

The following script will install Zabbix server and Zabbix agent.

  • You need to use "localhost" as Zabbix agent host name (Configuration -> Hosts -> Create Host).
  • MYSQL_PASSWD is a password of root user in MySQL and ZABBIX_PASSWD is password of zabbix user in MySQL.
#!/bin/sh -e


PHP_VERSION=7.2
[ -z "${MYSQL_PASSWD}" ] && MYSQL_PASSWD=mysql
[ -z "${ZABBIX_PASSWD}" ] && ZABBIX_PASSWD=zabbix

mysql_install()
{
  sudo apt install -y default-mysql-server
  sudo systemctl enable mysql
  sudo systemctl restart mysql
  cat <<EOF | sudo mysql_secure_installation

y
${MYSQL_PASSWD}
${MYSQL_PASSWD}
n
y
y
y
EOF
}

zabbix_install()
{
  sudo apt install -y \
       zabbix-server-mysql zabbix-frontend-php \
       php-mysql libapache2-mod-php
  sudo a2enconf zabbix-frontend-php

  timezone=$(cat /etc/timezone)
  sudo sed -i /etc/php/${PHP_VERSION}/apache2/php.ini \
       -e 's/^post_max_size = .*/post_max_size = 16M/g' \
       -e 's/^max_execution_time = .*/max_execution_time = 300/g' \
       -e 's/^max_input_time = .*/max_input_time = 300/g' \
       -e "s:^;date.timezone =.*:date.timezone = \"${timezone}\":g"

  cat <<EOF | sudo mysql -uroot -p${MYSQL_PASSWD}
CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 \
COLLATE utf8_unicode_ci;
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost \
IDENTIFIED BY '${ZABBIX_PASSWD}';
exit
EOF

  for sql in schema.sql.gz images.sql.gz data.sql.gz; do
    zcat /usr/share/zabbix-server-mysql/"${sql}" | \
      sudo mysql -uzabbix -p${ZABBIX_PASSWD} zabbix;
  done

  sudo sed -e 's/# ListenPort=.*/ListenPort=10051/g' \
       -e "s/# DBPassword=.*/DBPassword=${ZABBIX_PASSWD}/g" \
       -i /etc/zabbix/zabbix_server.conf

  # Skip setup.php
  cat <<EOF | sudo tee /etc/zabbix/zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global \$DB;

\$DB['TYPE']     = 'MYSQL';
\$DB['SERVER']   = 'localhost';
\$DB['PORT']     = '0';
\$DB['DATABASE'] = 'zabbix';
\$DB['USER']     = 'zabbix';
\$DB['PASSWORD'] = '${ZABBIX_PASSWD}';

// Schema name. Used for IBM DB2 and PostgreSQL.
\$DB['SCHEMA'] = '';

\$ZBX_SERVER      = 'localhost';
\$ZBX_SERVER_PORT = '10051';
\$ZBX_SERVER_NAME = '';

\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
EOF

  sudo a2enmod ssl
  sudo a2ensite default-ssl

  sudo systemctl enable apache2 zabbix-server
  sudo systemctl restart apache2 zabbix-server

  # This Hostname is used for Host name in
  # Configuration -> Hosts -> Create Host.
  sudo apt install -y zabbix-agent
  sudo sed -e "s/^Hostname=.*/Hostname=localhost/g" \
       -i /etc/zabbix/zabbix_agentd.conf
}

zabbix_main()
{
  mysql_install
  zabbix_install
}

zabbix_main

2 Access to Zabbix

Access to Zabbix via http or https. If you use https, please allow certification file to exception.

http://<server>/zabbix
https://<server>/zabbix

Input Admin to Username, zabbix to Passowrd (This passowrd is not ZABBIX_PASSWD).

0001_Zabbix.png