removed space from dir names
This commit is contained in:
159
Monitoring-Logging/ELK/01-Information.md
Normal file
159
Monitoring-Logging/ELK/01-Information.md
Normal file
@@ -0,0 +1,159 @@
|
||||
# ELK Stack Overview (DevOps Notes)
|
||||
|
||||
## What is ELK?
|
||||
|
||||
**ELK** stands for:
|
||||
|
||||
* **Elasticsearch**
|
||||
* **Logstash**
|
||||
* **Kibana**
|
||||
|
||||
The ELK Stack is a powerful platform used for **log management, monitoring, data analysis, and observability**. It is widely used in DevOps for **centralized logging, troubleshooting, and performance monitoring**.
|
||||
|
||||
---
|
||||
|
||||
## Core Components
|
||||
|
||||
### 1. Elasticsearch
|
||||
|
||||
* Distributed, REST-based **search and analytics engine**
|
||||
* Used for **storing, indexing, and searching logs and metrics**
|
||||
* Built on Apache Lucene
|
||||
* Highly scalable and fast for full-text search
|
||||
|
||||
**Key Responsibilities:**
|
||||
|
||||
* Store logs and events
|
||||
* Index data for fast search
|
||||
* Support aggregations and analytics
|
||||
|
||||
---
|
||||
|
||||
### 2. Logstash
|
||||
|
||||
* **Data processing pipeline**
|
||||
* Ingests data from multiple sources
|
||||
* Transforms, parses, enriches, and forwards data
|
||||
|
||||
**Pipeline Stages:**
|
||||
|
||||
```
|
||||
Input → Filter → Output
|
||||
```
|
||||
|
||||
**Examples of filters:**
|
||||
|
||||
* grok (parse logs)
|
||||
* mutate (modify fields)
|
||||
* date (timestamp handling)
|
||||
* geoip (location enrichment)
|
||||
|
||||
---
|
||||
|
||||
### 3. Kibana
|
||||
|
||||
* **Visualization and analytics UI**
|
||||
* Connects directly to Elasticsearch
|
||||
* Used for:
|
||||
|
||||
* Dashboards
|
||||
* Log exploration
|
||||
* Metrics visualization
|
||||
* Alerts and reporting
|
||||
|
||||
---
|
||||
|
||||
## Beats (Data Shippers)
|
||||
|
||||
**Beats** are lightweight agents installed on servers to collect and send data to Elasticsearch or Logstash.
|
||||
|
||||
Common Beats:
|
||||
|
||||
* **Filebeat** – collects log files
|
||||
* **Metricbeat** – system and service metrics (CPU, memory, disk)
|
||||
* **Heartbeat** – uptime and availability monitoring
|
||||
* **Packetbeat** – network traffic analysis
|
||||
* **Auditbeat** – security and audit data
|
||||
|
||||
**Role:**
|
||||
|
||||
* Data collection
|
||||
* Minimal resource usage
|
||||
* Sends data to Logstash or directly to Elasticsearch
|
||||
|
||||
---
|
||||
|
||||
## Fluentd
|
||||
|
||||
* **Cloud-native log aggregator and processor**
|
||||
* Alternative to Logstash
|
||||
* Common in Kubernetes environments
|
||||
|
||||
**Responsibilities:**
|
||||
|
||||
* Collect logs from multiple sources
|
||||
* Enrich and transform data
|
||||
* Route logs to multiple destinations (Elasticsearch, S3, Kafka)
|
||||
|
||||
---
|
||||
|
||||
## Typical ELK Architecture
|
||||
|
||||
```
|
||||
Server / Application
|
||||
↓
|
||||
Filebeat
|
||||
↓
|
||||
Logstash
|
||||
↓
|
||||
Elasticsearch
|
||||
↓
|
||||
Kibana
|
||||
```
|
||||
|
||||
> Note: In some setups, Beats can send data **directly to Elasticsearch** (Logstash optional).
|
||||
|
||||
---
|
||||
|
||||
## Database Concepts vs Elasticsearch Concepts
|
||||
|
||||
| Traditional Database | Elasticsearch |
|
||||
| -------------------- | -------------------------- |
|
||||
| Database | Index |
|
||||
| Schema | Mapping |
|
||||
| Table | Index (Type is deprecated) |
|
||||
| Column | Field |
|
||||
| Row | Document |
|
||||
| Primary Key | Document ID |
|
||||
|
||||
> ⚠️ **Note:** `Type` is deprecated in modern Elasticsearch versions (7+).
|
||||
|
||||
---
|
||||
|
||||
## Elasticsearch Data Model
|
||||
|
||||
* **Index**: Logical namespace for documents
|
||||
* **Document**: JSON object containing data
|
||||
* **Field**: Key-value pair in a document
|
||||
* **Mapping**: Defines field types and structure
|
||||
|
||||
---
|
||||
|
||||
## Why ELK in DevOps?
|
||||
|
||||
* Centralized logging
|
||||
* Faster incident response
|
||||
* Debugging distributed systems
|
||||
* Monitoring infrastructure and applications
|
||||
* Security analysis (SIEM use cases)
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
* **Elasticsearch** → Storage & search engine
|
||||
* **Logstash / Fluentd** → Data processing & enrichment
|
||||
* **Beats** → Lightweight data collectors
|
||||
* **Kibana** → Visualization & dashboards
|
||||
|
||||
The ELK Stack enables DevOps teams to **observe, analyze, and troubleshoot systems at scale**.
|
||||
220
Monitoring-Logging/ELK/02-Node-Types.md
Normal file
220
Monitoring-Logging/ELK/02-Node-Types.md
Normal file
@@ -0,0 +1,220 @@
|
||||
# ELK Node Types
|
||||
## Overview
|
||||
|
||||
The ELK Stack (Elasticsearch, Logstash, Kibana) is commonly deployed using multiple node types (roles) to ensure scalability, performance, and resilience. This document outlines the main node types used in production-grade ELK deployments from a DevOps perspective.
|
||||
|
||||
---
|
||||
|
||||
## 1. Elasticsearch Node Types
|
||||
|
||||
Elasticsearch nodes can be assigned one or more roles. In production environments, roles are usually separated for stability and performance.
|
||||
|
||||
### 1.1 Master Node (Dedicated Master)
|
||||
|
||||
**Purpose:** Cluster coordination and management
|
||||
|
||||
Responsibilities:
|
||||
|
||||
* Manages cluster state
|
||||
* Controls shard allocation
|
||||
* Handles node joins and failures
|
||||
|
||||
Best Practices:
|
||||
|
||||
* Deploy 3 dedicated master nodes (odd number for quorum)
|
||||
* Do not assign data or ingest roles
|
||||
* Require minimal CPU and disk, but stable memory
|
||||
|
||||
Configuration:
|
||||
|
||||
```yaml
|
||||
node.roles: [ master ]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 1.2 Data Nodes
|
||||
|
||||
**Purpose:** Store data and execute search and indexing operations
|
||||
|
||||
#### a. Hot Data Node
|
||||
|
||||
* Handles recent and high-traffic data
|
||||
* Requires fast SSD storage
|
||||
* Heavy indexing and querying workload
|
||||
|
||||
```yaml
|
||||
node.roles: [ data_hot ]
|
||||
```
|
||||
|
||||
#### b. Warm Data Node
|
||||
|
||||
* Stores less frequently accessed data
|
||||
* Moderate CPU and disk requirements
|
||||
|
||||
```yaml
|
||||
node.roles: [ data_warm ]
|
||||
```
|
||||
|
||||
#### c. Cold Data Node
|
||||
|
||||
* Stores rarely accessed data
|
||||
* Optimized for cost efficiency
|
||||
|
||||
```yaml
|
||||
node.roles: [ data_cold ]
|
||||
```
|
||||
|
||||
#### d. Frozen Data Node
|
||||
|
||||
* Archival data with searchable snapshots
|
||||
* Minimal local storage requirements
|
||||
|
||||
```yaml
|
||||
node.roles: [ data_frozen ]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 1.3 Coordinating Node
|
||||
|
||||
**Purpose:** Query routing and result aggregation
|
||||
|
||||
Characteristics:
|
||||
|
||||
* No data storage
|
||||
* No master role
|
||||
* Acts as a load balancer for search requests
|
||||
|
||||
Use Case:
|
||||
|
||||
* Kibana and client applications connect to coordinating nodes
|
||||
|
||||
```yaml
|
||||
node.roles: [ ]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 1.4 Ingest Node
|
||||
|
||||
**Purpose:** Data preprocessing before indexing
|
||||
|
||||
Responsibilities:
|
||||
|
||||
* Executes ingest pipelines
|
||||
* Performs grok parsing, enrichment, geoip, and transformations
|
||||
* Reduces load on data nodes
|
||||
|
||||
```yaml
|
||||
node.roles: [ ingest ]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 1.5 Machine Learning Node
|
||||
|
||||
**Purpose:** Run machine learning jobs
|
||||
|
||||
Use Cases:
|
||||
|
||||
* Anomaly detection
|
||||
* Advanced analytics
|
||||
|
||||
```yaml
|
||||
node.roles: [ ml ]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 1.6 Transform Node
|
||||
|
||||
**Purpose:** Data transformation and aggregation
|
||||
|
||||
Use Cases:
|
||||
|
||||
* Pivot and latest transforms
|
||||
* Pre-aggregated indices
|
||||
|
||||
```yaml
|
||||
node.roles: [ transform ]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Logstash Node Types
|
||||
|
||||
Logstash does not use formal roles but is deployed based on function.
|
||||
|
||||
### 2.1 Ingest / Collector Nodes
|
||||
|
||||
* Receive data from Beats, syslog, Kafka, etc.
|
||||
* Minimal processing
|
||||
|
||||
### 2.2 Processing Nodes
|
||||
|
||||
* Perform heavy parsing and enrichment
|
||||
* CPU-intensive workloads
|
||||
|
||||
### 2.3 Output Nodes
|
||||
|
||||
* Focused on reliable delivery to Elasticsearch
|
||||
|
||||
---
|
||||
|
||||
## 3. Kibana Node Types
|
||||
|
||||
### 3.1 Kibana Server Node
|
||||
|
||||
* Provides UI and REST API
|
||||
* Stateless and horizontally scalable
|
||||
|
||||
### 3.2 Reporting / Task Manager Node
|
||||
|
||||
* Handles scheduled tasks and reporting
|
||||
* Often separated in large deployments
|
||||
|
||||
---
|
||||
|
||||
## 4. Beats and Agents (Edge Nodes)
|
||||
|
||||
Although not part of the core ELK stack, Beats are critical for data collection.
|
||||
|
||||
Common Beats:
|
||||
|
||||
* Filebeat: Log collection
|
||||
* Metricbeat: System and service metrics
|
||||
* Auditbeat: Security events
|
||||
* Heartbeat: Uptime and endpoint monitoring
|
||||
|
||||
---
|
||||
|
||||
## 5. Typical Production Architectures
|
||||
|
||||
### Small Cluster
|
||||
|
||||
* 3 nodes with combined roles (master, data, ingest)
|
||||
|
||||
### Medium to Large Cluster
|
||||
|
||||
* 3 Dedicated Master Nodes
|
||||
* Hot, Warm, and Cold Data Nodes
|
||||
* Dedicated Ingest Nodes
|
||||
* Coordinating Nodes
|
||||
* Optional ML and Transform Nodes
|
||||
|
||||
---
|
||||
|
||||
## 6. Node Role Summary
|
||||
|
||||
| Node Type | Purpose |
|
||||
| --------------------------- | ---------------------------- |
|
||||
| Master | Cluster coordination |
|
||||
| Data (Hot/Warm/Cold/Frozen) | Data storage and querying |
|
||||
| Coordinating | Query routing |
|
||||
| Ingest | Data preprocessing |
|
||||
| ML | Anomaly detection |
|
||||
| Transform | Data aggregation |
|
||||
| Logstash | Data pipeline |
|
||||
| Kibana | Visualization and management |
|
||||
|
||||
252
Monitoring-Logging/Librenms/librenms.wiki
Executable file
252
Monitoring-Logging/Librenms/librenms.wiki
Executable file
@@ -0,0 +1,252 @@
|
||||
== مرحله اول: وب سرور لینوکسی ==
|
||||
|
||||
لایبر اناماس (به انگلیسی: LibreNMS) یک سیستم نظارت بر شبکه مبتنی بر PHP/MySQL است که از Observium جعبه شده است. LibreNMS با هدف استفاده آسان، استقرار بدون درد و پشتیبانی از نظارت بر طیف گستردهای از دستگاهها انجام شده است. مجوز Observium در ماه مه 2012 به مجوز QPL تغییر یافته تغییر یافت و اخیراً به نسخههای رایگان و تجاری تقسیم شد.هدف ما با LibreNMS استمرار ایجاد NMS قابل استفاده است. برای نصب این سرویس نیاز به وبسرویس لینوکسی داریم. من در این مقاله از Ngnix استفاده میکنم.
|
||||
|
||||
|
||||
'''برخی از وبسرویس های لینوکسی:'''
|
||||
|
||||
[https://www.nginx.com Nginx]
|
||||
|
||||
[https://www.apachefriends.org/ Xampp]
|
||||
|
||||
[https://www.apache.org/ Apache]
|
||||
|
||||
[https://www.litespeedtech.com/ LiteSpeed]
|
||||
|
||||
|
||||
|
||||
قبل از شروع دقت داشته باشید که این روش فقط روی '''Ubuntu 22.04''' تست شده است.
|
||||
|
||||
برای نصب Ngnix دستورهای زیر را در '''Terminal''' اجرا کنید.
|
||||
|
||||
<code>
|
||||
sudo apt install nginx</code>
|
||||
|
||||
''' نکته: ''' اگر فایروال (ufw) روی سیستم شما نصب نباشد می توانید از مرحله بگذرید.
|
||||
|
||||
'''نکته:''' می توانید با دستور <code>sudo ufw disable</code> فایروال را غیرفعال کنید و از این مرحله بگذرید '''(امنیت سیستم شما با این روش به خطر خواهد افتاد)'''
|
||||
|
||||
<p style="background-color: #fff18a; padding: 20px;">
|
||||
''' نکته: ''' با استفاده از <code>gufw</code> می توانید تنظیمات فایروال را با محیط گرافیکی انجام دهید
|
||||
<br>
|
||||
gufw با دستور <code>sudo apt install gufw</code> نصب میشود
|
||||
</p>
|
||||
|
||||
قبل از تست کردن Nginx باید فایروال را تنظیم کنیم. در لینوکس فایروال به عنوان <code>ufw</code> ثبت میشود. با دستور زیر لیست اپلیکیشنهای فایروال به شما نمایش داده خواهد شد.
|
||||
<br>
|
||||
<code>
|
||||
sudo ufw app list
|
||||
</code>
|
||||
|
||||
اگر Ngnix به درستی نصب شده باشد خروجی دستور بالا باید شامل سه App زیر باشد.
|
||||
|
||||
<pre style="color: gray">
|
||||
Nginx Full
|
||||
Nginx HTTP
|
||||
Nginx HTTPS
|
||||
</pre>
|
||||
|
||||
با دستور زیر فایروال اجازه دسترسی به Ngnix میدهد.
|
||||
<p style="direction:ltr; text-align: right;"><code>sudo ufw allow 'Nginx Full'</code></p>
|
||||
اگر همه چیز درست تنظیم شده باشد با اجرای دستور زیر باید '''Status: Active''' باشد.
|
||||
|
||||
<code>sudo ufw status</code>
|
||||
|
||||
'''خروجی:'''
|
||||
<pre style="color: gray">
|
||||
Status: active
|
||||
|
||||
To Action From
|
||||
-- ------ ----
|
||||
OpenSSH ALLOW Anywhere
|
||||
Nginx HTTP ALLOW Anywhere
|
||||
OpenSSH (v6) ALLOW Anywhere (v6)
|
||||
Nginx HTTP (v6) ALLOW Anywhere (v6)
|
||||
</pre>
|
||||
|
||||
اگر با ''' Status: inactive''' مواجه شدید.
|
||||
|
||||
با دستور <code>sudo ufw enable</code> فایروال را فعال کنید و دوباره دستور <code>sudo ufw status</code> را اجرا کنید، تا از فعال بودن ruleهای Ngnix اطمینان پیدا کنید.
|
||||
|
||||
با دستور <code>sudo systemctl status ngnix</code>
|
||||
باید با ''' Active: Active(Running) ''' مواجه شوید.
|
||||
|
||||
<pre style="color: gray">
|
||||
nginx.service - A high performance web server and a reverse proxy server
|
||||
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:>
|
||||
Active: active (running) since Mon 2023-09-25 15:49:44 +0330; 6min ago
|
||||
Docs: man:nginx(8)
|
||||
Process: 1033 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proce>
|
||||
Process: 1049 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (c>
|
||||
Main PID: 1057 (nginx)
|
||||
Tasks: 17 (limit: 18637)
|
||||
Memory: 18.6M
|
||||
CPU: 68ms
|
||||
|
||||
</pre>
|
||||
|
||||
اگر <code>localhost</code> را در قسمت URL مروگر خود وارد کنید باید با پیام Welcome to Ngnix مواجه شوید.
|
||||
|
||||
== مرحله دوم: اضافه کردن کاربر و دانلود LibreNMS ==
|
||||
با دستور زیر کاربری برای libreMNS اضافه می کنیم
|
||||
|
||||
<code>"sudo useradd librenms -d /opt/librenms -M -r -s "$(which bash)</code>
|
||||
|
||||
|
||||
|
||||
سپس با دستور <code>cd /opt</code> وارد محل نصب LibreMNS می شویم و با دستور زیر LibreMNS را دانلود می کنیم
|
||||
|
||||
<code>sudo git clone https://github.com/librenms/librenms.git</code>
|
||||
|
||||
|
||||
== مرحله سوم: دادن دسترسی ها ==
|
||||
با چهار دستور زیر دسترسی ها لازم را بدهید
|
||||
|
||||
<code>sudo chown -R librenms:librenms /opt/librenms</code>
|
||||
|
||||
<code>sudo chmod 771 /opt/librenms</code><code>sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage</code><code>sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage</code>
|
||||
|
||||
== مرحله چهارم: نصب PHP و وابستگی هایش ==
|
||||
برای اجرای LibreNMS نه تنها نیاز به سرور لینوکسی داریم بلکه به کامپایلر PHP نیز نیاز داریم. برای نصب کامپایلر PHP ابتدا باید repository آن را با دستورات زیر به apt اضافه کنیم.
|
||||
|
||||
<code>sudo apt install software-properties-common -y</code>
|
||||
|
||||
<code>sudo add-apt-repository universe</code>
|
||||
|
||||
|
||||
|
||||
سپس با دستورات زیر apt را بروز کرده و PHP و مشتقات آن را نصب میکنیم.
|
||||
|
||||
<code>sudo apt update</code>
|
||||
|
||||
<code>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 whois unzip python3-pymysql python3-dotenv python3-redis python3-setuptools python3-systemd python3-pip</code>
|
||||
|
||||
برای نصب وابستگی های PHP با دستور <code>sudo su - librenms</code> وارد یوزر که قبل تر ساختیم شوید و با اجرای دستور زیر وابستگی ها را دانلود و نصب کنید.
|
||||
|
||||
<code>scripts/composer_wrapper.php install --no-dev/.</code>
|
||||
|
||||
با دستور <code>exit</code> خارچ شوید
|
||||
|
||||
== مرحله پنجم: نصب MariaDB و ساخت دیتابیس ==
|
||||
برای نصب MariaDB از دستور زیر استفاده کنید.
|
||||
|
||||
<code>sudo apt install mariadb-server</code>
|
||||
|
||||
|
||||
|
||||
روی Ubuntu این سرویس بعد از نصب به طور خودکار اجرا خواهد شد. برای ورود به MariaDB و ساخت دیتابیس از دستور زیر استفاده کنید.
|
||||
|
||||
<code>sudo mysql</code>
|
||||
|
||||
|
||||
|
||||
با دستور زیر دیتابیسی به نام LibreMNS ساخته میشود.
|
||||
|
||||
<code>;mysql> CREATE DATABASE librenms</code>
|
||||
|
||||
|
||||
|
||||
با دو دستور زیر دسترسیهای لازم به دیتابیس داده میشود.
|
||||
|
||||
<code>;'mysql> GRANT ALL on librenms.* to librenms@localhost identified by 'yourpassword</code>
|
||||
|
||||
<code>;mysql> FLUSH PRIVILEGES</code>
|
||||
|
||||
|
||||
|
||||
'''توجه: بجای <code>yourpassword</code> رمز عبور دلخواه خود را قرار دهید.'''
|
||||
|
||||
با دستور زیر از mysql خارج میشویم.
|
||||
|
||||
<code>mysql> \q</code>
|
||||
|
||||
|
||||
|
||||
همچنین باید تغییراتی در این فایل ایجاد کنیم. برای باز کردن فایل از دستور زیر استفاده میکنیم.
|
||||
|
||||
<code>sudo gedit /etc/mysql/mariadb.conf.d/50-server.cnf</code>
|
||||
|
||||
|
||||
|
||||
بعد از باز کردن فایل، <code>[mysqld]</code> را پیدا کنید. (این Attribute برای من در خط ۹ بود) و این سه خط کد را در زیر <code>[mysqld]</code> اضافه کنید.
|
||||
|
||||
<code>innodb_file_per_table=1</code>
|
||||
|
||||
<code>lower_case_table_names=0</code>
|
||||
|
||||
|
||||
|
||||
سپس با دو دستور زیر MariaDb را Restart کنید.
|
||||
|
||||
<code>sudo systemctl enable mariadb</code>
|
||||
|
||||
<code>sudo systemctl restart mariadb</code>
|
||||
|
||||
== مرحله ششم: تنظیمات PHP-FPM ==
|
||||
با استفاده از دستور زیر Template کد PHP-FPM را کپی می کنیم
|
||||
|
||||
<code>sudo cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/librenms.conf</code>
|
||||
|
||||
|
||||
باید تغییراتی در فایل ایجاد کنیم پس فایل را با دستور زیر باز کنید
|
||||
|
||||
<code>sudo gedit /etc/php/8.1/fpm/pool.d/librenms.conf</code>
|
||||
|
||||
|
||||
در فایل به دنبال <code>[www]</code> بگردید و آن را به <code>[librenms]</code> تغییر دهید
|
||||
|
||||
<code>user</code> و <code>group</code> را نیز مانند زیر تغییر دهید
|
||||
|
||||
<code>user = librenms</code>
|
||||
|
||||
<code>group = librenms</code>
|
||||
|
||||
|
||||
همچنین پارامتر <code>Listen</code> را نیز مانند زیر تغییر دهید
|
||||
|
||||
<code>listen = /run/php-fpm-librenms.sock</code>
|
||||
|
||||
== مرحله هفتم: تنظیمات وب سرویس ==
|
||||
با دستور <code>sudo gedit /etc/nginx/conf.d/librenms.conf</code> فایل تنظیمات وب سرویس را بسازید.
|
||||
<span style="text-align: left" lang="en" dir="ltr">server {
|
||||
listen 80;
|
||||
server_name librenms.example.com;
|
||||
root /opt/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;
|
||||
}</span>
|
||||
'''توجه: <code>librenms.example.com</code>''' با آدرس سایت خود مانند <code>localhost</code> عوض کنید.
|
||||
|
||||
== مرحله هشتم: نصب گرافیکی ==
|
||||
با ورود به سایت yoursite/install ساخت حساب کاربری را انجام داده و اطلاعات دیتابیس مانند زیر وارد کنید.
|
||||
host: localhost
|
||||
username: librenms
|
||||
password: yourpassword
|
||||
|
||||
== مرحله نهم: کار با API (اختیاری) ==
|
||||
واسط برنامهنویسی نرمافزار کاربردی یا ایپیآی (به انگلیسی: API ، مخفف Application Programming Interface ) که به صورت خلاصه به آن واسط برنامهنویسی هم گفته میشود، واسط بین یک کتابخانه یا سیستمعامل و برنامههایی است که از آن تقاضای سرویس میکنند. در اینجا با استفاده از LibreNMS API می توانید هر کاری که در محیط گرافیکی نرم افزار را انجام می دهد در کد خود نیز تعبیه کنید.
|
||||
|
||||
|
||||
برای استفاده از API اول باید API CORS را روشن کنید. برای اینکار می توانید '''[http://37.152.185.153/settings/api yoursite.xxx/settings/api]''' را در مرورگر خود تایپ کنید و یا از طریق '''GlobalSetting -> API <- ⚙️''' وارد این منو شوید. سپس گزینه '''Enable CORS support for the API''' را فعال کنید.
|
||||
|
||||
|
||||
حال نیاز به API Access Token داریم برای دسترسی به این منو می توانید '''yoursite.xxx/api-access''' را در مرورگر خود تایپ کنید یا از طریق '''API -> API Settings''' '''<- ⚙️''' وارد صفحه شوید. حالا بر روی '''Create API Access Token''' کلیک کنید.
|
||||
|
||||
|
||||
'''نکته:''' برای استفاده از API باید '''API Access Token''' را با هدر '''X-Auth-Token''' ارسال کنید.
|
||||
|
||||
برای مشاهده توابع قابل استفاده به [https://docs.librenms.org/API/ Librenms API Docs] مراجعه کنید
|
||||
|
||||
164
Monitoring-Logging/Tools/stress-ng.md
Normal file
164
Monitoring-Logging/Tools/stress-ng.md
Normal file
@@ -0,0 +1,164 @@
|
||||
# Stress-ng: Hardware Stress Testing Tool
|
||||
|
||||
`stress-ng` is a powerful tool for performing various stress tests on your hardware components, including CPU, memory, and I/O. This utility helps in assessing hardware stability under heavy loads, making it useful for benchmarking or diagnosing hardware issues.
|
||||
|
||||
## Table of Contents
|
||||
- [Installation](#installation)
|
||||
- [CPU Stress Testing](#cpu-stress-testing)
|
||||
- [Memory Stress Testing](#memory-stress-testing)
|
||||
- [I/O Stress Testing](#io-stress-testing)
|
||||
- [Full System Stress Testing](#full-system-stress-testing)
|
||||
|
||||
### Installation
|
||||
|
||||
To install `stress-ng` on Ubuntu or other Debian-based systems, run:
|
||||
```bash
|
||||
sudo apt install stress-ng
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## CPU Stress Testing
|
||||
|
||||
Use `stress-ng` to test CPU performance under different configurations:
|
||||
|
||||
### 1. Run a CPU Test with a Specified Number of Threads
|
||||
|
||||
You can specify the number of threads to use during a CPU stress test. Using `0` as the thread number utilizes all available CPU cores, maximizing CPU usage.
|
||||
|
||||
```bash
|
||||
stress-ng --cpu <thread-number>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --cpu 4
|
||||
```
|
||||
This command uses 4 CPU threads to run the stress test.
|
||||
|
||||
### 2. Run a CPU Test for a Specified Duration
|
||||
|
||||
Specify both the number of CPU threads and a time limit for the test.
|
||||
|
||||
```bash
|
||||
stress-ng --cpu <thread-number> --timeout <seconds>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --cpu 2 --timeout 60s
|
||||
```
|
||||
This command uses 2 CPU threads and runs the test for 60 seconds.
|
||||
|
||||
### 3. Run a CPU Load Test at a Specific Percentage
|
||||
|
||||
You can control the CPU load by specifying a percentage, which is helpful for testing different levels of CPU usage.
|
||||
|
||||
```bash
|
||||
stress-ng --cpu-load <percentage>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --cpu-load 50
|
||||
```
|
||||
This command keeps the CPU load at approximately 50%.
|
||||
|
||||
---
|
||||
|
||||
## Memory Stress Testing
|
||||
|
||||
Stress test the system's memory by allocating and releasing blocks of memory. This can help evaluate memory stability and performance.
|
||||
|
||||
### 1. Basic Memory Stress Test
|
||||
|
||||
Run a memory test with a specified number of workers (processes) that continuously allocate and deallocate memory.
|
||||
|
||||
```bash
|
||||
stress-ng --vm <workers>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --vm 2
|
||||
```
|
||||
This command uses 2 workers to perform memory stress testing.
|
||||
|
||||
### 2. Run a Timed Memory Stress Test
|
||||
|
||||
Add a timeout option to run a memory test for a specific duration.
|
||||
|
||||
```bash
|
||||
stress-ng --vm <workers> --timeout <seconds>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --vm 2 --timeout 60s
|
||||
```
|
||||
This command uses 2 memory workers and runs the test for 60 seconds.
|
||||
|
||||
### 3. Allocate a Specific Amount of Memory
|
||||
|
||||
Specify the amount of memory to allocate per worker.
|
||||
|
||||
```bash
|
||||
stress-ng --vm <workers> --vm-bytes <size>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --vm 1 --vm-bytes 512M
|
||||
```
|
||||
This command allocates 512 MB of memory for one worker.
|
||||
|
||||
---
|
||||
|
||||
## I/O Stress Testing
|
||||
|
||||
I/O testing evaluates the performance of your system’s storage by reading and writing files repeatedly. This is useful for identifying storage bottlenecks and stress-testing the I/O subsystem.
|
||||
|
||||
### 1. Basic I/O Stress Test
|
||||
|
||||
Run an I/O test with a specified number of workers performing file operations.
|
||||
|
||||
```bash
|
||||
stress-ng --io <workers>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --io 4
|
||||
```
|
||||
This command runs 4 I/O workers, continuously reading and writing data to test disk performance.
|
||||
|
||||
### 2. Timed I/O Stress Test
|
||||
|
||||
Specify a timeout to limit the duration of the I/O stress test.
|
||||
|
||||
```bash
|
||||
stress-ng --io <workers> --timeout <seconds>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --io 4 --timeout 60s
|
||||
```
|
||||
This command runs the I/O stress test for 60 seconds with 4 workers.
|
||||
|
||||
---
|
||||
|
||||
## Full System Stress Testing
|
||||
|
||||
For a comprehensive stress test, `stress-ng` allows you to stress multiple components at once, such as CPU, memory, and I/O. This puts a combined load on the system to simulate heavy usage conditions.
|
||||
|
||||
```bash
|
||||
stress-ng --all --timeout <seconds>
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
stress-ng --all --timeout 10s
|
||||
```
|
||||
This command runs a 10-second full system stress test, targeting all components that `stress-ng` supports.
|
||||
|
||||
BIN
Monitoring-Logging/Zabbix/Zabbix-dashboard.png
Executable file
BIN
Monitoring-Logging/Zabbix/Zabbix-dashboard.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 181 KiB |
117
Monitoring-Logging/Zabbix/doc.wiki
Executable file
117
Monitoring-Logging/Zabbix/doc.wiki
Executable file
@@ -0,0 +1,117 @@
|
||||
زبیکس یک نرمافزار متن اوپن سورس برای مانیتور شبکهها و نرمافزارها در سطح سازمانی است، که توسط الکسی ولادیشو (به انگلیسی: Alexei Vladishev) ایجاد شدهاست. این نرمافزار برای مانیتور و تشخیص وضعیت سرویسهای شبکهها، سرورها و دیگر سخت افزارهای شبکه طراحی شدهاست.
|
||||
|
||||
زبیکس از mysql، PostgreSQL، sqlite، Oracle و db2برای ذخیره دادهها پشتیبانی میکند. برنامهنویسی سمت سرور از زبان C بهره میبرد و برنامهنویسی سمت کاربری آن از زبان PHP استفاده میکند.
|
||||
|
||||
== نحوه نصب ==
|
||||
|
||||
=== نصب زبیکس ===
|
||||
|
||||
==== نصب ریپازیتوری زبیکس ====
|
||||
(توجه کامند زیر برای هر سیستم و هر ورژن متفاوته و ما از ابونتو 22 استفاده میکنیم برای دیدن کامند های دیگر از این [https://www.zabbix.com/download?zabbix=6.4&os_distribution=ubuntu_arm64&os_version=20.04&components=server_frontend_agent&db=mysql&ws=apache لینک] استفاده کنید)
|
||||
|
||||
با استفاده کامند زیر پکیج زپیکس دانلود میشود.
|
||||
|
||||
<code>wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb</code>
|
||||
|
||||
برای وریفای کردن دانلود از دستور `ls` استفاده میشود.
|
||||
|
||||
برای نصب از کامند های زیر استفاده کنید
|
||||
|
||||
<code>sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb</code>
|
||||
|
||||
<code>sudo apt update</code>
|
||||
|
||||
==== نصب زبیکس از ریپازیتوری ====
|
||||
با کامند زیر زبیکس نصب میشد
|
||||
|
||||
<code>sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent</code>
|
||||
|
||||
=== اتصال دیتابیس ===
|
||||
|
||||
==== نصب دیتابیس ====
|
||||
<code>sudo apt install mysql-server</code>
|
||||
|
||||
برای وریفای کردن دیتابیس از دستور زیر استفاده میکنیم
|
||||
|
||||
<code>sudo service mysql status</code>
|
||||
|
||||
برای ایمن کردن دیتابیس از دستور زیر استفاده کنید
|
||||
|
||||
<code>sudo mysql_secure_installation</code>
|
||||
[[پرونده:./mysql.png|تنظیمات مای اسکیول|حاشیه|وسط|بیقاب|719x719پیکسل]]
|
||||
در تصویر بالا نحوه تنظیمات دیتابیس نمایش داده شده
|
||||
|
||||
==== اتصال زبیکس به دیتابیس ====
|
||||
برای ساخت دیتابیس ابتدا دستور زیر را وارد میکنید
|
||||
|
||||
<code>sudo mysql -uroot -p</code>
|
||||
|
||||
سپس پسورد خود را وارد کنید و وارد شوید
|
||||
|
||||
بعد از ورود به دیتابیس دستورات زیر را در دیتابیس خود وارد کنید
|
||||
|
||||
<span dir="ltr" lang="en">mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
|
||||
mysql> create user zabbix@localhost identified by 'password'; -- به جای پسورد رمز مورد نظر خود را وارد کنید
|
||||
mysql> grant all privileges on zabbix.* to zabbix@localhost;
|
||||
mysql> set global log_bin_trust_function_creators = 1;
|
||||
mysql> quit;</span>
|
||||
سپس دستور زیر را وارد کنید و پسوردی که در مرحله قبلی وارد کردید را وارد کنید
|
||||
|
||||
<code>zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix</code>
|
||||
|
||||
سپس دوباره با استفاده از دستور <code>sudo mysql -uroot -p</code> مجددا وارد دیتابیس شوید و دستورات زیر را وارد کنید
|
||||
|
||||
<span dir="ltr" lang="en">mysql> set global log_bin_trust_function_creators = 0;
|
||||
mysql> quit;</span>
|
||||
با دستورات زیر فایل /etc/zabbix/zabbix_server.conf را بازکنید و در انتهای فایل <code>DBPassword=your password</code>را وارد کنید (به جای your password) پسوردای که برای زبیکس ساختید را وارد کنید
|
||||
|
||||
<span dir="ltr" lang="en">cd /etc/zabbix/</span>
|
||||
sudo apt install vim
|
||||
sudo vim zabbix_server.conf
|
||||
درنهایت با دستورات زیر زبیکس را ری استارت کنیم
|
||||
sudo systemctl restart zabbix-server zabbix-agent apache2
|
||||
sudo systemctl enable zabbix-server zabbix-agent apache2
|
||||
برای وارد شدن به زبیکس از دستور زیر استفاده کنید
|
||||
|
||||
[http://localhost/zabbix/setup.php http://localhost/zabbix/]
|
||||
|
||||
سپس گزینه next را بزنید و دوباره گزینه next را بزنید
|
||||
|
||||
در قسمت passowrd پسورد زبیکس را وارد کنیدو نکست بزنید
|
||||
|
||||
اسم سرور را به دلخواه انتخاب کنید و دوباره نکست بزنید
|
||||
|
||||
دوباره نکست بزنید تا وارد صفحه لوگین شوید
|
||||
|
||||
با یوزنیم Admin با A بزرگ و پسورد zabbix
|
||||
|
||||
=== خطاهای احتمالی ===
|
||||
|
||||
==== Locale for language "en_US" is not found on the web server. ====
|
||||
درصورت برخورد با این ارور کامند زیر را وارد کنید
|
||||
sudo dpkg-reconfigure locales
|
||||
سپس در بین گزینه های موجود گزینه هایی که شامل en_US میشوند را پیدا کنید (به ترتیب الفباه که راحت بتونید پیدا کنید همش کنار همن) و با کلید space آنهارا انتخاب کنید
|
||||
|
||||
سپس با استفاده از کلید tab گزینه <code><ok></code>در پایین را بزنید و مجددا همان گزینه را بزنید تا لوکال ها لود بشوند
|
||||
|
||||
سپس با دستور زیر زبیکس را ریاستارت کنید
|
||||
sudo systemctl restart zabbix-server zabbix-agent apache2
|
||||
|
||||
== محیط نرم افزار ==
|
||||
[[پرونده:Zabbix-dashboard.png|حاشیه|وسط|بیقاب|865x865پیکسل]]
|
||||
درصورت مشاهده این تصویر (من رنگ پس زمینه رو مشکی کردم که در ادامه روش اینکار را به شما یاد خواهم داد)
|
||||
|
||||
رم سی پی یو در قسمت شمال غربی تصویر ساعت 9 تا 10 و نیم بالا سمت چپ اولین آیتم از بالا و دومین سمت چپ به اسم top hosts by cpu utiliization است که zabbix سرور، کلاینتیه که زبیکس در آن قرار دارد میزان utilization میزان کارایی سی پی یو (میزان استفاده شده سی پی) را به درصد بیان میکند و همچنین قسمت های 1m avg میانگین رم سی پی یو در یک دیقه اخیر، 5m avg در پنج دیقه اخیر، و 15m در پانزده دیقه اخیر نشان میدهد
|
||||
|
||||
در زیر قسمت سی پی یو و رم host availability قرار دارد که سرور های فعال، غیر فعال و نامشخص و تعداد کل به ترتیب چپ به راست را نشان میدهد
|
||||
|
||||
در سمت راست هاست problems by severtiy قرار دارد که تعداد ارور های سرور را نشان میدهد
|
||||
|
||||
در سمت راست پرابلمز geomap قرار دارد که یک لوکیشن در پایتخت لتونی یعنی ریگا را به شما نمایش میدهد و اگر خواستید میتونید به آنجا بروید و سازندگان این نرم افزار کاربردی را از نزدیک مشاهده کنید
|
||||
|
||||
در قسمت system information اطلاعات سیستم قرار دارد
|
||||
|
||||
ور در قسمت current problems ارور های فعلی
|
||||
|
||||
برای عوض کردن بک گراند به لوکیشن زیر بروید (از طریق نوار سمت راست) و تم دلخواه خود را انتخاب کنید
|
||||
administration > general > gui > default theme
|
||||
54
Monitoring-Logging/Zabbix/install_zabix.sh
Executable file
54
Monitoring-Logging/Zabbix/install_zabix.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!bin/bash
|
||||
|
||||
DISTRO=$(lsb_release -is)
|
||||
if [ "$DISTRO" != "Ubuntu" ]; then
|
||||
echo "This script is designed for Ubuntu. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#update package list and upgrade them
|
||||
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
#install prerequisite packeges
|
||||
|
||||
sudo apt install wget gnupg lsb-release -y
|
||||
|
||||
#Add zabix repo
|
||||
|
||||
wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu$(lsb_release -sc)_all.deb
|
||||
|
||||
sudo dpkg -i zabbix-release_6.4-1+${(lsb_release -sc)_all.deb
|
||||
|
||||
sudo apt update
|
||||
|
||||
#install zabix server-mysql
|
||||
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y
|
||||
|
||||
#install mysql and configure it
|
||||
|
||||
sudo apt install mysql-server -y
|
||||
sudo systemctl start mysql
|
||||
sudo systemctl enable mysql
|
||||
|
||||
# creating database
|
||||
|
||||
echo "please enter a password for zabix"
|
||||
read -s ZABBIX_DB_PASS
|
||||
mysql -uroot -p -e "create database zabbix character set utf8 collate utf8_bin;"
|
||||
mysql -uroot -p -e "create user zabbix@localhost identified by '$ZABBIX_DB_PASS';"
|
||||
mysql -uroot -p -e "grant all privileges on zabbix.* to zabbix@localhost;"
|
||||
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p$ZABBIX_DB_PASS zabbix
|
||||
|
||||
#update pass
|
||||
|
||||
sudo sed -i "s/# DBPassword=/DBPassword=$ZABBIX_DB_PASS/" /etc/zabbix/zabbix_server.conf
|
||||
|
||||
# Start Zabbix server and agent processes
|
||||
sudo systemctl restart zabbix-server zabbix-agent apache2
|
||||
sudo systemctl enable zabbix-server zabbix-agent apache2
|
||||
|
||||
|
||||
echo "done!,installation complated!"
|
||||
BIN
Monitoring-Logging/Zabbix/mysql.png
Executable file
BIN
Monitoring-Logging/Zabbix/mysql.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
44
Monitoring-Logging/netdata/netdata-install.md
Executable file
44
Monitoring-Logging/netdata/netdata-install.md
Executable file
@@ -0,0 +1,44 @@
|
||||
# NetData
|
||||
|
||||
NetData is an open-source, real-time system and performance monitoring tool designed for Linux systems. It provides detailed insights into various aspects of system performance, including CPU usage, memory utilization, disk activity, network traffic, and more. NetData offers an interactive, web-based dashboard that allows users to monitor and analyze their system's health in real-time.
|
||||
|
||||
## Key Features
|
||||
|
||||
- **Real-time Monitoring:** NetData provides continuous, minute-by-minute updates on system performance, giving users immediate visibility into any issues or anomalies.
|
||||
|
||||
- **Comprehensive Metrics:** It offers a wide range of metrics, covering CPU, memory, disks, network interfaces, processes, and more, enabling users to identify and address performance bottlenecks.
|
||||
|
||||
- **Interactive Web Interface:** The web-based dashboard is intuitive and user-friendly, allowing users to navigate through different metrics and customize their monitoring experience.
|
||||
|
||||
- **Alerting and Notifications:** NetData supports customizable alarms that can be set to trigger notifications for specific performance thresholds. This enables proactive monitoring and issue resolution.
|
||||
|
||||
- **Easy Installation:** NetData can be easily installed on Linux systems, and it requires minimal configuration to start monitoring.
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
NetData is primarily designed for Linux-based systems, including popular distributions like Ubuntu, CentOS, Debian, and others. It can also be used on FreeBSD systems.
|
||||
|
||||
## Installation
|
||||
|
||||
**Important : Run Command Az Sudoer User**
|
||||
|
||||
To install NetData, follow these steps:
|
||||
|
||||
- Download Installer Script
|
||||
```bash
|
||||
wget https://my-netdata.io/kickstart.sh
|
||||
```
|
||||
|
||||
- Move To Temp Dir
|
||||
|
||||
```bash
|
||||
mv kickstart.sh /tmp/kickstart.sh
|
||||
```
|
||||
|
||||
- Run Installer
|
||||
|
||||
```bash
|
||||
sh /tmp/netdata-kickstart.sh
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user