Sponsored Content
Top Forums Shell Programming and Scripting Weekly statistics using while loop. Post 302123730 by filthymonk on Wednesday 27th of June 2007 02:06:53 AM
Old 06-27-2007
Weekly statistics using while loop.

Hi people i have a situation here: my server generates a statistics text file every 30 mins. i have a script (txt2csv.sh) to convert all the statistics for the day into one csv file. Therefore i am doing a script to auto converts the text files into csv base on a weekly basis.
the script is suppose to be run using this command :
./wklystats 06 11 #base on mm dd
then it should generate a csv for a day one at a time and increase the date numbering by one and generate another csv file until the loop is completed.


Code:
#!/bin/sh

SCRIPTNAME=`basename $0`


show_help ()
{
    echo "Usage: $SCRIPTNAME [input month, mm] [input day, dd]"
    echo "This file is used to generate weekly statistics"
    echo ""
}

if [ $# != 2 ]; then
    show_help
    exit 1
fi

dateday=${2}
inputname="statistics-2007"${1}$dateday"-*"
outputname="statistics-2007"${1}$dateday".csv"


i=1
while [ $i -le 7 ]
do

        ./txt2csv.sh $inputname $outputname
        dateday=$(( dateday + 1))
        i=$(( i+1))

done

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Analyze Statistics

I have a file which contains records in the format of 2006-08-25 12:06:13|ABC|93 2006-08-25 12:45:55|ABC|203 2006-08-25 01:48:19|DEF|156 2006-08-25 01:49:09|ABC|12798 2006-08-25 02:49:59|GHL|4109 2006-08-25 03:50:50|DEF|234 where the format is "arrive time"|"message type"|"processing... (3 Replies)
Discussion started by: mpang_
3 Replies

2. UNIX for Advanced & Expert Users

Getting Socket statistics

Is there any way to get the file descriptor statistics of a socket file descriptor? I know that the fstat, stat system calls are for this purpose, but I want to know it there any way to get socket connection statistics for a file descriptor(like socket flags, connection type etc). Does /proc... (3 Replies)
Discussion started by: comp_wizard07
3 Replies

3. Solaris

how to get server statistics

Hello What commands can give following type of information about the server: Time: 20080331.12:10:39 Current CPU: 97.0% Current Memory: 3.7% Current Disk Space: 76% The resources on server is currently not available. Current CPU, Memory, or Disk Space is exceeding threshold Waiting for... (2 Replies)
Discussion started by: shalua
2 Replies

4. HP-UX

packets statistics

Hi there, are there any functions that can get the packets statistics on UNIX ? thanks. (2 Replies)
Discussion started by: Frank2004
2 Replies

5. AIX

Statistics Aix

Hello If there is a way to get a statistics from Aix box server from a month. cpu use, memory, disc use, etc. Maybe via smitty or I need to do a script. The os is Aix 5.3 Greetings (8 Replies)
Discussion started by: lo-lp-kl
8 Replies

6. Shell Programming and Scripting

statistics using awk

Hi, I have 3 columns in a file listed below. X Y X/(X+Y) 1 1 0.5 1 1 0.5 4 1 0.8 1 1 0.5 6 1 0.857142857 1 1 0.5 23 1 0.958333333 Now I want to find confidence interval using the formula for each row. (p-2 sqrt p(1-p)/(x+y), p+2... (7 Replies)
Discussion started by: Diya123
7 Replies

7. UNIX for Dummies Questions & Answers

Any way to get process statistics?

Hi, Can someone advise what "generic" command can I use to show statistics of a process or a running script/process? For example, I want to know how many hours/minutes it's taken to run or has been running, how much CPU it used and how much memory it used or uses. I want to be able to... (2 Replies)
Discussion started by: newbie_01
2 Replies

8. Shell Programming and Scripting

Text statistics

Hello every body if I want to get the following statistics from a text file 1- sorted the n frequent words 2- sorted the n frequent characters 3- sorted the n frequent diagrams (tow letter together like th OR he) 4- sorted frequent n trigrams like (the OR all etc. ) 5- any character... (10 Replies)
Discussion started by: khaled79
10 Replies
mailstats(1)						      General Commands Manual						      mailstats(1)

NAME
mailstats - print mail traffic statistics SYNOPSIS
cffile] stfile] DESCRIPTION
reads and interprets the statistics file, and then prints out the mail traffic statistics. The statistics file is the one set by the option in the The default statistics file is If the statistics file exists, collects statistics about your mail traffic and stores them in that file. This file does not grow. Statistics are gathered on a per-mailer basis for each mailer defined in the configuration file. Statistics are kept on the number of mes- sages and the number of bytes for all inbound and outbound traffic. The utility displays the time at which statistics collection was started on the first line. Then, the statistics of each mailer is dis- played on a single line, each with the following white space separated fields (see the "EXAMPLES" section below): The mailer number. Number of messages from the mailer. Kbytes from the mailer. Number of messages to the mailer. Kbytes to the mailer. Number of messages rejected. Number of messages discarded. The name of the mailer. After this display, a line totaling the values for all of the mailers is displayed, separated from the previous information by a line con- taining only equals (``='') characters. Note can be used by privileged users only. Options The options are as follows: Read the specified cffile instead of the default file. Read the specified statistics file, stfile, instead of the statistics file specified in the file. Do not display the name of the mailer in the output. Output information in program-readable mode and clear statistics. To clear the statistics file, execute, as root: RETURN VALUE
The utility exits with 0 on success, and >0 if an error occurs. DIAGNOSTICS
generates error messages if the statistics file is not accessible or if the size of the statistics file has changed. Error messages are: Either statistics-file is zero length, meaning that no mail has been transferred since it was cleared out, or its size has changed. Since the size of this file is supposed to remain constant, any change in size means that the file is invalid. The statistics file does not exist. The statistics file's permissions are set so that you cannot read it. EXAMPLES
Here is a typical example of output: ============================================================= This example shows that mailers 0, 3 and 5 have handled the given amounts of mail traffic since Thursday, Jul 11th. Specifically, has sent 11 messages containing 11 kilobytes via mailer esmtp (M 5), but has 4 messages rejected via mailer esmtp (M 5). AUTHOR
was developed by the University of California, Berkeley. FILES
default mail traffic statistics file sendmail configuration file SEE ALSO
sendmail(1M). mailstats(1)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy