Nmap (Network Mapper) adalah sebuah program open source yang berguna
untuk mengesksplorasi jaringan. Nmap didesain untuk dapat melakukan scan jaringan
yang besar, juga dapat digunakan untuk melakukan scan host tunggal. Nmap
menggunakan paket IP untuk menentukan host-host yang aktif dalam suatu jaringan,
port-port yang terbuka, sistem operasi yang dipunyai, tipe firewall yang dipakai, dll.
untuk mengesksplorasi jaringan. Nmap didesain untuk dapat melakukan scan jaringan
yang besar, juga dapat digunakan untuk melakukan scan host tunggal. Nmap
menggunakan paket IP untuk menentukan host-host yang aktif dalam suatu jaringan,
port-port yang terbuka, sistem operasi yang dipunyai, tipe firewall yang dipakai, dll.
Keunggulan-keunggulan yang dimiliki oleh Nmap:
• Powerful
Nmap dapat digunakan untuk men-scan jaringan yang besar
• Portable
Nmap dapat berjalan di berbagai macam sistem operasi seperti Linux, Windows,
FreeBSD, OpenBSD, Solaris, dll
• Mudah untuk digunakan
• Free
• Mempunyai dokumentasi yang baik
Menjalankan nmap
Untuk dapat menjalankan nmap Anda dapat menggunakan hak pengguna biasa, tetapi ada beberapa fitur dan teknik yang membutuhkan hak root karena melibatkan antarmuka kernel yang kritikal seperti raw socket. Hasil scanning nmap biasanya adalah daftar port 'menarik' yang terbuka, difilter atau tidak dari host target. Nmap selalu memberikan nama layanan untuk 'well-known-port' (jika ada), nomor, status, dan protokol.
Untuk dapat menjalankan nmap Anda dapat menggunakan hak pengguna biasa, tetapi ada beberapa fitur dan teknik yang membutuhkan hak root karena melibatkan antarmuka kernel yang kritikal seperti raw socket. Hasil scanning nmap biasanya adalah daftar port 'menarik' yang terbuka, difilter atau tidak dari host target. Nmap selalu memberikan nama layanan untuk 'well-known-port' (jika ada), nomor, status, dan protokol.
State
State pada nmap adalah "open", "filtered", dan "unfiltered". Open berarti mesin target dapat menerima koneksi pada port tersebut. Filtered berarti ada sebuah firewall, packet-filter, atau device jaringan yang menghalangi port dan mencegah nmap untuk menentukan port yang dddddddddddddddddterbuka. Unfiltered berarti port yang diketahui oleh nmap tertutup dan tidak ada firewall atau packet-filter yang menutupi. Unfiltered port adalah kasus umum yang hanya terlihat ketika sebagian besar port yang di-scan adalah dalam keadaan filtered
Instalasi Nmap
Program Nmap dapat diperoleh secara gratis dengan cara mendownloadnya
pada situs www.Nmap.org
Nama file yang didapatkan adalah Nmap-3.30.tar.gz. kebetulan saya pake linux,and juga bisa download versi winddowsnya File dalam bentuk ini
tidak dapat langsung diinstall, untuk dapat menginstalnya file ini harus
didecompreesed terlebih dahulu. Perintah yang digunakan untuk mendecompreesed
file tersebut adalah gunzip, jadi untuk mendecompreesed file Nmap-3.30.tar.gz
digunakan perintah seperti berikut:
Code:
[root@localhost root]#gunzip Nmap-3.30.tar.gz
Setelah perintah tersebut diberikan maka file Nmap-3.30.tar.gz akan berubah
menjadi Nmap-3.30.tar , bentuk file ini juga masih belum dapat digunakan, untuk
dapat menggunakannya harus diketikkan perintah seperti berikut:
Code:
[root@localhost root]#tar xvf Nmap-
Setelah perintah tersebut diketikkan maka semua file (biasanya dibuat dalam
satu folder, dalam hal ini folder Nmap-3.30) sudah dapat diakses, untuk menginstall
program Nmap, harus diketikkan perintah berikut pada folder Nmap-3.30:
Code:
[root@localhost Nmap-3.30]#./configure
[root@localhost Nmap-3.30]#make
[root@localhost Nmap-3.30]#make install
[root@localhost Nmap-3.30]#make
[root@localhost Nmap-3.30]#make install
Apabila tidak bermasalah maka program Nmap sudah dapat dijalankan.
Hal-hal yang Dapat Dilakukan dengan Menggunakan Nmap
Fungsi utama dari Nmap adalah sebagai port scanning, menurut definisinya
scanning adalah kegiatan probe dalam jumlah yang besar dengan menggunakan tool
secara otomatis, dalam hal ini adalah Nmap.
Sebuah scanner sebenarnya adalah scanner untuk port TCP/IP, yaitu sebuah
program yang menyerang port TCP/IP dan servis-servisnya (telnet, ftp, http, dan lain-
lain) dan mencatat respon dari komputer target. Dengan cara ini, user program
scanner dapat memperoleh informasi yang berharga dari host yang menjadi target.
Teknik-teknik yang dapat digunakan untuk men-scan port dari host yang
dituju ada berbagai macam cara, yaitu:
TCP connect() scanning ( -sT )
Adalah teknik yang paling dasar dalam TCP scanning, dengan menggunakan
teknik ini, scanning dilakukan setelah 3-way handshaking terjadi, 3-way
handshaking terjadi setelah melewati proses-proses seperti berikut:
Paket SYN dikirimkan dari terminal yang ingin melakukan scanning ke
terminal tujuan.
Paket SYN|ACK dikirmkan oleh terminal tujuan sebagai balasan dari paket
SYN yang diterimanya.
Paket ACK dikirimkan oleh terminal yang ingin melakukan scanning
sebagai balasan dari paket SYN|ACK yang diterimanya.
Keunggulan dari teknik adalah kecepatannya, teknik ini adalah teknik yang
tercepat untuk men-scan port pada Nmap.
Berikut adalah contoh dari TCP connect () scanning :
Code:
[root@localhost nmap-3.30]# nmap 152.102.20.184 -sT
Starting nmap 3.30
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
1723/tcp open pptp
3372/tcp open msdtc
Starting nmap 3.30
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
1723/tcp open pptp
3372/tcp open msdtc
TCP SYN scanning (-sS)
Teknik ini sering disebut sebagai half open scanning, karena dengan teknik ini
tidak dibuka koneksi TCP secara utuh. Paket yang dikirimkan adalah paket TCP
dengan flag SYN diset, apabila port pada target host aktif maka paket dengan flag
SYN|ACK akan dikirimkan dari port target host. Setelah paket dengan flag
SYN|ACK diterima, maka paket dengan flag RST akan dikirim untuk memutuskan
koneksi. Keuntungan utama dari teknik ini adalah sedikitnya host yang mencatat
aktivitas dari taknik scan seperti ini.
Berikut adalah contoh dari TCP SYN scanning :
Code:
[root@localhost nmap-3.30]# nmap 152.102.20.184 -sS
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
Nmap run completed -- 1 IP address (1 host up) scanned in 5.714 seconds
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
Nmap run completed -- 1 IP address (1 host up) scanned in 5.714 seconds
TCP FIN scanning (-sF)
Adalah sebuah teknik untuk menscan port pada target host dengan mengirimkan
paket TCP dengan flag FIN diset, apabila port yang dituju terbuka maka paket ini
akan dibiarkan saja, sedangkan apabila port yang dituju tertutup maka port ini
akan membalas paket RST.
Berikut adalah contoh dari TCP SYN scanning :
Code:
[root@localhost Nmap-3.30]#Nmap 10.7.7.3 –sF
Starting nmap 3.30
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
1723/tcp open pptp
3372/tcp open msdtc
Nmap run completed -- 1 IP address (1 host up) scanned in 5.714 seconds
Starting nmap 3.30
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
1723/tcp open pptp
3372/tcp open msdtc
Nmap run completed -- 1 IP address (1 host up) scanned in 5.714 seconds
Nmap juga dapat digunakan untuk mengetahui sistem operasi yang dipakai
oleh target host dengan menggunakan perintah:
Code:
[root@localhost nmap-3.30]# nmap 152.102.20.184 -O
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
1723/tcp open pptp
3372/tcp open msdtc
Device type: general purpose
Running: Microsoft Windows 95/98/ME|NT/2K/XP
OS details: Microsoft Windows Millennium Edition (Me), Win 2000
profressional or Advanced Server, or WinXP
Interesting ports on 152.102.20.184:
(The 1632 ports scanned but not shown below are in state: closed)
Port State Service
23/tcp open telnet
25/tcp open smtp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1032/tcp open iad3
1723/tcp open pptp
3372/tcp open msdtc
Device type: general purpose
Running: Microsoft Windows 95/98/ME|NT/2K/XP
OS details: Microsoft Windows Millennium Edition (Me), Win 2000
profressional or Advanced Server, or WinXP
Nmap juga dapat digunakan untuk melakukan scan lebih dari satu host secara
bersamaan, berikut ini adalah contohnya:
Code:
[root@localhost nmap-3.30]# nmap 152.102.20.157-158 -v -v -O
Host 152.102.20.157 appears to be up ... good.
Initiating SYN Stealth Scan against 152.102.20.157 at 08:35
Adding open port 135/tcp
Adding open port 445/tcp
Adding open port 80/tcp
Adding open port 139/tcp
Adding open port 1029/tcp
Adding open port 1026/tcp
Adding open port 21/tcp
Adding open port 3372/tcp
Adding open port 443/tcp
Adding open port 1025/tcp
The SYN Stealth Scan took 0 seconds to scan 1644 ports.
For OSScan assuming that port 21 is open and port 1 is closed and neither are
firewalled
Interesting ports on 152.102.20.157:
(The 1634 ports scanned but not shown below are in state: closed)
Port State Service
21/tcp open ftp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1029/tcp open ms-lsa
3372/tcp open msdtc
Device type: general purpose
Running: Microsoft Windows 95/98/ME|NT/2K/XP
OS details: Microsoft Windows Millennium Edition (Me), Win 2000 profressional or
Advanced Server, or WinXP
OS Fingerprint:
(None)
TCP Sequence Prediction: Class=random positive increments
Difficulty=14018 (Worthy challenge)
TCP ISN Seq. Numbers: 971BEF00 971D151E 971E5401 971F505D 97207012 97220E7C
IPID Sequence Generation: Incremental
Host 152.102.20.158 appears to be up ... good.
Initiating SYN Stealth Scan against 152.102.20.158 at 08:35
Adding open port 135/tcp
Adding open port 445/tcp
Adding open port 80/tcp
Adding open port 139/tcp
Adding open port 1029/tcp
Adding open port 25/tcp
Adding open port 119/tcp
Adding open port 1026/tcp
Adding open port 21/tcp
Adding open port 3372/tcp
Adding open port 443/tcp
Adding open port 1025/tcp
Adding open port 563/tcp
The SYN Stealth Scan took 0 seconds to scan 1644 ports.
For OSScan assuming that port 21 is open and port 1 is closed and neither are
firewalled
Interesting ports on 152.102.20.158:
(The 1631 ports scanned but not shown below are in state: closed)
Port State Service
21/tcp open ftp
25/tcp open smtp
80/tcp open http
119/tcp open nntp
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
563/tcp open snews
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1029/tcp open ms-lsa
3372/tcp open msdtc
Device type: general purpose
Running: Microsoft Windows 95/98/ME|NT/2K/XP
OS details: Microsoft Windows Millennium Edition (Me), Win 2000 profressional or
Advanced Server, or WinXP
OS Fingerprint:
(None)
TCP Sequence Prediction: Class=random positive increments
Difficulty=15858 (Worthy challenge)
TCP ISN Seq. Numbers: D40BCE8B D40CC35F D40DAE22 D40EF206 D40FF391 D41182B7
IPID Sequence Generation: Incremental
Nmap run completed -- 2 IP addresses (2 hosts up) scanned in 12.992 seconds
Host 152.102.20.157 appears to be up ... good.
Initiating SYN Stealth Scan against 152.102.20.157 at 08:35
Adding open port 135/tcp
Adding open port 445/tcp
Adding open port 80/tcp
Adding open port 139/tcp
Adding open port 1029/tcp
Adding open port 1026/tcp
Adding open port 21/tcp
Adding open port 3372/tcp
Adding open port 443/tcp
Adding open port 1025/tcp
The SYN Stealth Scan took 0 seconds to scan 1644 ports.
For OSScan assuming that port 21 is open and port 1 is closed and neither are
firewalled
Interesting ports on 152.102.20.157:
(The 1634 ports scanned but not shown below are in state: closed)
Port State Service
21/tcp open ftp
80/tcp open http
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1029/tcp open ms-lsa
3372/tcp open msdtc
Device type: general purpose
Running: Microsoft Windows 95/98/ME|NT/2K/XP
OS details: Microsoft Windows Millennium Edition (Me), Win 2000 profressional or
Advanced Server, or WinXP
OS Fingerprint:
(None)
TCP Sequence Prediction: Class=random positive increments
Difficulty=14018 (Worthy challenge)
TCP ISN Seq. Numbers: 971BEF00 971D151E 971E5401 971F505D 97207012 97220E7C
IPID Sequence Generation: Incremental
Host 152.102.20.158 appears to be up ... good.
Initiating SYN Stealth Scan against 152.102.20.158 at 08:35
Adding open port 135/tcp
Adding open port 445/tcp
Adding open port 80/tcp
Adding open port 139/tcp
Adding open port 1029/tcp
Adding open port 25/tcp
Adding open port 119/tcp
Adding open port 1026/tcp
Adding open port 21/tcp
Adding open port 3372/tcp
Adding open port 443/tcp
Adding open port 1025/tcp
Adding open port 563/tcp
The SYN Stealth Scan took 0 seconds to scan 1644 ports.
For OSScan assuming that port 21 is open and port 1 is closed and neither are
firewalled
Interesting ports on 152.102.20.158:
(The 1631 ports scanned but not shown below are in state: closed)
Port State Service
21/tcp open ftp
25/tcp open smtp
80/tcp open http
119/tcp open nntp
135/tcp open loc-srv
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
563/tcp open snews
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1029/tcp open ms-lsa
3372/tcp open msdtc
Device type: general purpose
Running: Microsoft Windows 95/98/ME|NT/2K/XP
OS details: Microsoft Windows Millennium Edition (Me), Win 2000 profressional or
Advanced Server, or WinXP
OS Fingerprint:
(None)
TCP Sequence Prediction: Class=random positive increments
Difficulty=15858 (Worthy challenge)
TCP ISN Seq. Numbers: D40BCE8B D40CC35F D40DAE22 D40EF206 D40FF391 D41182B7
IPID Sequence Generation: Incremental
Nmap run completed -- 2 IP addresses (2 hosts up) scanned in 12.992 seconds
semoga dengan kita tahu port yang terbuka serta kelemahan dari port yang terbuka itu kita bisa meminimalisir akan adanya serangan ke jaringan kita..terima kasih
Ethereal
Ethereal adalah sebuah protocol untuk mengalisa network atau sebuah paket sniffer yang akan mencapture dan secara interaktif membrowse isi dari frame network. Tujuan utama dari project ini adalah untuk membuat sebuah paket commercial-quality untuk Unix dan merupakan pakaet yang paling banyak digunakan untuk menganalisa paket dari berbagai platform.
Ethereal digunakan oleh professional dibidang network diseluruh dunia utuk mengatasi troubleshooting, analisa, software dan protocol pengembangan dan pembelajaran. Tool ini memiliki semua standart yang diharapkan dalam suatu protocol analyzer dan beberapa fitur yang lain yang tidak terlihat oleh produk yang lain.
[root@phred src] tar xzvf libpcap-0.5.2.tar.gz
[root@phred src] cd libpcap-0.5
[root@phred libpcap-0.5] ./configure
[root@phred libpcap-0.5] make
[root@phred libpcap-0.5] make install
[root@phred libpcap-0.5] mkdir -p /usr/local/lib/net
[root@phred libpcap-0.5] make install-incl
[root@phred src] tar xzvf ethereal-0.8.14.tar.gz
[root@phred src] cd ethereal-0.8.14
[root@phred ethereal-0.8.14] ./configure
[root@phred ethereal-0.8.14] make
[root@phred ethereal-0.8.14] make install
Ethereal adalah sebuah network protocol analyzer yang dapat didapatkan
secara gratis. Ethereal dapat berjalan pada sistem operasi Linux dan Window.
Ethereal memberikan ringkasan dan informasi yang mendetail mengenai paket yang
“ditangkap”.
Berikut ini adalah fitur-fitur yang dimiliki oleh Ethereal-0.9.14:
• Data dapat langsung ditangkap dari koneksi jaringan secara langsung.
• Ethereal dapat membaca file-file yang ditangkap oleh tcpdump, NAI’s Sniffer,
Sniffer Pro, Sunsnoop, atmsnoop, dll.
• Data langsung dapat dibaca dari Ethernet, FDDI , PPP, Token Ring, IEEE 802.11,
classical IP over ATM, dan loopback interface.
• Data yang ditangkap dapat dilihat secara grafis.
• 393 protocol dapat dikenali oleh Ethereal.
• Output dapat disimpan atau diprint sebagai plain text atau sebagai PostScript.
4.4.1. Hasil Capture dari Ethereal
Seperti yang telah disebutkan di atas bahwa ethereal berfungsi untuk
menangkap paket data langsung dari jaringan, dan juga memberikan informasi
mengenai paket data yang ditangkap. Berikut ini akan diperlihatkan hasil capture dari
ethereal.
39
Pada tampilan di atas dapat dilihat bahwa dengan menggunakan ethereal dapat
diketahui password yang dalam contoh ini untuk mendapatkan akses mengadakan
FTP session dengan 152.102.20.157.
Dari contoh di bawah ini dapat dilihat bahwa host 152.102.20.189 sedang
melakukan scanning terhadap host 152.102.20.158.
r 19.2. Hasil capture ethereal2
40
Dari hasil-hasil capture di atas dapat terlihat bahwa output dari ethereal
terbagi atas tiga bagian, yaitu:
• Bagian pertama menampilkan keseluruhan paket data yang ditangkap oleh
ethereal, bagian ini memberikan informasi mengenai waktu ditangkapnya paket
data oleh ethereal setelah program ethereal dijalankan, asal paket data berasal,
tujuan dari paket data, protokol yang dipergunakan, dan memberikan informasi
paket data yang ditanglap secara umum.
• Bagian kedua menampilkan informasi dari paket data secara lebih mendetail.
• Bagian ketiga menampilkan nilai heksa dari paket data yang ditangkap.



Program swatch dapat memantau segala macam log dan merespons peristiwa-peristiwa tertentu ketika itu terjadi. Konsepnya cukup sederhana. Swatch akan memonitor file log untuk kita, misalnya, file /var/log/syslog, dan ketika peristiwa tertentu terjadi (peristiwa ini dikonfigurasi dalam file config swatch) dan sudah login di file log, swatch dapat merespon dengan mengeksekusi program, mengirim email ke sysadmin atau mengirim pesan ke konsol mana swatch sedang dijalankan.
Sebuah contoh sederhana dari swatch dalam tindakan. Jika Anda adalah satu-satunya sysadmin webserver, Anda mungkin ingin diberitahu jika seseorang mencoba untuk login ke server Anda (bisa lewat ssh atau layanan otentikasi lainnya).Menjadi satu-satunya admin webserver, tidak ada orang lain yg bisa masuk pada sistem. Siapa pun kecuali admin yg mencoba untuk login ke sistem jelas tidak berada di sana dan mungkin memiliki niat buruk. Dalam hal ini, Anda dapat mengatur swatch untuk memonitor file auth.log untuk upaya logon yg gagal dan upaya logon yg sukses dan kemudian mengirimkan email log setiap kali mereka yg berupaya untuk masuk. Tentu saja ini akan memberitahu Anda bahkan ketika Anda login pada mesin, karena ini mungkin lebih praktis jika Anda memiliki sistem tanpa pengawasan (mungkin Anda sedang berlibur atau pergi untuk urusan bisnis).
Berikut cara installnya :
Berikut cara installnya :
sudo apt-get install swatch
Perintah-perintah pada Swatch
--config-file=filename or -c filename
Tells swatch where to find its configuration file. The default is ${ HOME }/.swatchrc.
--help
Prints usage information and exits.
--input-record-separator=regular_expression
Tells swatch to use regular_expression to delineate the boundary of each input record. The default is a carriage return.
--restart-time=[+]hh:mm[am|pm] or -r [+]hh:mm[am|pm]
Restart at the specified time where hh is hours and mm is minutes. If the am/pm indicator is omitted, then a 24-hour clock is assumed. If the time is preceeded by the "+" character, then the restart time will be set to the current time plus the specified time and the am/pm indicator will be ignored.
--script-dir=/path/to/directory
This switch causes the temporary watcher script to be written to a file in the specified directory rather than the user's home directory. It is highly advised that you do NOT use directories that are writable by others such as /tmp.
--version or -V
Prints version information and exits.
--use-cpan-file-tail
You may specify only one of the following options:
--tail-file=filename or -t filename
Examine lines of text as they are added to filename.
--read-pipe=command or -p command
Examine input piped in from the command.
--examine=filename or -f filename
Use filename as the file to examine. Swatch will do a single pass through the named file.
The following options are purely for debugging purposes, but are documented here for completeness:
--dump-script[=filename]
Instead of running the watcher script after it is generated, it is written to filename or to STDOUT .
If swatch is called with no options, it is the same as typing the command line
*
"swatch --config-file=~/.swatchrc --tail-file=/var/log/syslog"
or if /var/log/messages exists
"swatch --config-file=~/.swatchrc --tail-file=/var/log/messages"
If the configuration file doesn't exist then the following configuration is used:
watchfor /.*/
echo
The Configuration File
The configuration file is used by the swatch(8) program to determine what types of expression patterns to look for and what type of action(s) should be taken when a pattern is matched.
Each line should contain a keyword and a, sometimes optional, value for that keyword. The keyword and value are separated by space or an equal (=) sign.
watchfor regex
ignore regex
echo [modes]
.Echo the matched line. The text mode may be normal, bold, underscore, blink, inverse, black, red, green, yellow, blue, magenta, cyan, white, black_h, red_h, green_h, yellow_h, blue_h, magenta_h, cyan_h, and/or white_h. The _h colors specify a highlighting color. The other colors are assigned to the letters. Some modes may not work on some terminals. Normal is the default.
bell [N]
Echo the matched line, and send a bell N times (default = 1).
exec command
Execute command. The command may contain variables which are substituted with fields from the matched line. A $N will be replaced by the Nth field in the line. A $0 or $* will be replaced by the entire line.
mail [addresses=address:address:...][,subject=your_text_here]
Send mail to address(es) containing the matched lines as they appear (default address is the user who is running the program).
pipe command[,keep_open]
Pipe matched lines into command. Use the keep_open option to force the pipe to stay open until a different pipe action is run or until swatch exits.
write [user:user:...]
throttle hours:minutes:seconds,[use=message|regex|<regex]>
Use this action to limit the number of times that the matched pattern has actions performed on it.
The use=regex option will cause throttling to be based on the regular expression instead of the message.
You can also specify a perl compliant regular expression as the value for B,use>. The default is use="^\w{3}\s+\d{1,2}\s\d{2}:\d{2}:\d{2}\s+(.*)" causes the key to be the syslog message without the timestamp. This is most useful when throttling non-syslog created files.
threshold events:seconds,[repeat=no|yes]
This action limits the actions on a matched pattern based on the number of times it appears in a given time frame. An action like "threshold 4:60" will not perform any actions on that pattern unless it appears 4 times within any 60 second period (4:60 is the arbitrary default value).
The repeat=no option will prevent the timer from being reset after the threshold has been reached. By default (repeat=yes), once the pattern has been triggered, a new 60 second period is begun, which means that if the patterns match quickly enough, a threshold of 4:60 could mean that 1 in every 4 messages is reported. By using repeat=no, you indicate that there is not to be more than one match every time interval.
Note that this is similar to, but different from, the standard "throttle" command, since "throttle" shows the first line and ignores the rest, while "threshold" shows the last line and ignores the preceeding (and optionally the following). However, an action like "threshold 1:120" should perform similarly to "throttle 0:2:0,use=regex" and has the advantage of not relying on a particular timestamp format in the source log entry.
continue
Use this action to cause swatch to continue to try to match other pattern/action groups after it is done with the current pattern/action block.
quit
Use this action to cause swatch to clean up and quit immediately.
sumber :
http://budi.insan.co.id/courses/ec5010/projects/thomas-report.pdf
0 komentar:
Posting Komentar