Thứ Năm, 28 tháng 1, 2010

Rename command tips for multiple files

Ddd an extension to multiple files in different location:

$ EXT=`date "+%m%d%y.%H.%M"`
$ find . -type f -name "name" | xargs -i mv {} {}.$EXT


For example rename all *.bak file as *.txt, enter:

$ rename .bak .txt *.bak


Remove all blank space with rename command:

$ rename "s/ *//g" *.mp3


To remove .jpg file extension, you write command as follows:

$ rename 's/\.jpg$//' *.jpg


To convert all uppercase filenames to lowercase:

$ rename 'y/A-Z/a-z/' *


source http://snippets.dzone.com/posts/show/6136

Thứ Ba, 5 tháng 1, 2010

NET - Files .htaccess và .htpasswd được dùng để làm gì?

Nhiều web servers, trong đó có Apache thường dùng file .htaccess để bảo vệ các thư mục trên web server. Nếu một thư mục nào đó trên web server có lưu file .htaccess, khi bạn duyệt qua thư mục này, web server sẽ popup một hộp thoại yêu cầu nhập username và mật khẩu giống y như lúc bạn gặp Firewall của VDC! Chỉ khi nào bạn nhập vào một username và mật khẩu đúng, bạn mới có thể xem được trong thư mục đó có những gì?!
Danh sách các username và mật khẩu của .htaccess thường được lưu trong file .htpasswd
* Tại sao phải dùng dấu chấm ở trước trong tên file '.htaccess'? Các file có tên bắt đầu là một dấu chấm '.' sẽ được các web servers xem như là các file cấu hình. Các file này sẽ bị ẩn đi(hidden) khi bạn xem qua thư mục đã được bảo vệ bằng file .htaccess

Hướng dẫn sử dụng .htaccess

Bước 1: chuẩn bị username và mật khẩu cho .htaccess
[đt@localhost /]# htpasswd -c ./users vicki
New password: tyt
Re-type new password: tyt
Adding password for user vicki
-c để tạo file mới
Sau khi bạn chạy dòng lệnh trên, trong thư mục hiện tại sẽ xuất hiện file users với nội dung như sau:
vicki:JNSQVx3F3/n0c
File lưu username và mật khẩu có dạng như sau:
:
:
...
:
* Password thường được mã hóa bằng thuật toán DES(Data Encryption Standard). DES được dùng rất phổ biến trên Unix/Linux(*nix), đặc biệt là trong các files /etc/passwd hoặc /etc/shadow. DES rất khó bị crack. Bạn hãy tham khảo một số tài liệu khác để biết rõ về DES.
* Ngoài cách encrypt password bằng htpasswd như trên, bạn cũng có thể dùng Perl code sau để encrypt:
...
$encpass = &encrypt($password);
...
sub encrypt {
my($plain) = @_;
my(@salt);
@salt = ('a'..'z', 'A'..'Z', '0'..'9', '.', '/');
srand(time() ^ ($$ + ($$ << 15)) );
return crypt($plain, $salt[int(rand(@salt))] . $salt[int(rand(@salt))] );
}

Bước 2: tạo 1 file .htaccess với nội dung như sau:
AuthName "Khu vực cấm"
AuthType Basic
AuthUserFile /somepaths/users

require user vicki

# nếu bạn đang dùng Apache Server, hãy thêm các dòng sau vào
# để ngăn chặn users download các files .htaccess & .htpasswd


Order allow,deny
Deny from all



Order allow,deny
Deny from all


Giải thích

AuthName "Khu vực cấm" // tiêu đề của hộp thoại sẽ được popup
AuthUserFile /var/www.users // đường dẫn đầy đủ đến file lưu username & mật khẩu
require user vicki // danh sách các username được phép

Bước 3: tạo 1 thư mục trên web server, chẳng hạn như 'security', upload file .htaccess vào thư mục này, đừng quên chmod 644 cho file .htaccess và users. Thử upload vài files khác vào 'security'

Bước 4: mở trình duyệt web và vào thư mục 'security', http://localhost/security/. Bạn sẽ nhận được một hộp thông báo yêu cầu nhập username & password. Thử dùng username=vicki & password=tyt, bạn sẽ thấy được các files trong 'security' directory.


Hack .htaccess & .htpasswd

1/ Một số người sơ ý không chmod đúng cho files .htaccess và .htpasswd. Vì vậy bạn có thể dễ dàng download chúng về máy tính của mình. Sau đó bạn tìm một công cụ crack DES bằng tự điển như John the Ripper hoặc CrackJack để crack file .htpasswd
2/ Sử dụng các công cụ hack tự động
Bạn có thể sử dụng WWWHack hoặc Brutus để hack các websites được bảo vệ bằng files .htaccess và .htpasswd. Đây là các công cụ tấn công bằng tự điển gọn nhẹ nhưng đa năng, có hổ trợ proxy, rất dễ sử dụng. Tuy nhiên, nếu password quá khó hoặc tốc độ đường truyền của bạn cũng như của websites không tốt, có lẽ bạn phải chờ hàng giờ để WWWHack hoặc Brutus hoàn thành nhiệm vụ. Và bạn cũng đừng quên kiếm một tự điển tốt trước khi tiến hành hack.
* WWWHack và Brutus làm việc như thế nào? DES(Data Encryption Standard) dường như rất khó bị crack, chỉ có một cách duy nhất và cũng là dễ nhất là dùng tự điển. WWWHack và Brutuslàm việc gần giống như nhau. Chúng sẽ chọn một password bất kì trong tự điển, sau đó gởi đến website. Nếu nhận được HTML status code 401 - Authorization Required, "Access Denied", "Enter your password again" có nghĩa là password không đúng, chúng sẽ thử lại với một password khác có trong tự điển. Nếu nhận được HTML status code 200 OK, ... có nghĩa là password đúng, hay nói cách khác là đã bị crack.
(suu tập)


RefLink: http://thegioimang.org/security/files-.htaccess-va-.htpasswd-duoc-dung-de-lam-gi-.html

NET - Subnet Masks

Khi ta chia một Network ra thành nhiều Network nhỏ hơn, các Network nhỏ nầy được gọI là Subnet. Theo quy ước, các địa chỉ IP được chia ra làm ba Class (lớp) như sau:
class A : 255.0.0.0
class B : 255.255.0.0
class C : 255.255.255.0
Subnet Mask của Class A bằng 255.0.0.0 có nghĩa rằng ta dùng 8 bits, tính từ trái qua phải (các bits được set thành 1), của địa chỉ IP để phân biệt các NetworkID của Class A. Trong khi đó, các bits còn sót lại (trong trường hợp Class A là 24 bits đuợc reset thành 0) được dùng để biểu diễn computers, gọi là HostID. Nếu bạn chưa quen cách dùng số nhị phân hãy đọc qua bài Hệ thống số nhị phân.
Subnetting
Hãy xét đến một địa chỉ IP class B, 139.12.0.0, với subnet mask là 255.255.0.0 (có thể viết là: 139.12.0.0/16, ở đây số 16 có nghĩa là 16 bits được dùng cho NetworkID). Một Network với địa chỉ thế nầy có thể chứa 65,534 nodes hay computers (65,534 = (2^16) –2 ) . Đây là một con số quá lớn, trên mạng sẽ có đầy broadcast traffic.
Giả tỉ chúng ta chia cái Network nầy ra làm bốn Subnet. Công việc sẽ bao gồm ba bước:
1) Xác định cái Subnet mask
2) Liệt kê ID của các Subnet mới
3) Cho biết IP address range của các HostID trong mỗi Subnet
Bước 1: Xác định cái Subnet mask
Để đếm cho đến 4 trong hệ thống nhị phân (cho 4 Subnet) ta cần 2 bits. Công thức tổng quát là:
Y = 2^X
mà Y = con số Subnets (= 4)
X = số bits cần thêm (= 2)
Do đó cái Subnet mask sẽ cần 16 (bits trước đây) +2 (bits mới) = 18 bits
Địa chỉ IP mới sẽ là 139.12.0.0/18 (để ý con số 18 thay vì 16 như trước đây). Con số hosts tối đa có trong mỗi Subnet sẽ là: ((2^14) –2) = 16,382. Và tổng số các hosts trong 4 Subnets là: 16382 * 4 = 65,528 hosts.
Bước 2: Liệt kê ID của các Subnet mới
Trong địa chỉ IP mới (139.12.0.0/18) con số 18 nói đến việc ta dùng 18 bits, đếm từ bên trái, của 32 bit IP address để biểu diễn địa chỉ IP của một Subnet.
Subnet mask trong dạng nhị phân Subnet mask
11111111 11111111 11000000 00000000 255.255.192.0
Như thế NetworkID của bốn Subnets mới có là:
Như thế NetworkID của bốn Subnets mới có là:
Subnet Subnet ID trong dạng nhị phân Subnet ID
1 10001011.00001100.00000000.00000000 139.12.0.0/18
2 10001011.00001100.01000000.00000000 139.12.64.0/18
3 10001011.00001100.10000000.00000000 139.12.128.0/18
4 10001011.00001100.11000000.00000000 139.12.192.0/18
Bước 3: Cho biết IP address range của các HostID trong mỗi Subnet
Vì Subnet ID đã dùng hết 18 bits nên số bits còn lại (32-18= 14) được dùng cho HostID.
Nhớ cái luật dùng cho Host ID là tất cả mọi bits không thể đều là 0 hay 1.
Subnet HostID IP address trong dạng nhị phân HostID IP address Range
1 10001011.00001100.00000000.00000001
10001011.00001100.00111111.11111110 139.12.0.1/18 -139.12.63.254/18
2 10001011.00001100.01000000.00000001 10001011.00001100.01111111.11111110 139.12.64.1/18 -139.12.127.254/18
3 10001011.00001100.10000000.00000001
10001011.00001100.10111111.11111110 139.12.128.1/18 -139.12.191.254/18
4 10001011.00001100.11000000.00000001 10001011.00001100.11111111.11111110 139.12.192.0/18 –139.12.255.254
Bạn có để ý thấy trong mỗi Subnet, cái range của HostID từ con số nhỏ nhất (màu xanh) đến con số lớn nhất (màu cam) đều y hệt nhau không?
Bây giờ ta thử đặt cho mình một bài tập với câu hỏi:
Bạn có thể dùng Class B IP address cho một mạng gồm 4000 computers được không? Câu trả lời là ĐƯỢC. Chỉ cần làm một bài toán nhỏ.
Giả tỉ cái IP address là 192.168.1.1. Thay vì bắt đầu với Subnet mask, trước hết chúng ta tính xem mình cần bao nhiêu bits cho 4000 hosts.
Con số hosts ta có thể có trong một network được tính bằng công thức:
Y = (2^X –2)
Nhớ cái luật dùng cho Host ID là tất cả mọi bits không thể đều là 0 hay 1.
4094 = (2^12 –2)
X = 12 , ta cần 12 bits cho HostIDs, do đó Subnet mask sẽ chiếm 20 (=32-12) bits.
Quá trình tính toán nói trên nầy mang tên là Variable Length Subnet Mask(VLSM).
Supernetting
Giả tỉ ta mạng của ta có 3 Subnets:
Accounting: gồm 200 hosts
Finance : gồm 400 hosts
Marketing: gồm 200 hosts
Bạn hòa mạng với Internet và được Internet Service Provider (ISP) cho 4 Class C IP addresses như sau:
192.250.9.0/24
192.250.10.0/24
192.250.11.0/24
192.250.12.0/24
Bạn có 3 segments và bạn muốn mỗi segment chứa một Network.
Bây giờ bạn làm sao?
Địa chỉ IP trong Class C với default subnet mask 24 cho ta con số Hosts tối đa trong mỗi Network là [(2^X) – 2] = (2^8) – 2 = 254. Như thế segments Accounting và Marketing không bị trở ngại nào cả.
Nhưng ta thấy Segment Finance cần thêm 1 bit mới đủ. Ta làm như sau:
Bước 1: Liệt kê Network IP addresses trong dạng nhị phân
192.250.9.0/24 11000000 11111010 00001001 00000000 (1)
192.250.10.0/24 11000000 11111010 00001010 00000000 (2)
192.250.11.0/24 11000000 11111010 00001011 00000000 (3)
192.250.12.0/24 11000000 11111010 00001100 00000000 (4)
Bước 2: Nhận diện network prefix notation
23 bits đầu (từ trái qua phải) của 2 network IP address (2) and (3) đều giống nhau.
Nếu chúng ta thu Subnet mask từ 24 xuống 23 cho (2) và (3) ta sẽ có một Subnet có thể cung cấp 508 hosts.
IP address của mỗi segment trở thành:
Accounting: gồm 200 hosts: 192.250.9.0/24
Finance: gồm 400 hosts: 192.250.10.0/23
Marketing: gồm 200 hosts: 192.250.12.0/24
Bây giờ IP address 192.250.11.0 trở thành một HostID tầm thường trong Subnet 192.250.10.0/23.
Quá trình ta làm vừa qua bằng cách bớt số bits trong Subnet mask khi gom hai hay bốn (v.v..) subnets lại với nhau để tăng con số HostID tối đa trong một Subnet, được gọi là SUPERNETTING.
Supernetting đuợc dùng trong router bổ xung CIDR (Classless Interdomain Routing và VLSM (Variable Length Subnet Mask).
Và luôn luôn nhớ rằng trong internetwork, NETWORK ID phải là địa chỉ độc đáo (unique).



http://thegioimang.org/mang-can-ban/subnet-masks.html

NET - Mô hình TCP/IP

Kiến trúc phân tầng của mô hình TCP/IP

Bộ giao thức TCP/IP được phân làm 4 tầng:
Network access Layer: tương ứng với tầng Physical và Datalink của OSI.
Internet Layer: tương ứng với tầng Network của OSI.
Transport Layer: tương ứng với tầng Transport của OSI.
Application Layer: tương ứng với 3 tầng cao nhất(Session, Presentation, Application) trong OSI.

Có nhiều loại giao thức có trong bộ giao thức truyền thống TCP/IP, nhưng có hai giao thức quan trọng nhất được lấy để đặt tên cho bộ giao thức này là TCP(Transmission Control Protocol) và IP(Internet Protocol). Cụ thể sẽ là:
Các giao thức hoạt đông ở tầng Application:
FTP (File transfer Protocol): Giao thức truyền tệp, cho phép người dùng lấy hoặc gửi một tệp tin đến một máy khác.
Telnet: Chương trình mô phỏng thiết bị đầu cuối cho phép người dùng login vào máy chủ từ một máy khác trên mạng.
SMTP (Simple Mail Transfer Protocol): Một giao thức để truyền thư
DNS (Domain Name Service): Dịch vụ tên miền cho phép nhận ra một máy tính từ tên miền của nó thay vì phải đánh vào địa chỉ IP khó nhớ. Nhiều bạn thường nhầm DNS là Domain Name Server – Sai.
SNMP (Simple Network Management Protocol): Giao thức cung cấp các công cụ quản trị mạng.
Các giao thức hoạt đông ở tầng Transport:
UDP (User Datagram Protocol): Giao thức truyền không tin cậy nhưng ưu điểm của nó là nhanh và tiết kiệm.
TCP (Transmission Control Protocol): Cung cấp một phương thức truyền tin cậy
Các giao thức hoạt đông ở tầng Internet:
IP (Internet Protocol): Giao thức Internet, cung cấp các thông tin để làm sao các gói tin có thể đến được đích.
ARP (Address Resolution Protocol): Giao thức chuyển địa chỉ IP thành địa mạng chỉ vật lý
ICMP (Internet Control Message Protocol): Một giao thức thông báo lỗi xảy ra trên đường truyền.
Các công nghệ thường gặp ở tầng vật lý: Ethernet, Token Ring, Token Bus, Fiber.

Cũng giống như mô hình tham chiếu OSI, dữ liệu từ tầng Application đi xuống các tầng dưới, nơi mà mỗi tầng có nhưng định nghĩa riêng về dữ liệu mà nó sử dụng, chúng thêm vào các header của riêng mình trước khi chuyển tiếp xuống tầng tiếp theo, quá trình nhận diễn ra ngược lại.

Qua 2 bài viết của tôi chắc các bạn đã hình dung phần nào về mô hình phân lớp trong mạng, trong các bài viết này tôi mới nói qua về khái niệm còn nếu đi sâu vào từng lớp, từng giao thức thì còn rất nhiều để nói. Chờ ý kiến của các bạn rùi viết tiếp

RefLink: http://thegioimang.org/forum/ccna-ccnp-ccie/1153-mo-hinh-tcp-ip.html

Thứ Bảy, 2 tháng 1, 2010

LINUX - How to Find Large Files using Linux Command Line

find / -type f -size +20000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’

or

find / -type f -size +20000k -exec ls -lh {} ; | awk ‘{ print $9 “: ” $5 }’ > filelist.txt


find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nrk 2,2


To put the results in a text file.

Found here, a good resource for command line stuff – http://snippets.dzone.com/posts/show/1491

Thứ Hai, 28 tháng 12, 2009

Packages are used for building source

lm_sensors sysstat diffutils bzip2 gcc cpp gcc-c++ make autoconf libtool doxygen pkgconfig rpm-build

Thứ Ba, 22 tháng 12, 2009

Setting up Splunk with Syslog-ng and a FIFO

Assumptions ¶
* You have a supported Splunk platform and root access to the server.
* You are installing Splunk 3.3.x or higher.
The facts at abc company ¶
What is a FIFO? ¶
A FIFO is an old programming term that stands for First In First Out. A more accurate name for what you're setting up is a Named Pipe. Basically, what it is, is a special file on your UNIX system that receives input from some program and sends that information to another program. You can think of it as a stack. One program puts things on the stack, and another program takes stuff off the stack, but it starts with the first item that went on.
Why Syslog-ng? ¶
Well basically because the standard syslog daemon sucks. Seriously, the standard syslog daemon that comes with your typical UNIX is very limited. Syslog-ng is very flexible and includes support for many things that the standard syslog daemon does not, including, but not limited to: multiple sources and destinations, extensive filtering including regex support, the ability to read and write to pipes, and much more. It's also extremely efficient on system resources.
Syslog-ng installation ¶
Depending on your platform, the procedure for installing syslog-ng may vary widely. On Linux platforms, you will most likely be using RPM or Debs. On Solaris, it's quite likely that Sun Freeware will have a package that will work for you.
Examples for common platforms ¶
redhat variant# yum install syslog-ng

debian variant# apt-get install syslog-ng

gentoo# emerge syslog-ng

Run this command to install syslog-ng to abc company's servers:
server# yum install syslog-ng

To have the latest version, see Appendix F - Upgrading Syslog-ng.
Syslog deactivate ¶
Whistle syslog and syslog-ng are programs that have same purposes, please deactivate syslog before using the syslog-ng:
/etc/rc.d/init.d/syslog stop
chmod 644 /etc/rc.d/init.d/syslog
chkconfig syslog off
rm -f /etc/logrotate.d/syslog

Creating the FIFO ¶
Select a place on your filesystem for the FIFO to live. It doesn't matter much where as the FIFO will only buffer a limited amount of lines that will consume an insignificant amount of resources. I would suggest /var as that is where most sockets and pipes on the system are located by default. I gave mine a subdirectory called syslog-ng for the sake of tidiness.
Example command to create the FIFO: ¶
server# mkfifo /opt/syslog_fifo

Remember this location as you will need to put it in your syslog-ng and splunk config files.
Configuring syslog-ng ¶
In most installs of syslog-ng, your main configuration file will be located in /usr/local/etc/syslog-ng.conf (or /etc/syslog-ng.conf). At a minimum, you will need to set up a source that accepts remote connections [assuming that you wish to send logs from multiple systems to be included in your Splunk index], and a destination for your FIFO. It would also be wise to log to a location on the filesystem as well. Here's the first bit:
source remote {
udp();
};

destination splunk {
pipe("/opt/syslog_fifo");
};

log {
source(remote);
destination(splunk);
};

That will be sufficient to send the logs only to your named pipe. However, I would recommend that you also set up syslog-ng to log to a location on the local filesystem like so:
destination hosts {
file("/opt/hosts/$HOST/messages"
owner(root) group(logs) perm(0640) dir_perm(0750) create_dirs(yes));
};

log {
source(remote);
destination(hosts);
};

Note that the $HOST moniker is a magic variable in syslog-ng that is replaced by the hostname of the system that is sending the logs. It's quite handy. The create_dirs bit automatically creates the subdirectories if they do not exist.
See Apendix A for the initial configuration of syslog-ng at abc company.
Configuring Splunk ¶
For this portion, I will assume that Splunk was installed in it's default location of /opt. If you have installed in a different location, adjust the paths accordingly.
inputs.conf (3.x.x) ¶
Splunk Init script ¶
As root, you run:
splunk enable boot-start

This will create an init script (or other configuration change) appropriate for your operating system.
Reference:
http://www.splunk.com/doc/latest/installation/ConfigSystemStartup
http://www.splunk.com/doc/latest/installation/RunningNonRoot
Making a secondary syslog-ng server ¶
Create another instance of syslog-ng reduces the risk of losting log files.
Installing a secondary server is not different to installing the primary, except for the configuration file:

Primary server
Secondary server
* Destination directive:
d_local
file("/opt/syslog-ng/192.168.XX.YY/$YEAR/$MONTH/$DAY/$FACILITY.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));
file("/opt/syslog-ng/$YEAR/$MONTH/$DAY/192.168.XX.YY/$FACILITY.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));
* Destination directive:
d_separatedbyhosts
file("/opt/syslog-ng/$HOST/$YEAR/$MONTH/$DAY/$FACILITY.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));
file("/opt/syslog-ng/$YEAR/$MONTH/$DAY/$HOST/$FACILITY.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));
Forward to Splunk
Yes
Currently No
Forward the local log files
N/A
Forward from the secondary server to the primary server.
Debugging FIFOs ¶
If you are having problems with your FIFO, the first thing that you should do is to verify that it it getting data put into it by syslog-ng. I have written a small tool called Piper that can help you do this. Download Piper and run the following command:
./piper.pl -d debug.log /opt/syslog_fifo

Then check your debug.log to make sure that it contains data. If it does contain data, then syslog-ng and the FIFO that you created are working properly and you should re-examine your Splunk config. If it looks correct, contact Splunk support for assistance. If your debug.log does not contain any data, then something is most likely wrong with your syslog-ng config. First try restarting syslog-ng to make sure that your changes have applied. If that doesn't do the trick, examine your syslog-ng configuration closely and make sure that you didn't miss any semicolons or other necessary syntax.
Apendix A – The configuration of syslog-ng for the primary syslog-ng server at abc company ¶

Apendix B – daily crond script to compress log file ¶
[root@syslog ~]# cat /etc/cron.daily/syslog-ng
#!/bin/sh

/usr/bin/find /opt/syslog-ng ! -name "*bz2" -type f ! -path "*`/bin/date +%Y/%m/%d`*" -exec /usr/bin/bzip2 {} \;

Caution.
Make sure that this script can be executable.
Apendix B.1 – logrotate script of local syslog files ¶
[root@syslog ~]# cat /etc/logrotate.d/syslog-ng
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron /var/log/kern /opt/syslog-ng-internal/syslog-ng.log {
monthly
rotate 12
compress
postrotate
/etc/rc.d/init.d/syslog-ng reload 2>/dev/null
endscript
}

Caution.
Remember always disable the logrotate script /etc/logrotate.d/syslog associated with syslog program by commenting all commands or removing this file.
Apendix B.2 – logrotate script of Splunk log files ¶
By default, Splunk does not rotate some log files. So this script below will rotate logs that have too many lines.
[root@syslog ~]# touch /etc/logrotate.d/splunk
[root@syslog ~]# vim /etc/logrotate.d/splunk
[root@syslog ~]# cat /etc/logrotate.d/splunk
/opt/splunk/var/log/splunk/splunkd.log /opt/splunk/var/log/splunk/audit.log /opt/splunk/var/log/splunk/splunklogger.log /opt/splunk/var/log/splunk/python.log /opt/splunk/var/log/splunk/license_audit.log /opt/splunk/var/log/splunk/web_service.log {
missingok
monthly
rotate 12
create 0600 splunk splunk
}

Apendix C – the configuration of syslogd on Linux servers ¶
System messages on Linux server are logged to syslog-ng server by syslogd daemon. The main configuration file of syslogd is located at /etc/syslog.conf.
Here is a sample of syslog.conf file on Linux servers at abc company:
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages

# The authpriv file has restricted access.
authpriv.* /var/log/secure

# Log all the mail messages in one place.
mail.* -/var/log/maillog

# Log cron stuff
cron.* /var/log/cron

# Everybody gets emergency messages
*.emerg *

# Save boot messages also to boot.log
local7.* /var/log/boot.log

#
# log messages to syslog-ng servers
*.* @192.168.XX.YY
*.* @192.168.XX.YY

Important:
- Do not use syslogd on syslog-ng server. This will prevent syslog-ng from receiving log messages.
- Verify that the SSH daemon use LogFacilitate? = authpriv & LogLevel? = VERBOSE.
Apendix D – logging Windows applications using Datagram SyslogAgent? ¶
Unfortunately all Windows OSes does not support syslog protocol. They are only have Event Viewer, which stores all messages created by themselves. The event tool also receives messages from some applications supported to do this. To make the syslog server collect messages from Windows-based clients, we (DongA) use SyslogAgent from Datagram. This software is licenced under GNU GPL.
Download this software with the URI: http://download.eab.com.vn/pub/windows/server-installation/syslogagent_setup.zip. Read the setup-guide.txt on the zip file to install this software.
Merge these registries below to configure:
Windows Registry Editor Version 5.00

# Configure Syslog Agent parameters

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram]

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram\SyslogAgent]
"UsePingBeforeSend"=hex:00
"Syslog"="192.168.XX.YY"
"SendToPort"=dword:00000202
"ForwardToMirror"=hex:01
"Syslog1"="192.168.XX.YY"
"SendToBackupPort"=dword:00000202
"ForwardEventLogs"=hex:01
"ForwardApplicationLogs"=hex:01
"EventLogPollInterval"=dword:00000002
"LastRun"=dword:00000001
"EventIDFilterList"="1,1000,1001,17,4321,6013,7001,7035,7036,7040,4786,515,528,610,560"
"TCPDelivery"=hex:00
"CarrigeReturnReplacementCharInASCII"=dword:00000020
"LineFeedReplacementCharInASCII"=dword:00000020

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram\SyslogAgent\Application]
"Information"=dword:00000001
"Information Priority"=dword:000000be
"Warning"=dword:00000001
"Warning Priority"=dword:000000bc
"Error"=dword:00000001
"Error Priority"=dword:000000bb
"Audit Success"=dword:00000001
"Audit Success Priority"=dword:000000be
"Audit Failure"=dword:00000001
"Audit Failure Priority"=dword:000000bd

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram\SyslogAgent\ApplicationLogs]

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram\SyslogAgent\Security]
"Information"=dword:00000001
"Information Priority"=dword:00000026
"Warning"=dword:00000001
"Warning Priority"=dword:00000024
"Error"=dword:00000001
"Error Priority"=dword:00000023
"Audit Success"=dword:00000001
"Audit Success Priority"=dword:00000026
"Audit Failure"=dword:00000001
"Audit Failure Priority"=dword:00000025

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram\SyslogAgent\System]
"Information"=dword:00000001
"Information Priority"=dword:0000001e
"Warning"=dword:00000001
"Warning Priority"=dword:0000001c
"Error"=dword:00000001
"Error Priority"=dword:0000001b
"Audit Success"=dword:00000001
"Audit Success Priority"=dword:0000001e
"Audit Failure"=dword:00000001
"Audit Failure Priority"=dword:0000001d


# make the Syslog Agent service start automatically

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Syslog Agent]
"DisplayName"="Syslog Agent"
"Description"="Forwards Event logs to Syslog Server"
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"DependOnService"=hex(7):45,00,76,00,65,00,6e,00,74,00,4c,00,6f,00,67,00,00,00,\
00,00
"DependOnGroup"=hex(7):00,00

To filter out some messages, fill the EventIDFilterList parameter with event Ids, e.g.:
"EventIDFilterList"="1,1000,1001,17,4321,6013,7001,7035,7036,7040,4786,515,528,610,560"

To enable mirror delivery, make sure the clients have these registries below:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Datagram\SyslogAgent]
"UsePingBeforeSend"=hex:00
"ForwardToMirror"=hex:01
"Syslog1"="192.168.2.23"
"SendToBackupPort"=dword:00000202

Apendix E – Upgrading Syslog-ng ¶
Stop the 'monit' service
/etc/init.d/monit stop

Stop syslog-ng
/etc/init.d/syslog-ng stop