source: MondoRescue/devel/mr/lib/MondoRescue/Inventory.pm @ 2667

Last change on this file since 2667 was 2667, checked in by Bruno Cornec, 10 years ago

r3936@dhcp184-49-175-19: bruno | 2010-06-26 09:48:04 +0200

  • Inventory now in better shape. Needs useful and exhaustive content now.
File size: 3.1 KB
Line 
1#!/usr/bin/perl -w
2#
3# Subroutines brought by the MondoRescue project to do HW/FW/SW inventory
4#
5# $Id$
6#
7# Copyright B. Cornec 2008
8# Provided under the GPL v2
9
10package MondoRescue::Inventory;
11
12use strict 'vars';
13use Data::Dumper;
14use English;
15use File::Basename;
16use File::Copy;
17use POSIX qw(strftime);
18use lib qw (lib);
19use ProjectBuilder::Base;
20use ProjectBuilder::Conf;
21use ProjectBuilder::Distribution;
22use MondoRescue::LVM;
23use MondoRescue::Kernel;
24
25# Inherit from the "Exporter" module which handles exporting functions.
26
27use Exporter;
28
29# Export, by default, all the functions into the namespace of
30# any code which uses this module.
31
32our @ISA = qw(Exporter);
33our @EXPORT = qw(mr_inv_os $mr_os);
34
35# Globals
36our %mr_hw;
37our $mr_hw = \%mr_hw;
38our %mr_os;
39our $mr_os = \%mr_hw;
40
41=pod
42
43=head1 NAME
44
45MondoRescue::Inventory, part of the mondorescue.org
46
47=head1 DESCRIPTION
48
49This modules provides inventory functions for the Mondorescue project in order to report
50the precise context of the system to be archived (Hardware, Firmware and Software as much as possible)
51This module aims to be OS independent
52
53=head1 USAGE
54
55=over 4
56
57=item B<mr_inv_hw>
58
59This function reports Hardware inventory of the system to archive
60
61=cut
62
63sub mr_inv_hw {
64   
65    # Keyboard
66    # Raid SW - DM
67    # Partitions
68    # FS/swaps
69    # LVM / ...
70    # PCI / USB / lssd / ...
71    # messages/dmesg
72    # Kernel / Initrd
73    # Kernel Modules
74    # cmdline
75}
76
77sub mr_inv_os {
78
79($mr_os->{'name'}, $mr_os->{'version'}, $mr_os->{'family'}, $mr_os->{'type'}, $mr_os->{'os'}, $mr_os->{'suffix'}, $mr_os->{'update'}, $mr_os->{'arch'}) = pb_distro_init();
80
81# Get some conf file content when they exist; Depends on genre or more precise tuple
82for my $p ("mr_cmdline","mr_fstab","mr_raidtab","mr_swap","mr_partitions","mr_filesystems","mr_modules","mr_xen") {
83    my $key = $p;
84    $key =~ s/mr_//;
85    my ($pp) = pb_conf_get_if($p);
86    if (defined $pp) {
87        my $file = pb_distro_get_param($mr_os->{'name'},$mr_os->{'version'},$mr_os->{'arch'},$pp,$mr_os->{'family'},$mr_os->{'type'},$mr_os->{'os'});
88        if (-r $file) {
89            pb_log(2,"DEBUG: File found: $file\n");
90            $mr_os->{'files'}->{$key} = pb_get_content($file);
91        } else {
92            pb_log(2,"WARNING: $file not found\n");
93        }
94    }
95}
96
97# Get some commands result content when they exist; Depends on genre or more precise tuple
98for my $p ("mr_mount","mr_lsmod","mr_df") {
99    my $key = $p;
100    $key =~ s/mr_//;
101    my ($pp) = pb_conf_get_if($p);
102    if (defined $pp) {
103        my $cmd = pb_distro_get_param($mr_os->{'name'},$mr_os->{'version'},$mr_os->{'arch'},$pp,$mr_os->{'family'},$mr_os->{'type'},$mr_os->{'os'});
104        pb_log(2,"DEBUG: Cmd found: $cmd\n");
105        $mr_os->{'cmd'}->{$key} = `$cmd`;
106    }
107}
108#
109# LVM setup
110#
111($mr_os->{'lvmver'},$mr_os->{'$lvmcmd'}) = mr_lvm_check();
112
113# Summary of conf printed.
114pb_log(1,"OS Inventory: ".Dumper($mr_os)."\n");
115}
116
117=item B<mr_inv_fw>
118
119This function reports Firmware inventory of the system to archive
120
121=cut
122
123sub mr_inv_fw {
124
125    # Linked to bkphw
126    # On Proliant use hpacucli, conrep, hponcfg
127}
128
129=item B<mr_inv_sw>
130
131This function reports Software inventory of the system to archive
132
133=cut
134
135sub mr_inv_sw {
136
137    # Commands presence - use FindBin
138    # deplist
139    # mountlist
140}
Note: See TracBrowser for help on using the repository browser.