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

Last change on this file since 2668 was 2668, checked in by Bruno Cornec, 14 years ago

r3939@athonet: bruno | 2010-06-30 16:50:32 +0200
Renaming of conf file parameters to be more specific

File size: 3.5 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;
23
24# Inherit from the "Exporter" module which handles exporting functions.
25
26use Exporter;
27
28# Export, by default, all the functions into the namespace of
29# any code which uses this module.
30
31our @ISA = qw(Exporter);
32our @EXPORT = qw(mr_inv_os $mr_os);
33
34# Globals
35our %mr_hw;
36our $mr_hw = \%mr_hw;
37our %mr_os;
38our $mr_os = \%mr_hw;
39
40=pod
41
42=head1 NAME
43
44MondoRescue::Inventory, part of the mondorescue.org
45
46=head1 DESCRIPTION
47
48This modules provides inventory functions for the Mondorescue project in order to report
49the precise context of the system to be archived (Hardware, Firmware and Software as much as possible)
50This module aims to be OS independent
51
52=head1 USAGE
53
54=over 4
55
56=item B<mr_inv_hw>
57
58This function reports Hardware inventory of the system to archive
59
60=cut
61
62sub mr_inv_hw {
63
64 # Keyboard
65 # Raid SW - DM
66 # Partitions
67 # FS/swaps
68 # LVM / ...
69 # PCI / USB / lssd / ...
70 # messages/dmesg
71 # Kernel / Initrd
72 # Kernel Modules
73 # cmdline
74}
75
76sub mr_inv_os {
77
78($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();
79
80# Get some conf file content when they exist; Depends on genre or more precise tuple
81for my $p ("mr_proc_cmdline","mr_etc_fstab","mr_etc_raidtab","mr_proc_swaps","mr_proc_partitions","mr_proc_filesystems","mr_proc_modules","mr_proc_xen","mr_proc_cpuinfo","mr_proc_devices","mr_proc_meminfo","mr_proc_misc","mr_proc_mounts","mr_proc_version") {
82 my $key = $p;
83 $key =~ s/mr_//;
84 my ($pp) = pb_conf_get_if($p);
85 if (defined $pp) {
86 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'});
87 if (-r $file) {
88 pb_log(2,"DEBUG: File found: $file\n");
89 $mr_os->{'files'}->{$key} = pb_get_content($file);
90 } else {
91 pb_log(1,"WARNING: $file not found\n");
92 }
93 }
94}
95
96# Get some commands result content when they exist; Depends on genre or more precise tuple
97for my $p ("mr_cmd_mount","mr_cmd_df","mr_cmd_dmidecode","mr_cmd_lshw") {
98 my $key = $p;
99 $key =~ s/mr_cmd_//;
100 my ($pp) = pb_conf_get_if($p);
101 my ($po) = pb_conf_get_if("mr_opt_".$key);
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 my $opt = "";
105 $opt = pb_distro_get_param($mr_os->{'name'},$mr_os->{'version'},$mr_os->{'arch'},$po,$mr_os->{'family'},$mr_os->{'type'},$mr_os->{'os'}) if (defined ($po));
106 if (-x $cmd) {
107 pb_log(2,"DEBUG: Cmd found: $cmd $opt\n");
108 $mr_os->{'cmd'}->{$key} = `$cmd $opt`;
109 } else {
110 pb_log(1,"WARNING: $cmd not found\n");
111 }
112 }
113}
114#
115# LVM setup
116#
117($mr_os->{'lvmver'},$mr_os->{'lvmcmd'}) = mr_lvm_check();
118
119# Summary of conf printed.
120pb_log(1,"OS Inventory: ".Dumper($mr_os)."\n");
121}
122
123=item B<mr_inv_fw>
124
125This function reports Firmware inventory of the system to archive
126
127=cut
128
129sub mr_inv_fw {
130
131 # Linked to bkphw
132 # On Proliant use hpacucli, conrep, hponcfg
133}
134
135=item B<mr_inv_sw>
136
137This function reports Software inventory of the system to archive
138
139=cut
140
141sub mr_inv_sw {
142
143 # Commands presence - use FindBin
144 # deplist
145 # mountlist
146}
Note: See TracBrowser for help on using the repository browser.