Now that we have all this wonderful ps data in a database, what are we going to do with it? Why, generate graphs of it on request, of course, just like we did with the rstat data. Here’s a sample CGI script that will do just that, and a sample graph generated from it. (To use the CGI script, you have to put it in your web server’s cgi-bin directory, and then hit the URL corresponding to the script.)
#!/usr/local/bin/perl use DBI; $ENV{ORACLE_HOME} = "/opt/ORACLE/product"; print qq|Content-type: text/html\n\n|; #<meta http-equiv = "Pragma" Content = "no-cache"> #<meta http-equiv = "Expires" Content = "Thu, Jan 1 1970 12:00:00 GMT"> print qq|<HTML><HEAD><TITLE>generate a graph</TITLE> </HEAD><BODY><H1>generate a graph</H1>|; if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $contents{$name} = $value; } } $machine = $contents{"machine"}; $args = $contents{"args"}; $daterange = ....