Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 rodolico 1
#!/usr/bin/env perl
2
use warnings;
26 rodolico 3
use strict;  
2 rodolico 4
 
37 rodolico 5
# Description: Basic template for modules. Do NOT enable
2 rodolico 6
 
37 rodolico 7
our $VERSION = '1.2';
8
 
9
exit 1;
10
 
20 rodolico 11
# Put some comments here on who wrote it and what it does
12
 
2 rodolico 13
BEGIN {
14
   push @INC, shift;
15
}
16
 
17
use library;
18
 
19
# category we will use for all values found
20
# see sysinfo for a list of valid categories
21
my $CATEGORY = 'system';
22
 
20 rodolico 23
# run the commands necessary to do whatever you want to do
24
# The library entered above has some helper routines
25
# validCommandOnSystem -- passed a name, returns the fully qualified path or '' if it does not exist
26
# cleanUp - passed a delimiter and a string, does the following (delimiter can be '')
27
#           chomps the string (removes trailing newlines)
28
#           removes all text BEFORE the delimiter, the delimiter, and any whitespace
29
#           thus, the string 'xxI Am x  a weird string' with a newline will become
30
#           'a weird string' with no newline
2 rodolico 31
 
20 rodolico 32
# now, return the tab delimited output (to STDOUT). $CATEGORY is the first
33
# item, name as recognized by sysinfo is the second and the value is
34
# the last one. For multiple entries, place on separate lines (ie, newline separated)
35
 
36
# Example of getting last_boot and uptime on a Unix system
37
 
38
if ( -d '/proc/uptime' ) {
2 rodolico 39
   my $uptime = qx(cat /proc/uptime);
40
   $uptime =~ m/(\d+)/;
41
   $uptime = int($1); # uptime now has the up time in seconds
42
   print "$CATEGORY\tlast_boot\t" . (time - $uptime) . "\n";
43
   print "$CATEGORY\tuptime\t" . $uptime . "\n";
20 rodolico 44
   exit 0;
45
} else {
46
   exit 1;
2 rodolico 47
}
48
 
20 rodolico 49
# if you have not done an exit state above (1 indicating no data), do one
50
# here (exit 0 indicates success)
51
# NOTE: you can bail early with exit 1 if you can not process anything
52
# because it is the wrong system or something
2 rodolico 53
exit 0;