pscount

Package: WA2L/edrc 1.5.57
Section: Library Commands (3)
Updated: 01 December 2022
Index Return to Main Contents

 

NAME

pscount - count operating systems processes

 

SYNOPSIS

edrc/lib/pscount [ -h ]

cat ps_list | pscount

pscount < ps_list

cat ps_list | pscount [ -l ] [ -d deliminator ] [ -i indent ] [ -f processfile ]

cat ps_list | pscount { -s | -u } [ -d deliminator ] [ -f processfile ]

pscount -p [ -d deliminator ] [ -f processfile ]

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

count processes and evaluate if the situation correlates to a defined situation as received thru stdin.

This command is intended to be used to check if the correct number of needed processes for an application are running on the system.

The format of the process count selection definition ps_list is:

MIN;MAX;DESCRIPTION;USER;PROCESS_SELECTION;

where

MIN
Minimum number of processes that are expected (integer number). If there is no defined minimum, this field should be left empty. It is allowed to use spaces in the MIN field to align the numbers.

MAX
Maximum number of processes that are expected (integer number). If there is no defined maximum, this field should be left empty. It is allowed to use spaces in the MAX field to align the numbers.

DESCRIPTION
Description of the selected processes.

USER
Username of the selected processes. This is a regular expression. If there is no defined user, this field can be left empty.

PROCESS_SELECTION
Process selection. This is a regular expression. When using the pscount -p command to get a first start for the ps_list, be aware, that there might be needed some more escaping of regular expression terms in addition to the ones given by the command output.

 

OPTIONS

-h
usage message.

-l
long output. Beside the DESCRIPTION, MIN, MAX, CURRENT and STATE columns, the USER and PROCESS_SELECTION columns are also printed.

-u
print processes not matched by any count selection. This is a verification function to help to check if all processes that relate to an application are selected in the process selection list.

-s
silent, no text output of counting result, only set the EXIT STATUS.

-p
print process list based on system. This output can be used to generate a process count selection definition or a filename.kp (known process) file.

The header line 'MIN;MAX;DESCRIPTION;USER;PROCESS_SELECTION;' can be kept in the *.kp file, it does not influence the counting.

To print a nice formatted output of the 'known process' file, the command pscount -p | csv list can be used.

-d deliminator
record deliminator.

-i indent
left indent of output.

-f processfile
read the processes from a file instead directly from the system.

The format of the process file is the output created by the command ps -eww -o user,command on Linux and ps -e -o user,command on other operating systems.

 

ENVIRONMENT

-

 

EXIT STATUS

0
number of processes on the system are as defined.

1
number of processes on the system are different from the provided definition.

2
Operating system not supported. See osid (3) if you get this error.

4
usage printed.

5
program aborted.

11
a temporary directory could not be claimed or created in /tmp. Check the system temporary directory /tmp if you get this error, it is an indicator of system intrusion.

 

FILES

edrc/var/pscount/
base directory for the 'known process' files. The *.kp files are read when using the pscount -p command.

edrc/var/pscount/apps/<Application>.kp
in the app directory, application related *.kp files are saved.

edrc/var/pscount/os/<OSID>.kp
in the os directory, operating system related *.kp files are saved. The filename must be as returned by the osid(3) command.

edrc/var/pscount/template.kp
template *.kp file to be used for application or operating system 'known process' files. To efficiently create a 'known process' file of for a running system, use the pscount -p > filename.kp command and edit the filename.kp file.

 

EXAMPLES

1) count processes using the 'in here' mechanism (e.g. in a script)

cat << EOM | pscount
1; 1;Oracle Listener ;oracle;.+/tnslsnr LISTENER .+;
1;10;Oracle DB Writer;oracle;ora_dbw[0-9]_ACMEDB;
1;  ;Oracle Connects ;oracle;oracleACMEDB .+;
EOM

DESCRIPTION       MIN  MAX  CURRENT  STATE
----------------  ---  ---  -------  -----
Oracle Listener     1    1        1  OK
Oracle DB Writer    1   10        2  OK
Oracle Connects     1             0  FAIL
 *TOTAL*            3   11        3  FAIL
(4)

2) count processes based on an input file

Process count definition list saved in a file:

cat ACME_DBs.kp

#
# ACME_DBs.kp - Process List for ACME Databases 
#
# [00] 20.12.2012 CWa Initial Version
#
1; 1;Oracle Listener ;oracle;.+/tnslsnr LISTENER .+;
1;10;Oracle DB Writer;oracle;ora_dbw[0-9]_ACMEDB;
1;  ;Oracle Connects ;oracle;oracleACMEDB .+;

Use the process count definition list thru a pipe:

cat ACME_DBs.kp | pscount

DESCRIPTION       MIN  MAX  CURRENT  STATE
----------------  ---  ---  -------  -----
Oracle Listener     1    1        1  OK
Oracle DB Writer    1   10        2  OK
Oracle Connects     1             5  OK
 *TOTAL*            3   11        8  OK
(4)

or use the process count definition list thru input redirection:

pscount -l < ACME_DBs.kp

DESCRIPTION       MIN  MAX  CURRENT  STATE  USER    PROCESS_SELECTION
----------------  ---  ---  -------  -----  ------  ----------------------
Oracle Listener     1    1        1  OK     oracle  .+/tnslsnr LISTENER .+
Oracle DB Writer    1   10        2  OK     oracle  ora_dbw[0-9]_ACMEDB
Oracle Connects     1             5  OK     oracle  oracleACMEDB .+
 *TOTAL*            3   11        8  OK
(4)

 

SEE ALSO

edrcintro(1), csv(3), osid(3), pslist(3)

 

NOTES

The pscount command uses the pslist(3) command internally to resolve the processes.

 

BUGS

-

 

AUTHOR

pscount was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2022 by Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
ENVIRONMENT
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 16:54:05 GMT, August 28, 2024