| 20 |
rodolico |
1 |
#!/usr/bin/env perl
|
|
|
2 |
use warnings;
|
| 26 |
rodolico |
3 |
use strict;
|
| 2 |
rodolico |
4 |
|
| 37 |
rodolico |
5 |
# Description: Get Kernel, distro, etc... on Unix systems
|
| 20 |
rodolico |
6 |
|
| 37 |
rodolico |
7 |
our $VERSION = '1.1';
|
|
|
8 |
|
| 20 |
rodolico |
9 |
# Linux module for sysinfo client
|
|
|
10 |
# Author: R. W. Rodolico
|
|
|
11 |
# Date: 2016-04-08
|
|
|
12 |
|
| 2 |
rodolico |
13 |
# gets information on linux systems with lsb on them
|
|
|
14 |
|
| 251 |
rodolico |
15 |
# find our location and use it for searching for libraries
|
| 2 |
rodolico |
16 |
BEGIN {
|
| 251 |
rodolico |
17 |
use FindBin;
|
|
|
18 |
use File::Spec;
|
|
|
19 |
use lib File::Spec->catdir($FindBin::Bin);
|
|
|
20 |
eval( 'use library;' ); die "Could not find library.pm in the code directory\n" if $@;
|
|
|
21 |
eval( 'use Data::Dumper;' );
|
| 2 |
rodolico |
22 |
}
|
|
|
23 |
|
| 251 |
rodolico |
24 |
# check for valid OS.
|
|
|
25 |
exit 1 unless &checkOS( { 'linux' => undef } );
|
| 2 |
rodolico |
26 |
|
| 251 |
rodolico |
27 |
# check for required commands, return 2 if they don't exist. Enter an full list of all commands required. If one doesn't exist
|
|
|
28 |
# script returns a 2
|
|
|
29 |
foreach my $command ( 'lsb_release', 'uname' ) {
|
|
|
30 |
exit 2 unless &validCommandOnSystem( $command );
|
|
|
31 |
}
|
| 2 |
rodolico |
32 |
my $CATEGORY = 'operatingsystem';
|
|
|
33 |
|
|
|
34 |
my $command = 'lsb_release';
|
| 251 |
rodolico |
35 |
print "$CATEGORY\tdistribution\t" . &cleanUp(':', qx($command -i)) . "\n";
|
|
|
36 |
print "$CATEGORY\tdescription\t" . &cleanUp(':', qx($command -d)) . "\n";
|
|
|
37 |
print "$CATEGORY\trelease\t" . &cleanUp(':', qx($command -r)) . "\n";
|
|
|
38 |
print "$CATEGORY\tcodename\t" . &cleanUp(':', qx($command -c)) . "\n";
|
| 2 |
rodolico |
39 |
|
| 251 |
rodolico |
40 |
$command = 'uname';
|
|
|
41 |
print "$CATEGORY\tos_name\t" . &cleanUp('', qx($command -s)) . "\n";
|
|
|
42 |
print "$CATEGORY\tkernel\t" . &cleanUp('', qx($command -r)) . "\n";
|
| 2 |
rodolico |
43 |
|
|
|
44 |
print "$CATEGORY\tos_version\t" . &cleanUp('', qx(cat /proc/version)) . "\n" if -e '/proc/version';
|