summaryrefslogtreecommitdiff
path: root/cpupload.pl
blob: a490a89fc67985479800969874a0240814ebf6fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
# cpuload.pl 2010 (c) Paul Buetow

use strict;
use warnings;

sub say (@) {
   	print "$_\n" for @_;
	return scalar @_;
}

sub reduce (&@) {
   	
}

sub parse_stat_line ($) {
   	my %load;
	my ($name, $user, $nice, $system, $idle, @rest) = split / +/, shift;
	my $total = $user + $nice + $system + $idle;
	print $nice, "\n";

	return undef;
}

sub parse_stat (@) {
	my ($total,@rest) = @_;

	parse_stat_line $total;

	return undef;
}

sub get_local_stat () {
   	open my $fh, '/proc/stat' or die "$!: /proc/stat\n";
	my @stat = <$fh>;
	close $fh;

	return @stat;
}

sub main () {
	parse_stat get_local_stat;

	exit 0;
}

main;