#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw/warningsToBrowser fatalsToBrowser/; use Proc::ProcessTable; use Data::Dumper; use HTML::Template; my $q = new CGI; my $template = HTML::Template->new(filename => "status_ps.html"); my $t = new Proc::ProcessTable; my @needed = qw/Textmate Terminal mysqld launchd securityd/; # add here needed processes my $report; my @missing; my %seen; foreach my $p ( @{$t->table} ){ my $cmd = $p->cmndline; $cmd =~ s/(.*)/$1<\/span>/i if grep /$cmd/i, @needed; push @$report , { cmdline => $cmd, pid => $p->pid, state => $p->state, }; $seen{$p->cmndline}++; } for my $n (@needed) { push @missing, { proc => ''.$n.'', } unless grep /$n/i, keys %seen; } $template->param( report => $report , missing => \@missing, ); print $q->header(), $template->output();