- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Reg Bill's adminalert.sh script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 05:58 AM
05-28-2015 05:58 AM
Hi Bill ,
Its an excellent script.
But somehow its not running for one of my process .
ps -ef |grep -i str F0004
test 28899 1 0 13:31:02 pts/3 0:00 str F0004
rte 28254 1 0 May 21 ? 0:01 str F0004
dfr 3509 16295 1 15:58:12 pts/0 0:00 grep -i F0004
ddk17349 1 0 May 21 ? 0:04 str F0004
when am mentioning ;
ProcMon=1
PROCS=F0004:1:2
Where do i put second argument "str" ??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 06:31 AM
05-28-2015 06:31 AM
Re: Reg Bill's adminalert.sh script
According to your 'ps' output the script that is running is actually 'str' and the first argument to 'str' is F0004.
However, if you are wanting to check to make sure 'str F0004' is running, I'm not sure how to do that. I don't know that Bill designed the script to handle spaces in the process name(s) it is looking for.
I sent Bill an e-mail alerting him to your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 06:41 AM
05-28-2015 06:41 AM
Re: Reg Bill's adminalert.sh script
There is no process named "str F0004"
The process name is str as reported by ps.
The string "F0004" is just an argument. There is no provision to look for a process and then look for arguments.
The correct entry would be:
ProcMon=1
PROCS=str:1:2
which will email a message if "str" is not running, or there are more than 2 copies running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 07:00 AM
05-28-2015 07:00 AM
Re: Reg Bill's adminalert.sh script
Thanks Patrick :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 07:48 AM
05-28-2015 07:48 AM
Re: Reg Bill's adminalert.sh script
Hi Pooderbill,
I need to grep F0004 primarily , not str .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 09:08 AM - edited 05-28-2015 09:11 AM
05-28-2015 09:08 AM - edited 05-28-2015 09:11 AM
SolutionSo F0004 might appear on the command line for multiple programs?
As a reminder, grep and ps can be an unstable combination. grep matches any string of characters, anywhere on the ps line. That means that a user named F0004 will be found, an argument on a command line such as A:AFF000423, and of course the grep command itself which will have F0004 on the command line.
To narrow down the search (and make it more accurate), I would use the UNIX95=1 feature to enable these extra options:
-C <process name(s)>
-H to parent/child relationships
-o <columns to list>
The two options for this task would be -C to list only the processes that might have F0004 on the command line, and -o which allows you to customize the output for easier scripting.
Let's assume that there are 3 different processes that might have F0004, str, strabc and abc. To find exactly those processes by name, NEVER use grep but rather, use this:
UNIX95=1 ps -f -C str,strabc,abc
This will not find processes like abc123 or str2, only exact name matches.
Now that you have only the programs to be tested, you can then choose which columns to have displayed by ps.
This is done with the -o option. For example:
# UNIX95=1 ps -C httpd -o pid -o args PID COMMAND 4282 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start 4279 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start 4364 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start 4363 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start and without a title line: # UNIX95=1 ps -C httpd -o pid= -o args= 4282 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start 4279 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start 4364 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start 4363 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start
The UNIX95=1 is a temporary assignment just for the ps command.
Don't assign the variable on a separate line as this change the behavior of other commands.
The column names are listed in the man page.
To eliminate the title line, set the column name to nothing or use "" as in pid= or pid=""
If all you need is the PID, then this is the easiest way. Now you can grep F0004 from just the listed processes.
# UNIX95=1 ps -C str,strabc,abc -o pid= -o args= | grep F0004 17546 str F00004 12789 abc -a "zz43 F0004" -w ww9
(Note for the purists: UNIX95=1 can be just UNIX95= in order to define the variable. See man 5 standards)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 10:51 AM
05-28-2015 10:51 AM
Re: Reg Bill's adminalert.sh script
Hi Bill ,
So where exactly i need to make changes ? to grep F0004 alongwith str ??
Will you please help me with it .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 10:58 AM
05-28-2015 10:58 AM
Re: Reg Bill's adminalert.sh script
My script will not work for your requirement.
You'll need to create a script that performs the monitoring using ps and grep for F0004, then add logic to see if it meets your requirements.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 11:08 AM
05-28-2015 11:08 AM
Re: Reg Bill's adminalert.sh script
Oh :( .
Anyway thanks for the hint.
Will check it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 11:53 PM
05-28-2015 11:53 PM
Re: Reg Bill's adminalert.sh script
> There is no process named "str F0004"
> The process name is str as reported by ps.
Does the concept of a "process name" even exist on UNIX? It does on
VMS (where a process name may have little or nothing to do with the
executable being run). For example, given a process ID, one can request
its name (using the Get Job and Process Information service):
alp $ write sys$output f$getjpi( "20200410", "PRCNAM")
AUDIT_SERVER
On UNIX, one can pretend that argv[0] is a process name, but, because
multiple processes can run the same executable, multiple processes can
have the same "name" (argv[0]), so this "name" does not uniquely
identify a process. Even on VMS, a process name is unique only within
a process group, but it's a better identifier there than argv[0] is on
UNIX.
"man ps" mentions "args", "arguments", and "command name", but I
don't see "process name" anywhere.