Merge lp:~pakdel-gmail/ocsinventory-unix-agent/hpux into lp:ocsinventory-unix-agent

Proposed by Amir Pakdel
Status: Needs review
Proposed branch: lp:~pakdel-gmail/ocsinventory-unix-agent/hpux
Merge into: lp:ocsinventory-unix-agent
Diff against target: 1163 lines (+467/-409)
19 files modified
lib/Ocsinventory/Agent/Backend.pm (+1/-1)
lib/Ocsinventory/Agent/Backend/OS/Generic/Processes.pm (+2/-2)
lib/Ocsinventory/Agent/Backend/OS/HPUX.pm (+30/-11)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Bios.pm (+29/-38)
lib/Ocsinventory/Agent/Backend/OS/HPUX/CPU.pm (+55/-76)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Controller.pm (+1/-1)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Drives.pm (+44/-48)
lib/Ocsinventory/Agent/Backend/OS/HPUX/IPv4.pm (+0/-28)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Mem.pm (+0/-28)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Memory.pm (+77/-79)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Networks.pm (+122/-87)
lib/Ocsinventory/Agent/Backend/OS/HPUX/README (+2/-3)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Slots.pm (+2/-2)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Software.pm (+2/-2)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Storages.pm (+1/-1)
lib/Ocsinventory/Agent/Backend/OS/HPUX/Uptime.pm (+29/-0)
lib/Ocsinventory/Agent/Backend/OS/Linux/Network/iLO.pm (+66/-0)
lib/Ocsinventory/Agent/Backend/OS/Linux/Storages.pm (+2/-2)
lib/Ocsinventory/Agent/XML/Inventory.pm (+2/-0)
To merge this branch: bzr merge lp:~pakdel-gmail/ocsinventory-unix-agent/hpux
Reviewer Review Type Date Requested Status
OCS Inventory Dev Team Pending
Review via email: mp+25581@code.launchpad.net

Description of the change

Swapped "Type" and "File System" in HP-UX/Drives

To post a comment you must log in.
Revision history for this message
Amir Pakdel (pakdel-gmail) wrote :

Any testing yet?

Revision history for this message
mortheres (mortheres) wrote :

Hi Amir,

Yes we are currently testing and specially the 'uname' command that does not works as expected.
Dwizz (ake François) has made some tests and he got unwanted outputs from the uname command on HPUX version
11.0, 11.11 and 11.23. This is the kind of outputs he got :

uname -v -> result is : U
uname -r -> result is : B.11.00

> Any testing yet?

Revision history for this message
dwizz (dwizz-donowin) wrote :

I have find the same information in the hp documentation

(in french)

for the version, they use the uname -r (extract of the documentation. I done the traduction after)

http://docs.hp.com/fr/5187-0193/ch02s04.html
Pour identifier la version du système d’exploitation installée sur votre système, entrez :
uname -r
Après avoir procédé à l’installation standard de HP-UX 11i v1.6, vous remarquerez que la commande uname identifie la version 11i sous le numéro B.11.22.

traduction:
For identification of the operating system installed on your system, press:
uname -r
After you have done standard installation of Hp-Ux 11i v1.6, you can see that the command uname indentify the version
11i under the number B.11.22

So i think the man is wrong and it's beter to put the uname -r for version in the HPUX.pm

967. By Amir Pakdel <amir@WS1524O-PAK-Linux>

iLO is Integrated Lights-Out which is Management Interface of HP ProLiant servers

Revision history for this message
mortheres (mortheres) wrote :

Hi,

Is this problem solved now ? Can I merge Amir modifications into the trunk branch ?

Kind regards,

--
Guillaume

Revision history for this message
Amir Pakdel (pakdel-gmail) wrote :

Hi,

I have changed the code to use uname -r and committed.

Best regards,

Amir

On Thu, Jun 24, 2010 at 1:18 AM, mortheres
<email address hidden>wrote:

> Hi,
>
> Is this problem solved now ? Can I merge Amir modifications into the trunk
> branch ?
>
> Kind regards,
>
> --
> Guillaume
> --
>
> https://code.launchpad.net/~pakdel-gmail/ocsinventory-unix-agent/hpux/+merge/25581<https://code.launchpad.net/%7Epakdel-gmail/ocsinventory-unix-agent/hpux/+merge/25581>
> You are the owner of lp:~pakdel-gmail/ocsinventory-unix-agent/hpux.
>

Revision history for this message
Amir Pakdel (pakdel-gmail) wrote :

LinkedIn
------------

I'd like to add you to my professional network on LinkedIn.

- Amir

Amir Pakdel
System Administrator at Karafarin Bank
Iran

Confirm that you know Amir Pakdel
https://www.linkedin.com/e/sk0pgr-gbpacn0b-15/isd/1473385750/InNVNUwB/

------
(c) 2010, LinkedIn Corporation

Unmerged revisions

967. By Amir Pakdel <amir@WS1524O-PAK-Linux>

iLO is Integrated Lights-Out which is Management Interface of HP ProLiant servers

966. By Amir Pakdel <amir@WS1524O-PAK-Linux>

Swapped "Type" and "File System" (continued)

965. By Amir Pakdel <amir@WS1524O-PAK-Linux>

Swapped "Type" and "File System"
$type needed a chomp

964. By Amir Pakdel <amir@WS1524O-PAK-Linux>

Merely minor changes

963. By Amir Pakdel <amir@WS1524O-PAK-Linux>

Checks to be able to run model
Gets UUID

962. By Amir Pakdel <amir@WS1524O-PAK-Linux>

can_run now understands "no $binary in /usr/sbin...." which may be returned in HP-UX

961. By Amir Pakdel <amir@WS1524O-PAK-Linux>

lib/Ocsinventory/Agent/Backend/OS/HPUX/Networks.pm
To get the network status (up/down) it checks both lanadmin and ifconfig.

960. By Amir Pakdel <amir@WS1524O-PAK-Linux>

lib/Ocsinventory/Agent/Backend/OS/HPUX/Uptime.pm
Performs exactly as in Linux version

959. By Amir Pakdel <amir@WS1524O-PAK-Linux>

lib/Ocsinventory/Agent/Backend/OS/HPUX* related changes:

IPV4.pm
Moved its functionality to Networks.pm so that I could get network related
information in one place (since all are TCP/IP related data)
********************************************************************************
Mem.pm
/var/adm/syslog/syslog.log might be rotated
Total physical memory and swap are measured in Memory.pm
********************************************************************************
HPUX.pm
According to "man uname":
-r: Display the current release level of the operating system.
-v: Display the current version level of the operating system.
********************************************************************************
CPU.pm
According to Inventory.pm / setHardware()
The use of setHardware() to update USERID and PROCESSOR* informations is
deprecated, please, use addUser() and addCPU() instead.

If the last line of macinfo related to CPU in HPUX versions other than B11.23 is like "Cache info:", Please uncomment the "last" for speedup
********************************************************************************
Memory.pm
#please rename addMemories to addMemory()

echo 'sc product mem;il'| /usr/sbin/cstm
cstm>sc product mem;il
                ^-- Unknown list entry. --
The list entry (mem) is undefined.

                    ^-- (InfoLog) is currently disabled. --
********************************************************************************
Networks.pm
Renamed to Networks-Perl.pm so I can add Netwoks-lanadmin.pm to be run in case it failed
It does not need "Net::IP qw(:PROC)" anymore:
 none of my servers have that and the only subroutine used is ip_iptobin

Network interface speed and gateway are implemented
********************************************************************************
End of lib/Ocsinventory/Agent/Backend/OS/HPUX* related changes
********************************************************************************

Ocsinventory::Agent::Backend::OS::Linux::Storages
Added floppy detection
********************************************************************************
package Ocsinventory::Agent::XML::Inventory;
Added SPEED to addNetwork
********************************************************************************

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Ocsinventory/Agent/Backend.pm'
2--- lib/Ocsinventory/Agent/Backend.pm 2009-12-07 15:34:33 +0000
3+++ lib/Ocsinventory/Agent/Backend.pm 2010-05-27 07:07:27 +0000
4@@ -27,7 +27,7 @@
5
6 my $calling_namespace = caller(0);
7 chomp(my $binpath=`which $binary 2>/dev/null`);
8- return unless -x $binpath;
9+ return unless $binpath !~ /no $binary in/ or -x $binpath;
10 $self->{logger}->debug(" - $binary found");
11 1
12 },
13
14=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Generic/Processes.pm'
15--- lib/Ocsinventory/Agent/Backend/OS/Generic/Processes.pm 2010-05-05 19:31:57 +0000
16+++ lib/Ocsinventory/Agent/Backend/OS/Generic/Processes.pm 2010-05-27 07:07:27 +0000
17@@ -30,9 +30,9 @@
18 $os=`uname -s`;
19
20 if ($os eq "SunOS") {
21- open(PS, "ps -A -o user,pid,pcpu,pmem,vsz,rss,tty,s,stime,time,comm|");
22+ open(PS, "ps -A -o user,pid,pcpu,pmem,vsz,rss,tty,s,stime,time,comm 2>/dev/null |");
23 } else {
24- open(PS, "ps aux|");
25+ open(PS, "ps aux 2>/dev/null |");
26 }
27
28 while ($line = <PS>) {
29
30=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX.pm'
31--- lib/Ocsinventory/Agent/Backend/OS/HPUX.pm 2010-01-22 14:39:51 +0000
32+++ lib/Ocsinventory/Agent/Backend/OS/HPUX.pm 2010-05-27 07:07:27 +0000
33@@ -4,27 +4,46 @@
34 use vars qw($runAfter);
35 $runAfter = ["Ocsinventory::Agent::Backend::OS::Generic"];
36
37-sub check { $^O =~ /hpux/ }
38+sub check { $^O =~ /^hpux$/ }
39
40 sub run {
41 my $params = shift;
42 my $inventory = $params->{inventory};
43 my $OSName;
44 my $OSVersion;
45- my $OSComment;
46+ my $OSRelease;
47+ my $OSLicense;
48 #my $uname_path = &_get_path('uname');
49
50- # Operating systeminformations
51-
52- chomp($OSName = `uname -s`);
53- chomp($OSVersion = `uname -r`);
54- chomp($OSComment = `uname -l`);
55+ # Operating system informations
56+ chomp($OSName = `uname -s`); #It should allways be "HP-UX"
57+ chomp($OSVersion = `uname -v`);
58+ chomp($OSRelease = `uname -r`);
59+ chomp($OSLicense = `uname -l`);
60+
61+ # Last login informations
62+ my $LastLoggedUser;
63+ my $LastLogDate;
64+ my @query = runcmd("last");
65+
66+ while ( my $tempLine = shift @query) {
67+ #if ( /^reboot\s+system boot/ ) { continue } #It should never be seen above a user login entry (I hope)
68+ if ( $tempLine =~ /^(\S+)\s+\S+\s+(.+\d{2}:\d{2})\s+/ ) {
69+ $LastLoggedUser = $1;
70+ $LastLogDate = $2;
71+ last;
72+ }
73+ }
74+
75+#TODO add grep `hostname` /etc/hosts
76
77 $inventory->setHardware({
78- OSNAME => $OSName,
79- OSCOMMENTS => $OSComment,
80- OSVERSION => $OSVersion,
81- });
82+ OSNAME => $OSName,
83+ OSVERSION => $OSVersion . ' ' . $OSLicense,
84+ OSCOMMENTS => $OSRelease,
85+ LASTLOGGEDUSER => $LastLoggedUser,
86+ DATELASTLOGGEDUSER => $LastLogDate
87+ });
88
89 }
90
91
92=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Bios.pm'
93--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Bios.pm 2010-02-25 18:36:52 +0000
94+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Bios.pm 2010-05-27 07:07:27 +0000
95@@ -9,7 +9,7 @@
96 #
97 ###
98
99-sub check { $^O =~ /hpux/ }
100+sub check { can_run ("model") }
101
102 sub run {
103 my $params = shift;
104@@ -19,49 +19,40 @@
105 my $BiosDate;
106 my $SystemModel;
107 my $SystemSerial;
108+ my $SystemUUID;
109
110
111 $SystemModel=`model`;
112- if ( can_run ("machinfo") )
113- {
114- foreach ( `machinfo` )
115- {
116- if ( /Firmware\s+revision\s+[:=]\s+(\S+)/ )
117- {
118- $BiosVersion=$1;
119- }
120- elsif ( /achine\s+serial\s+number\s+[:=]\s+(\S+)/ )
121- {
122- $SystemSerial=$1;
123- }
124- }
125- }
126- else
127- {
128- for ( `echo 'sc product cpu;il' | /usr/sbin/cstm | grep "PDC Firmware"` )
129- {
130- if ( /Revision:\s+(\S+)/ )
131- {
132- $BiosVersion="PDC $1";
133- }
134- }
135- for ( `echo 'sc product system;il' | /usr/sbin/cstm | grep "System Serial Number"` )
136- {
137- if ( /:\s+(\w+)/ )
138- {
139- $SystemSerial=$1;
140- }
141- }
142+ if ( can_run ("/usr/contrib/bin/machinfo") ) {
143+ foreach ( `/usr/contrib/bin/machinfo` ) {
144+ if ( /Firmware\s+revision\s+[:=]\s+(\S+)/ ) {
145+ $BiosVersion = $1;
146+ } elsif ( /achine\s+serial\s+number\s+[:=]\s+(\S+)/ ) {
147+ $SystemSerial = $1;
148+ } elsif (/achine\s+id\s+number\s+=\s+(\S+)/) {
149+ $SystemUUID = uc $1;
150+ }
151+ }
152+ } else { #Could not run machinfo
153+ for ( `echo 'sc product cpu;il' | /usr/sbin/cstm | grep "PDC Firmware"` ) {
154+ if ( /Revision:\s+(\S+)/ ) { $BiosVersion = "PDC $1" }
155+ }
156+ for ( `echo 'sc product system;il' | /usr/sbin/cstm | grep "System Serial Number"` ) {
157+ if ( /:\s+(\w+)/ ) { $SystemSerial = $1 }
158+ }
159 }
160
161 $inventory->setBios ({
162- BVERSION => $BiosVersion,
163- BDATE => $BiosDate,
164- BMANUFACTURER => "HP",
165- SMANUFACTURER => "HP",
166- SMODEL => $SystemModel,
167- SSN => $SystemSerial,
168- });
169+ BVERSION => $BiosVersion,
170+ BDATE => $BiosDate,
171+ BMANUFACTURER => "HP",
172+ SMANUFACTURER => "HP",
173+ SMODEL => $SystemModel,
174+ SSN => $SystemSerial,
175+ });
176+ $inventory->setHardware({
177+ UUID => $SystemUUID
178+ });
179 }
180
181 1;
182
183=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/CPU.pm'
184--- lib/Ocsinventory/Agent/Backend/OS/HPUX/CPU.pm 2010-02-25 18:36:52 +0000
185+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/CPU.pm 2010-05-27 07:07:27 +0000
186@@ -11,18 +11,14 @@
187 use strict;
188 use LWP::UserAgent;
189
190-sub check { $^O =~ /hpux/ }
191+sub check { $^O =~ /^hpux$/ }
192
193 sub run {
194 my $params = shift;
195 my $inventory = $params->{inventory};
196
197- my $processort;
198- my $processorn;
199- my $processors="";
200- my $DeviceType;
201- my $cpuInfo;
202- my $serie;
203+ my $CPUinfo = { MANUFACTURER => 'unknow', TYPE => 'unknow', SERIAL => 'No Serial Number available!', SPEED => 0 };
204+ my $CPUcount;
205
206 # Using old system HpUX without machinfo
207 # the Hpux whith machinfo will be done after
208@@ -58,79 +54,62 @@
209 "N4000-44"=>"8500 440",
210 "ia64 hp server rx1620"=>"itanium 1600");
211
212- if ( can_run ("machinfo") )
213- {
214- foreach ( `machinfo`)
215- {
216- if ( /Number of CPUs\s+=\s+(\d+)/ )
217- {
218- $processorn=$1;
219- }
220- if ( /Clock speed\s+=\s+(\d+)\s+MHz/ )
221- {
222- $processors=$1;
223- }
224- # Added for HPUX 11.31
225- if ( /Intel\(R\) Itanium 2 9000 series processor \((\d+\.\d+)/ )
226- {
227- $processors=$1*1000;
228- }
229- if ( /(\d+)\s+logical processors/ )
230- {
231- $processorn=$1;
232- }
233- # end HPUX 11.31
234-
235- }
236- }
237- else
238- {
239- chomp($DeviceType =`model |cut -f 3- -d/`);
240- my $cpuInfo = $cpuInfos{"$DeviceType"};
241- if ( "$cpuInfo" =~ /^(\S+)\s(\S+)/ )
242- {
243- $processort=$1;
244- $processors=$2;
245- }
246- else
247- {
248- for ( `echo 'sc product cpu;il' | /usr/sbin/cstm | grep "CPU Module"` )
249- {
250- if ( /(\S+)\s+CPU\s+Module/ )
251- {
252- $processort=$1;
253- }
254- };
255- for ( `echo 'itick_per_usec/D' | adb -k /stand/vmunix /dev/kmem` )
256- {
257- if ( /tick_per_usec:\s+(\d+)/ )
258- {
259- $processors=$1;
260- }
261- }
262- };
263+ if ( can_run ("/usr/contrib/bin/machinfo") ) {
264+ my @machinfo = `/usr/contrib/bin/machinfo`;
265+ s/\s+/ /g for (@machinfo);
266+ foreach (@machinfo) {
267+ if (/Number of CPUs = (\d+)/) {
268+ $CPUcount = $1;
269+ } elsif (/processor model: \d+ (.+)$/) {
270+ $CPUinfo->{TYPE} = $1;
271+ } elsif (/Clock speed = (\d+) MHz/) {
272+ $CPUinfo->{SPEED} = $1;
273+ } elsif (/vendor information =\W+(\w+)/) {
274+ $CPUinfo->{MANUFACTURER} = $1;
275+ } elsif (/Cache info:/) {
276+ # last; #Not tested on versions other that B11.23
277+ }
278+ # Added for HPUX 11.31
279+ if ( /Intel\(R\) Itanium 2 9000 series processor \((\d+\.\d+)/ ) {
280+ $CPUinfo->{SPEED} = $1*1000;
281+ }
282+ if ( /(\d+) logical processors/ ) {
283+ $CPUcount = $1;
284+ }
285+ # end HPUX 11.31
286+ }
287+ } else {
288+ chomp(my $DeviceType =`model |cut -f 3- -d/`);
289+ my $tempCpuInfo = $cpuInfos{"$DeviceType"};
290+ if ( $tempCpuInfo =~ /^(\S+)\s(\S+)/ ) {
291+ $CPUinfo->{TYPE} = $1;
292+ $CPUinfo->{SPEED} = $2;
293+ } else {
294+ for ( `echo 'sc product cpu;il' | /usr/sbin/cstm | grep "CPU Module"` ) {
295+ if ( /(\S+)\s+CPU\s+Module/ ) {
296+ $CPUinfo->{TYPE} = $1;
297+ }
298+ }
299+ for ( `echo 'itick_per_usec/D' | adb -k /stand/vmunix /dev/kmem` ) {
300+ if ( /tick_per_usec:\s+(\d+)/ ) {
301+ $CPUinfo->{SPEED} = $1;
302+ }
303+ }
304+ }
305 # NBR CPU
306- chomp($processorn=`ioscan -Fk -C processor | wc -l`);
307- #print "HP $processort A $processorn A $processors ";
308+ chomp($CPUcount=`ioscan -Fk -C processor | wc -l`);
309 }
310
311+ my $serie;
312 chomp($serie = `uname -m`);
313- if ( $serie =~ /ia64/)
314- {
315- $processort="Itanium"
316- }
317- if ( $serie =~ /9000/)
318- {
319- $processort="PA$processort";
320- }
321- $inventory->setHardware({
322-
323- PROCESSORT => $processort,
324- PROCESSORN => $processorn,
325- PROCESSORS => $processors,
326- });
327-
328-
329+ if ( $CPUinfo->{TYPE} eq 'unknow' and $serie =~ /ia64/) {
330+ $CPUinfo->{TYPE} = "Itanium"
331+ }
332+ if ( $serie =~ /9000/) {
333+ $CPUinfo->{TYPE} = "PA" . $CPUinfo->{TYPE};
334+ }
335+
336+ foreach ( 1..$CPUcount ) { $inventory->addCPU($CPUinfo) }
337 }
338
339 1;
340
341=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Controller.pm'
342--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Controller.pm 2010-01-22 14:39:51 +0000
343+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Controller.pm 2010-05-27 07:07:27 +0000
344@@ -1,7 +1,7 @@
345 package Ocsinventory::Agent::Backend::OS::HPUX::Controller;
346 use strict;
347
348-sub check { $^O =~ /hpux/ }
349+sub check { can_run('ioscan') }
350
351 sub run {
352 my $params = shift;
353
354=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Drives.pm'
355--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Drives.pm 2010-01-22 14:39:51 +0000
356+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Drives.pm 2010-05-27 07:07:27 +0000
357@@ -1,55 +1,51 @@
358 package Ocsinventory::Agent::Backend::OS::HPUX::Drives;
359
360-sub check { $^O =~ /hpux/ }
361+sub check { can_run('fstyp') and can_run('grep') and can_run('bdf') }
362
363 sub run {
364- my $params = shift;
365- my $inventory = $params->{inventory};
366-
367- my $type;
368- my $fs;
369- my $lv;
370- my $total;
371- my $free;
372-
373-
374- for ( `fstyp -l | grep -v nfs` ) {
375- $type=$_;
376- for ( `bdf -t $type `) {
377- if ( /Filesystem/ ) { ; } ;
378- if ( /^(\S+)\s(\d+)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(\S+)/ ) {
379- $lv=$1;
380- $total=$2;
381- $free=$3;
382- $fs=$6;
383- $inventory->addDrives({
384- FREE => $free,
385- FILESYSTEM => $fs,
386- TOTAL => $total,
387- TYPE => $type,
388- VOLUMN => $lv,
389- });
390-
391- };
392- if ( /^(\S+)\s/) {
393- $lv=$1;
394- };
395- if ( /(\d+)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(\S+)/) {
396- $total=$1;
397- $free=$3;
398- $fs=$5;
399- # print "fs $fs lv $lv total $total free $free type $type\n";
400- $inventory->addDrives({
401- FREE => $free,
402- FILESYSTEM => $fs,
403- TOTAL => $total,
404- TYPE => $type,
405- VOLUMN => $lv,
406- });
407- };
408- };
409-
410- };
411+ my $params = shift;
412+ my $inventory = $params->{inventory};
413+
414+ my $type;
415+ my $fs;
416+ my $lv;
417+ my $total;
418+ my $free;
419+
420+ for ( `fstyp -l | grep -v nfs` ) {
421+ chomp;
422+ $type=$_;
423+ for ( `bdf -t $type `) {
424+ next if ( /Filesystem/ );
425+ if ( /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(\S+)/ ) {
426+ $lv=$1;
427+ $total=$2;
428+ $free=$3;
429+ $fs=$6;
430+ $inventory->addDrive({
431+ FREE => $free,
432+ FILESYSTEM => $type,
433+ TOTAL => $total,
434+ TYPE => $fs,
435+ VOLUMN => $lv,
436+ })
437+ } elsif ( /^(\S+)\s/) {
438+ $lv=$1
439+ } elsif ( /(\d+)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(\S+)/) {
440+ $total=$1;
441+ $free=$3;
442+ $fs=$5;
443+ # print "fs $fs lv $lv total $total free $free type $type\n";
444+ $inventory->addDrive({
445+ FREE => $free,
446+ FILESYSTEM => $type,
447+ TOTAL => $total,
448+ TYPE => $fs,
449+ VOLUMN => $lv,
450+ })
451+ }
452+ } # for bdf -t $type
453+ }
454 }
455
456 1;
457
458=== removed file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/IPv4.pm'
459--- lib/Ocsinventory/Agent/Backend/OS/HPUX/IPv4.pm 2010-02-25 18:36:52 +0000
460+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/IPv4.pm 1970-01-01 00:00:00 +0000
461@@ -1,28 +0,0 @@
462-package Ocsinventory::Agent::Backend::OS::HPUX::IPv4;
463-
464-sub check {`which ifconfig 2>&1`; ($? >> 8)?0:1
465-}
466-
467-# Initialise the distro entry
468-sub run {
469- my $params = shift;
470- my $inventory = $params->{inventory};
471- my $ip;
472- my $hostname;
473-
474- if ( `hostname` =~ /(\S+)/ )
475- {
476- $hostname=$1;
477- }
478-
479- for ( `grep $hostname /etc/hosts ` )
480- {
481- if ( /(^\d+\.\d+\.\d+\.\d+)\s+/ )
482- {
483- $ip=$1;
484- $inventory->setHardware({IPADDR => $ip});
485- }
486- }
487-}
488-
489-1;
490
491=== removed file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Mem.pm'
492--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Mem.pm 2010-01-22 14:39:51 +0000
493+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Mem.pm 1970-01-01 00:00:00 +0000
494@@ -1,28 +0,0 @@
495-package Ocsinventory::Agent::Backend::OS::HPUX::Mem;
496-use strict;
497-
498-sub check { $^O =~ /hpux/ }
499-
500-sub run {
501- my $params = shift;
502- my $inventory = $params->{inventory};
503-
504- my $mem;
505- my $swap;
506-
507- $mem = `grep Physical /var/adm/syslog/syslog.log|tr -s " "|cut -f 7 -d " "` ;
508- if ( $mem eq "" ) {
509- $mem = `grep Physical /var/adm/syslog/OLDsyslog.log|tr -s " "|cut -f 7 -d " "` ;
510- };
511- $mem = int ($mem/1024);
512-
513- $swap = `swapinfo -mdfq`;
514-
515-
516- $inventory->setHardware({
517- MEMORY => $mem,
518- SWAP => $swap,
519- });
520-}
521-
522-1;
523
524=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Memory.pm'
525--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Memory.pm 2010-02-25 18:36:52 +0000
526+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Memory.pm 2010-05-27 07:07:27 +0000
527@@ -1,4 +1,5 @@
528 package Ocsinventory::Agent::Backend::OS::HPUX::Memory;
529+
530 use strict;
531
532 sub check { $^O =~ /hpux/ }
533@@ -7,45 +8,48 @@
534 my $params = shift;
535 my $inventory = $params->{inventory};
536
537- my $capacity=0;
538- my $caption;
539- my $description;
540- my $numslot;
541- my $subnumslot;
542- my $serialnumber;
543- my $type;
544- my @list_mem=`echo 'sc product mem;il'| /usr/sbin/cstm`;
545-
546- my $ok=0;
547-
548- if ( `uname -m` =~ /ia64/ )
549- {
550- for ( `echo 'sc product IPF_MEMORY;il' | /usr/sbin/cstm` )
551- {
552- if ( /\w+IMM\s+Location/ )
553- {
554- ;
555- }
556- elsif ( /(\w+IMM)\s+(\w+)\s+(\S+)\s+(\w+IMM)\s+(\w+)\s+(\S+)/ )
557- {
558- $inventory->addMemories({
559- CAPACITY => $3,
560- CAPTION => $2 ,
561- NUMSLOTS => "1" ,
562- TYPE => $1,
563- });
564- $inventory->addMemories({
565- CAPACITY => $6,
566- CAPTION => $5 ,
567- NUMSLOTS => "1" ,
568- TYPE => $4,
569- });
570- }
571+ if ( `uname -m` =~ /ia64/ ) {
572+ for ( `echo 'sc product IPF_MEMORY;il' | /usr/sbin/cstm` ) {
573+ if ( /\w+IMM\s+Location/ ) {
574+ next
575+ } elsif (/Total Configured Memory:\s(\d+)\sMB/i) {
576+ my $TotalMemSize = $1;
577+ my $TotalSwapSize = `swapinfo -dt | tail -n1`;
578+ $TotalSwapSize =~ s/^total\s+(\d+)\s+\d+\s+\d+\s+\d+%\s+\-\s+\d+\s+\-/$1/i;
579+ $inventory->setHardware({ MEMORY => $TotalMemSize, SWAP => sprintf("%i", $TotalSwapSize/1024), });
580+ } elsif ( /(\w+IMM)\s+(\w+)\s+(\d+|\-+)\s+(\w+IMM)\s+(\w+)\s+(\d+|\-+)/ ) {
581+ $inventory->addMemory({
582+ CAPACITY => $3,
583+ DESCRIPTION => $1,
584+ CAPTION => $1 . ' ' . $2,
585+ SPEED => 'No Speed data vailable!',
586+ TYPE => $1,
587+ NUMSLOTS => $2,
588+ SERIALNUMBER => 'No Serial Number available!',
589+ });
590+ $inventory->addMemory({
591+ CAPACITY => $6,
592+ DESCRIPTION => $4,
593+ CAPTION => $4 . ' ' . $5,
594+ SPEED => 'No Speed data vailable!',
595+ TYPE => $4,
596+ NUMSLOTS => $5,
597+ SERIALNUMBER => 'No Serial Number available!',
598+ });
599 }
600- }
601- else
602- {
603- for ( `echo 'sc product system;il' | /usr/sbin/cstm ` ) {
604+ }
605+ } else {
606+ my $capacity = 0;
607+ my $caption;
608+ my $description;
609+ my $numslot = 1;
610+ my $subnumslot;
611+ my $serialnumber = 'No Serial Number available!';
612+ my $type;
613+ my @list_mem=`echo 'sc product mem;il'| /usr/sbin/cstm`;
614+ my $ok=0;
615+
616+ for ( `echo 'sc product system;il' | /usr/sbin/cstm` ) {
617 if ( /FRU\sSource\s+=\s+\S+\s+\(memory/ ) {
618 $ok=0;
619 #print "FRU Source memory\n";
620@@ -57,59 +61,53 @@
621 if ( /Extender\s+Location\s+=\s+(\S+)/ ) {
622 $subnumslot=$1;
623 #print "Extended sub $subnumslot\n";
624- };
625+ }
626 if ( /DIMMS\s+Rank\s+=\s+(\S+)/ ) {
627 $numslot=sprintf("%02x",$1);
628 #print "Num slot $numslot\n";
629 }
630
631 if ( /FRU\s+Name\.*:\s+(\S+)/ ) {
632- if ( /(\S+)_(\S+)/ ) {
633- $type=$1;
634- $capacity=$2;
635- #print "Type $type capa $capacity\n";
636- }
637- elsif ( /(\wIMM)(\S+)/ )
638- {
639- $ok=1;
640- $type=$1;
641- $numslot=$2;
642- #print "Type $type numslot $numslot\n";
643- }
644+ if ( /(\S+)_(\S+)/ ) {
645+ $type=$1;
646+ $capacity=$2;
647+ #print "Type $type capa $capacity\n";
648+ } elsif ( /(\wIMM)(\S+)/ ) {
649+ $ok=1;
650+ $type=$1;
651+ $numslot=$2;
652+ #print "Type $type numslot $numslot\n";
653+ }
654 }
655 if ( /Part\s+Number\.*:\s*(\S+)\s+/ ) {
656 $description=$1;
657 #print "ref $description\n";
658- };
659+ }
660 if ( /Serial\s+Number\.*:\s*(\S+)\s+/ ) {
661- $serialnumber=$1;
662- if ( $ok eq 1 )
663- {
664- if ( $capacity eq 0 )
665- {
666- foreach ( @list_mem )
667- {
668- if ( /\s+$numslot\s+(\d+)/ )
669- {
670- $capacity=$1;
671- #print "Capacity $capacity\n";
672- }
673- }
674+ $serialnumber=$1;
675+ if ( $ok eq 1 ) {
676+ if ( $capacity eq 0 ) {
677+ foreach ( @list_mem ) {
678+ if ( /\s+$numslot\s+(\d+)/ ) {
679+ $capacity=$1;
680+ #print "Capacity $capacity\n";
681+ }
682 }
683- $inventory->addMemories({
684- CAPACITY => $capacity,
685- CAPTION => "Ext $subnumslot Slot $numslot" ,
686- DESCRIPTION => "Part Number $description",
687- NUMSLOTS => "1" ,
688- SERIALNUMBER => $serialnumber,
689- TYPE => $type,
690- });
691- $ok=0;
692- $capacity=0;
693- };
694- #print "Serial $serialnumber\n\n";
695- };
696- };
697+ }
698+ $inventory->addMemory({
699+ CAPACITY => $capacity,
700+ DESCRIPTION => "Part Number $description",
701+ CAPTION => "Ext $subnumslot Slot $numslot",
702+ SPEED => 'No Speed data vailable!',
703+ TYPE => $type,
704+ NUMSLOTS => '1',
705+ SERIALNUMBER => $serialnumber,
706+ });
707+ $ok=0;
708+ $capacity=0;
709+ } # $ok eq 1
710+ } # /Serial\s+Number\.*:\s*(\S+)\s+/
711+ } # echo 'sc product system;il' | /usr/sbin/cstm
712 }
713
714 }
715
716=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Networks.pm'
717--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Networks.pm 2010-02-25 18:36:52 +0000
718+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Networks.pm 2010-05-27 07:07:27 +0000
719@@ -1,93 +1,128 @@
720 package Ocsinventory::Agent::Backend::OS::HPUX::Networks;
721
722-sub check { can_load("Net::IP qw(:PROC)"); }
723+#$runMeIfTheseChecksFailed = ["Ocsinventory::Agent::Backend::OS::HPUX::Networks-Perl"];
724+
725+#"Net::IP qw(:PROC)" is not needed anymore
726+#TODO Get driver pcislot virtualdev
727+
728+sub check { can_run("lanadmin") and can_run("lanscan") and can_run("netstat")
729+ and can_run("ifconfig") and can_run("hostname") and can_run("uname") }
730
731 sub run {
732- my $params = shift;
733- my $inventory = $params->{inventory};
734-
735- my $name;
736- my $lanid;
737-
738- my $ipmask;
739- my $ipgateway;
740- my $status;
741- my $macaddr;
742- my $speed;
743- my $type;
744- my $ipsubnet;
745- my $description;
746- my $ipaddress;
747-
748- my $binip;
749- my $binmask;
750- my $binsubnet;
751-
752- for ( `lanscan -iap`) {
753- # Reinit variable
754- $name="";
755- $lanid="";
756- $ipmask="";
757- $ipgateway="";
758- $status="";
759- $macaddr="";
760- $speed="";
761- $type="";
762- $ipsubnet="";
763- $description="";
764- $ipaddress="";
765-
766- if ( /^(\S+)\s(\S+)\s(\S+)\s+(\S+)/) {
767- $name=$2;
768- $macaddr=$1;
769- $lanid=$4;
770-
771- #print "name $name macaddr $macaddr lanid $lanid\n";
772- for ( `lanadmin -g $lanid` ) {
773- if (/Type.+=\s(.+)/) { $type = $1; };
774- if (/Description\s+=\s(.+)/) { $description = $1; };
775- if (/Speed.+=\s(\d+)/) {
776- $speed = $1;
777-
778- unless ( $speed <= 1000000 ) { # in old version speed was given in Mbps
779- # we want speed in Mbps
780- $speed = $1/1000000;
781- }
782- };
783- if (/Operation Status.+=\s(.+)/) { $status = $1; };
784-
785- }; # for lanadmin
786- #print "name $name macaddr $macaddr lanid $lanid speed $speed status $status \n";
787- for ( `ifconfig $name 2> /dev/null` ) {
788- if ( /inet\s(\S+)\snetmask\s(\S+)\s/ ) {
789- $ipaddress=$1;
790- $ipmask=$2;
791- if ($ipmask =~ /(..)(..)(..)(..)/) {
792- $ipmask=sprintf ("%i.%i.%i.%i",hex($1),hex($2),hex($3),hex($4));
793- }
794-
795- };
796- }; # For ifconfig
797- $binip = ip_iptobin ($ipaddress ,4);
798- $binmask = ip_iptobin ($ipmask ,4);
799- $binsubnet = $binip & $binmask;
800- $ipsubnet = ip_bintoip($binsubnet,4);
801-
802- $inventory->addNetworks({
803-
804- DESCRIPTION => $description,
805- IPADDRESS => $ipaddress,
806- IPGATEWAY => $ipgateway,
807- IPMASK => $ipmask,
808- IPSUBNET => $ipsubnet,
809- MACADDR => $macaddr,
810- STATUS => $status,
811- SPEED => $speed,
812- TYPE => $type,
813- });
814-
815- }; # If
816- }; # For lanscan
817- }
818+ my $params = shift;
819+ my $inventory = $params->{inventory};
820+
821+ my $name;
822+ my $lanid;
823+ my $ipmask;
824+ my $ipgateway;
825+ my $status;
826+ my $macaddr;
827+ my $speed;
828+ my $type;
829+ my $ipsubnet;
830+ my $description;
831+ my $ipaddress;
832+
833+ my $hostname = 'Unknown';
834+ if ( `hostname` =~ /(\S+)/ ) {
835+ $hostname=$1
836+ } elsif ( `uname -n` =~ /(\S+)/ ) { # It should never reach here, as `hostname` should never fail!
837+ $hostname=$1
838+ }
839+
840+ for ( `grep $hostname /etc/hosts ` ) {
841+ if ( /(^\d+\.\d+\.\d+\.\d+)\s+/ ) {
842+ $inventory->setHardware({IPADDR => $1});
843+ last;
844+ }
845+ }
846+
847+ my %gateway;
848+ foreach (`netstat -nrv`) {
849+ if (/^(\S+\/\d+\.\d+\.\d+\.\d+)\s+(\d+\.\d+\.\d+\.\d+)/) {
850+ $gateway{$1} = $2 if not defined $gateway{$1}; #Just keep the first one
851+ }
852+ }
853+ if (defined ($gateway{'default/0.0.0.0'})) {
854+ $inventory->setHardware({
855+ DEFAULTGATEWAY => $gateway{'default/0.0.0.0'}
856+ })
857+ }
858+
859+ for ( `lanscan -iap`) {
860+ # Reinit variables
861+ $name="";
862+ $lanid="";
863+ $ipmask="";
864+ $ipgateway="";
865+ $status="";
866+ $macaddr="";
867+ $speed="";
868+ $type="";
869+ $ipsubnet="";
870+ $description="";
871+ $ipaddress="";
872+
873+ if ( /^(\S+)\s(\S+)\s(\S+)\s+(\S+)/) {
874+ $macaddr=$1;
875+ $name=$2;
876+ $lanid=$4;
877+ if ( $macaddr =~ /^0x(..)(..)(..)(..)(..)(..)$/ ) { $macaddr = "$1:$2:$3:$4:$5:$6" }
878+ #print "name $name macaddr $macaddr lanid $lanid\n";
879+ for ( `lanadmin -g $lanid` ) {
880+ if (/Type.+=\s(.+)/) { $type = $1; }
881+ if (/Description\s+=\s(.+)/) { $description = $1; }
882+ if (/Speed.+=\s(\d+)/) {
883+ $speed = ($1 > 1000000)? $1/1000000 : $1; # in old version speed was given in Mbps and we want speed in Mbps
884+ }
885+ if (/Operation Status.+=\sdown\W/i) { $status = "Down"; } #It is not the only criteria
886+ } # for lanadmin
887+ #print "name $name macaddr $macaddr lanid $lanid speed $speed status $status \n";
888+ for ( `ifconfig $name 2> /dev/null` ) {
889+ if ( not $status and /$name:\s+flags=.*\WUP\W/ ) { #Its status is not reported as down in lanadmin -g
890+ $status = 'Up';
891+ }
892+ if ( /inet\s(\S+)\snetmask\s(\S+)\s/ ) {
893+ $ipaddress=$1;
894+ $ipmask=$2;
895+ if ($ipmask =~ /(..)(..)(..)(..)/) {
896+ $ipmask=sprintf ("%i.%i.%i.%i",hex($1),hex($2),hex($3),hex($4));
897+ }
898+ }
899+ } # For ifconfig
900+ $ipsubnet = join '.', unpack('C4C4C4C4', pack('B32',
901+ unpack('B32', pack('C4C4C4C4', split(/\./, $ipaddress)))
902+ & unpack('B32', pack('C4C4C4C4', split(/\./, $ipmask)))
903+ ));
904+
905+ $ipgateway = $gateway{$ipsubnet.'/'.$ipmask};
906+ # replace the $ipaddress (ie IP Address of the interface itself) by the default gateway IP adress if it exists
907+ if (defined($ipgateway) and $ipgateway eq $ipaddress and defined($gateway{'default/0.0.0.0'})) {
908+ $ipgateway = $gateway{'default/0.0.0.0'}
909+ }
910+
911+ #Some cleanups
912+ if ( $ipaddress eq '0.0.0.0' ) { $ipaddress = "" }
913+ if ( not $ipaddress and not $ipmask and $ipsubnet eq '0.0.0.0' ) { $ipsubnet = "" }
914+ if ( not $status ) { $status = 'Down' }
915+
916+ $inventory->addNetwork({
917+ DESCRIPTION => $description,
918+ IPADDRESS => $ipaddress,
919+ IPMASK => $ipmask,
920+ IPSUBNET => $ipsubnet,
921+ MACADDR => $macaddr,
922+ STATUS => $status,
923+ TYPE => $type,
924+ SPEED => $speed,
925+ IPGATEWAY => $ipgateway,
926+# PCISLOT => $pcislot,
927+# DRIVER => $driver,
928+# VIRTUALDEV => $virtualdev,
929+ });
930+ } # If
931+ } # For lanscan
932+}
933
934 1;
935
936=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/README'
937--- lib/Ocsinventory/Agent/Backend/OS/HPUX/README 2010-01-22 14:39:51 +0000
938+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/README 2010-05-27 07:07:27 +0000
939@@ -47,7 +47,7 @@
940
941 It will be used automaticly
942
943-I have test the script on only n4000 system for th moment on HP-Ux 11.0
944+I have test the script on only n4000 system for the moment on HP-Ux 11.0
945 I try it on rp3440 but some informations are not in the same format
946
947 If you wish to help me, you are welwome.
948@@ -61,11 +61,10 @@
949 Controller.pm
950 Domains.pm
951 Drives.pm
952- IPv4.pm
953- Mem.pm
954 Memory.pm
955 Networks.pm
956 Slots.pm
957 Software.pm
958 Storages.pm
959+ Uptime.pm
960
961
962=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Slots.pm'
963--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Slots.pm 2010-01-22 14:39:51 +0000
964+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Slots.pm 2010-05-27 07:07:27 +0000
965@@ -1,7 +1,7 @@
966 package Ocsinventory::Agent::Backend::OS::HPUX::Slots;
967 use strict;
968
969-sub check { $^O =~ /hpux/ }
970+sub check { can_run('ioscan') }
971
972 sub run {
973 my $params = shift;
974@@ -22,7 +22,7 @@
975 $interface=$3;
976 $info=$4;
977 $type=$1;
978- $inventory->addSlots({
979+ $inventory->addSlot({
980 DESCRIPTION => "$name",
981 DESIGNATION => "$interface $info",
982 NAME => "$type",
983
984=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Software.pm'
985--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Software.pm 2010-01-22 14:39:51 +0000
986+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Software.pm 2010-05-27 07:07:27 +0000
987@@ -6,7 +6,7 @@
988 # Do not run an package inventory if there is the --nosoft parameter
989 return if ($params->{params}->{nosoft});
990
991- $^O =~ /hpux/
992+ can_run('swlist') and can_run('grep')
993 }
994
995 sub run {
996@@ -22,7 +22,7 @@
997 foreach $software (@softList) {
998 chomp( $software );
999 if ( $software =~ /^ (\S+)\s(\S+)\s(.+)/ ) {
1000- $inventory->addSoftwares({
1001+ $inventory->addSoftware({
1002 'NAME' => $1 ,
1003 'VERSION' => $2 ,
1004 'COMMENTS' => $3 ,
1005
1006=== modified file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Storages.pm'
1007--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Storages.pm 2010-02-25 18:36:52 +0000
1008+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Storages.pm 2010-05-27 07:07:27 +0000
1009@@ -1,6 +1,6 @@
1010 package Ocsinventory::Agent::Backend::OS::HPUX::Storages;
1011
1012-sub check { $^O =~ /hpux/ }
1013+sub check { can_run('ioscan') and can_run('cut') and can_run('pvdisplay') and can_run('diskinfo') }
1014
1015 sub run {
1016 my $params = shift;
1017
1018=== added file 'lib/Ocsinventory/Agent/Backend/OS/HPUX/Uptime.pm'
1019--- lib/Ocsinventory/Agent/Backend/OS/HPUX/Uptime.pm 1970-01-01 00:00:00 +0000
1020+++ lib/Ocsinventory/Agent/Backend/OS/HPUX/Uptime.pm 2010-05-27 07:07:27 +0000
1021@@ -0,0 +1,29 @@
1022+package Ocsinventory::Agent::Backend::OS::HPUX::Uptime;
1023+use strict;
1024+
1025+sub check { can_run("uptime") and can_run ("uname") }
1026+
1027+sub run {
1028+ my $params = shift;
1029+ my $inventory = $params->{inventory};
1030+
1031+ # Uptime
1032+ my $uptime = `uptime`;
1033+ my $seconds = 0;
1034+ if ( $uptime =~ /.*\sup\s((\d+)\sdays\D+)?(\d{1,2}):(\d{1,2}).*/ ) {
1035+ $seconds += $2 * 24 * 3600;
1036+ $seconds += $3 * 3600;
1037+ $seconds += $4 * 60;
1038+ }
1039+
1040+ # Uptime conversion
1041+ my ($UYEAR, $UMONTH , $UDAY, $UHOUR, $UMIN, $USEC) = (gmtime ($seconds))[5,4,3,2,1,0];
1042+
1043+ # Write in ISO format
1044+ $uptime=sprintf "%02d-%02d-%02d %02d:%02d:%02d", ($UYEAR-70), $UMONTH, ($UDAY-1), $UHOUR, $UMIN, $USEC;
1045+
1046+ chomp(my $DeviceType =`uname -m`);
1047+ $inventory->setHardware({ DESCRIPTION => "$DeviceType/$uptime" });
1048+}
1049+
1050+1
1051
1052=== added file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Network/iLO.pm'
1053--- lib/Ocsinventory/Agent/Backend/OS/Linux/Network/iLO.pm 1970-01-01 00:00:00 +0000
1054+++ lib/Ocsinventory/Agent/Backend/OS/Linux/Network/iLO.pm 2010-05-27 07:07:27 +0000
1055@@ -0,0 +1,66 @@
1056+package Ocsinventory::Agent::Backend::OS::Linux::Network::iLO;
1057+
1058+use strict;
1059+use warnings;
1060+
1061+sub check {
1062+ return unless can_run("hponcfg") && can_load("Net::IP qw(:PROC)");
1063+ 1;
1064+}
1065+
1066+sub run {
1067+ my $params = shift;
1068+ my $inventory = $params->{inventory};
1069+ my $logger = $params->{logger};
1070+
1071+ my $name;
1072+ my $ipmask;
1073+ my $ipgateway;
1074+ my $speed;
1075+ my $ipsubnet;
1076+ my $ipaddress;
1077+ my $status;
1078+# my $macaddr;
1079+
1080+ foreach (`hponcfg -aw -`) {
1081+ if ( /<IP_ADDRESS VALUE="([0-9.]+)"\/>/ ) {
1082+ $ipaddress = $1;
1083+ } elsif ( /<SUBNET_MASK VALUE="([0-9.]+)"\/>/ ) {
1084+ $ipmask = $1;
1085+ } elsif ( /<GATEWAY_IP_ADDRESS VALUE="([0-9.]+)"\/>/ ) {
1086+ $ipgateway = $1;
1087+ } elsif ( /<NIC_SPEED VALUE="([0-9]+)"\/>/ ) {
1088+ $speed = $1;
1089+ } elsif ( /<DNS_NAME VALUE="([^"]+)"\/>/ ) {
1090+ $name = $1;
1091+ } elsif ( /<ENABLE_NIC VALUE="(.)"\/>/ ) {
1092+ $status = 'Up' if $1 =~ /Y/i;
1093+ }
1094+ }
1095+ if ( defined($ipaddress) && defined($ipmask) ) {
1096+ $ipsubnet = ip_bintoip(ip_iptobin ($ipaddress ,4) & ip_iptobin ($ipmask ,4), 4);
1097+ }
1098+
1099+ #Some cleanups
1100+ if ( $ipaddress eq '0.0.0.0' ) { $ipaddress = "" }
1101+ if ( not $ipaddress and not $ipmask and $ipsubnet eq '0.0.0.0' ) { $ipsubnet = "" }
1102+ if ( not $status ) { $status = 'Down' }
1103+
1104+ $inventory->addNetwork({
1105+ DESCRIPTION => 'Management Interface - HP iLO',
1106+ IPADDRESS => $ipaddress,
1107+ IPMASK => $ipmask,
1108+ IPSUBNET => $ipsubnet,
1109+ STATUS => $status,
1110+ TYPE => 'Ethernet',
1111+ SPEED => $speed,
1112+ IPGATEWAY => $ipgateway,
1113+ MANAGEMENT => 'iLO',
1114+# MACADDR => $macaddr,
1115+# PCISLOT => $pcislot,
1116+# DRIVER => $driver,
1117+# VIRTUALDEV => $virtualdev,
1118+ });
1119+}
1120+1;
1121+
1122
1123=== modified file 'lib/Ocsinventory/Agent/Backend/OS/Linux/Storages.pm'
1124--- lib/Ocsinventory/Agent/Backend/OS/Linux/Storages.pm 2009-08-04 11:46:48 +0000
1125+++ lib/Ocsinventory/Agent/Backend/OS/Linux/Storages.pm 2010-05-27 07:07:27 +0000
1126@@ -129,7 +129,7 @@
1127 my $value;
1128 foreach my $line (`lshal`) {
1129 chomp $line;
1130- if ( $line =~ s{^udi = '/org/freedesktop/Hal/devices/storage.*}{}) {
1131+ if ( $line =~ s{^udi = '/org/freedesktop/Hal/devices/(storage|legacy_floppy|block).*}{}) {
1132 $in = 1;
1133 %temp = ();
1134 } elsif ($in == 1 and $line =~ s{^\s+(\S+) = (.*) \s*\((int|string|bool|string list|uint64)\)}{} ) {
1135@@ -216,7 +216,7 @@
1136 my ($manufacturer, $model, $media, $firmware, $serialnumber, $capacity, $partitions, $description);
1137 foreach (glob ("/sys/block/*")) {# /sys fs style
1138 $partitions->{$1} = undef
1139- if (/^\/sys\/block\/([sh]d[a-z])$/)
1140+ if (/^\/sys\/block\/([sh]d[a-z]|fd\d)$/)
1141 }
1142 foreach (`fdisk -l`) {# call fdisk to list partitions
1143 chomp;
1144
1145=== modified file 'lib/Ocsinventory/Agent/XML/Inventory.pm'
1146--- lib/Ocsinventory/Agent/XML/Inventory.pm 2010-03-24 20:28:01 +0000
1147+++ lib/Ocsinventory/Agent/XML/Inventory.pm 2010-05-27 07:07:27 +0000
1148@@ -497,6 +497,7 @@
1149 my $status = $args->{STATUS};
1150 my $type = $args->{TYPE};
1151 my $virtualdev = $args->{VIRTUALDEV};
1152+ my $speed = $args->{SPEED};
1153
1154 # return unless $ipaddress;
1155
1156@@ -515,6 +516,7 @@
1157 STATUS => [$status?$status:''],
1158 TYPE => [$type?$type:''],
1159 VIRTUALDEV => [$virtualdev?$virtualdev:''],
1160+ SPEED => [$speed?$speed:''],
1161
1162 };
1163 }

Subscribers

People subscribed via source and target branches