2024年6月28日 星期五

ubuntu 安裝 zabbix-sender

 ubuntu 安裝 zabbix-sender

# wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu24.04_all.deb

# sudo dpkg -i zabbix-release_7.0-1+ubuntu24.04_all.deb

# sudo 1apt update

# sudo apt install zabbix-sender

ubuntu 24.04.1 install zabbix 7.0_ngnix

 ubuntu 24.04.1 install zabbix 7.0_ngnix

設定固定IP

1.sudo nano /etc/netplan/50-cloud-init.yaml

network:

  version: 2

  ethernets:

    eth0:

      dhcp4: false

      addresses: [192.168.137.205/24]

      routes:

      - to: default

        via: 192.168.137.1

      nameservers:

        addresses: [1.1.1.1,8.8.8.8]


重啟網路設定

sudo netplan apply

更改系統的時區

看目前時區

timedatectl

修改時區

sudo timedatectl set-timezone Asia/Taipei

安裝NTP同步時間

sudo apt update

sudo apt upgrade

sudo reboot

sudo apt install -y ntp

sudo systemctl start ntp

sudo systemctl enable ntp

ntpq -p

wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu24.04_all.deb

sudo dpkg -i zabbix-release_7.0-1+ubuntu24.04_all.deb

sudo apt update

安装Zabbix server,Web前端,agent

sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent mysql-server

mysql --version

sudo systemctl start mysql.service

sudo systemctl enable mysql.service

sudo mysql -uroot

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '1qaz2wsx';

exit;

sudo mysql_secure_installation

Enter password for user root:

VALIDATE PASSWORD COMPONENT can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n

Using existing password for root.

Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

Success.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No)                      : y

 - Dropping test database...

Success.

 - Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Success.

All done!

mysql -uroot -p

# mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;

# mysql> create user zabbix@localhost identified by '1qaz2wsx';

# mysql> grant all privileges on zabbix.* to zabbix@localhost;

# mysql> set global log_bin_trust_function_creators = 1;

# mysql> SHOW VARIABLES LIKE 'char%';

# mysql> SHOW VARIABLES LIKE 'collation%';

# mysql> quit;

sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

mysql -uroot -p

mysql> set global log_bin_trust_function_creators = 0;

mysql> quit;

sudo nano /etc/zabbix/zabbix_server.conf

修改

DBPassword=1qaz2wsx

sudo nano /etc/zabbix/nginx.conf

  listen          80;

  server_name     192.168.137.243;--zabbix server ip

# sudo systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm

# sudo systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm

http://IP --設定一些規則

http://IP Admin--zabbix  --登入

/usr/share/zabbix/conf/zabbix.conf.php --設定位置

sudo nano /usr/share/zabbix/include/locales.inc.php #打開此文件確認中文已經打開顯示(true)

'zh_TW' => ['name' => _('Chinese (zh_TW)'),     'display' => true],

sudo apt install -y language-pack-zh-hant language-pack-zh-hans #安裝中文

sudo nano /etc/environment 

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

添加以下2行

LANG="zh_TW.UTF-8"

LANGUAGE="zh_TW:zh:en_US:en"

sudo dpkg-reconfigure locales 

sudo systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm

find / -name fonts 

cd /usr/share/zabbix/assets/fonts

ls

graphfont.ttf

sudo wget https://alist.yyzq.cf/d/%20%E6%9C%AC%E5%9C%B0%E7%BD%91%E7%9B%98/software%20/fonts/simkai.ttf #下載新字體

sudo mv graphfont.ttf graphfont.ttfbak #備份原字體

sudo mv simkai.ttf graphfont.ttf #使用新字體

sudo systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm


ubuntu install snmpv3 設定

ubuntu install snmpv3 設定 

cilent端

===========================================

sudo apt install snmp snmpd libsnmp-dev

sudo service snmpd stop

sudo net-snmp-config --create-snmpv3-user -ro -X AES -A SHA -a my_authpass -x my_privpass snmpv3user

sudo net-snmp-create-v3-user -ro -X AES -A SHA -a my_authpass -x my_privpass snmpv3user

/etc/snmp/snmpd.conf

###########################################################################

#

# snmpd.conf

# An example configuration file for configuring the Net-SNMP agent ('snmpd')

# See snmpd.conf(5) man page for details

#

###########################################################################

# SECTION: System Information Setup

#


# syslocation: The [typically physical] location of the system.

#   Note that setting this value here means that when trying to

#   perform an snmp SET operation to the sysLocation.0 variable will make

#   the agent return the "notWritable" error code.  IE, including

#   this token in the snmpd.conf file will disable write access to

#   the variable.

#   arguments:  location_string

sysLocation    Sitting on the Dock of the Bay

sysContact     Me <me@example.org>


# sysservices: The proper value for the sysServices object.

#   arguments:  sysservices_number

sysServices    72

###########################################################################

# SECTION: Agent Operating Mode

#

#   This section defines how the agent will operate when it

#   is running.

# master: Should the agent operate as a master agent or not.

#   Currently, the only supported master agent type for this token

#   is "agentx".

#

#   arguments: (on|yes|agentx|all|off|no)

master  agentx

# agentaddress: The IP address and port number that the agent will listen on.

#   By default the agent listens to any and all traffic from any

#   interface on the default SNMP port (161).  This allows you to

#   specify which address, interface, transport type and port(s) that you

#   want the agent to listen on.  Multiple definitions of this token

#   are concatenated together (using ':'s).

#   arguments: [transport:]port[@interface/address],...

#agentaddress  127.0.0.1,[::1]

###########################################################################

# SECTION: Access Control Setup

#

#   This section defines who is allowed to talk to your running

#   snmp agent.

# Views

#   arguments viewname included [oid]

#  system + hrSystem groups only

view   systemonly  included   .1.3.6.1.2.1.1

view   systemonly  included   .1.3.6.1.2.1.25.1

view   systemview  included   .1

# rocommunity: a SNMPv1/SNMPv2c read-only access community name

#   arguments:  community [default|hostname|network/bits] [oid | -V view]

# Read-only access to everyone to the systemonly view

rocommunity  public default -V systemonly

rocommunity6 public default -V systemonly

# SNMPv3 doesn't use communities, but users with (optionally) an

# authentication and encryption string. This user needs to be created

# with what they can view with rouser/rwuser lines in this file.

#

# createUser username (MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224) authpassphrase [DES|AES] [privpassphrase]

# e.g.

# createuser authPrivUser SHA-512 myauthphrase AES myprivphrase

#

# This should be put into /var/lib/snmp/snmpd.conf

#

# rouser: a SNMPv3 read-only access username

#    arguments: username [noauth|auth|priv [OID | -V VIEW [CONTEXT]]]

rouser authPrivUser authpriv -V systemonly

# include a all *.conf files in a directory

includeDir /etc/snmp/snmpd.conf.d

存檔後

sudo systemctl restart snmpd

================================================================

zabbix server

sudo apt install snmp snmpd libsnmp-dev

看是否抓到資料

sudo snmpwalk -v 3 -a SHA -A my_authpass -x AES -X my_privpass -l authpriv -u snmpv3user guestip | head -10

2024年6月25日 星期二

ubuntu 修改 hostname

1.sudo hostnamectl set-hostname new_hostname

2.sudo sed -i "s/old_hostname/new_hostname/g" /etc/hosts

重新開機即可