August 14

Resize disk in Linux OS:

1. Use lsblk to locate partitions and their IDs:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 40G 0 disk
├─vda1 8:1 0 1M 0 part
└─vda2 8:2 0 40G 0 part /

2. LVM case:

growpart /dev/vda 2
pvresize /dev/vda2
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
xfs_growfs /dev/mapper/ubuntu--vg-ubuntu--lv

OR, if we use ext4:

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

3. non-LVM case:

growpart /dev/vda 2
xfs_growfs /

OR, if we use ext4:

resize2fs /

ps. growpart is provided by the following package in RHEL:

cloud-utils-growpart
August 11

Nagios script to check host uptime

#!/bin/bash
#Simple script to check the server uptime in seconds
#written by Vasyl T.
minimum='86400' # 1 day (24 hours) in seconds
real=$(/usr/bin/awk -F'.' '{print $1}' /proc/uptime)

if [[ "$minimum" -gt "$real" ]];then
echo "CRITICAL. Server uptime is $real seconds, when expected - more than: $minimum"
exit 2;
else
days=$(($real / $minimum))
echo "OK. Server uptime is $real seconds or $days day(s)"
exit 0;
fi
August 4

track requested URLs in joomla 3.6 by ChatGPT

Simple code to insert into the index.php file (at the top of it) and see in the log the list of domains requested by the website:

// 🔥 HTTP Debug Trap with backtrace
class MyHttpSniffer {
public $context;

function stream_open($path, $mode, $options, &$opened_path) {
$logFile = __DIR__ . '/http-trap.log';
$timestamp = date('c');

// Захоплюємо бектрейс
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$backtrace = ob_get_clean();

// Формуємо лог
$logEntry = "[$timestamp] HTTP REQUEST TO: $path\n";
$logEntry .= "Backtrace:\n$backtrace\n";
$logEntry .= str_repeat("-", 80) . "\n";

file_put_contents($logFile, $logEntry, FILE_APPEND);

// Не відкриваємо — блокуємо виклик
return false;
}

function stream_stat() {}
function stream_read($count) { return false; }
function stream_eof() { return true; }
function stream_seek($offset, $whence) { return false; }
function stream_tell() { return 0; }
}

@stream_wrapper_unregister("http");
@stream_wrapper_unregister("https");
@stream_wrapper_register("http", "MyHttpSniffer");
@stream_wrapper_register("https", "MyHttpSniffer");