#!/usr/bin/perl -w use strict; use CGI qw/:standard :push -nph/; my $q=CGI->new; $| = 1; open FH,"; my $ut=$1 if /^\s*(\d+\.\d+) .*/; $_=; my $idl=$1 if /^cpu\s+\d+\s+\d+\s+\d+\s+(\d+)\s.*/; return $ut." ".$idl/400; } print $q->header(-type=>'text/event-stream',-charset=>"utf-8"); $SIG{'PIPE'}=sub { close FH; exit 0; }; while (1) { printf "event: ut\ndata:%s\n\n", readprocuptime; select undef,undef,undef,1; };