Labels
amazon
apache
apt
aptitude
automate docker image
awk
aws
awstat
backup
bandwidth
bash
binary log
bond
bridge
caching
centos
centos 7
cluster
concurrency
csv
digitalocean
disk
django
docker
docker images
dovecot
drop cache
enviroment
error
explain
free
fstab
ftp
git
gluster
go
gpg
grep
grub
header
header check
icinga2
imapsync
information
innodb
ip
iproute
isolation
ispconfig
java
jenkins
jump
kdump
keepalived
kvm
linux
locale
logbuffer
lookbehind
macos
mail
maillog
matplotlib
mcrypt
memory
modrewrite
monitoring
mount
msyql ndbcluster
mta
multipath
mutt
my.cnf
mysql
mysql error
mysql optimization
mysql permission
mysqlcluster
mysqldump
nethogs
network
nginx
node
nopasswd
ntp
nxlog
openssl
optimization
parsing
parted
password
pflogsumm
php
php-fpm
php5-mcrypt
phpmyadmin
pip
policyd
post
postfix
proxy
pycurl
python
query_cache
querydict
rdesktop
rds
recommender systems
recover mysql
redhat
redolog
regex
regularexpression
resilver
roundcube
route
rsync
scrapy
script
scrub
security
service
setfacl
sftp
slow
smtp
snnp
spamassassin
spotlight
sql
squirrelmail
ssc
ssh
ssh-copy-id
ssl
startup
syslog
syslog over tls
tar
telnet
tls
tomcat
transaction
troubleshoot
tuning
ubuntu
udev
ulimit
usb
vdev removal
virtualhost
virtualization
virtualmin
vrrp
watch
webscrape
wget
x11
zfs
zfs send
zfs recv
zpool
tar complete system backup
#!/bin/bash
tar -zcvpf /backups/fullbackup-`date
+"%F"`.tar.gz / --exclude=/proc --exclude=/sys --exclude=/dev/pts
--exclude=/backups --exclude=/tmp --exclude=/run --exclude=/var/run
--exclude=/lost+found --exclude=/dev --exclude=/sys
--exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/network/interfaces --exclude=/etc/udev/rules.d/70-persistent-net.rules
nxlog ssl tls
nxlog.conf file for sending logs over ssl. Copy this file from server /opt/data/etc/remote_connection/certificates/ca.crt
to windows machine . c:\Program Files\nxlog\cert
Replace 192.168.15.118 ip with your siem server ip then restart the nxlog service from the Window system.
Panic Soft
define ROOT C:\Program Files\nxlog
#ModuleDir %ROOT%\modules
#CacheDir %ROOT%\data
#SpoolDir %ROOT%\data
define CERTDIR %ROOT%\cert
define CONFDIR %ROOT%\conf
# Note that these two lines define constants only; the log file location
# is ultimately set by the `LogFile` directive (see below). The
# `MYLOGFILE` define is also used to rotate the log file automatically
# (see the `_fileop` block).
define LOGDIR %ROOT%\data
define MYLOGFILE %LOGDIR%\nxlog.log
# By default, `LogFile %MYLOGFILE%` is set in log4ensics.conf. This
# allows the log file location to be modified via NXLog Manager. If you
# are not using NXLog Manager, you can instead set `LogFile` below and
# disable the `include` line.
#LogFile %MYLOGFILE%
LogLevel INFO
LogFile %MYLOGFILE%
#include %CONFDIR%\log4ensics.conf
<Extension _syslog>
Module xm_syslog
</Extension>
<Extension _exec>
Module xm_exec
</Extension>
<Extension _json>
Module xm_json
</Extension>
<Input in>
Module im_msvistalog
ReadFromLast TRUE
<QueryXML>
<QueryList>
<Query Id='1'>
<Select Path='Application'>*</Select>
<Select Path='Security'>*</Select>
<Select Path='System'>*</Select>
</Query>
</QueryList>
</QueryXML>
</Input>
<Output out>
#Module om_tcp
Module om_ssl
Host 192.168.15.118
Port 515
CAFile %CERTDIR%/ca.crt
AllowUntrusted TRUE
Exec to_json();$Message=$raw_event;to_syslog_bsd();
</Output>
<Route 1>
Path in => out
</Route>
Please let us know if this helped you or not.
Recover LVM metadata
Recovery of lvm metadata in case of mishaps while modifying partition or corruption
root@myserver:~# apt install lvm2
root@myserver:~# head /root/lvm/archive/SIEM-vg_00002-106947711.vg
# Generated by LVM2 version 2.03.07(2) (2019-11-30): Wed Aug 4 14:54:30 2021
contents = "Text Format Volume Group"
version = 1
description = "Created *before* executing 'lvextend -l +100%FREE /dev/SIEM-vg/data'"
creation_host = "MC-UKHC1-LPSH-MAP" # Linux MC-UKHC1-LPSH-MAP 5.4.0-65-generic #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021 x86_64
creation_time = 1628088870 # Wed Aug 4 14:54:30 2021
root@myserver:~# head /root/lvm/archive/SIEM-vg_00002-106947711.vg -n 40
# Generated by LVM2 version 2.03.07(2) (2019-11-30): Wed Aug 4 14:54:30 2021
contents = "Text Format Volume Group"
version = 1
description = "Created *before* executing 'lvextend -l +100%FREE /dev/SIEM-vg/data'"
creation_host = "MC-UKHC1-LPSH-MAP" # Linux MC-UKHC1-LPSH-MAP 5.4.0-65-generic #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021 x86_64
creation_time = 1628088870 # Wed Aug 4 14:54:30 2021
SIEM-vg {
id = "fKhTFb-Uyy5-gnKu-R6Dv-keXh-73xZ-mRj31X"
seqno = 4
format = "lvm2" # informational
status = ["RESIZEABLE", "READ", "WRITE"]
flags = []
extent_size = 8192 # 4 Megabytes
max_lv = 0
max_pv = 0
metadata_copies = 0
physical_volumes {
pv0 {
id = "wKDxJk-B5tL-cMZH-aPNW-1FyP-8KAy-ozWwQA"
device = "/dev/sda4" # Hint only
status = ["ALLOCATABLE"]
flags = []
dev_size = 156342272 # 74.5498 Gigabytes
pe_start = 2048
pe_count = 19084 # 74.5469 Gigabytes
}
pv1 {
id = "FcTEwf-MIY9-0zcd-3T4B-hLBl-Ybfm-DZeRLd"
device = "/dev/sdb" # Hint only
status = ["ALLOCATABLE"]
flags = []
...
root@myserver:~# pvcreate --uuid "FcTEwf-MIY9-0zcd-3T4B-hLBl-Ybfm-DZeRLd" --restorefile /root/lvm/archive/SIEM-vg_00002-106947711.vg /dev/sdc
WARNING: Couldn't find device with uuid wKDxJk-B5tL-cMZH-aPNW-1FyP-8KAy-ozWwQA.
WARNING: Couldn't find device with uuid FcTEwf-MIY9-0zcd-3T4B-hLBl-Ybfm-DZeRLd.
Cannot use /dev/sdc: device is partitioned
root@myserver:~# sfdisk -l /dev/sdc
Disk /dev/sdc: 2 TiB, 2199023255552 bytes, 4294967296 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D174C1CF-EC08-42F9-A7E6-F9B838671444
root@myserver:~# sfdisk -d /dev/sdc >> sdcparttablebackup
root@myserver:~# cat sdcparttablebackup
label: gpt
label-id: D174C1CF-EC08-42F9-A7E6-F9B838671444
device: /dev/sdc
unit: sectors
first-lba: 34
last-lba: 4294967262
sector-size: 512
root@myserver:~# gdisk /dev/sdc
Command (? for help): x
z zap (destroy) GPT data structures and exit
Expert command (? for help): z
About to wipe out GPT on /dev/sdc. Proceed? (Y/N): Y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): Y
root@myserver:~# pvcreate --uuid "FcTEwf-MIY9-0zcd-3T4B-hLBl-Ybfm-DZeRLd" --restorefile /root/lvm/archive/SIEM-vg_00002-106947711.vg /dev/sdc
WARNING: Couldn't find device with uuid wKDxJk-B5tL-cMZH-aPNW-1FyP-8KAy-ozWwQA.
WARNING: Couldn't find device with uuid FcTEwf-MIY9-0zcd-3T4B-hLBl-Ybfm-DZeRLd.
Physical volume "/dev/sdc" successfully created.
root@myserver:~# pvscan
WARNING: PV /dev/sdc in VG SIEM-vg is missing the used flag in PV header.
PV /dev/sdb4 VG SIEM-vg lvm2 [<74.55 GiB / 0 free]
PV /dev/sdc VG SIEM-vg lvm2 [<1024.00 GiB / 0 free]
Total: 2 [1.07 TiB] / in use: 2 [1.07 TiB] / in no VG: 0 [0 ]
root@myserver:~# vgcfgrestore -f /root/lvm/backup/SIEM-vg SIEM-vg
Volume group SIEM-vg has active volume: app.
WARNING: Found 1 active volume(s) in volume group "SIEM-vg".
Restoring VG with active LVs, may cause mismatch with its metadata.
Do you really want to proceed with restore of volume group "SIEM-vg", while 1 volume(s) are active? [y/n]: y
Restored volume group SIEM-vg.
root@myserver:~# blkid
/dev/sda3: UUID="dfc2bdb0-6f36-470a-9dfc-c98924b332b1" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="5e192eda-6b4c-4fa0-ae8d-8a53d91020ad"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/sdb2: UUID="43abf87d-d093-4a77-a3b6-e1faab8d0c65" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="9ddcbbe8-dca3-4236-9612-569eb7e13da0"
/dev/sdb3: UUID="3d066f7e-9ca3-46d7-afd0-021373bdb159" TYPE="swap" PARTUUID="a46bf250-cd06-4d6b-a965-1215d3610e73"
/dev/sdb4: UUID="wKDxJk-B5tL-cMZH-aPNW-1FyP-8KAy-ozWwQA" TYPE="LVM2_member" PARTUUID="1f7270a4-0caa-4025-9d3c-2fae2a801ef0"
/dev/sda2: UUID="B474-DDD0" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="d413ec6f-39c4-47d2-8a5b-06b48847f215"
/dev/mapper/SIEM--vg-app: UUID="ac421fd4-dd0f-4aa0-874b-ae4a6554ff96" BLOCK_SIZE="4096" TYPE="ext4"
/dev/sdb1: PARTUUID="a95b528d-a529-4ea8-92de-ea8b46fd67f3"
/dev/sdc: UUID="FcTEwf-MIY9-0zcd-3T4B-hLBl-Ybfm-DZeRLd" TYPE="LVM2_member"
/dev/sda1: PARTUUID="18b705bc-4c32-4391-ab95-0b47ab67e831"
root@myserver:~# vgchange -ay SIEM-vg
2 logical volume(s) in volume group "SIEM-vg" now active
Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7F434980-3FBB-4D7D-9770-F446936F74FE
Device Start End Sectors Size Type
/dev/sdb1 2048 63487 61440 30M BIOS boot
/dev/sdb2 63488 37746687 37683200 18G EFI System
/dev/sdb3 37746688 53370879 15624192 7.5G Linux swap
/dev/sdb4 53370880 209713151 156342272 74.5G Linux LVM
Disk /dev/sdc: 2 TiB, 2199023255552 bytes, 4294967296 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 12D18C3D-9E89-4B69-8FB3-E163A97BD783
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 1054719 1050624 513M EFI System
/dev/sda3 1054720 209713151 208658432 99.5G Linux filesystem
Disk /dev/mapper/SIEM--vg-app: 18.63 GiB, 19998441472 bytes, 39059456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/SIEM--vg-data: 1.05 TiB, 1159553089536 bytes, 2264752128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
root@myserver:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb4 SIEM-vg lvm2 a-- <74.55g 0
/dev/sdc SIEM-vg lvm2 a-- <1024.00g 0
root@myserver:~# pvre
pvremove pvresize
root@myserver:~# pvresize -t /dev/sdc
TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
Physical volume "/dev/sdc" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
Subscribe to:
Posts (Atom)