Syslog Messages from Remote Server are not writing to Log File Anymore


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Syslog Messages from Remote Server are not writing to Log File Anymore
# 1  
Old 09-25-2014
Syslog Messages from Remote Server are not writing to Log File Anymore

Hello All,

Server: SUSE Linux Enterprise Server 11.3 (x86_64)

Syslog-ng Version: syslog-ng 2.0.9

We have configured a Cisco router to send it's log messages to this server listed above. This has been working just perfectly
for the last couple months, but we had never setup the log rotation part of it and the log file was getting extremely large.
So I decided to manually move the current log file to a new file and then ran touch on the original log filename to re-create it.

Code:
/var/log# mv remote.syslog.log remote.syslog.log_20140925
/var/log# touch remote.syslog.log
/var/log# chmod 640 remote.syslog.log
/var/log# bzip2 -z remote.syslog.log_20140925

I did this so I could compress the original log file with bzip2 seeing how large it was getting... Now, the log messages
from the router are not being written to the log file anymore. I ran Wireshark and I could see the router sending the messages,
to the server, yet nothing is being written to the log file anymore...

Did I mess this up somehow by moving and re-creating the original log file?

If anyone knows how I can fix this please feel free... But any thoughts or suggestions would be greatly appreciated!

Thanks in Advance,
Matt
# 2  
Old 09-25-2014
You need to tell syslog there's a new log file by hupping (kill -hup PID) it...
This User Gave Thanks to RudiC For This Post:
# 3  
Old 09-25-2014
Did you HUP the running syslogd process?

I bet if you look under /proc for your syslogd process, you'll find the original log file still open under /proc/PID/fd/
This User Gave Thanks to achenle For This Post:
# 4  
Old 09-25-2014
Hey Guys, thanks for the replies!

No I haven't tried that... But I think your right... Check this out:
Code:
nagios:/proc/2975/fd # ll
total 0
lr-x------ 1 root root 64 Sep 25 16:44 0 -> /dev/null
l-wx------ 1 root root 64 Sep 25 16:44 1 -> /dev/null
l-wx------ 1 root root 64 Sep 25 16:44 10 -> /var/log/mail.info
l-wx------ 1 root root 64 Sep 25 16:44 11 -> /var/log/messages
l-wx------ 1 root root 64 Sep 25 16:44 2 -> /dev/null
lrwx------ 1 root root 64 Sep 25 16:44 3 -> socket:[131564428]
lrwx------ 1 root root 64 Sep 25 16:44 4 -> socket:[131564430]
lrwx------ 1 root root 64 Sep 25 16:44 5 -> /dev/xconsole
l-wx------ 1 root root 64 Sep 25 16:44 6 -> /var/log/remote.syslog.log_20140925 (deleted)
l-wx------ 1 root root 64 Sep 25 16:44 7 -> /var/log/mail
lrwx------ 1 root root 64 Sep 25 16:44 8 -> /dev/tty10
l-wx------ 1 root root 64 Sep 25 16:44 9 -> /var/log/warn

So would I run something like:
Code:
# service syslog-ng restart

Also, what does the "-hup" part of the kill command do?

Thanks again for the replies, much appreciated!

Thanks,
Matt

---------- Post updated at 04:51 PM ---------- Previous update was at 04:46 PM ----------

Ok, so I ran the following and now the log file is being written to again.

Code:
# service syslog restart

Thanks for the help guys, much appreciated!

Thanks Again,
Matt
# 5  
Old 09-26-2014
kill (somewhat misleading name!) sends signals to processes; use kill -l to list all of them. Processes react on signals, e.g. by "committting suicide when tapped on their shoulder and asked to do so" by the TERM signal. HUP (hangup) is one of them. syslog uses it to reread its config and if need be start a new logfile. So no restart necessary for a new file...
# 6  
Old 09-26-2014
To expand on what RudiC (correctly) explained:

When a process (your syslog for example) writes to a file it has to open it first. To "open it" means issuing a system call fopen(). The OS gives back a "file handle" by which the process now can access the file (until it closes it, which means issuing another system call).

This file handle now identifies the file not by its name but by a more "personal" identification: the inode number. When you delete the file and create a new one with the same name in its place then exactly this has happened: a new file with the same name is in the place of the old file, but the new file and the old file are still distinct files and they have different inode numbers.

Think of it like this: some "John Smith" lives in an appartment. When he moves out and another guy, incidentally also named "John Smith", moves in, they are still not the same person, yes?

Therefore, until told otherwise, your process still writes into the old file, even if it is no longer visible because you deleted it. It even takes space on your harddisk until your process holds it open. Only when you stop the last process holding it open (more than one process could open a file simultaneously) it will be finally "unlinked" - the space it takes will be relinquished and its data be destroyed.

With sending a signal to the process you tell it to "start over": re-read its configuration files, open the necessary files anew, etc., similar to stopping and restarting it, but without the actual program stop and program start.

I hope this helps.

bakunin
# 7  
Old 09-26-2014
Hey RudiC/bakunin, thanks for the replies!

Ok gotcha, makes sense... Thanks for the detailed explaination, much appreciated!

Yea, I was slightly familiar with signals but just a little... The only other thing I used kill for (*other then killing a process) was to
send the USR1 or SIGUSR1 signal to check the status of dd. But that's good to know. I assume you could use that for most
daemons that are running?

Thanks Again,
Matt
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

3. Linux

How to push Tomcat logs to remote syslog server?

I found a script for automatically push tomcat logs to syslog server which is locate in same server. How do I change it to push logs to remote server? log4j.rootLogger=INFO, WARN, console, file, SYSLOG log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.append=true... (2 Replies)
Discussion started by: heshandh
2 Replies

4. UNIX for Dummies Questions & Answers

[Solved] syslog not accepting remote messages?

Hi, I created central syslog server, but it's not accepting the messages from remote. Not sure why I can't start the service with -r options? Please help. # service syslog restart Shutting down kernel logger: Shutting down system logger: ... (1 Reply)
Discussion started by: samnyc
1 Replies

5. Shell Programming and Scripting

Continuous log file transfer to remote server

I have several production servers and 1 offline server. Production server continuously generates new log files for my application. Depending on time of day new files may be generated every few seconds and at other times every few hours. I also have an offline server where I would like to pull log... (3 Replies)
Discussion started by: yoda9691
3 Replies

6. UNIX for Advanced & Expert Users

Forwarding syslog msgs to remote server non standard port

Hello Forumers! Has anyone successfully implemented forwarding of syslog messages to a remote server which is listening on a port other than udp514? Thanks! (3 Replies)
Discussion started by: bluescreen
3 Replies

7. Shell Programming and Scripting

Writing to remote file

hello All, I have the login name and pasword. I want to know how to use this info and open a file and write to it. Ex: login: expr pasword: xxxx file: /expr/tmp.txt I know how to use ftp (use Net::FTP) and upload files but I want to know how to write to a file. Thanks, (4 Replies)
Discussion started by: rimser9
4 Replies

8. UNIX for Advanced & Expert Users

writing the log file into syslog

Hi, we are trying to enable auditing for few oracle 9i database. and right now it writies into adump directory. As adump can be read/write by oracle user so could it be possible to write into syslog while oracle keeps writing to adump . thanks in advance. Pk (2 Replies)
Discussion started by: p4cldba
2 Replies

9. HP-UX

How to Redirect the error messages from Syslog file to our own Application Log File

Hello, I am New to Unix. I am Using HP-UX 9000 Series for my Application. I am Currently Facing an Issue that the error messages are being written in the syslog file instead of the Application Log File. The Codes for that Syslog.h is written in Pro*C. I want to know how to Redirect these... (3 Replies)
Discussion started by: balasubramaniam
3 Replies
Login or Register to Ask a Question