Sys::Load - Perl module for getting the current system load and uptime

WWW: http://search.cpan.org/dist/Sys-Load/

PR:		ports/154139
Submitted by:	Konstantin Menshikov <kostjnspb at yandex.ru>
Approved by:	pgollucci (mentor)
Feature safe:	yes
This commit is contained in:
Steve Wills 2011-01-29 20:00:32 +00:00
parent c00a7b4e83
commit f03648e2d8
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=268397
7 changed files with 82 additions and 0 deletions

View file

@ -598,6 +598,7 @@
SUBDIR += p5-Sys-HostIP
SUBDIR += p5-Sys-Hostname-FQDN
SUBDIR += p5-Sys-Hostname-Long
SUBDIR += p5-Sys-Load
SUBDIR += p5-Sys-Syslog
SUBDIR += p5-Sys-User-UIDhelper
SUBDIR += p5-Sys-Utmp

View file

@ -0,0 +1,22 @@
# New ports collection makefile for: p5-Sys-Load
# Date created: 19 January 2010
# Whom: Konstantin Menshikov <kostjnspb@yandex.ru>
#
# $FreeBSD$
#
PORTNAME= Sys-Load
PORTVERSION= 0.2
CATEGORIES= sysutils perl5
MASTER_SITES= CPAN \
http://kostjn.spb.ru/freebsd/
PKGNAMEPREFIX= p5-
MAINTAINER= kostjnspb@yandex.ru
COMMENT= Getting the current system load and uptime
PERL_CONFIGURE= YES
MAN3= Sys::Load.3
.include <bsd.port.mk>

View file

@ -0,0 +1,2 @@
SHA256 (Sys-Load-0.2.tar.gz) = 27ef03e0fc455cf51b363b1a10609233de105aa3f3d51086a0a9244b1581275d
SIZE (Sys-Load-0.2.tar.gz) = 1794

View file

@ -0,0 +1,20 @@
--- Load.pm 2002-09-01 09:54:44.000000000 +0000
+++ Load.pm 2011-01-19 12:07:33.000000000 +0000
@@ -17,17 +17,6 @@
bootstrap Sys::Load $VERSION;
# Preloaded methods go here.
-
-use constant UPTIME => "/proc/uptime";
-
-sub uptime {
- open(FILE, UPTIME) || return 0;
- my $line = <FILE>;
- my($uptime, $idle) = split /\s+/, $line;
- close FILE;
- return $uptime;
-}
-
1;
__END__

View file

@ -0,0 +1,27 @@
--- Load.xs 2002-08-31 02:00:32.000000000 +0000
+++ Load.xs 2011-01-19 12:07:14.000000000 +0000
@@ -2,6 +2,7 @@
#include "perl.h"
#include "XSUB.h"
#include "stdlib.h"
+#include <time.h>
MODULE = Sys::Load PACKAGE = Sys::Load
@@ -22,3 +23,16 @@
XPUSHs(sv_2mortal(newSVnv(load[2])));
}
+void
+uptime()
+PROTOTYPE:
+PREINIT:
+ struct timespec t;
+ int i;
+PPCODE:
+ i = clock_gettime(CLOCK_MONOTONIC, &t);
+ if(i == -1)
+ XSRETURN_EMPTY;
+ else {
+ XPUSHs(sv_2mortal(newSVnv(t.tv_sec)));
+ }

View file

@ -0,0 +1,3 @@
Sys::Load - Perl module for getting the current system load and uptime
WWW: http://search.cpan.org/dist/Sys-Load/

View file

@ -0,0 +1,7 @@
%%SITE_PERL%%/mach/auto/Sys/Load/.packlist
%%SITE_PERL%%/mach/auto/Sys/Load/Load.so
%%SITE_PERL%%/mach/auto/Sys/Load/Load.bs
%%SITE_PERL%%/mach/Sys/Load.pm
@dirrmtry %%SITE_PERL%%/mach/auto/Sys/Load
@dirrmtry %%SITE_PERL%%/mach/auto/Sys
@dirrmtry %%SITE_PERL%%/mach/Sys