]> the.earth.li Git - htag.git/blob - plugins/08uptime
ffa34f643aba55c6ace5928db387c90d708fb4db
[htag.git] / plugins / 08uptime
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2000-2001 Simon Huggins
4 # uptime merely calls uptime.  You can influence the output a bit.
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 # for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc., 59
18 # Temple Place, Suite 330, Boston, MA 02111-1307  USA
19
20 # Outputs `uptime` to tmpdir/U
21 # Therefore replaces @U... in sigs via merge.
22
23 use integer;
24 use strict;
25
26 my @found = scansigfile("U");
27 return if not @found;
28
29 #srand( time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required
30
31 open(OUT, ">$cfg{'tmpdir'}/U") or htagdie "$0: Could not open $cfg{'tmpdir'}/U: $!\n";
32 reg_deletion("$cfg{'tmpdir'}/U");
33 my $uptime = `uptime`;
34 chomp $uptime;
35 $uptime =~ s/^.*?(up (?:[0-9]+ days?,)?[^,]+),.*$/$1/ if $cfg{'uptime_time'};
36 $uptime =~ s/[ ]+/ /g;
37 foreach my $f (@found) {
38         my @f = @{$f};
39         if (length $uptime <= $f[1]) {
40                 print OUT chunksizealign($uptime, $f[1], $f[2]),"\n";
41         } else {
42                 htagdie "Can't fit uptime in <= $f[1].\nPerhaps your space isn't big enough.\nAlternatively modify this script to give less information.\n";
43         }
44 }
45 close(OUT);
46 return;