Traffic Monitoring Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Traffic Monitoring Script
# 1  
Old 01-12-2012
Traffic Monitoring Script

Hello All,

I have written a script to check for http error code 500 in the logs.

here is the code
Code:
#!/bin/bash

#########################################################################################################
# Shellscript    :    trafficchk.sh -Traffic Monitoring
# Version    :    V1.0
# Owner         :    SiddheshK <siddheshk@maildomain.com>
# Date        :    2012-01-12
# Category       :    Files Management
#########################################################################################################
# Description:  This scipt will Monitor traffic on each XMP service blades and for HTTP error 500
#            
#########################################################################################################

#Defining Variable
#------------------------
LOG_FILE=/var/xmp/log/XMP_*| tail -1 
HTA_STATUS=`logscan -in $LOG_FILE -live |grep HTA_ResponseStatus: 500|wc -l

if [ $HTA_STATUS -gt 500 ]; then
 echo " Too many HTTP 500 Errors observed in activity log !!! "

printf "*****  XMP Application Alert System  *****\n\nHost: `hostname` \n\nHost_Address: \n\nInfo:Internal Error:500 \n\nDATE:`date` \n\n" | /bin/mail -s "Host `hostname` --HTTP-Internal Error:500 observed...Please Check Immeiately " siddheshk@maildomain.com

fi

exit 0

I have a issue with one thing here.

Code:
HTA_STATUS=`logscan -in $LOG_FILE -live |grep HTA_ResponseStatus: 500|wc -l

The above mentioned logscan command, does not end automatically and needs to be killed manually (ctrl+c)

How do i implement the same in script.

Regards,
Siddhesh.K

Last edited by methyl; 01-13-2012 at 09:23 AM.. Reason: remove real names
# 2  
Old 01-13-2012
Where is the ending tick (`)? Also, have you tried quoting "HTA_ResponseStatus: 500"?
# 3  
Old 01-13-2012
Code:
HTA_STATUS=$(logscan -in $LOG_FILE -live |grep -c "HTA_ResponseStatus: 500")

# 4  
Old 01-13-2012
Quote:
LOG_FILE=/var/xmp/log/XMP_*| tail -1
This variable assignment does not work. The value of $LOG_FILE is always blank.
It is executed as two parts:
LOG_FILE=/var/xtmp/log/XMP_*
Which fills $LOGFILE with a long continuous line of filenames and produces no output.
tail -1
Which reads the blank output from the first command and blanks out $LOGFILE.

Because the script contains many syntax errors, we need to know what each stage of the script is meant to do.



Spelling police:
Please Check Immeiately
should be
Please Check Immediately
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with a script for proxy traffic

Hello folks; I'm trying to write a script to test our proxy servers to see if they're passing traffic and i need help please. I wrote this code below to implement "httpie" tool but still having issues. Can someone please take a look and let me know what's wrong with this code? The code is supposed... (2 Replies)
Discussion started by: Katkota
2 Replies

2. Shell Programming and Scripting

Script for real time network traffic per process

Hi All Gurus, I want to write a script (bash/ksh/csh) which will show real time network traffic ( TCP or UDP ) generated by per process/PID. For both Linux/AIX system, as nethogs ( Linux package ) shows ? Any suggestion is MOST welcome. Thanks in Advance, Amritendu Das (3 Replies)
Discussion started by: linux.amrit
3 Replies

3. AIX

Script for real time network traffic per process

Hi All Gurus, I want to write a script (bash/ksh/csh) which will show real time network traffic ( TCP or UDP ) generated by per process/PID. For both Linux/AIX system, as nethogs ( Linux package ) shows ? Any suggestion is MOST welcome. Thanks in Advance, Amritendu Das (1 Reply)
Discussion started by: linux.amrit
1 Replies

4. HP-UX

Monitoring traffic in the network

I Colleagues, Somebody can say me how to monitoring traffic in the network. also I am interested in monitoring memory. if somebody to know a guide with command advanced in unix welcome for me. Thank you for adcanced. (0 Replies)
Discussion started by: systemoper
0 Replies

5. Cybersecurity

Monitoring network traffic on wireless router

Hi all, How can I monitor packet traffic on my wireless router? Some info - my wireless router is netgear wgr614 - everyone can connect it i.e. no password required - I would like to see where they connect, how they are using the internet connection I installed wireshark and captured... (3 Replies)
Discussion started by: SaTYR
3 Replies

6. UNIX for Dummies Questions & Answers

NIC card monitoring traffic question

Folks; I have 2 NIC cards on my SUSE Linux server. One of them was reporting receive errors for a while now it's OK, but i'd like to monitor it. Is there any command i can run to tell me the usage in the past or give me a history of traffic and the speed that going on this specific card? I... (1 Reply)
Discussion started by: Katkota
1 Replies

7. UNIX for Advanced & Expert Users

Monitoring network traffic using snoop

I want to monitor network traffic. For this purpose i use snoop command. But snoop command only show those packets which are broadcasted or those packets which recieved by host. But I want to examine whole network traffic. Please tell me how to use snoop for monitoring whole network traffic or if... (3 Replies)
Discussion started by: mansoorulhaq
3 Replies

8. UNIX for Dummies Questions & Answers

monitoring network traffic

there are commands to monitor the memory, paging, io... how about network traffic. i mean commands to see whether the network traffic (LAN) is congested? the closest i got is netstat thanks (6 Replies)
Discussion started by: yls177
6 Replies
Login or Register to Ask a Question