Troubleshooting and debugging syslog-ng.

Sometimes, syslog-ng seems to be working wrong, it does not send logs, or it does not start or in an extreme case it crashes.
Is it a real syslog-ng bug or not?

First of all, syslog-ng has a lot of parameters for debugging:

root# syslog-ng –help-all

-F, –foreground Do not go into the background after initialization
-v, –verbose Be a bit more verbose
-d, –debug Enable debug messages
-t, –trace Enable trace messages
-e, –stderr Log messages to stderr
-s, --syntax-only Only read and parse config file

For example:

root# syslog-ng -F
WARNING: the match() filter without the use of the value() option is deprecated and hinders performance, please update your configuration;
Error resolving reference; content='source', name='_src', location='/etc/syslog-ng/conf.d/iptables.conf:3:7'
root#

cat /etc/syslog-ng/conf.d/iptables.conf
destination iptables { file("/var/log/iptables.log" owner("user") group("adm") perm(0644)); };
filter iptables { facility(kern) and match("IN=") and match("OUT="); };
log { source(_src); filter(iptables); destination(iptables); };

So what is missing? ‘s’ in name=’_src’ The syntax should look like this:


cat /etc/syslog-ng/conf.d/iptables.conf
destination iptables { file("/var/log/iptables.log" owner("aryps") group("adm") perm(0644)); };
filter iptables { facility(kern) and match("IN=") and match("OUT="); };
log { source(s_src); filter(iptables); destination(iptables); };

Worth to add the following and not filter(iptables) to filter f_kern and filter f_messages so the filters will look like this:


cat /etc/syslog-ng/syslog-ng.conf
...
filter f_messages { level(info,notice,warn) and not facility(auth,authpriv,cron,daemon,mail,news) and not filter(iptables); };
filter f_kern { facility(kern) and not filter(f_debug) and not filter(iptables); };
...

Send a file as a mail attachment using mail command.

The simplest way to send a file as a mail attachment is shown by the following examples:

# uuencode snoopy1.jpeg snoopy1.jpeg | mail user@dump.4network.org

If user uses a current mail reader like Mozilla, Netscape Messenger or Microsoft Exchange, she/he will see a mail containing just one file attachment: the file “snoopy1.jpeg”.

This way we can include text, too:

# (cat mailtext; uuencode snoopy1.jpeg snoopy1.jpeg) | mail user@dump.4network.org

The file called “snoopy1.jpeg” again appears twice on the uuencode command line: the first time to specify the input file name, the second time for the remote extraction file name.

or

echo -e "text in line1 ntext in line2"| mail -s "Subject of an e-mail" -r "User1<user1@dump.4network.org>" -a "/tmp/abc.zip" name@domian.com

Lists all files beginning with n or S followed by "-release".

ls [nS]*-release

Lists all files beginning with n or S followed by “-release” (e.g., novell-release)

oes11-34:/etc # ls -la [nS]*-release
-rw-r--r-- 1 root root 72 Jan 21 2014 novell-release
-rw-r--r-- 1 root root 69 Jun 3 2013 SuSE-release
oes11-34:/etc # cat [nS]*-release
Novell Open Enterprise Server 11 (x86_64)
VERSION = 11.2
PATCHLEVEL = 2
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 3
oes11-34:/etc #

How to Identify Your Linux File System Type.

To identify a Linux file system you can use the following standard command:
df -T or cat /etc/fstab or mount but the commands listed below are much more cool:

Use the file command.

root# file -sL /dev/sdc1
/dev/sdc1: sticky Linux rev 1.0 ext3 filesystem data, UUID=28d01367-3886-4f67-a3c9-447bf006ae27 (needs journal recovery) (errors) (large files)

root# file -sL /dev/sdc1
/dev/sdc1: sticky Linux rev 1.0 ext3 filesystem data, UUID=28d01367-3886-4f67-a3c9-447bf006ae27 (needs journal recovery) (errors) (large files)

Use the fsck command:

root# fsck -N /dev/sdc1
fsck from util-linux 2.20.1
[/sbin/fsck.ext3 (1) -- /mnt/data] fsck.ext3 /dev/sdc1

root# fsck -N /dev/zeus/root
fsck from util-linux 2.20.1
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/mapper/zeus-root

How do I shrink the root logical volume (LV) on LVM?

The root partition and LV resizing should be done on unmounted partitions, so you have to boot from a rescue CD or USB stick, run it as live CD. Then make sure, that your root LV is not installed, by

mount

and unmount it when necessary. The LVM command vgchange changes attributes of volume groups. What needs to be “changed” to access the volume is the “availability” — i.e. to make the kernel realize the LVM volumes are there. This can be done by the command:

lvm vgchange -a y

Note, in rescue mode the system command is lvm and the LVM command that is run is vgchange. The -a y argument sets the availability to “y” or yes. As there are no specified LVM volume groups, this command will make all LVM volumes found available to the rescue kernel.

Once the kernel is aware of all LVM volumes they will be automatically mapped as devices. These are usually located under /dev/VolGroup or /dev/mapper/VolGroup (where “VolGroup” is the name of the Volume Group). Then do filesystem check

e2fsck -f /dev/yourVG/yourLV

on this LV. Then shrink filesystem

resize2fs /dev/yourVG/yourLV 5G

and reduce LV

lvreduce -L 5G /dev/yourVG/yourLV

Reboot to your system, Enjoy!

Write ISO to USB stick.

After inserting your USB stick, you can find out what device it is using the following command:

grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short)

Finally, once you've found your block device, write the image to it. Point 'dd' to the full path such as '/home/user/Downloads/Linux-x86_64.iso'

umount /dev/sdX
dd if=/path/to/downloaded.iso of=/dev/sdX

How to use bind mounts in Linux.

Bind mounting is quite simple. Instead of mounting a block device into a particular path you are mounting one path into another path.

mount -o bind /home/andzia /ftp/andzia

You will now see this reflected when running the mount command:

mount | grep var
/home/andzia on /ftp/andzia type none (rw,bind)

If you want this to persist across reboots, you’ll just need to update your /etc/fstab with the bind mount as well.

/home/andzia /ftp/andzia none bind 0 0

Get a hardware information using a CLI.

Dmidecode is a tool for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. While this is a good point in terms of report speed and safe‐ness, this also makes the presented information possibly unreliable.


dmidecode |grep -i product