If you post code, logs, data etc. use code-tags for better readability please.
Ok, processing the relevant part of your output:
Code:
awk -F"|" '
$NF ~ /Alive/ {r+=1; a+=1; print}
$NF ~ /Down/ {r+=1; d+=1; print}
END{if( a != r ) {print "some not up!"}}
' infile
ASG | ASG |N/A | Down
OC4JGroup:default_group | OC4J:IP-BO-C-I~ |21242 |Alive
OC4JGroup:default_group | OC4J:P-BO-M10 |N/A | Down
OC4JGroup:default_group | OC4Jc4j_soa |21240 | Alive
HTTP_Server | HTTP_Server |21239 | Alive
some not up!
Setting | as field separator
$NF is the last field, checking if it contains the pattern Alive
If so, the stuff in the curly braces is being done, ie. it increases the record counter r by +1 and the Alive counter a by 1. With the record counter we track how many rows we processed over all.
If it doesn't find the pattern "Alive" in the last field, it will use this line and check $NF for the pattern "Down". It increases the record counter by 1 and the Down counter d. The Down counter is not necessary but maybe for future use.
In the end, when all lines are processed, it checkes the variables and if the Alive counter is not equal the number of processed relevant rows/records, it will spit an error message as you can see.
All other lines that don't fit to the 2 rules $NF ~ /Alive/ or $NF ~ /Down/ are just bypassed.
Last edited by zaxxon; 02-02-2009 at 12:18 PM..
Reason: Exploring the LIST-tag :)
On AIX 5.2, I use "ps -ef " command to display the process status, the field of command looks like: , the detailed contents are:
# ps -ef |grep rtesfmrt
Display:
osa 32455 1 0 18:20 - 1:57
The origianl format shoud be:
osa 32455 1 0 18:20 - 1:57 ... (2 Replies)
Hi,
I am writing a shell script to invoke a C++ program. Before I start the C++ program (oi7loadbalancer), I am checking if the process is already running. I start the process only if it is not already running. I have the following check in my script.
proccount=`ps -f -u $USER_NAME | grep... (8 Replies)
Hi all,
How can a process be aware of the signals it handles. I looked at available signal API, but couldn't find any help.
If a process defines it own handler for a signal, the default handler for that signal becomes overridden.
I am interested in getting to know the... (2 Replies)
hello everybody!!
i want to post a question!
is there any way to get process status using C commands?
To be more specific, i want to know whether a process is running or is stop or killed.
thanks in advance! (3 Replies)
All,
I have fair amount of knowledge about shell scripting, but only liitle on system administration.
I would like to know how to analyze whether the particular linux process is alive or not ? If it is alive, will it affect the performace of other process ?.
Also is it still consuming... (1 Reply)
;)Hi Everyone,
I am using solaris 5.10.
I have a java process running in server mode in unix.
The problem is that it automatically forks i.e creates a child process.
I mean suddenly two instances of that process start running , in which the process-id of first instance is the parent... (0 Replies)
Hi Everyone,
I am using solaris 5.10.
I have a java process running in server mode in unix.
The problem is that it automatically forks i.e creates a child process.
I mean suddenly two instances of that process start running , in which the process-id of first instance is the parent... (5 Replies)
Hi,
I have a cron job which runs every ten minutes, now i hav to check the process whether it is running or not only once and then this should be sent to a log file..
crontab :
00,10,20,30,40,50 * * * * a
process check
ps = 'ps -ef |grep a '
if
then
echo " Success" >... (3 Replies)
I have run 10 instances of the process eg, process name is BG
nohup /WP01IRB1_irbapp/IRBWPROD/RB/bin/BG -c 1 -t 23 -a '-caTop TESTBILLCYCLE='5FEB13_81PT19NPT''>a.txt &
nohup /WP01IRB1_irbapp/IRBWPROD/RB/bin/BG -c 2 -t 23 -a '-caTop TESTBILLCYCLE='5FEB13_81PT19NPT''>b.txt &
nohup... (3 Replies)
Hi,
I want to write one program in C in Unix OS which will check the running status of a process time to time. If the process is stopped somehow by any means, it will ensure that the process is restarted and only one copy of the process image should run in memory at any point of time for the user.... (2 Replies)
Discussion started by: sanzee007
2 Replies
LEARN ABOUT DEBIAN
tapset::snmp
TAPSET::SNMP(3stap)TAPSET::SNMP(3stap)NAME
tapset::snmp - Systemtap simple network management protocol probe points.
DESCRIPTION
This family of probe points enhances the Linux system's implementation of the Simple Network Management Protocol (SNMP) by allowing the
user to collect per-socket statistics. SNMP data is collected in the Linux kernel by counting various events occurring in the networking
subsystem. Linux provides one counter for each type of event, thus providing a system-wide collection of network statistics. These statis-
tics can be viewed with the command: netstat -s.
The probe points defined in the SNMP group of tapsets allow users to aberrate each SNMP counter into groups of counters. For example, the
user may count SNMP events for a single network socket or for a group of sockets.
Severals SNMP tapsets have been created. Each tapset represents a single layer of the network stack and defines a group of counters called
management information blocks or MIBs. Currently tapsets are provided that support MIBS for IP, TCP layers and the enhanced linux MIB. See
the file /usr/include/linux/snmp.h for a list of MIBS supported by linux.
PROBE HANDLERS, COUNTERS AND CALLBACKS
Each probe represents a single SNMP statistic. The probe's handler is called each time the system performs an operation that would alter
the associated statistic. Each probe also defines an indexed set of counters used to record probe hits. The probe handler calls a user sup-
plied callback functions to determine which counter to alter. The user's callback should return a key value that will be used to index the
counter. For example a callback could return a unique value for each socket. This would results in a separate counter being used for each
socket.
Each tapset is now described. Examples of probe names and counter names are given. See the tapset itself for a complete list of supported
probes. Users of the tapset must provide a callback function matching the name and prototype as shown.
IP MIB Tapset:
Example probe name: ipmib.InReceives
Example counter name: InReceives
Callback prototype:
ipmib_filter_key:long (skb:long, op:long, SourceIsLocal:long)
This user supplied function should compute and return a value used to index the statistical counter. The skb is a pointer to the struct
sk_buff being processed at the time. The local ip-address and port number will be located in either the source or destination fields of the
network packet. SourceIsLocal will be true if the local address is in the source field. The probe handler will add the value of op to the
counter. To skip counting the event return a value of zero.
TCP MIB tapset:
Example probe name: tcpmib.InSegs
Example counter name: InSegs
Callback prototype:
tcpmib_filter_key:long (sk:long, op:long)
This user supplied function should compute and return a value used to index the statistical counter. The sk is a pointer to the struct sock
being processed at the time. The probe handler will add the value of op to the counter. To skip counting the event return a value of zero.
LINUX MIB tapset:
linuxmib.stp
Example probe name: linuxmib.DelayedACKs
Example counter name: DelayedACKs
Callback prototype:
linuxmib_filter_key:long (sk:long, op:long)
This user supplied function should compute and return a value used to index the statistical counter. The sk is a pointer to the struct sock
being processed at the time. The probe handler will add the value of op to the counter. To skip counting the event return a value of zero.
EXAMPLE
This example script counts the number of TCP retransmits and records them per-remote address. It displays the counts when terminated.
/* Enable the statistic we want to record. */
probe tcpmib.RetransSegs {}
/*
* Find the remote address and return
* it as an index to the counter array.
*/
function tcpmib_filter_key: long ( sk:long, op:long ){
if ( !sk ) return 0;
raddr = sk_get_daddr(sk);
return raddr
}
/* Print the results. */
probe end {
foreach (addr in RetransSegs )
printf ("%s %d
",ip_ntop(htonl(addr)), lport)
}
FILES
/usr/share/doc/systemtap*/examples/tcpipstat.stp
SEE ALSO stap(1), stapprobes(3stap), stapfuncs(3stap)IBM TAPSET::SNMP(3stap)