AGREEMENT Copyright (c) 1997 Meta-Xceed, Inc. |
The following programs were scheduled to run every 10 minutes via the crontab facility.
*-------------------------------------------------------------*; * program: ls_ps.sas *; * Description: Compare the process information with the work *; * space and generate a report which show those *; * work space with no process. *; * By: Sy Truong, 10/10/97 *; *-------------------------------------------------------------*; libname sasin '.'; *** Collect information for SAS processes ***; filename psetenv pipe "/usr/ucb/ps -uaw | grep :"; options linesize=162; *** Parse UNIX process information ***; data sasin.ps_uaw; length user $8 pid $5 cpu $4 mem $4 sz $5 start $8 time $4 command $100; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input user $1-8 pid $10-15 cpu $16-20 mem $21-25 sz $25-30 start $47-55 time $56-60 command $62-162; if command ne "<defunct>" then do; * compute a new date *; curdate = input("&sysdate",date7.); year1 = put(year(curdate),$4.); year2 = substr(year1,3,2); *** Check to see if it is a date ***; if index(start,":") then do; sdate = input("&sysdate",date7.); stime = input(start,time8.); end; else do; sdate = input(compress(substr(start,4) || substr(start,1,3) || year2),date7.); *** Approximate the time ***; stime = input("12:00",time5.); end; ndate = input("&sysdate",date7.); ntime = input("&systime",time5.); durday = ndate - sdate; durtime = ntime - stime; *** Round off time if it has just happened ***; if durtime < 0 then durtime = 0; format sdate date7. stime durtime time5. ; * check to see if it is sas *; if index(command,"sas") > 0 or index(command,"ssub") > 0 then output; end; run; *** Collect information for work spaces ***; filename psetenv pipe "/usr/ucb/ls -al /sastmp | grep SAS_work"; options linesize=162 macrogen; data sasin.ls; length filesys $25 link 8 user $8 size 8 month $3 day $2 time $5 direct $20 ; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input filesys link user size month day time direct ; * compute a new date *; curdate = input("&sysdate",date7.); year = year(curdate); date = input(compress(day||month||year),date9.); format date date7.; run; *** Remove sessions which are editing files ***; data ps; set sasin.ps_uaw; if index(command,"vi ") > 0 or index(command,"/opt/tpu4.1/nu_tpu/solaris/tpu_v41") > 0 then delete; run; proc sort data = sasin.ls (keep = user date direct) out = ls; by user date; run; proc sort data = ps (keep = user sdate command rename = (sdate=date)) out = ps; by user date; run; data analysis (keep = direct); merge ps (in=ps) ls (in=ls); by user date; if (ls) and not(ps) then output; run; *** Merged found work with original list ***; proc sort data = sasin.ls out=ls; by direct; run; proc sort data=analysis; by direct; run; data new ; merge ls (in=ls) analysis (in=an); by direct; if (an) then output; run; *** Generate an report of those that have work directories but no process ***; filename outhtm "ls_ps.html"; proc sort data = work.new out=work.sorted; by date time; run; *** Create HTML page from results ***; data _null_; file outhtm; set work.sorted end=eof; by date time; tc1 = " <TH BGCOLOR=silver ALIGN=CENTER VALIGN=MIDDLE><font size=2>"; _tc1 = " </TH> "; retain count 0; count = count + 1; *** Create HTML header ***; if count = 1 then do; put // "<HTML>" / "<HEAD>" / ' <META NAME="SAS Monitor Generated"' / ' CONTENT="SAS Monitor Tool by Sy Truong">' / " <TITLE>SAS Monitor - Work Space with no Process </TITLE>" / "</HEAD>" / "<BODY BGCOLOR=white>" / '<h2 align="center"> Work Space With No Process</h2>' / '<div align="center"><center>' / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=4' / 'CELLSPACING=1 BGCOLOR=white>' / '<TR>' / tc1 'User' _tc1 / tc1 'Size (bytes)' _tc1 / tc1 'Date' _tc1 / tc1 'Time' _tc1 / tc1 'Directory' _tc1 / '</TR>' ; end; tc2 = "<TD><font size=2>"; tc2c = "<TD ALIGN=CENTER><font size=2>"; tc2rc = '<TD ALIGN=CENTER bgcolor="#FF8080"><font color="#FF0000" size=2>'; tc2rl = '<TD bgcolor="#FF8080"><font color="#FF0000" size=2>'; _tc2 = "</TD>"; *** Create body of table ***; put / '<TR>' / tc2 user _tc2 / tc2 size _tc2 / tc2 date date7. _tc2 / tc2 time _tc2 / tc2 direct _tc2 ; **** Create the HTML Footer ***; if (eof) then do; put / "</TABLE>" / '<p> </p>' / '</center></div>' / '<hr width="50%">' / '<p align="center"><font size="2"><em>SAS Monitor, Last Modified: ' " &sysdate &systime" / "</BODY>" / "</HTML>" ; end; run; x "rcp ls_ps.html webserver:/path/sasmon/ls_ps.html";
*-------------------------------------------------------------*; * program: df.sas *; * Description: This program captures and displays the amount *; * of disk space occupied by file systems *; * pertaining to SAS. *; * By: Sy Truong, 10/10/97 *; *-------------------------------------------------------------*; *** Capture information from UNIX command ***; filename psetenv pipe "/usr/ucb/df | grep sas"; options linesize=162; libname sasin '.'; *** Parase information from UNIX ***; data sasin.df ; length filesys $25 kbytes 8 used 8 avail 8 capacity $4 volume $12; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input filesys kbytes used avail capacity volume; * format the capacity to a numeric value *; ncapa = input(substr(capacity,1,length(capacity)-1),8.); run; *** Create the Graph ***; filename outgif './df.gif'; goptions reset = all ftext = swissb htext = 2.3 colors = (black) cback = white gunit = pct gsflen = 132 gsfmode = replace gsfname = outgif device = imggif display noprompt gaccess = gsasfile gend = '0a'x hsize = 6.5 in vsize = 5.0 in hpos=45 vpos=75 ; options pagesize=48 linesize=150 nonumber nodate nosource2; ************************************************************ * Set up formats for titles, footnotes, plot symbols, etc.* ************************************************************; title1 f = swissb h = 4.0 j = center "SAS Related Disk Volume Usage"; title2 f = swissb h = 3.0 j=c 'rosie.gene.com' ; footnote1 f = swissb h = 2.0 j = l "Generated &sysdate &systime" j = r "SAS/Monitor by Sy Truong" ; pattern1 value = S color =blue; pattern2 value = S color =red; pattern3 value = S color =yellow; axis1 label=none value=none; legend frame across = 1 label = none; proc gchart data = sasin.df; vbar ncapa / discrete maxis = axis1 raxis = 0 to 100 by 5 group = volume minor = 0 width = 2 nozero sumvar = ncapa legend = legend coutline = black sum; label ncapa = 'Capacity (%)' volume = 'Disk Volume'; run ; x 'rcp df.gif webserver:/path/sasmon/df.gif'; *** Generate the HTML file which uses the GIF images ***; filename outhtm './df.html'; *** Create HTML page from results ***; data _null_; file outhtm; set sasin.df end=eof; tc1 = " <TH BGCOLOR=silver ALIGN=CENTER VALIGN=MIDDLE><font size=2>"; _tc1 = " </TH> "; retain count 0; count = count + 1; *** Create HTML header ***; if count = 1 then do; put // "<HTML>" / "<HEAD>" / ' <META NAME="SAS Monitor Generated"' / ' CONTENT="SAS Monitor Tool by Sy Truong">' / " <TITLE>SAS Monitor - Disk Usage </TITLE>" / "</HEAD>" / "<BODY BGCOLOR=white>" / '<h2 align="center"> Disk and Swap Space Usage </h2>' / '<div align="center"><center>' / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=1 CELLSPACING=1 BGCOLOR=white>' / '<TR>' / tc1 'File System' _tc1 / tc1 'Kbytes' _tc1 / tc1 'Used' _tc1 / tc1 'Available' _tc1 / tc1 'Capacity (%)' _tc1 / tc1 'Disk Volume' _tc1 / '</TR>' ; end; tc2 = "<TD><font size=2>"; tc2c = "<TD ALIGN=CENTER><font size=2>"; tc2rc = '<TD ALIGN=CENTER bgcolor="#FF8080"><font color="#FF0000" size=2>'; tc2rl = '<TD bgcolor="#FF8080"><font color="#FF0000" size=2>'; _tc2 = "</TD>"; *** Create body of table ***; put / '<TR>' / tc2 filesys _tc2 / tc2 kbytes _tc2 / tc2 used _tc2 / tc2 avail _tc2 / tc2c capacity _tc2 / tc2 volume _tc2 ; **** Create the HTML Footer ***; if (eof) then do; put / "</TABLE>" / '<p> </p>' / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=1' / ' CELLSPACING=1 BGCOLOR=white>' / '<TR>' / '<td><p align="center"> <img src="./df.gif"> </p></td>' / '</TR>' / '</TABLE>' / '<p> </p>' / '<hr width="50%">' / '<p align="center"><font size="2"><em>SAS Monitor, Last Modified: ' " &sysdate &systime" / '</center></div>' / "</BODY>" / "</HTML>" ; end; run; x 'rcp df.html webserver:/path/sasmon/df.html';
*-------------------------------------------------------------*; * program: ls.sas *; * Description: Generates a list of files which are in the *; * work space. Produce HTML files sorted by *; * User and Date. *; * By: Sy Truong, 10/10/97 *; *-------------------------------------------------------------*; *** Define UNIX command which captures file in work area ***; filename psetenv pipe "/usr/ucb/ls -al /sastmp | grep SAS_work"; options linesize=162 macrogen; *** Parse the information from UNIX command ***; data work.ls; length filesys $25 link 8 user $8 size 8 month $3 day $2 time $5 direct $20 ; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input filesys link user size month day time direct ; * compute a new date *; curdate = input("&sysdate",date7.); year = year(curdate); date = input(compress(day||month||year),date9.); format date date7.; run; *** Define the macro the Generate HTML files ***; %macro htmlgen (outfile,sortord,descend,link,link2); *** Generate the HTML file reporting resuls***; filename outhtm "&outfile"; proc sort data = work.ls out=work.sorted; by &descend &sortord; run; *** Create HTML page from results ***; data _null_; file outhtm; set work.sorted end=eof; by &descend &sortord; tc1 = " <TH BGCOLOR=silver ALIGN=CENTER VALIGN=MIDDLE><font size=2>"; _tc1 = " </TH> "; retain count 0; count = count + 1; *** Create HTML header ***; if count = 1 then do; put // "<HTML>" / "<HEAD>" / ' <META NAME="SAS Monitor Generated"' / ' CONTENT="SAS Monitor Tool by Sy Truong">' / " <TITLE>SAS Monitor - /sastmp Files </TITLE>" / "</HEAD>" / "<BODY BGCOLOR=white>" / '<h2 align="center">Work Space (/sastmp) Listing </h2>' / '<div align="center"><center>' / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=4' / 'CELLSPACING=1 BGCOLOR=white>' / '<TR>' / tc1 &link2 'User' _tc1 / tc1 'Size (bytes)' _tc1 / tc1 &link 'Date' _tc1 / tc1 'Time' _tc1 / tc1 'Directory' _tc1 / '</TR>' ; end; tc2 = "<TD><font size=2>"; tc2c = "<TD ALIGN=CENTER><font size=2>"; tc2rc = '<TD ALIGN=CENTER bgcolor="#FF8080"><font color="#FF0000" size=2>'; tc2rl = '<TD bgcolor="#FF8080"><font color="#FF0000" size=2>'; _tc2 = "</TD>"; *** Create body of table ***; put / '<TR>' / tc2 user _tc2 / tc2 size _tc2 / tc2 date date7. _tc2 / tc2 time _tc2 / tc2 direct _tc2 ; **** Create the HTML Footer ***; if (eof) then do; put / "</TABLE>" / '<p> </p>' / '</center></div>' / '<hr width="50%">' / '<p align="center"><font size="2"><em>SAS Monitor, Last Modified: ' " &sysdate &systime" / "</BODY>" / "</HTML>" ; end; run; *** Copy HTML output produced to webserver ***; x "rcp &outfile webserver:/path/sasmon/&outfile"; %mend htmlgen; *** Invoke macro to produce HTML files with different sort orders ***; %htmlgen(ls_time1.html,date time, ,'<a href="ls_time2.html">','<a href="ls_user1.html">'); %htmlgen(ls_time2.html,date time,descending,'<a href="ls_time1.html">','<a href="ls_user1.html">'); %htmlgen(ls_user1.html,user date time, ,'<a href="ls_time1.html">','<a href="ls_user2.html">'); %htmlgen(ls_user2.html,user date time,descending,'<a href="ls_time1.html">','<a href="ls_user1.html">');
*-------------------------------------------------------------*; * program: ps.sas *; * Description: Display all UNIX processes which pertain to *; * SAS. Generate reports which are sorted by *; * user and start date. *; * By: Sy Truong, 10/10/97 *; *-------------------------------------------------------------*; *** Define UNIX command to capture UNIX process information ***; filename psetenv pipe "/usr/ucb/ps -uaw"; options linesize=162; *** Parse the information from the UNIX command ***; data work.ps_uaw; length user $8 pid $5 cpu $4 mem $4 sz $5 start $8 time $4 command $100; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input user $1-8 pid $10-15 cpu $16-20 mem $21-25 sz $25-30 start $47-55 time $56-60 command $62-162; * check to see if it is sas *; if index(command,"sas") > 0 or index(command,"ssub") > 0 then output; run; *** Store this information in physical file for future usage ***; libname sasin '.'; data ps_uaw; set sasin.ps_uaw; run; data work.duration; set sasin.ps_uaw; run; *** Define the macro the Generate HTML files ***; %macro htmlgen (outfile,sortord,descend,link1,link2); proc sort data = work.duration out = odur (keep = user pid sdate stime durday durtime command); by &descend &sortord; run; *** Generate the HTML from data set ***; title "SAS Related Process Ordered by Duration"; *** Generate the HTML file reporting resuls***; filename outhtm "&outfile"; *** Create HTML page from results ***; data _null_; file outhtm; set work.odur end=eof; tc1 = " <TH BGCOLOR=silver ALIGN=CENTER VALIGN=MIDDLE><font size=2>"; _tc1 = " </TH> "; retain count 0; count = count + 1; *** Create HTML header ***; if count = 1 then do; put // "<HTML>" / "<HEAD>" / ' <META NAME="SAS Monitor Generated"' / ' CONTENT="SAS Monitor Tool by Sy Truong">' / " <TITLE>SAS Monitor - Duration </TITLE>" / "</HEAD>" / "<BODY BGCOLOR=white>" / '<h2 align="center"> SAS Processes</h2>' / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=1 CELLSPACING=1 BGCOLOR=white>' / '<TR>' / tc1 &link2 'User' _tc1 / tc1 " Process ID" _tc1 / tc1 &link1 'Start Date' _tc1 / tc1 " Start Time" _tc1 / tc1 " Duration (Day)" _tc1 / tc1 " Duration (Time)" _tc1 / tc1 " Command" _tc1 / '</TR>' ; end; tc2 = "<TD><font size=2>"; tc2c = "<TD ALIGN=CENTER><font size=2>"; tc2rc = '<TD ALIGN=CENTER bgcolor="#FF8080"><font color="#FF0000" size=2>'; tc2rl = '<TD bgcolor="#FF8080"><font color="#FF0000" size=2>'; _tc2 = "</TD>"; *** Create body of table ***; put / '<TR>' / tc2 user _tc2 / tc2 pid _tc2 / tc2 sdate _tc2 / tc2 stime _tc2 ; if (durday > 1) then put tc2rc durday _tc2; else put tc2c durday _tc2; put / tc2c durtime _tc2 / tc2 command _tc2 / '</TR>' ; **** Create the HTML Footer ***; if (eof) then do; put / "</TABLE>" / '<p> </p>' / '<hr width="50%">' / '<p align="center"><font size="2"><em>SAS Monitor, Last Modified: ' " &sysdate &systime" / "</BODY>" / "</HTML>" ; end; run; *** Copy created files over to Web server ***; x "rcp &outfile webserver:/path/sasmon/&outfile"; %mend htmlgen; *** Invoke macro to generate files in various sort order ***; %htmlgen(ps_time1.html,sdate stime pid, ,'<a href="ps_time2.html">', '<a href="ps_user1.html">'); %htmlgen(ps_time2.html,sdate stime pid, descending , '<a href="ps_time1.html">', '<a href="ps_user1.html">'); %htmlgen(ps_user1.html,user sdate stime , , '<a href="ps_time1.html">', '<a href="ps_user2.html">'); %htmlgen(ps_user2.html,user sdate stime , descending , '<a href="ps_time1.html">', '<a href="ps_user1.html">');
*-------------------------------------------------------------*; * program: uptime.sas *; * Description: This program captures: the length of time *; * the system has been up, and the average number *; * of jobs in the run queue over the last 1, 5 *; * in the run queue over the last 1, 5 and 15 *; * minutes. It produces an HTML report of this *; * information graphically and textually. *; * By: Sy Truong, 10/10/97 *; *-------------------------------------------------------------*; *** Issue UNIX command to gather information ***; filename psetenv pipe "/usr/bin/uname -a"; options linesize=162; *** Parse the information ***; data work.uname ; length os $5 node $14 release $3 osver $17 hardwr $5 proctp $5; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input os node release osver hardwr proctp; run; filename psetenv pipe "/usr/ucb/uptime "; options linesize=162; data work.uptime ; length curtime $7 updays $9 uptime $5 usern $8 load1 $4 load5 $4 load15 $4; * Read STDOUT from UNIX command *; infile psetenv lrecl=162 missover pad; * Input whole STDOUT line *; input curtime $3-9 updays $14-23 uptime $25-30 usern $33-41 load1 $58-62 load5 $64-68 load15 $70-74; run; data all; set uname uptime; run; options ls= 100; proc print; run; *** Transform the numbers for graphs ***; data uptime; set uptime; length nload1 nload5 nload15 8 time 8; nload1 = input(load1,8.); nload5 = input(load5,8.); nload15 = input(load15,8.); time = 1; load = nload1; output; time = 5; load = nload5; output; time = 15; load = nload15; output; run; *** Create the Graph ***; filename outgif 'uptime.gif'; goptions reset = all ftext = swissb htext = 2.3 colors = (black) cback = white gunit = pct gsflen = 132 gsfmode = replace gsfname = outgif device = imggif display noprompt gaccess = gsasfile gend = '0a'x hsize = 6.0 in vsize = 5.0 in hpos=45 vpos=75 ; options pagesize=48 linesize=150 nonumber nodate nosource2; ************************************************************ * Set up formats for titles, footnotes, plot symbols, etc.* ************************************************************; title1 f = swissb h = 4.0 j = center "System Load Over Last 15 Minutes"; title2 f = swissb h = 3.0 j=c 'Rosie.gene.com' ; footnote1 f = swissb h = 2.0 j = l "Generated &sysdate &systime" j = r "SAS/Monitor by Sy Truong" ; pattern1 value = S color =blue; pattern2 value = S color =red; pattern3 value = S color =yellow; axis1 label=none value=none; legend frame across = 1 label = none; proc gchart data = uptime; vbar load / discrete maxis = axis1 raxis = 0 to 20 by 2 group = time width = 2 nozero sumvar = load legend = legend coutline = black sum; label load = 'Average Job Load' time = 'Within Last Minutes'; run ; x 'rcp uptime.gif webserver:/path/sasmon/uptime.gif'; *** Generate the HTML file which uses the GIF images ***; filename outhtm './uptime.html'; *** Create HTML page from results ***; data _null_; file outhtm; set work.all end=eof; tc1 = " <TH BGCOLOR=silver ALIGN=CENTER VALIGN=MIDDLE><font size=2>"; _tc1 = " </TH> "; retain count 0; count = count + 1; *** Create HTML header ***; if count = 1 then do; put // "<HTML>" / "<HEAD>" / ' <META NAME="SAS Monitor Generated"' / ' CONTENT="SAS Monitor Tool by Sy Truong">' / " <TITLE>SAS Monitor - System Load </TITLE>" / "</HEAD>" / "<BODY BGCOLOR=white>" / '<h2 align="center"> System Load </h2>' / '<div align="center"><center>'; end; tc2 = "<TD><font size=2>"; tc2c = "<TD ALIGN=CENTER><font size=2>"; tc2rc = '<TD ALIGN=CENTER bgcolor="#FF8080"><font color="#FF0000" size=2>'; tc2rl = '<TD bgcolor="#FF8080"><font color="#FF0000" size=2>'; _tc2 = "</TD>"; *** Create the table containing uname information ***; if os ne ' ' then do; put / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=1 CELLSPACING=1 BGCOLOR=white>' / '<TR>' / tc1 'Operating System' _tc1 / tc1 'Node Name' _tc1 / tc1 'OS Release' _tc1 / tc1 'OS Version' _tc1 / tc1 'Hardware Name' _tc1 / tc1 'Processor Type' _tc1 / '</TR>' / '<TR>' / tc2c os _tc2 / tc2c node _tc2 / tc2c release _tc2 / tc2c osver _tc2 / tc2c hardwr _tc2 / tc2c proctp _tc2 / "</TABLE>" / '<p> </p>' ; end; *** Create table for uptime information ***; if curtime ne ' ' then do; put / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=1 CELLSPACING=1 BGCOLOR=white>' / '<TR>' / tc1 'Current Time' _tc1 / tc1 'Number of Days System Has Been Up' _tc1 / tc1 'Lenth of Time System Has Been Up' _tc1 / tc1 'Number of Users' _tc1 / tc1 'Average Number of Jobs In Queue Over Last 1 Minute' _tc1 / tc1 'Average Number of Jobs In Queue Over Last 5 Minutes' _tc1 / tc1 'Average Number of Jobs In Queue Over Last 15 Minutes' _tc1 / '</TR>' / '<TR>' / tc2c curtime _tc2 / tc2c updays _tc2 / tc2c uptime _tc2 / tc2c usern _tc2 / tc2c load1 _tc2 / tc2c load5 _tc2 / tc2c load15 _tc2 / "</TABLE>" / '<p> </p>' ; end; **** Create the HTML Footer ***; if (eof) then do; put / '<TABLE BORDER=1 WIDTH=175 ALIGN=CENTER CELLPADDING=4' / ' CELLSPACING=1 BGCOLOR=white>' / '<TR>' / '<td><p align="center"> <img src="./uptime.gif"> </p></td>' / '</TR>' / '</TABLE>' / '</center></div>' / '<p> </p>' / '<hr width="50%">' / '<p align="center"><font size="2"><em>SAS Monitor, Last Modified: ' " &sysdate &systime" / "</BODY>" / "</HTML>" ; end; run; x 'rcp uptime.html webserver:/path/sasmon/uptime.html';