IT
Hiển thị các bài đăng có nhãn IT. Hiển thị tất cả bài đăng

Network Pinger - Ping it

Network Pinger - Ping it

A simple command-line tool to ping a single IP address or a range of IP addresses to check their availability.

Features

  • Ping a single IP address.
  • Ping a range of IP addresses.
  • Display results in a user-friendly format.
  • Export data to excel.

Requirements

  • Python 3.x
  • Required libraries: requirements.txt

Installation

  1. Clone the repository:


   git clone https://github.com/cuongitl/pyNetworkPinger.git
   cd pyNetworkPinger

  1. Install the required libraries:


   pip install -r requirements.txt

Usage

Quick mode

Ping a Single IP Address

To ping a single IP address, run the following command:

python pingit.py <IP_ADDRESS>

Replace <IP_ADDRESS> with the actual IP address you want to ping.

Ping a Range of IP Addresses

Install NetBox under 10 Minutes or less?

 

What's Netbox? Why Netbox


This is a note; I'll write more fully later!

Install NetBox under 10 Minutes or less?

All steps are automated 100% by Python!

1. preparing_data: upload on config files to target host.

2. environment_setup: Installing Docker and Docker-Compose

3. Deploy containers: netbox, nginx, postgresql, redis, rq_worker...

4. Create new createsuperuser (Optional)

Details:

1.Upload config files:

- .env

- docker-compose.yml

- docker_install.sh

- netbox_full_setup.sh

- nsteam.it.crt

- nsteam.it.key


2. Installing Docker and Docker-Compose

- by docker_install.sh


3. Deploy docker containers: netbox, nginx, postgresql, redis, rq_worker...

- by netbox_full_setup.sh

4. Create new createsuperuser (Optional)

- by python code.




Shell Script to auto install Docker on Linux


#!/bin/bash
:: Filename: docker_install.sh
:: Modified: 2025-05-02
:: Purpose: Quick install Docker on RHEL system.

# Built with ❤️ by Cuongitl (https://infra.lecuong.info)
# Reset color
RESET='\033[0m'

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'

# Update the system packages
echo -e "${YELLOW}Updating system packages...${RESET}"
sudo dnf update -y || { echo -e "${RED}Error updating system packages. Exiting.${RESET}"; exit 1; }

# Install the necessary packages
echo -e "${YELLOW}Installing necessary packages...${RESET}"
sudo dnf install -y dnf-utils || { echo -e "${RED}Error installing dnf-utils. Exiting.${RESET}"; exit 1; }

# Add the Docker repository
echo -e "${YELLOW}Adding Docker repository...${RESET}"
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo || { echo -e "${RED}Error adding Docker repository. Exiting.${RESET}"; exit 1; }

# Install Docker
echo -e "${YELLOW}Installing Docker...${RESET}"
sudo dnf install docker-ce docker-ce-cli containerd.io -y || { echo -e "${RED}Error installing Docker. Exiting.${RESET}"; exit 1; }

# Start the Docker service
echo -e "${YELLOW}Starting Docker service...${RESET}"
sudo systemctl start docker || { echo -e "${RED}Error starting Docker service. Exiting.${RESET}"; exit 1; }

# Enable the Docker service to start automatically on system boot
echo -e "${YELLOW}Enabling Docker service to start automatically on system boot...${RESET}"
sudo systemctl enable docker || { echo -e "${RED}Error enabling Docker service. Exiting.${RESET}"; exit 1; }

# Verify the Docker installation
echo -e "${YELLOW}Verifying Docker installation...${RESET}"
sudo docker --version || { echo -e "${RED}Error verifying Docker installation. Exiting.${RESET}"; exit 1; }

# Install Docker Compose
echo -e "${YELLOW}Installing Docker Compose...${RESET}"
sudo curl -L "https://github.com/docker/compose/releases/download/v2.35.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose || { echo -e "${RED}Error downloading Docker Compose. Exiting.${RESET}"; exit 1; }
sudo chmod +x /usr/local/bin/docker-compose || { echo -e "${RED}Error making Docker Compose executable. Exiting.${RESET}"; exit 1; }

# Verify the Docker Compose installation
echo -e "${YELLOW}Verifying Docker Compose installation...${RESET}"
if [ -x "/usr/local/bin/docker-compose" ]; then
    echo -e "${GREEN}Docker Compose installed successfully.${RESET}"
else
    echo -e "${RED}Error verifying Docker Compose installation. Exiting.${RESET}"
    exit 1
fi

# (Optional) Create a symlink for easier access
echo -e "${YELLOW}Creating symlink for Docker Compose...${RESET}"
if [ ! -L "/usr/bin/docker-compose" ]; then
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose || { echo -e "${RED}Error creating symlink for Docker Compose. Exiting.${RESET}"; exit 1; }
else
    echo -e "${CYAN}Symlink for Docker Compose already exists. Skipping.${RESET}"
fi

# Verify the Docker Compose version
echo -e "${YELLOW}Verifying Docker Compose version...${RESET}"
docker-compose --version || { echo -e "${RED}Error verifying Docker Compose version. Exiting.${RESET}"; exit 1; }

echo -e



https://gist.github.com/cuongitl/docker-install.sh






How to block a wildcard domain on Windows

To block a wildcard domain on Windows:


We can use Acrylic DNS Proxy (free and open source). It creates a proxy DNS server on your computer with its own hosts file, which supports wildcards.

1. Download and Install Acrylic DNS Proxy

Download Acrylic DNS Proxy from the official website and install it: https://infra.lecuong.info/acrylic-dns-proxy

2. Edit Network Adapter Settings to Point to Acrylic DNS Proxy (127.0.0.1)

Set the Preferred DNS server to 127.0.0.1


IPv4 or IPv6

By completing this step, your system will route all DNS queries through Acrylic DNS Proxy.

3. Configuring Acrylic DNS Proxy to Block a Wildcard Domain

To block a wildcard domain, such as *.youtube.com, follow these steps:

Understanding networking protocols is a must for anyone in IT.

  


With so many out there, it can get overwhelming—so let’s break down some of the most common and important ones in simple terms:  

𝗧𝗖𝗣/𝗜𝗣 – The backbone of the internet! TCP ensures data is split into packets and delivered correctly, while IP handles addressing and routing. Without them, the internet wouldn't work as we know it.  

𝗗𝗡𝗦 – Think of this as the internet’s phonebook. It translates domain names (like 𝚐𝚘𝚘𝚐𝚕𝚎.𝚌𝚘𝚖) into IP addresses, so computers know where to connect.  

POWERSHELL SCRIPT TO AUTOMATE BACKUP OF A FILE AND APPEND THE DATE WITH SUFFIX

PowerShell script is to automate the process of copying a file  from a source directory to a destination directory

Purpose of the Script 

The purpose of this PowerShell script is to automate the process of copying a file (abc.xlsx) from a source directory to a destination directory, ensuring that: 

  1.  The source file exists before attempting any further actions. 
  2. The destination directory exists or is created if it doesn't. 
  3. No overwriting of existing files occurs in the destination directory. If a file with the same name already exists, the script appends a numeric counter (-1, -2, etc.) to the filename to ensure that each copied file has a unique name. 
  4. Safe file operations are ensured by checking for file existence and automatically generating a unique file name when necessary. 

Main Use Case:

 This script is useful when automating tasks like backing up files, copying reports, logs, or other documents, where the filenames may need to be adjusted based on the date or incremented to avoid conflicts with existing files. 

It ensures that the latest copy of the file is always transferred to the destination directory without any risk of overwriting existing files. 

 In summary, this script is designed to automate the process of file copying, making it safe, efficient, and organized, especially in environments where files with the same name (but potentially different versions) need to be handled daily or periodically.

backupfile.ps1

How to split an MP3 file into multiple tracks using specified start and end times

 How to split an MP3 file into multiple tracks using specified start and end times?

Hôm nay có một bạn học viên hỏi cách cắt một file mp3 ra nhiều file khác nhau với track times cụ thể.
Yêu cầu này cũng thường gặp đối với nhiều người học tiếng Anh hoặc học bất cứ thứ gì từ file mp3, cần cắt ngắn file gốc ra nhiều file nhỏ theo từng bài học.

Vì lười kiếm phần mềm cắt thử  rồi test tới lui các kiểu nên tôi viết nhanh đoạn code thực hiện việc này! 

Dùng Python code như sau:

IT Infrastructure Monitoring with Zabbix - Part02

Configure Zabbix Agent: Active vs. Passive ?


Zabbix Agent is installed on servers or client-side devices. Thereby, Zabbix Agent will collect the necessary information from the client computer that needs to be monitored, checked and collected data related to CPU, Memory, Disk and Network interface… or other administrator requirements, then send the results back to Zabbix Server for storage and visualization. It runs on any modern operating system and is very flexible because its functionality can be extended with scripts and modules.
 
First, you need to understand about Active vs Passive Zabbix Agent mode.

See this:

Active vs Passive agent connection

When using a Zabbix agent in active mode, it will connect to the Zabbix server via port 10051 to retrieve configuration and send data. This is a great feature that allows an active Zabbix agent to work behind the firewall and to offload the Zabbix server in large environments.

On the other hand, if you use a Zabbix agent in passive mode, Zabbix server will initiate a connection via port 10050 and retrieve data from the agent. The Zabbix server will do this for every metric (item) every few minutes – which is very inefficient! Because of this, active mode is more recommended.

An additional advantage of the Zabbix agent in active mode is that it can read logs from the device and that is not possible if the Zabbix agent is used in passive mode.

Because, Zabbix-agent is quite easy to install so I won't mention it here.


In this tutorial, I will show you how to configure  Zabbix agent and add host to monitoring system.

1/ Configure Zabbix agent on Linux OS:

Automation configure Zabbix Agent with bash script:

Shell Script to install MariaDB on Linux

How Install MariaDB Instead of MySQL?

Tạo một file lưu cấu hình tên là params.ini với nội dung như sau:

DB_ROOT_PASSWORD='your-password'
DB_PORT='3307'

Thật ra không cần dùng file 'param.ini' cũng được, nhưng tôi có thói quen đọc/sửa mọi thứ từ file cấu hình cho tiện, không muốn sau này phải sửa trực tiếp từ script. 

  Tiếp theo là script cài đặt các gói cần thiết và Mariadb-Server
vim mariadb_install.sh 

Dán đoạn code sau vào:

IT Infrastructure Monitoring with Zabbix - Part01

Take-note: step by step how to install Zabbix-Server.

Zabbix - Easy Steps for Installation and Configuration:

This is my topo:


Part 01 of  IT Infrastructure Monitoring with Zabbix. In this article:

- server01: Zabbix

- server02: MySQL 

Let's go!

# server01

vim /etc/hosts
Add this:

172.16.2.201 vnsmysql01.infra.lecuong.info
172.16.2.203 vnszabbix01.infra.lecuong.info

Add the Zabbix Repository:

Zabbix v6


rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-latest.el9.noarch.rpm

Zabbix v7


rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest.el9.noarch.rpm


Install Zabbix Server, Frontend, and Agent:

How to dynamically choose the database and table based on input with SQLAlchemy?

 Python: How to dynamically choose the database and table based on input with SQLAlchemy?

If you want to dynamically choose the database URL and table based on input, you can use a more flexible approach by creating a factory function to handle this. This will involve dynamically creating the engine and session based on the input, and then dynamically loading the appropriate model.

Here's a step-by-step guide to achieve this:

1. Define a Model Registry

You can maintain a dictionary of model classes for each database. This way, you can dynamically choose the model based on the table name.

How to disable/enable network card on windows for specific time?

How to disable/enable network card on windows for specific time?

 Hôm nay có một vị phụ huynh than phiền rằng con anh ấy thức khuya quá.

Anh ấy nhờ giúp khóa mạng trên máy tính Windows cho laptop của con anh ấy theo giờ từ 00:00 đến 06:00 sáng.

Với yêu cầu : khóa mạng internet theo khung giờ, chúng ta có thể thực hiện dễ dàng mà không cần cài phần mềm gì cả.

TẠO CÁC ĐOẠN SCRIPTS CẦN THIẾT

Can't install upgrade to new Microsoft Teams

 App installation failed with error message: error 0x80070005: Opening the package from location MSTeams-x64.msix failed. (0x80070005)

App installation failed with error message: error 0x80070005: Opening the package from location MSTeams-x64.msix failed. (0x80070005)

Hôm nay, tôi gặp lỗi  khi cập nhật Microsoft Teams lên bản mới nên chia sẻ cho mọi người. 

Cập nhật Microsoft Teams từ Microsoft Store hoặc tải trực tiếp từ trang chủ:"new Microsoft Teams app for desktop" (MSTeams-x64.msix) để cài thì đều bị lỗi. 

Nguyên nhân:

Shell Script to install Python on Linux

Tạo một file lưu cấu hình tên là params.ini với nội dung là phiên bản Python muốn cài:

PY_VERSION='3.9.18'

Thật ra không cần dùng file 'param.ini' cũng được, nhưng tôi có thói quen đọc/sửa mọi thứ từ file cấu hình cho tiện, không muốn sau này phải sửa trực tiếp từ script. 

  Tiếp theo là script cài đặt Python và gói 'virtualenv' (rất cần thiết)
vim python3_install.sh 

Dán đoạn code sau vào:

Set up disaster recovery for Azure VMs

This tutorial shows you how to set up disaster recovery for Azure VMs using Azure Site Recovery. 

In this article, you learn how to:

  • Verify Azure settings and permissions
  • Prepare VMs you want to replicate
  • Create a Recovery Services vault
  • Enable VM replication

Set up disaster recovery using shared disk

 Bài viết này hướng dẫn thiết lập shared disk nhằm bảo vệ, giám sát, chuyển đổi dự phòng, và bảo vệ workloads đang chạy trên Windows Server Failover Clusters (WSFC) trên hệ thống máy ảo Azure.

Azure shared disks là một tính năng quản lý ổ đĩa cho phép đính kèm ổ đĩa vào nhiều máy ảo cùng lúc, việc này cho phép bạn triển khai ứng dụng cụm mới hoặc di chuyển ứng dụng cụm hiện có sang Azure.

Sử dụng tính năng share disks của Azure Site Recovery, chúng ta có thể:

  • Protect your clusters.
  • Create recovery points (App and Crash) that are consistent across all the virtual machines and disks of the cluster.
  • Monitor protection and health of the cluster and all its nodes from a single page.
  • Failover the cluster with a single click.
  • Change recovery point and reprotect the cluster after failover with a single click.
  • Failback the cluster to the primary region with minimal data loss and downtime.

Run a disaster recovery drill for Azure VMs

Learn how to run a disaster recovery drill to another Azure region, for Azure VMs replicating with Azure Site Recovery. 

In this article, you:

  • Verify prerequisites
  • Check VM settings before the drill
  • Run a test failover
  • Clean up after the drill

Elasticsearch-la-gi

 Elasticsearch là một cơ sở dữ liệu (NoSQL), là một công cụ tìm kiếm và phân tích dữ liệu lớn, có mã nguồn mở được xây dựng trên nền tảng Apache Lucene. Công nghệ cung cấp khả năng tìm kiếm nhanh chóng và phân tích dữ liệu phức tạp thông qua giao diện RESTful và JSON.

Elastic search là gì? Tổng hợp những khái niệm và tính ứng dụng cần biết về Elasticsearch

Đối tượng sử dụng Elasticsearch?

[FIXED] Sửa lỗi bản cập nhật KB5034441 cho Windows 10

KB5034441 ERROR_INSTALL_FAILURE 0x80070643

BẢN CẬP NHẬT KB5034441 CÓ CHỨC NĂNG GÌ

Theo công bố từ Microsoft, bản cập nhật KB5034441 có chức năng vá lỗ hổng bảo mật có thể cho phép hacker và tin tặc vượt qua mã hóa Bitlocker bằng cách khai thác Windows Recovery Environment (WinRE).

NGUYÊN NHÂN KHÔNG THỂ CẬP NHẬT

Quản trị tài nguyên và tối ưu hiệu quả chi phí Azure

#takenote

Bí kíp triển khai hệ thống bảo mật hiệu quả trên Azure, nhằm đảm bảo tối ưu vận hành và ngăn chặn thất thoát chi phí.

1. Azure Multi-Factor Authentication (MFA)  
2. Azure Security Defaults  
3. Conditional Access  
4. Azure Policy  
5. Azure Blueprints  
6. Role-based Access Control (RBAC)  
7. Resource Locks  
8. Azure Cost Management  
9. Resource Groups + Tags  
10. Budget Alert  
11. Sign-in logs