說明
- 在不額外安裝netstat下,可以使用以下指令查看 LISTEN 的 port
查看ipv4
> ss -nlt4
查看ipv6
> ss -nlt6
同時查看ipv4 及 ipv6
> ss -nlt
依比鴨鴨
> ss -nlt4
> ss -nlt6
> ss -nlt
https://docs.librenms.org/Installation/Install-LibreNMS/
sudo apt install acl curl fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php-cli php-curl php-fpm php-gd php-gmp php-json php-mbstring php-mysql php-snmp php-xml php-zip rrdtool snmp snmpd unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip whois traceroute
sudo useradd librenms -d /home/librenms -M -r -s “$(which bash)”
cd /home
sudo git clone https://github.com/librenms/librenms.git
sudo chown -R librenms:librenms /home/librenms
sudo chmod 771 /home/librenms
sudo setfacl -d -m g::rwx /home/librenms/rrd /home/librenms/logs /home/librenms/bootstrap/cache/ /home/librenms/storage/
sudo setfacl -R -m g::rwx /home/librenms/rrd /home/librenms/logs /home/librenms/bootstrap/cache/ /home/librenms/storage/
sudo su - librenms
./scripts/composer_wrapper.php install —no-dev
exit
sudo vi /etc/php/8.1/fpm/php.ini
sudo vi /etc/php/8.1/cli/php.inidate.timezone = Asia/Taipei
sudo timedatectl set-timezone Asia/Taipei
sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
在[mysqld]下一行加入以下兩行
innodb_file_per_table=1
lower_case_table_names=0
sudo systemctl enable mariadb
sudo systemctl restart mariadb
sudo mysql_secure_installation
sudo mysql -u root
輸入以下SQL Command
CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY '[yourpassword]';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
exit
sudo cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/librenms.conf
sudo vi /etc/php/8.1/fpm/pool.d/librenms.conf
[www]改成[librenms]
[librenms]
user = librenms
group = librenms
listen = /run/php-fpm-librenms.sock
sudo vi /etc/nginx/conf.d/librenms.conf
server {
listen 80;
server_name [yourdomain or ip];
root /home/librenms/html;
index index.php;
charset utf-8;
gzip on;
gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php-fpm-librenms.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
sudo rm /etc/nginx/sites-enabled/default
sudo systemctl restart nginx
sudo systemctl restart php8.1-fpm
sudo ln -s /home/librenms/lnms /usr/bin/lnms
sudo cp /home/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
sudo cp /home/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
sudo vi /etc/snmp/snmpd.conf
找到 RANDOMSTRINGGOESHERE 改成 public(或自已想要的)
sudo curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
sudo chmod +x /usr/bin/distro
sudo systemctl enable snmpd
sudo systemctl restart snmpd
sudo cp /home/librenms/dist/librenms.cron /etc/cron.d/librenms
sudo vi /etc/cron.d/librenms
將所有的路徑裡的資料夾opt改成home
sudo cp /home/librenms/dist/librenms-scheduler.service /home/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
sudo systemctl enable librenms-scheduler.timer
sudo systemctl start librenms-scheduler.timer
sudo vi /etc/systemd/system/librenms-scheduler.service
將所有的路徑裡的資料夾opt改成home
sudo cp /home/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
sudo vi /home/librenms/.env
DB_HOST= localhost
DB_DATABASE= librenms
DB_USERNAME= librenms
DB_PASSWORD= [yourpassword]
sudo su - librenms
lnms migrate
php artisan key:generate
php artisan config:clear
php artisan config:cache
exit
sudo chown librenms:librenms /home/librenms/config.php
sudo su - librenms
cd /home/librenms
./validate.php
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" -Name SpecialPollInterval -Value 3600
w32tm /unregister
w32tm /register
net start w32time
w32tm /config /manualpeerlist:"time.stdtime.gov.tw" /syncfromflags:manual /update
w32tm /resync
w32tm /query /status
輸出瀏覽器資訊
document.getElementById("showbrowser").innerHTML = navigator.userAgent;
<div id='showbrowser'></div>
確認各家瀏覽器
var isChrome = (navigator.userAgent.indexOf("Chrome") > -1) && (navigator.userAgent.indexOf("Safari") > -1);
var isIOSChrome = navigator.userAgent.indexOf("CriOS") > -1;
var isAndroidChrome = (navigator.userAgent.indexOf("Android") > -1) && (navigator.userAgent.indexOf("Chrome") > -1) && (navigator.userAgent.indexOf("Safari") > -1);
var isMacOSSafari = (navigator.userAgent.indexOf("Macintosh") > -1) && (navigator.userAgent.indexOf("Safari") > -1);
var isiPhoneSafari = (navigator.userAgent.indexOf("iPhone") > -1) && (navigator.userAgent.indexOf("Safari") > -1);
var isEdge = (navigator.userAgent.indexOf("Chrome") > -1) && (navigator.userAgent.indexOf("Safari") > -1) && (navigator.userAgent.indexOf("Edg") > -1);
var isFirefox = navigator.userAgent.indexOf("Firefox") > -1;