1856408 Members
2244 Online
104112 Solutions
New Discussion

Re: glance from cron?

 
Wayne Jones_2
New Member

glance from cron?

Can anyone tell me how to get glance to run from root's cron.
It runs okay from the command line and it runs okay inside script
that is run from the command line. But, when the script is run from root's cron
glance produces not output.

What do I need to do to get glance to execute from crom or...
is there a more efficient method of obtaining physical memory utilization?

Thanx,
Wayne Jones
Life is like a violin string . . .Not enough stress and it is dull, just enough stress and it is harmonious, too much stress and it snaps.
12 REPLIES 12
Antoanetta Naghiu
Esteemed Contributor

Re: glance from cron?

Glance is an interactive tool. Why don't try to get reports from Measureware and PerfView?
Alan Riggs
Honored Contributor

Re: glance from cron?

I asusme you have a reason for wanting non-interactive glance screens rather than measurewear. If not, then please use measurewear. No sense taking the additional system load if one product is already doing what you need.

As far as glance through cron, though, realize that cron does not invoke either a terminal or a user environment. It might simply be an issue of providing the full path to the glance command. Alternatively, there might be some environmental variables you need to set. Some troubleshooting steps:

1) make usre you use full pathnames for the glance executable and any logfiles.
2) test
3) invoke a complete user environment (source /etc/profile and /root/.profile)
4) test
5) set the LINES and COLUMNS terminal variables (I suggest 24 and 80).
6) test

Remember to check /var/adm/cron/log after each test to see whether a failed return code is indicated.
Wayne Jones_2
New Member

Re: glance from cron?

Sorry, I am not a sysadmin. I am writing this script to monitor the physical memory utilization. I told the sysadmin that I didn't like using glance, but he could not suggest anything else. The have been two responses to use measureware. I talked to the SA and he doesn't know how to do it, neither do I. Any example of how the get physical memory utilization from measureware.
Life is like a violin string . . .Not enough stress and it is dull, just enough stress and it is harmonious, too much stress and it snaps.
Alan Riggs
Honored Contributor

Re: glance from cron?

First, check to make sure measurewear is running. (mwa status) If so, then you are probably fine. If not, start it (mwa start) and make sure it starts autimatically at boot time (standard startup script in /sbin/init.d && /etc/rc.config.d).

With measurewear running, you can extract history reports with readings every 5 minutes (detail) or every hour (summary). The command you want is "extract". There is a good man page on the utility, and it has a helpful interactive mode which wil step you through creating a config file for your desired report. The requirement is to create a file (default /var/opt/perf/reptfile) and specify which parameters you wish to extract from measuewear date. It seems you want to look at the Global Memory Metrics.

If the interactive extract gives you trouble, you can manually create a report file and acess it as follows:

cd /var/opt/perf
cp reptfile rept.mem
vi rept.mem
(uncomment those metrics you care about -- don't forget date and time)
extract -xp -G -r rept.mem -f memory_report.asc

That will create a global summary report in ascii format named memory_report.asc

See the man page for other options tpo the command
Martha Mueller
Super Advisor

Re: glance from cron?

Try the command vmstat. The value of the fifth field times the size of a virtual page is approximately equal to the amount of free memory as shown by glance or top. For example, I use a script that sends ITO a message if the amount of free memory falls below 15 meg.

FREEMEM=`vmstat | tail -1 | awk '{print $5 * 4}'`

gives me free memory in Kilobytes
Deshpande Prashant
Honored Contributor

Re: glance from cron?

If you need to get only memory utilization "vmstat" command can help you.
You can put vmstat in your cron to capture memory utilization.
eg. vmstat 1 5
This will capture memory snapshot every 1sec for 5 samples.

You will need perfview software to analyse measureware data.

Thanks
Take it as it comes.
Alan Riggs
Honored Contributor

Re: glance from cron?

It is not correct that you need the PerfView software to analyze measurewear date. The PerfView product (not free) provides a graphical view of/hook into measurewear data. The extract command, however, works quite nicely to generate ascii files with the same information. If desired, you can always import the data into your favorite graphing/data modeling application.
Ramesh Donti
Frequent Advisor

Re: glance from cron?

Hi,
To get the memory utilization, you have multipe choices:

1. Use the coventional 'sar' utility. Put the following entry in ur root's crontab file. It will creat daily sar file in /var/adm/sa directory.
00 * * * * /usr/lib/sa/sa1 900 4 > /dev/null

2. If you have Measureware running (check by using perfstat command)
You can export the raw data collected by measureware into ascii files (using extract utility)and import them into excel to view in tabular columns or to create nice graphs. You can use report files to extract the statistics for only desired metrics.

3. If you have perfview running, you can get nice graphs and it is very much useful/recommended to do online performance analysis of a system. From perfview also, you can export the data into ascii or worksheet files.
Always Keep Smiling
Jim Welch
Respected Contributor

Re: glance from cron?

It is possible to run glance in adviser only mode from cron as root. However if all you want is the %util of memory, I'd run sar, vmstat, or some other low overhead utility. MeasureWare will give you the info every 5 minutes, but if you don't own measureware it's not worth buying just for that.
Any sufficiently advanced technology is indistinguishable from Magic - Arthur C. Clarke
curt larson
Frequent Advisor

Re: glance from cron?

Well, there are a few ways to handle this. They all make use of a pseudo-terminal.

1) how are your C programing skills?

open a pseudo-terminal (/dev/ptym/clone,ptsname,etc) and use glance with your pseudo-terminal file descriptors.

2) Don Libes has written a generic scripting Tcl-based toolkit for automating interactive programs, called expect. it creates pseudo-terminals and does co-processing and would do this easily. But you have to install Tcl and Expect on your system to use it.

3) pick a pseudo-terminal capable utility and wrap some co-processing around it
such as this:

#!/usr/bin/ksh

TERM=hp
export TERM

iterations=2
interval=5
command=m
outfile=/tmp/glance.test

PATH=$PATH:/opt/perf/bin

# you'll need to setup a .rhosts file to allow login without a password
# or you can add lines to input the userid and password if you like
#
rlogin camintd1 |&
exec 3<&p
exec 4>&p

# send commands to your rlogin process
#
echo "glance -f $outfile -j $interval -iterations $iterations -m" >&4

# sleep till your glance processes has finished
#
sleep $(( ($iterations + 2)*interval ))

# exit from your rlogin session
#
echo "exit;exit" >&4

# print everything written out from the rlogin session
# mostly crap because there isn't a valid terminal
# I suppose you could add some stty commands
# if you wanted and other stuff, but your desired
# output is in the file given in the glance command.
# you'll have to do some editing for form feeds and
# such
#
while read -ru3 line
do
print -r -- $line
done > /dev/null

nobody else has this problem
Jim Welch
Respected Contributor

Re: glance from cron?

You don't need to use a pseudo terminal to run glance in adviser only mode (at least not in the current version). Just use the
-adviser_only option. I've setup glance to run from cron and from system startup scripts with no problems to collect data over long intervals and either save it to ascii files or feed it into measuresware using dsi. Without the -adviser_only switch, glance will try to initialize the terminal device and will fail if it doesn't exist.
Any sufficiently advanced technology is indistinguishable from Magic - Arthur C. Clarke
curt larson
Frequent Advisor

Re: glance from cron?

Jim,

Happen to have an example of a cron script that works?

using the -advisor_only option does not result in a "can not initialize terminal" error. But I'm unable view any information. Using the -f file option and redirecting stdout have only resulted in empty files for me. Which, of course, should be the case being the adviser thesholds haven't been reached to produce any output.

So, where is the data being logged?
nobody else has this problem