Sponsored Content
Full Discussion: formating output
Top Forums Shell Programming and Scripting formating output Post 302105331 by radoulov on Thursday 1st of February 2007 06:04:57 AM
Old 02-01-2007
Are you using GNU awk?

Code:
$ cat file
Content-type: text/html

<H2>No query</H2>
infodba-marabou:/tmp
=> export QUERY_STRING="IMAN_server_report=full"
infodba-marabou:/tmp
=> $IMAN_ROOT/web/htdocs/cgi-bin/iman > /tmp/proc.txt
infodba-marabou:/tmp
=> cat proc.txt
Content-type: text/html

<HTML><META HTTP-EQUIV="REFRESH" CONTENT=10><HEAD><TITLE>TcEng Web server report</TITLE>
</HEAD><BODY>
<H1>TcEng Web server report</H1>
<p>Thu Feb 1 00:16:43 2007 - I am alive and well (pid 712), up since Sat Dec 16 22:26:32 2
006</p>
<p>click <a href=/iman>here</a> to login to this server</p>
<p>click <a href="/cgi-bin/iman?IMAN_server_report">here</a> for a shortened report</p><p>
click <a href="/cgi-bin/iman?IMAN_server_report=xml">here</a> for an xml report</p><p>Comp
leted 47155 out of 47183 queries; averag
e runtime 2.252 secs (4 timeouts).</p>

<hr>
<H2>Preferences</H2><pre>
Port number: 8181
Select time: 18000
Heartbeat time: 1000
Query time limit: 18000
Maximum number of queries: 750
Minimum number of free processes: 1
Maximum number of processes: 500
Soft login timeout: 120
Hard login timeout: 36000
Process lifespan (in queries): 10000
Maximum login processes per user: 1
Maximum retries on blocked sockets (Windows only): 5
Maximum concurrent logins 500
Maximum CPU usage 80
CPU usage monitoring 0
CPU usage check interval 10
Maximum no of requests/user in queue 5
Maximum length of the queue of pending connections 128
Number of active file descriptors: 1760
Monitoring switch: 1
Internal buffer size: 16384
IMANScript program: /Application/ugs/tceng/tceng0912/web/bin/imanscript
IMAN Document Root: /Application/ugs/tceng/tceng0912/web/htdocs
IMAN Environment:

</pre>
<hr>
<H2>Processes</H2><table align=center width=100% border=1><tr><th>No.</th><th>State</th><t
h>Query</th><th>Time s</th><th>User</th><th>Processed</th><th>Syslog</th></tr><tr><td>1</t
d><td>ready</td><td>&nbsp;</td><td>idle 46s</td><td>&nbsp;</td><td>1</td><td>/Application/
ugsvols/bldata01/logs/imanscript9994.syslog</td></tr><tr><td>2</td><td>ready</td><td>&nbsp
;</td><td>idle 937s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/im
anscript7599.syslog</td></tr><tr><td>3</td><td>ready</td><td>&nbsp;</td><td>idle 469s</td>
<td>X036091&nbsp;</td><td>24</td><td>/Application/ugsvols/bldata01/logs/imanscript1963.sys
log</td></tr><tr><td>4</td><td>ready</td><td>&nbsp;</td><td>idle 7842s</td><td>X045672&nbs
p;</td><td>7</td><td>/Application/ugsvols/bldata01/logs/imanscript16225.syslog</td></tr><t
r><td>5</td><td>ready</td><td>&nbsp;</td><td>idle 9989s</td><td>X035077 &nbsp;</td><td>5</
td><td>/Application/ugsvols/bldata01/logs/imanscript10210.syslog</td></tr><tr><td>6</td><t
d>ready</td><td>&nbsp;</td><td>idle 13089s</td><td>X035466&nbsp;</td><td>5</td><td>/Applic
ation/ugsvols/bldata01/logs/imanscript561.syslog</td></tr><tr><td>7</td><td>ready</td><td>
&nbsp;</td><td>idle 18113s</td><td>103818&nbsp;</td><td>5</td><td>/Application/ugsvols/bld
ata01/logs/imanscript16278.syslog</td></tr><tr><td>8</td><td>ready</td><td>&nbsp;</td><td>
idle 11560s</td><td>X039371&nbsp;</td><td>15</td><td>/Application/ugsvols/bldata01/logs/im
anscript15120.syslog</td></tr><tr><td>9</td><td>ready</td><td>&nbsp;</td><td>idle 20340s</
td><td>22320&nbsp;</td><td>4</td><td>/Application/ugsvols/bldata01/logs/imanscript25488.sy
slog</td></tr><tr><td>10</td><td>ready</td><td>&nbsp;</td><td>idle 27042s</td><td>&nbsp;</
td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript20999.syslog</td></tr><tr><t
d>11</td><td>ready</td><td>&nbsp;</td><td>idle 27504s</td><td>101568&nbsp;</td><td>13</td>
<td>/Application/ugsvols/bldata01/logs/imanscript19396.syslog</td></tr><tr><td>12</td><td>
ready</td><td>&nbsp;</td><td>idle 29098s</td><td>64920&nbsp;</td><td>10</td><td>/Applicati
on/ugsvols/bldata01/logs/imanscript14646.syslog</td></tr><tr><td>13</td><td>ready</td><td>
&nbsp;</td><td>idle 30198s</td><td>X030111 &nbsp;</td><td>3</td><td>/Application/ugsvols/b
ldata01/logs/imanscript7582.syslog</td></tr><tr><td>14</td><td>ready</td><td>&nbsp;</td><t
d>idle 31676s</td><td>X041708&nbsp;</td><td>42</td><td>/Application/ugsvols/bldata01/logs/
imanscript7183.syslog</td></tr><tr><td>15</td><td>ready</td><td>&nbsp;</td><td>idle 34199s
</td><td>67733&nbsp;</td><td>40</td><td>/Application/ugsvols/bldata01/logs/imanscript18706
.syslog</td></tr><tr><td>16</td><td>ready</td><td>&nbsp;</td><td>idle 31602s</td><td>79826
&nbsp;</td><td>14</td><td>/Application/ugsvols/bldata01/logs/imanscript22502.syslog</td></
tr><tr><td>17</td><td>ready</td><td>&nbsp;</td><td>idle 51645s</td><td>&nbsp;</td><td>1</t
d><td>/Application/ugsvols/bldata01/logs/imanscript12580.syslog</td></tr><tr><td>18</td><t
d>ready</td><td>&nbsp;</td><td>idle 30371s</td><td>11421&nbsp;</td><td>34</td><td>/Applica
tion/ugsvols/bldata01/logs/imanscript29761.syslog</td></tr><tr><td>19</td><td>ready</td><t
d>&nbsp;</td><td>idle 56147s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata0
1/logs/imanscript29658.syslog</td></tr><tr><td>20</td><td>ready</td><td>&nbsp;</td><td>idl
e 30908s</td><td>X035887&nbsp;</td><td>74</td><td>/Application/ugsvols/bldata01/logs/imans
cript20039.syslog</td></tr><tr><td>21</td><td>ready</td><td>&nbsp;</td><td>idle 31650s</td
><td>X042268&nbsp;</td><td>95</td><td>/Application/ugsvols/bldata01/logs/imanscript14166.s
yslog</td></tr><tr><td>22</td><td>ready</td><td>&nbsp;</td><td>idle 34610s</td><td>X044587
&nbsp;</td><td>242</td><td>/Application/ugsvols/bldata01/logs/imanscript929.syslog</td></t
r><tr><td>23</td><td>ready</td><td>&nbsp;</td><td>idle 80449s</td><td>&nbsp;</td><td>1</td
><td>/Application/ugsvols/bldata01/logs/imanscript18783.syslog</td></tr><tr><td>24</td><td
>ready</td><td>&nbsp;</td><td>idle 84051s</td><td>&nbsp;</td><td>1</td><td>/Application/ug
svols/bldata01/logs/imanscript5679.syslog</td></tr></table>
<hr>
<H2>Queries</H2><p>No queries.</p>

<hr>
<h2>Recently deceased processes</h2><table border=1><tr><th>username</th><th>syslog</th></
tr>
<tr><td>90927&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript28329.syslog</td>
</tr>
<tr><td>11920&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript12775.syslog</td>
</tr>
<tr><td>83144&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript16492.syslog</td>
</tr>
<tr><td>&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript23739.syslog</td></tr>

<tr><td>11403&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript10134.syslog</td>
</tr>
<tr><td>&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript23248.syslog</td></tr>

<tr><td>&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript23153.syslog</td></tr>

<tr><td>X033586&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript1533.syslog</td
></tr>
<tr><td>X037095&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript5629.syslog</td
></tr>
<tr><td>91011&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript9653.syslog</td><
/tr>
</table>

$ awk --version | head -1
GNU Awk 3.1.5
$ awk '/idle/{sub(/s.*/,"",$2);if($2>20000)print "kill -9",$3}' \
> FS="idle |/logs/imanscript" RS=".syslog" file
kill -9 25488
kill -9 20999
kill -9 19396
kill -9 14646
kill -9 7582
kill -9 7183
kill -9 18706
kill -9 22502
kill -9 12580
kill -9 29761
kill -9 29658
kill -9 20039
kill -9 14166
kill -9 929
kill -9 18783
kill -9 5679

$ awk '/idle/{sub(/s.*/,"",$2);if($2>20000)print "Idle is:",$2,"PID is:",$3}' FS="idle |/
logs/imanscript" RS=".syslog" file
Idle is: 20340 PID is: 25488
Idle is: 27042 PID is: 20999
Idle is: 27504 PID is: 19396
Idle is: 29098 PID is: 14646
Idle is: 30198 PID is: 7582
Idle is: 31676 PID is: 7183
Idle is: 34199 PID is: 18706
Idle is: 31602 PID is: 22502
Idle is: 51645 PID is: 12580
Idle is: 30371 PID is: 29761
Idle is: 56147 PID is: 29658
Idle is: 30908 PID is: 20039
Idle is: 31650 PID is: 14166
Idle is: 34610 PID is: 929
Idle is: 80449 PID is: 18783
Idle is: 84051 PID is: 5679

$ awk '/idle/{sub(/s.*/,"",$2);if($2<20000)print "Idle is:",$2,"PID is:",$3}' FS="idle |/
logs/imanscript" RS=".syslog" file
Idle is: 46 PID is: 9994
Idle is: 937 PID is: 7599
Idle is: 469 PID is: 1963
Idle is: 7842 PID is: 16225
Idle is: 9989 PID is: 10210
Idle is: 13089 PID is: 561
Idle is: 18113 PID is: 16278
Idle is: 11560 PID is: 15120


Last edited by radoulov; 02-01-2007 at 07:45 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formating cal output

Hi Gurus, In my Cal output i want to cut the date of 2nd saturday how tyo achive this. for eg in the below output i need that second saturday 13 to be cut. crypto $ cal January 2007 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26... (2 Replies)
Discussion started by: Krrishv
2 Replies

2. Shell Programming and Scripting

formating array file output using perl

Hello, I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example: @array= 1..14; Needs to be output to the file like so: 1 ... (4 Replies)
Discussion started by: seismic_willy
4 Replies

3. Shell Programming and Scripting

Output formating

Dear All I am stuck in one problem. Kindly help me. I am taking below mention file as input file and want some op file as mention below. Kindly send me all possible suggestion and query. Thnaks Jaydeep bELOW IS THE INPUT FILE: *** Connected to BSCANGR ***... (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

4. Shell Programming and Scripting

Problem In Formating Table as Output

Hi! I'm working a program that collects 4 various inputs and format my output into tabular form.Problem is my table margins move with different character lengths. Is there a way to fix my table margins even though the variables inside the table varies in length? thank you very much...:( (1 Reply)
Discussion started by: Lo11001
1 Replies

5. Shell Programming and Scripting

formating output

Hi all, I want to start a new topic on this matter I have this script, #!perl use strict; use warnings; use Data::Dumper; open my $log, '>', 'log-external.txt' or die "Could not open log: $!"; print $log "Subnet,Static,DHCP,Unused\n"; open my $dump, '>', 'dump.log' or die... (2 Replies)
Discussion started by: richsark
2 Replies

6. Shell Programming and Scripting

Formating output

Hello Team i have a file with following data (as columns). I need implement a syntax like below for altering table ALTER TABLE1 TABLENAME ADD COLUMN COL1 CHAR(5) NOT NULL WITH DEFAULT ADD COLUMN COL2 CHAR(5) .. .. ADD COLUMN COLn CHAR(5) NOT NULL... (1 Reply)
Discussion started by: rocking77
1 Replies

7. UNIX for Advanced & Expert Users

Formating and Parsing Autosys output

if you want to parse the output from an autosys you can use the below autorep -j Prefix_% | awk '{ if ($6 ~ /^/) printf "%-20s \t\t %-20s\n",$1,$5 ; else if ($6 ~ /^/) printf "%-20s \t\t %-20s\n",$1,$6; else printf "%-20s \t\t %-20s\n",$1,$4 }' | awk '{ if ($2... (1 Reply)
Discussion started by: phpsnook
1 Replies

8. UNIX for Advanced & Expert Users

remove print formating from printer output file

I have a print file taken from the print spooler and I want to delete all the formatting leaving only the text. If you vi the file it shows "\304\304 ...." which translates into a printed line on print output. I need to be able to edit and pass this file to another process Thnaks (10 Replies)
Discussion started by: petercp
10 Replies

9. UNIX for Dummies Questions & Answers

Help with formating when using mailx

Hi I am a newbie here. I tried searching for the solution but I guess I either didn't find it or there hasn't been one posted. my problem is I spooled the results of a query into a .txt file. When I cat the file the formating looks great. All the columns are aligned. However once I mailx the... (2 Replies)
Discussion started by: RB26DETT
2 Replies

10. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies
All times are GMT -4. The time now is 09:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy