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); };
...

The df command not showing correct values.

A common programming technique is to create a temporary file and immediately unlink() it. This leaves the file (and its space) available for the duration of the program but automatically causes its removal when the program using it terminates. One advantage is that no epilog (cleanup) code is necessary to write. To determine if you have a process holding an unlinked file open, do:

lsof -a +L1 /ebstest01db

or

lsof +D /ebstest01db +L1

Look for any files with an NLINK value of zero (0). These would be files with a zero link count that will vanish when the last process terminates. The SIZE/OFFSET column will offer the character size of the file in question.

sles02:/ # lsof -a +L1 /ebstest01db
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
oracle 9605 ebstest01 256u REG 8,33 40255488 0 3678213 /oradata/data_old/cntrl01.dbf (deleted)
oracle 9605 ebstest01 257u REG 8,33 40255488 0 5775361 /oradata/data_old/cntrl02.dbf (deleted)
oracle 9605 ebstest01 258u REG 8,33 40255488 0 9969665 /oradata/data_old/cntrl03.dbf (deleted)
oracle 9605 ebstest01 259uW REG 8,33 4294975488 0 2629640 /oradata/data_old/system01.dbf (deleted)
oracle 9605 ebstest01 260uW REG 8,33 4294975488 0 3678209 /oradata/data_old/system02.dbf (deleted)
oracle 9605 ebstest01 261uW REG 8,33 4294975488 0 3678210 /oradata/data_old/system03.dbf (deleted)
oracle 9605 ebstest01 262uW REG 8,33 4294975488 0 1597441 /oradata/data_old/system04.dbf (deleted)
oracle 9605 ebstest01 263uW REG 8,33 4294975488 0 1597448 /oradata/data_old/system05.dbf (deleted)
oracle 9605 ebstest01 264uW REG 8,33 4294975488 0 1597449 /oradata/data_old/system06.dbf (deleted)
oracle 9605 ebstest01 265uW REG 8,33 4294975488 0 1597450 /oradata/data_old/system07.dbf (deleted)
oracle 9605 ebstest01 266uW REG 8,33 4294975488 0 1597451 /oradata/data_old/system08.dbf (deleted)
oracle 9605 ebstest01 267uW REG 8,33 4632879104 0 4931624 /oradata/data_old/sysaux01.dbf (deleted)
oracle 9605 ebstest01 268uW REG 8,33 4554235904 0 4931599 /oradata/data_old/sysaux02.dbf (deleted)

And now kill the 3605 process.

Use logger to write a messages to log files.

The basic syntax for logger is logger message. It does not require any options if you are just going to write a message to the logfile and you want to write to the default /var/log/messages at the notice level.

root# logger Added a new disk to a machine

You can see a message in /var/log/message file. Also you can run this command with option -s Log the message to standard error, as well as the system log.

root# logger -s Added a new disk to a machine

Rescan of a SCSI bus without rebooting the VM.

To issue a SCSI bus rescan you must know on which bus you’ve added the device. If you don’t know which bus and if there are mutliple buses on the system you can rescan each bus which will be somehow annoying but will not interrupt the system.
To initiate a SCSI bus rescan type:
root# echo "- - -" > /sys/class/scsi_host/hostX/scan
where X stands for the SCSI bus you want to scan, and then you can type the following:

root# lsscsi
root# fdisk -l
root# tail -f /var/log/message

Also C T L “Channel on HBA” “Tatget SCSI id” “LUN” can be used instead of “—“.

Flush caching BIND (DNS cache)

All you have to do is restart bind to clear its cache:

root# /etc/init.d/named restart

You can also use rndc command as follows flush out all cache:

root# rndc restart

or

root# rndc exec

BIND v9.3.0 and above will support flushing all of the records attached to a particular domain name with rndc flushname command.

root# rndc flushname domain.name.com

It is also possible to flush out BIND views. For example, lan and wan views can be flushed using the following command:

root# rndc flush lan
root# rndc flush wan

Recover the MySQL root password.

To recover the MySQL root Password, please follow these steps:

1. Stop the MySQL server process.

root# /etc/init.d/mysql stop

2. Start the MySQL process with the –skip-grant-tables option, so that it will not prompt for a password.

root# mysqld_safe --skip-grant-tables &

root@mad:/home/user# mysqld_safe –skip-grant-tables &
[1] 23126
root@mad:/home/user# 140729 11:09:49 mysqld_safe Logging to syslog.
140729 11:09:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3. Connect to a MySQL as the root user.

root# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 5.5.38-0+wheezy1-log (Debian)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
mysql>

4. Set the new password for the MySQL root account.

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-PASSWORD") where user='root';
mysql> flush privileges;
mysql> quit

5. Exit and then stop and start or restart the MySQL server.

root# /etc/init.d/mysql restart

"Cannot access path" error when mounting an NCP share from OES11 SP1 using ncpmount.

When trying to mount an NCP share with the ncpmount command, the system prints out the following error:

Cannot access path "{volume-name}": Invalid argument

A network trace reveals a problem in the name space negotiation between the server and client. Even though the OES11 SP1 NCP server advertises the NFS namespace with the volume to be mounted, it returns error 191 (ERR_INVALID_NAMESPACE) when the NFS name space is used in requests for accessing the given volume.

ncpmount -S 192.168.87.70 -A 192.168.87.70 -o tcp,nonfs -V VOLC1 -U admin.novell /mnt

Testing whether a string is null.

Testing whether a string is null.

#!/bin/bash
# str-test.sh: Testing null strings and unquoted strings,
#+ but not strings and sealing wax, not to mention cabbages and kings . . .

# Using if [ … ]

# If a string has not been initialized, it has no defined value.
# This state is called “null” (not the same as zero!).

if [ -n $string1 ] # string1 has not been declared or initialized.
then
echo “String “string1″ is not null.”
else
echo “String “string1″ is null.”
fi # Wrong result.
# Shows $string1 as not null, although it was not initialized.

echo
Continue reading “Testing whether a string is null.”