- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: what wrong with my 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
Forums
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
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
03-08-2006 01:02 PM
03-08-2006 01:02 PM
what wrong with my script
I am writing some script to monitor the CPU usage of a remote machine. If the CPU is busy then I will get an email. Apparently I notice that the IDLE value is always empty. If I run the script it seem to be okay
IDLE=`ssh user@hostname sar -u 1 5 | grep Average | awk '{print $5}'`
function func_send_email
{
(
echo "To:myemail@mydomain.com"
echo "Subject:CPU Alert"
) | /usr/sbin/sendmail -t
}
echo $IDLE >> /tmp/cpu.log
if [ $IDLE -lt "10" ]
then
echo "Warning High CPU more than 90%"
func_send_email
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 03:27 PM
03-08-2006 03:27 PM
Re: what wrong with my script
Did you set a shell at the start?
#!/bin/sh
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 06:13 PM
03-08-2006 06:13 PM
Re: what wrong with my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 06:18 PM
03-08-2006 06:18 PM
Re: what wrong with my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 06:29 PM
03-08-2006 06:29 PM
Re: what wrong with my script
Please be aware that when cron runs your script, it is not in the shell with profile/.profile executed. So you have 2 choices. One either mention Obsolute path names to all your commands are define a PATH variable explicitly.
Along with RAC's suggestion of exporting the IDLE variable, Please also define a PATH variable.. You can see it defined in /etc/profile, ~/.profile or /etc/PATH file..
In my example I would include the following lines in my script.
PATH=/usr/bin:/usr/contrib/bin:/opt/local/bin:/opt/perf/bin:/opt/OV/bin/OpC:/opt/hparray/bin:/opt/graphics/common/bin:/usr/sbin/diag/contrib:/opt/h
pnpl//bin:/opt/ansic/bin:/opt/langtools/bin:/opt/imake/bin:/opt/OV/bin:/opt/ignite/bin:/opt/resmon/bin:.
export PATH
Regards,
Senthil Kumar .A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 08:07 PM
03-08-2006 08:07 PM
Re: what wrong with my script
ssh user@hostname sar -u 1 5 | grep Average | awk '{print $5}
the remote execution of command won't work in my script if it is running in background.
Any more input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 09:09 PM
03-08-2006 09:09 PM
Re: what wrong with my script
e.g.
IDLE=`ssh user@hostname sar -u 1 5|awk '$1~/verage/{print$5}'`
But that's only cosmetic.
However, there's a subtle difference if you quote the pipe or don't, as you have done.
e.g.
... sar -u 1 5 \| awk ...
In the first case (i.e. quoted pipe) the parsing is done on the remote host,
while in the latter awk is called on the local host.
Apropos quotes,
you also may have a quoting issue, especially with awk's execution block.
Sometimes some weird quoting is necessary.
In such cases I usually play at the shell to see how tokens get expanded until I fixed any quoting issues.
What return code is reported in /var/adm/cron/log for your job?
Does the cronjob's user receive a mail of stdout and stderr on the local host?
How does your local user (i.e. the uid the cronjob runs under) authenticate with the remote host?
(e.g. Rhosts vs. RSAPubKey)
Maybe extra reference to the right keys is necessary (viz. ssh -i ...)?
Maybe split the job into single tasks for debugging.
E.g. first run the ssh sar command as cron or at job to see if the remote command gets executed and its output is caught.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 01:34 AM
03-09-2006 01:34 AM
Re: what wrong with my script
You need to run commands explicitly - IE give the full path...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 03:59 AM
03-09-2006 03:59 AM
Re: what wrong with my script
Why dont use net-snmp? Is possible use command snmpget for get information from another host.
Download "HP-UX Internet Express for HP-UX 11i version 1"
See description:
"HP-UX Internet Express version A.06.00 for HP-UX 11i version 1 contains two sets of components. The first set is a collection of HP-UX Internet Express Open Source Web, Internet, and security components, which have been tested and qualified on HP-UX. The second set of components is a selection of software products available on HP-UX 11i version 1 Operating Environments (OEs)."
Schimidt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 04:03 AM
03-09-2006 04:03 AM
Re: what wrong with my script
See /etc/mail/sendmail.cf
# In order to limit load on a very busy system, sendmail can be #
# configured to queue up low priority messages rather than attempt #
# delivery immediately if the five-minute load average is greater #
# than some integer value, by default 8. This value is defined on #
# the line beginning O QueueLA=.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 05:31 AM
03-09-2006 05:31 AM
Re: what wrong with my script
assuming you use key-authentication in that ssh connection with the default environment with HOME being not set in cron, ssh (which should be fully quallified as already said) needs to know where the key-files is.
-i file Identity for public key authentication (default: ~/.ssh/identity)
with "~" beinig a substititute for $HOME.
Specify the key file with the "-i" option or set
export HOME=....
prior calling ssh
Good luck !
Volker