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

Last change on this file since 3110 was 3110, checked in by Bruno Cornec, 11 years ago
  • Store a status for devel ersion of mondo
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 uname);
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->{'pbos'} = pb_distro_init();
79
80pb_log(2,"OS Inventory: pbos ".Dumper($mr_os)."\n");
81
82# Get some running kernel info
83($mr_os->{'uname'}->{'sysname'}, $mr_os->{'uname'}->{'nodename'}, $mr_os->{'uname'}->{'release'}, $mr_os->{'uname'}->{'version'}, $mr_os->{'uname'}->{'machine'}) = uname();
84
85pb_log(2,"OS Inventory: uname ".Dumper($mr_os)."\n");
86
87# Get some conf file content when they exist; Depends on genre or more precise tuple
88for 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") {
89 my $key = $p;
90 $key =~ s/mr_//;
91 my ($pp) = pb_conf_get_if($p);
92 if (defined $pp) {
93 my $file = pb_distro_get_param($mr_os->{'pbos'},$pp);
94 if (-r $file) {
95 pb_log(2,"DEBUG: File found: $file\n");
96 $mr_os->{'files'}->{$key} = pb_get_content($file);
97 } else {
98 pb_log(1,"WARNING: $file not found\n");
99 }
100 }
101}
102
103pb_log(2,"OS Inventory: files ".Dumper($mr_os)."\n");
104
105return;
106# Get some commands result content when they exist; Depends on genre or more precise tuple
107for my $p ("mr_cmd_mount","mr_cmd_df","mr_cmd_dmidecode","mr_cmd_lshw") {
108 my $key = $p;
109 $key =~ s/mr_cmd_//;
110 my ($pp) = pb_conf_get_if($p);
111 my ($po) = pb_conf_get_if("mr_opt_".$key);
112 if (defined $pp) {
113 my $cmd = pb_distro_get_param($mr_os->{'pbos'},$pp);
114 my $opt = "";
115 $opt = pb_distro_get_param($mr_os->{'pbos'},$po) if (defined ($po));
116 if (-x $cmd) {
117 pb_log(2,"DEBUG: Cmd found: $cmd $opt\n");
118 $mr_os->{'cmd'}->{$key} = `$cmd $opt`;
119 } else {
120 pb_log(1,"WARNING: $cmd not found\n");
121 }
122 }
123}
124
125pb_log(2,"OS Inventory: cmds ".Dumper($mr_os)."\n");
126#
127# LVM setup
128#
129($mr_os->{'lvmver'},$mr_os->{'lvmcmd'}) = mr_lvm_check();
130
131# Summary of conf printed.
132pb_log(1,"OS Inventory: ".Dumper($mr_os)."\n");
133}
134
135=item B<mr_inv_fw>
136
137This function reports Firmware inventory of the system to archive
138
139=cut
140
141sub mr_inv_fw {
142
143 # Linked to bkphw
144 # On Proliant use hpacucli, conrep, hponcfg
145}
146
147=item B<mr_inv_sw>
148
149This function reports Software inventory of the system to archive
150
151=cut
152
153sub mr_inv_sw {
154
155 # Commands presence - use FindBin
156 # deplist
157 # mountlist
158}
Note: See TracBrowser for help on using the repository browser.