hyperic-sigar 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. data/COPYING +339 -0
  2. data/EXCEPTIONS +104 -0
  3. data/README +2 -0
  4. data/Rakefile +87 -0
  5. data/bindings/SigarWrapper.pm +2934 -0
  6. data/bindings/ruby/examples/cpu_info.rb +16 -0
  7. data/bindings/ruby/examples/df.rb +32 -0
  8. data/bindings/ruby/examples/free.rb +19 -0
  9. data/bindings/ruby/examples/ifconfig.rb +67 -0
  10. data/bindings/ruby/examples/netstat.rb +54 -0
  11. data/bindings/ruby/examples/pargs.rb +18 -0
  12. data/bindings/ruby/examples/penv.rb +14 -0
  13. data/bindings/ruby/examples/route.rb +31 -0
  14. data/bindings/ruby/examples/who.rb +13 -0
  15. data/bindings/ruby/extconf.rb +110 -0
  16. data/bindings/ruby/rbsigar.c +628 -0
  17. data/include/sigar.h +901 -0
  18. data/include/sigar_fileinfo.h +141 -0
  19. data/include/sigar_format.h +65 -0
  20. data/include/sigar_getline.h +18 -0
  21. data/include/sigar_log.h +82 -0
  22. data/include/sigar_private.h +365 -0
  23. data/include/sigar_ptql.h +55 -0
  24. data/include/sigar_util.h +192 -0
  25. data/src/os/aix/aix_sigar.c +1927 -0
  26. data/src/os/aix/sigar_os.h +71 -0
  27. data/src/os/darwin/darwin_sigar.c +3450 -0
  28. data/src/os/darwin/sigar_os.h +82 -0
  29. data/src/os/hpux/dlpi.c +284 -0
  30. data/src/os/hpux/hpux_sigar.c +1205 -0
  31. data/src/os/hpux/sigar_os.h +51 -0
  32. data/src/os/linux/linux_sigar.c +2595 -0
  33. data/src/os/linux/sigar_os.h +84 -0
  34. data/src/os/netware/netware_sigar.c +719 -0
  35. data/src/os/netware/sigar_os.h +26 -0
  36. data/src/os/osf1/osf1_sigar.c +593 -0
  37. data/src/os/osf1/sigar_os.h +42 -0
  38. data/src/os/solaris/get_mib2.c +321 -0
  39. data/src/os/solaris/get_mib2.h +127 -0
  40. data/src/os/solaris/hmekstat.h +77 -0
  41. data/src/os/solaris/kstats.c +182 -0
  42. data/src/os/solaris/procfs.c +99 -0
  43. data/src/os/solaris/sigar_os.h +225 -0
  44. data/src/os/solaris/solaris_sigar.c +2561 -0
  45. data/src/os/stub/sigar_os.h +8 -0
  46. data/src/os/stub/stub_sigar.c +303 -0
  47. data/src/os/win32/peb.c +213 -0
  48. data/src/os/win32/sigar_os.h +623 -0
  49. data/src/os/win32/sigar_pdh.h +49 -0
  50. data/src/os/win32/win32_sigar.c +3718 -0
  51. data/src/sigar.c +2292 -0
  52. data/src/sigar_cache.c +181 -0
  53. data/src/sigar_fileinfo.c +792 -0
  54. data/src/sigar_format.c +649 -0
  55. data/src/sigar_getline.c +1849 -0
  56. data/src/sigar_ptql.c +1966 -0
  57. data/src/sigar_signal.c +218 -0
  58. data/src/sigar_util.c +1061 -0
  59. data/version.properties +11 -0
  60. metadata +112 -0
@@ -0,0 +1,2934 @@
1
+ #extension source generator for all bindings
2
+ package SigarWrapper;
3
+
4
+ use strict;
5
+ use Cwd;
6
+ use Exporter;
7
+ use File::Path;
8
+ use IO::File ();
9
+
10
+ use vars qw(@ISA @EXPORT);
11
+ @ISA = qw(Exporter);
12
+ @EXPORT = qw(generate);
13
+
14
+ my %platforms = (
15
+ A => "AIX",
16
+ D => "Darwin",
17
+ F => "FreeBSD",
18
+ H => "HPUX",
19
+ L => "Linux",
20
+ S => "Solaris",
21
+ W => "Win32",
22
+ );
23
+
24
+ my %has_name_arg = map { $_, 1 } qw(FileSystemUsage DiskUsage
25
+ FileAttrs DirStat DirUsage
26
+ NetInterfaceConfig NetInterfaceStat);
27
+
28
+ my %proc_no_arg = map { $_, 1 } qw(stat);
29
+
30
+ my %get_not_impl = map { $_, 1 } qw(net_address net_route net_connection net_stat cpu_perc
31
+ who cpu_info file_system); #list funcs only
32
+
33
+ sub supported_platforms {
34
+ my $p = shift;
35
+ return 'Undocumented' unless $p;
36
+ if ($p eq '*') {
37
+ return 'All';
38
+ }
39
+
40
+ my @platforms;
41
+ for (split //, $p) {
42
+ push @platforms, $platforms{$_};
43
+ }
44
+
45
+ return join ", ", @platforms;
46
+ }
47
+
48
+ sub hash {
49
+ return unpack("%32C*", shift) % 65535;
50
+ }
51
+
52
+ my $nfs_v2 = [
53
+ {
54
+ name => 'null', type => 'Long',
55
+ },
56
+ {
57
+ name => 'getattr', type => 'Long',
58
+ },
59
+ {
60
+ name => 'setattr', type => 'Long',
61
+ },
62
+ {
63
+ name => 'root', type => 'Long',
64
+ },
65
+ {
66
+ name => 'lookup', type => 'Long',
67
+ },
68
+ {
69
+ name => 'readlink', type => 'Long',
70
+ },
71
+ {
72
+ name => 'read', type => 'Long',
73
+ },
74
+ {
75
+ name => 'writecache', type => 'Long',
76
+ },
77
+ {
78
+ name => 'write', type => 'Long',
79
+ },
80
+ {
81
+ name => 'create', type => 'Long',
82
+ },
83
+ {
84
+ name => 'remove', type => 'Long',
85
+ },
86
+ {
87
+ name => 'rename', type => 'Long',
88
+ },
89
+ {
90
+ name => 'link', type => 'Long',
91
+ },
92
+ {
93
+ name => 'symlink', type => 'Long',
94
+ },
95
+ {
96
+ name => 'mkdir', type => 'Long',
97
+ },
98
+ {
99
+ name => 'rmdir', type => 'Long',
100
+ },
101
+ {
102
+ name => 'readdir', type => 'Long',
103
+ },
104
+ {
105
+ name => 'fsstat', type => 'Long',
106
+ },
107
+ ];
108
+
109
+ my $nfs_v3 = [
110
+ {
111
+ name => 'null', type => 'Long',
112
+ },
113
+ {
114
+ name => 'getattr', type => 'Long',
115
+ },
116
+ {
117
+ name => 'setattr', type => 'Long',
118
+ },
119
+ {
120
+ name => 'lookup', type => 'Long',
121
+ },
122
+ {
123
+ name => 'access', type => 'Long',
124
+ },
125
+ {
126
+ name => 'readlink', type => 'Long',
127
+ },
128
+ {
129
+ name => 'read', type => 'Long',
130
+ },
131
+ {
132
+ name => 'write', type => 'Long',
133
+ },
134
+ {
135
+ name => 'create', type => 'Long',
136
+ },
137
+ {
138
+ name => 'mkdir', type => 'Long',
139
+ },
140
+ {
141
+ name => 'symlink', type => 'Long',
142
+ },
143
+ {
144
+ name => 'mknod', type => 'Long',
145
+ },
146
+ {
147
+ name => 'remove', type => 'Long',
148
+ },
149
+ {
150
+ name => 'rmdir', type => 'Long',
151
+ },
152
+ {
153
+ name => 'rename', type => 'Long',
154
+ },
155
+ {
156
+ name => 'link', type => 'Long',
157
+ },
158
+ {
159
+ name => 'readdir', type => 'Long',
160
+ },
161
+ {
162
+ name => 'readdirplus', type => 'Long',
163
+ },
164
+ {
165
+ name => 'fsstat', type => 'Long',
166
+ },
167
+ {
168
+ name => 'fsinfo', type => 'Long',
169
+ },
170
+ {
171
+ name => 'pathconf', type => 'Long',
172
+ },
173
+ {
174
+ name => 'commit', type => 'Long',
175
+ },
176
+ ];
177
+
178
+ use vars qw(%classes %cmds);
179
+
180
+ %classes = (
181
+ Mem => [
182
+ {
183
+ name => 'total', type => 'Long',
184
+ desc => 'Total system memory',
185
+ plat => '*',
186
+ cmd => {
187
+ AIX => 'lsattr -El sys0 -a realmem',
188
+ Darwin => '',
189
+ FreeBSD => '',
190
+ HPUX => '',
191
+ Linux => 'free',
192
+ Solaris => '',
193
+ Win32 => 'taskman',
194
+ },
195
+ },
196
+ {
197
+ name => 'ram', type => 'Long',
198
+ desc => 'System Random Access Memory (in MB)',
199
+ plat => '*',
200
+ cmd => {
201
+ AIX => 'lsattr -El sys0 -a realmem',
202
+ Darwin => '',
203
+ FreeBSD => '',
204
+ HPUX => '',
205
+ Linux => 'cat /proc/mtrr | head -1',
206
+ Solaris => '',
207
+ Win32 => '',
208
+ },
209
+ },
210
+ {
211
+ name => 'used', type => 'Long',
212
+ desc => 'Total used system memory',
213
+ plat => '*',
214
+ cmd => {
215
+ AIX => '',
216
+ Darwin => '',
217
+ FreeBSD => '',
218
+ HPUX => '',
219
+ Linux => 'free',
220
+ Solaris => '',
221
+ Win32 => 'taskman',
222
+ },
223
+ },
224
+ {
225
+ name => 'free', type => 'Long',
226
+ desc => 'Total free system memory (e.g. Linux plus cached)',
227
+ plat => '*',
228
+ cmd => {
229
+ AIX => '',
230
+ Darwin => '',
231
+ FreeBSD => '',
232
+ HPUX => '',
233
+ Linux => 'free',
234
+ Solaris => '',
235
+ Win32 => 'taskman',
236
+ },
237
+ },
238
+ {
239
+ name => 'actual_used', type => 'Long',
240
+ desc => 'Actual total used system memory (e.g. Linux minus buffers)',
241
+ plat => '*',
242
+ cmd => {
243
+ AIX => '',
244
+ Darwin => '',
245
+ FreeBSD => '',
246
+ HPUX => '',
247
+ Linux => 'free',
248
+ Solaris => '',
249
+ Win32 => 'taskman',
250
+ },
251
+ },
252
+ {
253
+ name => 'actual_free', type => 'Long',
254
+ desc => 'Actual total free system memory',
255
+ plat => '*',
256
+ cmd => {
257
+ AIX => '',
258
+ Darwin => '',
259
+ FreeBSD => '',
260
+ HPUX => '',
261
+ Linux => 'free',
262
+ Solaris => '',
263
+ Win32 => 'taskman',
264
+ },
265
+ },
266
+ {
267
+ name => 'used_percent', type => 'Double',
268
+ desc => 'Percent total used system memory',
269
+ plat => '*',
270
+ cmd => {
271
+ AIX => '',
272
+ Darwin => '',
273
+ FreeBSD => '',
274
+ HPUX => '',
275
+ Linux => 'free',
276
+ Solaris => '',
277
+ Win32 => 'taskman',
278
+ },
279
+ },
280
+ {
281
+ name => 'free_percent', type => 'Double',
282
+ desc => 'Percent total free system memory',
283
+ plat => '*',
284
+ cmd => {
285
+ AIX => '',
286
+ Darwin => '',
287
+ FreeBSD => '',
288
+ HPUX => '',
289
+ Linux => 'free',
290
+ Solaris => '',
291
+ Win32 => 'taskman',
292
+ },
293
+ },
294
+ ],
295
+ Swap => [
296
+ {
297
+ name => 'total', type => 'Long',
298
+ desc => 'Total system swap',
299
+ plat => '*',
300
+ cmd => {
301
+ AIX => 'lsps -s',
302
+ Darwin => 'sysctl vm.swapusage',
303
+ FreeBSD => '',
304
+ HPUX => '',
305
+ Linux => 'free',
306
+ Solaris => 'swap -s',
307
+ Win32 => '',
308
+ },
309
+ },
310
+ {
311
+ name => 'used', type => 'Long',
312
+ desc => 'Total used system swap',
313
+ plat => '*',
314
+ cmd => {
315
+ AIX => 'lsps -s',
316
+ Darwin => '',
317
+ FreeBSD => '',
318
+ HPUX => '',
319
+ Linux => 'free',
320
+ Solaris => 'swap -s',
321
+ Win32 => '',
322
+ },
323
+ },
324
+ {
325
+ name => 'free', type => 'Long',
326
+ desc => 'Total free system swap',
327
+ plat => '*',
328
+ cmd => {
329
+ AIX => '',
330
+ Darwin => '',
331
+ FreeBSD => '',
332
+ HPUX => '',
333
+ Linux => 'free',
334
+ Solaris => 'swap -s',
335
+ Win32 => '',
336
+ },
337
+ },
338
+ {
339
+ name => 'page_in', type => 'Long',
340
+ desc => 'Pages in',
341
+ plat => '*',
342
+ cmd => {
343
+ AIX => '',
344
+ Darwin => '',
345
+ FreeBSD => '',
346
+ HPUX => '',
347
+ Linux => 'vmstat',
348
+ Solaris => 'vmstat',
349
+ Win32 => '',
350
+ },
351
+ },
352
+ {
353
+ name => 'page_out', type => 'Long',
354
+ desc => 'Pages out',
355
+ plat => '*',
356
+ cmd => {
357
+ AIX => '',
358
+ Darwin => '',
359
+ FreeBSD => '',
360
+ HPUX => '',
361
+ Linux => 'vmstat',
362
+ Solaris => 'vmstat',
363
+ Win32 => '',
364
+ },
365
+ },
366
+ ],
367
+ Cpu => [
368
+ {
369
+ name => 'user', type => 'Long',
370
+ desc => 'Total system cpu user time',
371
+ plat => '*'
372
+ },
373
+ {
374
+ name => 'sys', type => 'Long',
375
+ desc => 'Total system cpu kernel time',
376
+ plat => '*'
377
+ },
378
+ {
379
+ name => 'nice', type => 'Long',
380
+ desc => 'Total system cpu nice time',
381
+ plat => 'DFHL'
382
+ },
383
+ {
384
+ name => 'idle', type => 'Long',
385
+ desc => 'Total system cpu idle time',
386
+ plat => '*'
387
+ },
388
+ {
389
+ name => 'wait', type => 'Long',
390
+ desc => 'Total system cpu io wait time',
391
+ plat => 'ALHS'
392
+ },
393
+ {
394
+ name => 'irq', type => 'Long',
395
+ desc => 'Total system cpu time servicing interrupts',
396
+ plat => 'FLHW'
397
+ },
398
+ {
399
+ name => 'soft_irq', type => 'Long',
400
+ desc => 'Total system cpu time servicing softirqs',
401
+ plat => 'L'
402
+ },
403
+ {
404
+ name => 'stolen', type => 'Long',
405
+ desc => 'Total system cpu involuntary wait time',
406
+ plat => 'L'
407
+ },
408
+ {
409
+ name => 'total', type => 'Long',
410
+ desc => 'Total system cpu time',
411
+ plat => '*'
412
+ },
413
+ ],
414
+ CpuPerc => [
415
+ {
416
+ name => 'user', type => 'Double',
417
+ desc => 'Percent system cpu user time',
418
+ plat => '*'
419
+ },
420
+ {
421
+ name => 'sys', type => 'Double',
422
+ desc => 'Percent system cpu kernel time',
423
+ plat => '*'
424
+ },
425
+ {
426
+ name => 'nice', type => 'Double',
427
+ desc => 'Percent system cpu nice time',
428
+ plat => 'DFHL'
429
+ },
430
+ {
431
+ name => 'idle', type => 'Double',
432
+ desc => 'Percent system cpu idle time',
433
+ plat => '*'
434
+ },
435
+ {
436
+ name => 'wait', type => 'Double',
437
+ desc => 'Percent system cpu io wait time',
438
+ plat => 'ALHS'
439
+ },
440
+ {
441
+ name => 'irq', type => 'Double',
442
+ desc => 'Percent system cpu time servicing interrupts',
443
+ plat => 'FLHW'
444
+ },
445
+ {
446
+ name => 'soft_irq', type => 'Double',
447
+ desc => 'Percent system cpu time servicing softirqs',
448
+ plat => 'L'
449
+ },
450
+ {
451
+ name => 'stolen', type => 'Double',
452
+ desc => 'Percent system cpu involuntary wait time',
453
+ plat => 'L'
454
+ },
455
+ {
456
+ name => 'combined', type => 'Double',
457
+ desc => 'Sum of User + Sys + Nice + Wait',
458
+ plat => '*'
459
+ },
460
+ ],
461
+ CpuInfo => [
462
+ {
463
+ name => 'vendor', type => 'String',
464
+ desc => 'CPU vendor id',
465
+ plat => 'AFLHSW'
466
+ },
467
+ {
468
+ name => 'model', type => 'String',
469
+ desc => 'CPU model',
470
+ plat => 'AFLHSW'
471
+ },
472
+ {
473
+ name => 'mhz', type => 'Int',
474
+ desc => 'CPU speed',
475
+ plat => 'AFHLSW'
476
+ },
477
+ {
478
+ name => 'cache_size', type => 'Long',
479
+ desc => 'CPU cache size',
480
+ plat => 'AL'
481
+ },
482
+ {
483
+ name => 'total_cores', type => 'Int',
484
+ desc => 'Total CPU cores (logical)',
485
+ },
486
+ {
487
+ name => 'total_sockets', type => 'Int',
488
+ desc => 'Total CPU sockets (physical)',
489
+ },
490
+ {
491
+ name => 'cores_per_socket', type => 'Int',
492
+ desc => 'Number of CPU cores per CPU socket',
493
+ },
494
+ ],
495
+ Uptime => [
496
+ {
497
+ name => 'uptime', type => 'Double',
498
+ desc => 'Time since machine started in seconds',
499
+ plat => '*'
500
+ },
501
+ ],
502
+ ProcMem => [
503
+ {
504
+ name => 'size', type => 'Long',
505
+ desc => 'Total process virtual memory',
506
+ plat => '*'
507
+ },
508
+ {
509
+ name => 'resident', type => 'Long',
510
+ desc => 'Total process resident memory',
511
+ plat => '*'
512
+ },
513
+ {
514
+ name => 'share', type => 'Long',
515
+ desc => 'Total process shared memory',
516
+ plat => 'AHLS'
517
+ },
518
+ {
519
+ name => 'minor_faults', type => 'Long',
520
+ desc => 'non i/o page faults',
521
+ plat => 'AHLS'
522
+ },
523
+ {
524
+ name => 'major_faults', type => 'Long',
525
+ desc => 'i/o page faults',
526
+ plat => 'AHLS'
527
+ },
528
+ {
529
+ name => 'page_faults', type => 'Long',
530
+ desc => 'Total number of page faults',
531
+ plat => 'ADHLSW'
532
+ },
533
+ ],
534
+ ProcCred => [
535
+ {
536
+ name => 'uid', type => 'Long',
537
+ desc => 'Process user id',
538
+ plat => 'ADFHLS'
539
+ },
540
+ {
541
+ name => 'gid', type => 'Long',
542
+ desc => 'Process group id',
543
+ plat => 'ADFHLS'
544
+ },
545
+ {
546
+ name => 'euid', type => 'Long',
547
+ desc => 'Process effective user id',
548
+ plat => 'ADFHLS'
549
+ },
550
+ {
551
+ name => 'egid', type => 'Long',
552
+ desc => 'Process effective group id',
553
+ plat => 'ADFHLS'
554
+ },
555
+ ],
556
+ ProcCredName => [
557
+ {
558
+ name => 'user', type => 'String',
559
+ desc => 'Process owner user name',
560
+ plat => '*'
561
+ },
562
+ {
563
+ name => 'group', type => 'String',
564
+ desc => 'Process owner group name',
565
+ plat => '*'
566
+ },
567
+ ],
568
+ ProcTime => [
569
+ {
570
+ name => 'start_time', type => 'Long',
571
+ desc => 'Time process was started in seconds',
572
+ plat => '*'
573
+ },
574
+ {
575
+ name => 'user', type => 'Long',
576
+ desc => 'Process cpu user time',
577
+ plat => '*'
578
+ },
579
+ {
580
+ name => 'sys', type => 'Long',
581
+ desc => 'Process cpu kernel time',
582
+ plat => '*'
583
+ },
584
+ {
585
+ name => 'total', type => 'Long',
586
+ desc => 'Process cpu time (sum of User and Sys)',
587
+ plat => '*'
588
+ },
589
+ ],
590
+ ProcCpu => [
591
+ {
592
+ name => 'percent', type => 'Double',
593
+ desc => 'Process cpu usage',
594
+ plat => '*'
595
+ },
596
+ {
597
+ name => 'last_time', type => 'Long',
598
+ desc => '',
599
+ plat => '*'
600
+ },
601
+ ],
602
+ ProcState => [
603
+ {
604
+ name => 'state', type => 'Char',
605
+ desc => 'Process state (Running, Zombie, etc.)',
606
+ plat => '*'
607
+ },
608
+ {
609
+ name => 'name', type => 'String',
610
+ desc => 'Name of the process program',
611
+ plat => '*'
612
+ },
613
+ {
614
+ name => 'ppid', type => 'Long',
615
+ desc => 'Process parent process id',
616
+ plat => '*'
617
+ },
618
+ {
619
+ name => 'tty', type => 'Int',
620
+ desc => 'Device number of rocess controling terminal',
621
+ plat => 'AHLS'
622
+ },
623
+ {
624
+ name => 'nice', type => 'Int',
625
+ desc => 'Nice value of process',
626
+ plat => 'ADFHLS'
627
+ },
628
+ {
629
+ name => 'priority', type => 'Int',
630
+ desc => 'Kernel scheduling priority of process',
631
+ plat => 'DFHLSW'
632
+ },
633
+ {
634
+ name => 'threads', type => 'Long',
635
+ desc => 'Number of active threads',
636
+ plat => 'ADHLSW'
637
+ },
638
+ {
639
+ name => 'processor', type => 'Int',
640
+ desc => 'Processor number last run on',
641
+ plat => 'AHLS'
642
+ },
643
+ ],
644
+ ProcFd => [
645
+ {
646
+ name => 'total', type => 'Long',
647
+ desc => 'Total number of open file descriptors',
648
+ plat => 'AHLSW'
649
+ },
650
+ ],
651
+ ProcStat => [
652
+ {
653
+ name => 'total', type => 'Long',
654
+ desc => 'Total number of processes',
655
+ plat => '*'
656
+ },
657
+ {
658
+ name => 'idle', type => 'Long',
659
+ desc => 'Total number of processes in idle state',
660
+ plat => '*'
661
+ },
662
+ {
663
+ name => 'running', type => 'Long',
664
+ desc => 'Total number of processes in run state',
665
+ plat => '*'
666
+ },
667
+ {
668
+ name => 'sleeping', type => 'Long',
669
+ desc => 'Total number of processes in sleep state',
670
+ plat => '*'
671
+ },
672
+ {
673
+ name => 'stopped', type => 'Long',
674
+ desc => 'Total number of processes in stop state',
675
+ plat => '*'
676
+ },
677
+ {
678
+ name => 'zombie', type => 'Long',
679
+ desc => 'Total number of processes in zombie state',
680
+ plat => '*'
681
+ },
682
+ {
683
+ name => 'threads', type => 'Long',
684
+ desc => 'Total number of threads',
685
+ plat => '*'
686
+ },
687
+ ],
688
+ ProcExe => [
689
+ {
690
+ name => 'name', type => 'String',
691
+ desc => 'Name of process executable',
692
+ plat => 'FLSW',
693
+ cmd => {
694
+ AIX => '',
695
+ Darwin => '',
696
+ FreeBSD => '',
697
+ HPUX => '',
698
+ Linux => 'ls -l /proc/$$/exe',
699
+ Solaris => '',
700
+ Win32 => '',
701
+ },
702
+ },
703
+ {
704
+ name => 'cwd', type => 'String',
705
+ desc => 'Name of process current working directory',
706
+ plat => 'LSW',
707
+ cmd => {
708
+ AIX => '',
709
+ Darwin => '',
710
+ FreeBSD => '',
711
+ HPUX => '',
712
+ Linux => 'ls -l /proc/$$/cwd',
713
+ Solaris => '',
714
+ Win32 => '',
715
+ },
716
+ },
717
+ ],
718
+ ThreadCpu => [
719
+ {
720
+ name => 'user', type => 'Long',
721
+ desc => 'Thread cpu user time',
722
+ plat => 'AHLSW'
723
+ },
724
+ {
725
+ name => 'sys', type => 'Long',
726
+ desc => 'Thread cpu kernel time',
727
+ plat => 'AHLSW'
728
+ },
729
+ {
730
+ name => 'total', type => 'Long',
731
+ desc => 'Thread cpu time (sum of User and Sys)',
732
+ plat => 'AHLSW'
733
+ },
734
+ ],
735
+ FileSystem => [
736
+ {
737
+ name => 'dir_name', type => 'String',
738
+ desc => 'Directory name',
739
+ plat => '*'
740
+ },
741
+ {
742
+ name => 'dev_name', type => 'String',
743
+ desc => 'Device name',
744
+ plat => '*'
745
+ },
746
+ {
747
+ name => 'type_name', type => 'String',
748
+ desc => 'File system generic type name',
749
+ plat => '*'
750
+ },
751
+ {
752
+ name => 'sys_type_name', type => 'String',
753
+ desc => 'File system os specific type name',
754
+ plat => '*'
755
+ },
756
+ {
757
+ name => 'options', type => 'String',
758
+ desc => 'File system mount options',
759
+ plat => '*'
760
+ },
761
+ {
762
+ name => 'type', type => 'Int',
763
+ desc => 'File system type',
764
+ plat => '*'
765
+ },
766
+ {
767
+ name => 'flags', type => 'Long',
768
+ desc => 'File system flags',
769
+ plat => '*'
770
+ },
771
+ ],
772
+ FileSystemUsage => [
773
+ {
774
+ name => 'total', type => 'Long',
775
+ desc => 'Total Kbytes of filesystem',
776
+ plat => '*'
777
+ },
778
+ {
779
+ name => 'free', type => 'Long',
780
+ desc => 'Total free Kbytes on filesystem',
781
+ plat => '*'
782
+ },
783
+ {
784
+ name => 'used', type => 'Long',
785
+ desc => 'Total used Kbytes on filesystem',
786
+ plat => '*'
787
+ },
788
+ {
789
+ name => 'avail', type => 'Long',
790
+ desc => 'Total free Kbytes on filesystem available to caller',
791
+ plat => '*'
792
+ },
793
+ {
794
+ name => 'files', type => 'Long',
795
+ desc => 'Total number of file nodes on the filesystem',
796
+ plat => 'ADFHLS'
797
+ },
798
+ {
799
+ name => 'free_files', type => 'Long',
800
+ desc => 'Number of free file nodes on the filesystem',
801
+ plat => 'ADFHLS'
802
+ },
803
+ {
804
+ name => 'disk_reads', type => 'Long',
805
+ desc => 'Number of physical disk reads',
806
+ plat => 'AFHLSW'
807
+ },
808
+ {
809
+ name => 'disk_writes', type => 'Long',
810
+ desc => 'Number of physical disk writes',
811
+ plat => 'AFHLSW'
812
+ },
813
+ {
814
+ name => 'disk_read_bytes', type => 'Long',
815
+ desc => 'Number of physical disk bytes read',
816
+ plat => ''
817
+ },
818
+ {
819
+ name => 'disk_write_bytes', type => 'Long',
820
+ desc => 'Number of physical disk bytes written',
821
+ plat => ''
822
+ },
823
+ {
824
+ name => 'disk_queue', type => 'Double',
825
+ desc => '',
826
+ plat => ''
827
+ },
828
+ {
829
+ name => 'disk_service_time', type => 'Double',
830
+ desc => '',
831
+ plat => ''
832
+ },
833
+ {
834
+ name => 'use_percent', type => 'Double',
835
+ desc => 'Percent of disk used',
836
+ plat => '*'
837
+ },
838
+ ],
839
+ DiskUsage => [
840
+ {
841
+ name => 'reads', type => 'Long',
842
+ desc => 'Number of physical disk reads',
843
+ plat => 'AFHLSW'
844
+ },
845
+ {
846
+ name => 'writes', type => 'Long',
847
+ desc => 'Number of physical disk writes',
848
+ plat => 'AFHLSW'
849
+ },
850
+ {
851
+ name => 'read_bytes', type => 'Long',
852
+ desc => 'Number of physical disk bytes read',
853
+ plat => ''
854
+ },
855
+ {
856
+ name => 'write_bytes', type => 'Long',
857
+ desc => 'Number of physical disk bytes written',
858
+ plat => ''
859
+ },
860
+ {
861
+ name => 'queue', type => 'Double',
862
+ desc => '',
863
+ plat => ''
864
+ },
865
+ {
866
+ name => 'service_time', type => 'Double',
867
+ desc => '',
868
+ plat => ''
869
+ },
870
+ ],
871
+ FileAttrs => [
872
+ {
873
+ name => 'permissions', type => 'Long',
874
+ },
875
+ {
876
+ name => 'type', type => 'Int',
877
+ },
878
+ {
879
+ name => 'uid', type => 'Long',
880
+ },
881
+ {
882
+ name => 'gid', type => 'Long',
883
+ },
884
+ {
885
+ name => 'inode', type => 'Long',
886
+ },
887
+ {
888
+ name => 'device', type => 'Long',
889
+ },
890
+ {
891
+ name => 'nlink', type => 'Long',
892
+ },
893
+ {
894
+ name => 'size', type => 'Long',
895
+ },
896
+ {
897
+ name => 'atime', type => 'Long',
898
+ },
899
+ {
900
+ name => 'ctime', type => 'Long',
901
+ },
902
+ {
903
+ name => 'mtime', type => 'Long',
904
+ },
905
+ ],
906
+ DirStat => [
907
+ {
908
+ name => 'total', type => 'Long',
909
+ },
910
+ {
911
+ name => 'files', type => 'Long',
912
+ },
913
+ {
914
+ name => 'subdirs', type => 'Long',
915
+ },
916
+ {
917
+ name => 'symlinks', type => 'Long',
918
+ },
919
+ {
920
+ name => 'chrdevs', type => 'Long',
921
+ },
922
+ {
923
+ name => 'blkdevs', type => 'Long',
924
+ },
925
+ {
926
+ name => 'sockets', type => 'Long',
927
+ },
928
+ {
929
+ name => 'disk_usage', type => 'Long',
930
+ },
931
+ ],
932
+ NetInfo => [
933
+ {
934
+ name => 'default_gateway', type => 'String',
935
+ desc => '',
936
+ plat => ''
937
+ },
938
+ {
939
+ name => 'host_name', type => 'String',
940
+ desc => '',
941
+ plat => ''
942
+ },
943
+ {
944
+ name => 'domain_name', type => 'String',
945
+ desc => '',
946
+ plat => ''
947
+ },
948
+ {
949
+ name => 'primary_dns', type => 'String',
950
+ desc => '',
951
+ plat => ''
952
+ },
953
+ {
954
+ name => 'secondary_dns', type => 'String',
955
+ desc => '',
956
+ plat => ''
957
+ },
958
+ ],
959
+ NetRoute => [
960
+ {
961
+ name => 'destination', type => 'NetAddress',
962
+ desc => '',
963
+ plat => 'HLW'
964
+ },
965
+ {
966
+ name => 'gateway', type => 'NetAddress',
967
+ desc => '',
968
+ plat => 'HLW'
969
+ },
970
+ {
971
+ name => 'flags', type => 'Long',
972
+ desc => '',
973
+ plat => 'L'
974
+ },
975
+ {
976
+ name => 'refcnt', type => 'Long',
977
+ desc => '',
978
+ plat => 'L'
979
+ },
980
+ {
981
+ name => 'use', type => 'Long',
982
+ desc => '',
983
+ plat => 'L'
984
+ },
985
+ {
986
+ name => 'metric', type => 'Long',
987
+ desc => '',
988
+ plat => 'L'
989
+ },
990
+ {
991
+ name => 'mask', type => 'NetAddress',
992
+ desc => '',
993
+ plat => 'HL'
994
+ },
995
+ {
996
+ name => 'mtu', type => 'Long',
997
+ desc => '',
998
+ plat => 'L'
999
+ },
1000
+ {
1001
+ name => 'window', type => 'Long',
1002
+ desc => '',
1003
+ plat => 'L'
1004
+ },
1005
+ {
1006
+ name => 'irtt', type => 'Long',
1007
+ desc => '',
1008
+ plat => 'L'
1009
+ },
1010
+ {
1011
+ name => 'ifname', type => 'String',
1012
+ desc => '',
1013
+ plat => 'L'
1014
+ },
1015
+ ],
1016
+ NetInterfaceConfig => [
1017
+ {
1018
+ name => 'name', type => 'String',
1019
+ desc => '',
1020
+ plat => '*'
1021
+ },
1022
+ {
1023
+ name => 'hwaddr', type => 'NetAddress',
1024
+ desc => '',
1025
+ plat => '*'
1026
+ },
1027
+ {
1028
+ name => 'type', type => 'String',
1029
+ desc => '',
1030
+ plat => '*'
1031
+ },
1032
+ {
1033
+ name => 'description', type => 'String',
1034
+ desc => '',
1035
+ plat => '*'
1036
+ },
1037
+ {
1038
+ name => 'address', type => 'NetAddress',
1039
+ desc => '',
1040
+ plat => '*'
1041
+ },
1042
+ {
1043
+ name => 'destination', type => 'NetAddress',
1044
+ desc => '',
1045
+ plat => '*'
1046
+ },
1047
+ {
1048
+ name => 'broadcast', type => 'NetAddress',
1049
+ desc => '',
1050
+ plat => '*'
1051
+ },
1052
+ {
1053
+ name => 'netmask', type => 'NetAddress',
1054
+ desc => '',
1055
+ plat => '*'
1056
+ },
1057
+ {
1058
+ name => 'flags', type => 'Long',
1059
+ desc => '',
1060
+ plat => '*'
1061
+ },
1062
+ {
1063
+ name => 'mtu', type => 'Long',
1064
+ desc => '',
1065
+ plat => 'DFL'
1066
+ },
1067
+ {
1068
+ name => 'metric', type => 'Long',
1069
+ desc => '',
1070
+ plat => 'DFL'
1071
+ },
1072
+ ],
1073
+ NetInterfaceStat => [
1074
+ {
1075
+ name => 'rx_bytes', type => 'Long',
1076
+ desc => '',
1077
+ plat => '*'
1078
+ },
1079
+ {
1080
+ name => 'rx_packets', type => 'Long',
1081
+ desc => '',
1082
+ plat => '*'
1083
+ },
1084
+ {
1085
+ name => 'rx_errors', type => 'Long',
1086
+ desc => '',
1087
+ plat => '*'
1088
+ },
1089
+ {
1090
+ name => 'rx_dropped', type => 'Long',
1091
+ desc => '',
1092
+ plat => ''
1093
+ },
1094
+ {
1095
+ name => 'rx_overruns', type => 'Long',
1096
+ desc => '',
1097
+ plat => ''
1098
+ },
1099
+ {
1100
+ name => 'rx_frame', type => 'Long',
1101
+ desc => '',
1102
+ plat => ''
1103
+ },
1104
+ {
1105
+ name => 'tx_bytes', type => 'Long',
1106
+ desc => '',
1107
+ plat => '*'
1108
+ },
1109
+ {
1110
+ name => 'tx_packets', type => 'Long',
1111
+ desc => '',
1112
+ plat => '*'
1113
+ },
1114
+ {
1115
+ name => 'tx_errors', type => 'Long',
1116
+ desc => '*',
1117
+ plat => ''
1118
+ },
1119
+ {
1120
+ name => 'tx_dropped', type => 'Long',
1121
+ desc => '',
1122
+ plat => ''
1123
+ },
1124
+ {
1125
+ name => 'tx_overruns', type => 'Long',
1126
+ desc => '',
1127
+ plat => ''
1128
+ },
1129
+ {
1130
+ name => 'tx_collisions', type => 'Long',
1131
+ desc => '',
1132
+ plat => ''
1133
+ },
1134
+ {
1135
+ name => 'tx_carrier', type => 'Long',
1136
+ desc => '',
1137
+ plat => ''
1138
+ },
1139
+ {
1140
+ name => 'speed', type => 'Long',
1141
+ desc => '',
1142
+ plat => ''
1143
+ },
1144
+ ],
1145
+ NetConnection => [
1146
+ {
1147
+ name => 'local_port', type => 'Long',
1148
+ desc => '',
1149
+ plat => 'LFSW'
1150
+ },
1151
+ {
1152
+ name => 'local_address', type => 'NetAddress',
1153
+ desc => '',
1154
+ plat => 'LFSW'
1155
+ },
1156
+ {
1157
+ name => 'remote_port', type => 'Long',
1158
+ desc => '',
1159
+ plat => 'LFSW'
1160
+ },
1161
+ {
1162
+ name => 'remote_address', type => 'NetAddress',
1163
+ desc => '',
1164
+ plat => 'LFSW'
1165
+ },
1166
+ {
1167
+ name => 'type', type => 'Int',
1168
+ desc => '',
1169
+ plat => 'LFSW'
1170
+ },
1171
+ {
1172
+ name => 'state', type => 'Int',
1173
+ desc => '',
1174
+ plat => 'LFSW'
1175
+ },
1176
+ {
1177
+ name => 'send_queue', type => 'Long',
1178
+ desc => '',
1179
+ plat => 'LFS'
1180
+ },
1181
+ {
1182
+ name => 'receive_queue', type => 'Long',
1183
+ desc => '',
1184
+ plat => 'LFS'
1185
+ },
1186
+ ],
1187
+ #only for jfieldId cache/setters
1188
+ NetStat => [
1189
+ {
1190
+ name => 'tcp_inbound_total', type => 'Int',
1191
+ },
1192
+ {
1193
+ name => 'tcp_outbound_total', type => 'Int',
1194
+ },
1195
+ {
1196
+ name => 'all_inbound_total', type => 'Int',
1197
+ },
1198
+ {
1199
+ name => 'all_outbound_total', type => 'Int',
1200
+ },
1201
+ ],
1202
+ Tcp => [
1203
+ {
1204
+ name => 'active_opens', type => 'Long',
1205
+ desc => '',
1206
+ plat => ''
1207
+ },
1208
+ {
1209
+ name => 'passive_opens', type => 'Long',
1210
+ desc => '',
1211
+ plat => ''
1212
+ },
1213
+ {
1214
+ name => 'attempt_fails', type => 'Long',
1215
+ desc => '',
1216
+ plat => ''
1217
+ },
1218
+ {
1219
+ name => 'estab_resets', type => 'Long',
1220
+ desc => '',
1221
+ plat => ''
1222
+ },
1223
+ {
1224
+ name => 'curr_estab', type => 'Long',
1225
+ desc => '',
1226
+ plat => ''
1227
+ },
1228
+ {
1229
+ name => 'in_segs', type => 'Long',
1230
+ desc => '',
1231
+ plat => ''
1232
+ },
1233
+ {
1234
+ name => 'out_segs', type => 'Long',
1235
+ desc => '',
1236
+ plat => ''
1237
+ },
1238
+ {
1239
+ name => 'retrans_segs', type => 'Long',
1240
+ desc => '',
1241
+ plat => ''
1242
+ },
1243
+ {
1244
+ name => 'in_errs', type => 'Long',
1245
+ desc => '',
1246
+ plat => ''
1247
+ },
1248
+ {
1249
+ name => 'out_rsts', type => 'Long',
1250
+ desc => '',
1251
+ plat => ''
1252
+ },
1253
+ ],
1254
+ NfsClientV2 => $nfs_v2,
1255
+ NfsServerV2 => $nfs_v2,
1256
+ NfsClientV3 => $nfs_v3,
1257
+ NfsServerV3 => $nfs_v3,
1258
+ ResourceLimit => [
1259
+ {
1260
+ name => 'cpu_cur',
1261
+ },
1262
+ {
1263
+ name => 'cpu_max',
1264
+ },
1265
+ {
1266
+ name => 'file_size_cur',
1267
+ },
1268
+ {
1269
+ name => 'file_size_max',
1270
+ },
1271
+ {
1272
+ name => 'pipe_size_max',
1273
+ },
1274
+ {
1275
+ name => 'pipe_size_cur',
1276
+ },
1277
+ {
1278
+ name => 'data_cur',
1279
+ },
1280
+ {
1281
+ name => 'data_max',
1282
+ },
1283
+ {
1284
+ name => 'stack_cur',
1285
+ },
1286
+ {
1287
+ name => 'stack_max',
1288
+ },
1289
+ {
1290
+ name => 'core_cur',
1291
+ },
1292
+ {
1293
+ name => 'core_max',
1294
+ },
1295
+ {
1296
+ name => 'memory_cur',
1297
+ },
1298
+ {
1299
+ name => 'memory_max',
1300
+ },
1301
+ {
1302
+ name => 'processes_cur',
1303
+ },
1304
+ {
1305
+ name => 'processes_max',
1306
+ },
1307
+ {
1308
+ name => 'open_files_cur',
1309
+ },
1310
+ {
1311
+ name => 'open_files_max',
1312
+ },
1313
+ {
1314
+ name => 'virtual_memory_cur',
1315
+ },
1316
+ {
1317
+ name => 'virtual_memory_max',
1318
+ },
1319
+ ],
1320
+ SysInfo => [
1321
+ {
1322
+ name => 'name', type => 'String',
1323
+ desc => '',
1324
+ plat => '*'
1325
+ },
1326
+ {
1327
+ name => 'version', type => 'String',
1328
+ desc => '',
1329
+ plat => '*'
1330
+ },
1331
+ {
1332
+ name => 'arch', type => 'String',
1333
+ desc => '',
1334
+ plat => '*'
1335
+ },
1336
+ {
1337
+ name => 'machine', type => 'String',
1338
+ desc => '',
1339
+ plat => '*'
1340
+ },
1341
+ {
1342
+ name => 'description', type => 'String',
1343
+ desc => '',
1344
+ plat => '*'
1345
+ },
1346
+ {
1347
+ name => 'patch_level', type => 'String',
1348
+ desc => '',
1349
+ plat => 'W'
1350
+ },
1351
+ {
1352
+ name => 'vendor', type => 'String',
1353
+ desc => '',
1354
+ plat => '*'
1355
+ },
1356
+ {
1357
+ name => 'vendor_version', type => 'String',
1358
+ desc => '',
1359
+ plat => '*'
1360
+ },
1361
+ {
1362
+ name => 'vendor_name', type => 'String',
1363
+ desc => '',
1364
+ plat => '*'
1365
+ },
1366
+ {
1367
+ name => 'vendor_code_name', type => 'String',
1368
+ desc => '',
1369
+ plat => '*'
1370
+ },
1371
+ ],
1372
+ Who => [
1373
+ {
1374
+ name => 'user', type => 'String',
1375
+ desc => '',
1376
+ plat => ''
1377
+ },
1378
+ {
1379
+ name => 'device', type => 'String',
1380
+ desc => '',
1381
+ plat => ''
1382
+ },
1383
+ {
1384
+ name => 'host', type => 'String',
1385
+ desc => '',
1386
+ plat => ''
1387
+ },
1388
+ {
1389
+ name => 'time', type => 'Long',
1390
+ desc => '',
1391
+ plat => ''
1392
+ },
1393
+ ],
1394
+ );
1395
+
1396
+ $classes{DirUsage} = $classes{DirStat};
1397
+
1398
+ my(%extends) = (
1399
+ ProcCpu => 'ProcTime',
1400
+ );
1401
+
1402
+ while (my($subclass, $superclass) = each %extends) {
1403
+ push @{ $classes{$subclass} }, @{ $classes{$superclass} };
1404
+ }
1405
+
1406
+ %cmds = (
1407
+ Mem => {
1408
+ AIX => 'top',
1409
+ Darwin => 'top',
1410
+ FreeBSD => 'top',
1411
+ HPUX => 'top',
1412
+ Linux => 'top',
1413
+ Solaris => 'top',
1414
+ Win32 => 'taskman',
1415
+ },
1416
+ Swap => {
1417
+ AIX => 'top',
1418
+ Darwin => 'top',
1419
+ FreeBSD => 'top',
1420
+ HPUX => 'top',
1421
+ Linux => 'top',
1422
+ Solaris => 'top',
1423
+ Win32 => 'taskman',
1424
+ },
1425
+ Cpu => {
1426
+ AIX => 'top',
1427
+ Darwin => 'top',
1428
+ FreeBSD => 'top',
1429
+ HPUX => 'top',
1430
+ Linux => 'top',
1431
+ Solaris => 'top',
1432
+ Win32 => 'taskman',
1433
+ },
1434
+ CpuInfo => {
1435
+ AIX => 'lsattr -El proc0',
1436
+ Darwin => '',
1437
+ FreeBSD => '',
1438
+ HPUX => '',
1439
+ Linux => 'cat /proc/cpuinfo',
1440
+ Solaris => 'psrinfo -v',
1441
+ Win32 => '',
1442
+ },
1443
+ Uptime => {
1444
+ AIX => 'uptime',
1445
+ Darwin => 'uptime',
1446
+ FreeBSD => 'uptime',
1447
+ HPUX => 'uptime',
1448
+ Linux => 'uptime',
1449
+ Solaris => 'uptime',
1450
+ Win32 => '',
1451
+ },
1452
+ ProcMem => {
1453
+ AIX => 'top, ps',
1454
+ Darwin => 'top, ps',
1455
+ FreeBSD => 'top, ps',
1456
+ HPUX => 'top, ps',
1457
+ Linux => 'top, ps',
1458
+ Solaris => 'top, ps',
1459
+ Win32 => 'taskman',
1460
+ },
1461
+ ProcCred => {
1462
+ AIX => 'top, ps',
1463
+ Darwin => 'top, ps',
1464
+ FreeBSD => 'top, ps',
1465
+ HPUX => 'top, ps',
1466
+ Linux => 'top, ps',
1467
+ Solaris => 'top, ps',
1468
+ Win32 => 'taskman',
1469
+ },
1470
+ ProcTime => {
1471
+ AIX => 'top, ps',
1472
+ Darwin => 'top, ps',
1473
+ FreeBSD => 'top, ps',
1474
+ HPUX => 'top, ps',
1475
+ Linux => 'top, ps',
1476
+ Solaris => 'top, ps',
1477
+ Win32 => 'taskman',
1478
+ },
1479
+ ProcState => {
1480
+ AIX => 'top, ps',
1481
+ Darwin => 'top, ps',
1482
+ FreeBSD => 'top, ps',
1483
+ HPUX => 'top, ps',
1484
+ Linux => 'top, ps',
1485
+ Solaris => 'top, ps',
1486
+ Win32 => 'taskman',
1487
+ },
1488
+ ProcFd => {
1489
+ AIX => 'lsof',
1490
+ Darwin => 'lsof',
1491
+ FreeBSD => 'lsof',
1492
+ HPUX => 'lsof',
1493
+ Linux => 'lsof',
1494
+ Solaris => 'lsof',
1495
+ Win32 => '',
1496
+ },
1497
+ ProcStat => {
1498
+ AIX => 'top, ps',
1499
+ Darwin => 'top, ps',
1500
+ FreeBSD => 'top, ps',
1501
+ HPUX => 'top, ps',
1502
+ Linux => 'top, ps',
1503
+ Solaris => 'top, ps',
1504
+ Win32 => 'taskman',
1505
+ },
1506
+ FileSystemUsage => {
1507
+ AIX => 'df',
1508
+ Darwin => 'df',
1509
+ FreeBSD => 'df',
1510
+ HPUX => 'df',
1511
+ Linux => 'df',
1512
+ Solaris => 'df',
1513
+ Win32 => '',
1514
+ },
1515
+ NetRoute => {
1516
+ AIX => '',
1517
+ Darwin => '',
1518
+ FreeBSD => '',
1519
+ HPUX => '',
1520
+ Linux => 'route -n',
1521
+ Solaris => '',
1522
+ Win32 => '',
1523
+ },
1524
+ NetInterfaceConfig => {
1525
+ AIX => '',
1526
+ Darwin => '',
1527
+ FreeBSD => '',
1528
+ HPUX => '',
1529
+ Linux => 'ifconfig',
1530
+ Solaris => 'ifconfig -a',
1531
+ Win32 => '',
1532
+ },
1533
+ NetInterfaceStat => {
1534
+ AIX => '',
1535
+ Darwin => '',
1536
+ FreeBSD => '',
1537
+ HPUX => '/usr/sbin/lanadmin -g mibstats 0, netstat -i',
1538
+ Linux => 'ifconfig',
1539
+ Solaris => '',
1540
+ Win32 => '',
1541
+ },
1542
+ NetConnection => {
1543
+ AIX => '',
1544
+ Darwin => '',
1545
+ FreeBSD => '',
1546
+ HPUX => '',
1547
+ Linux => 'netstat',
1548
+ Solaris => '',
1549
+ Win32 => '',
1550
+ },
1551
+ Tcp => {
1552
+ Linux => 'cat /proc/net/snmp',
1553
+ Solaris => 'netstat -s -P tcp',
1554
+ },
1555
+ );
1556
+
1557
+ sub warning_comment {
1558
+ my $self = shift;
1559
+
1560
+ return "WARNING: this file was generated by $0
1561
+ on $self->{timestamp}.
1562
+ Any changes made here will be LOST.";
1563
+ }
1564
+
1565
+ sub c_warning_comment {
1566
+ my $self = shift;
1567
+ my $comment = $self->warning_comment;
1568
+ $comment =~ s/^/ * /mg;
1569
+ return <<EOF
1570
+ /*****************************************************
1571
+ $comment
1572
+ *****************************************************/
1573
+ EOF
1574
+ }
1575
+
1576
+ sub erl_warning_comment {
1577
+ my $self = shift;
1578
+ my $comment = $self->warning_comment;
1579
+ $comment =~ s/^/% /mg;
1580
+ "$comment\n";
1581
+ }
1582
+
1583
+ sub generate {
1584
+ my($lang, $dir) = @_ ? @_ : @ARGV;
1585
+
1586
+ my $mtime = (stat __FILE__)[9];
1587
+
1588
+ my $cwd = cwd();
1589
+ unless (-d $dir) {
1590
+ die "Invalid build directory '$dir'";
1591
+ }
1592
+
1593
+ chdir $dir;
1594
+ my(%param) = (
1595
+ build_dir => $dir,
1596
+ mtime => $mtime,
1597
+ );
1598
+
1599
+ my $package = __PACKAGE__ . "::$lang";
1600
+ eval "require $package";
1601
+
1602
+ unless ($package->can('new')) {
1603
+ die "unsupported language: $lang";
1604
+ }
1605
+ $@ = '';
1606
+
1607
+ my $wrapper = $package->new(%param);
1608
+ unless ($wrapper->uptodate($wrapper->sources)) {
1609
+ eval {
1610
+ $wrapper->start();
1611
+
1612
+ my $mappings = $wrapper->get_mappings;
1613
+ for my $func (@$mappings) {
1614
+ $wrapper->generate_class($func);
1615
+ }
1616
+
1617
+ $wrapper->finish;
1618
+ };
1619
+ }
1620
+ die $@ if $@;
1621
+ chdir $cwd;
1622
+ }
1623
+
1624
+ sub new {
1625
+ my $class = shift;
1626
+ return bless {
1627
+ timestamp => scalar localtime,
1628
+ @_
1629
+ }, $class;
1630
+ }
1631
+
1632
+ sub uptodate {
1633
+ my $self = shift;
1634
+ for my $file (@_) {
1635
+ my $mtime = (stat $file)[9];
1636
+ if ($mtime > $self->{mtime}) {
1637
+ print "$file up-to-date\n";
1638
+ }
1639
+ else {
1640
+ print "$file needs update\n";
1641
+ return 0;
1642
+ }
1643
+ }
1644
+ return 1;
1645
+ }
1646
+
1647
+ my(%warning_comment) =
1648
+ ((map { $_ => \&c_warning_comment } qw(c h java)),
1649
+ (map { $_ => \&erl_warning_comment } qw(erl hrl)));
1650
+
1651
+ sub create {
1652
+ my($self, $file) = @_;
1653
+ my $handle = SigarWrapper::File->create($file);
1654
+ if ($file =~ /\.(\w+)$/) {
1655
+ my $comment = $warning_comment{$1};
1656
+ $handle->print($self->$comment()) if $comment;
1657
+ }
1658
+ return $self->{files}->{$file} = $handle;
1659
+ }
1660
+
1661
+ sub start {
1662
+ }
1663
+
1664
+ sub finish {
1665
+ my $self = shift;
1666
+ while (my($file, $handle) = each %{ $self->{files} }) {
1667
+ next unless $handle->opened;
1668
+ if ($handle->close) {
1669
+ #print "closing $file\n";
1670
+ }
1671
+ else {
1672
+ warn "close($file): $!";
1673
+ }
1674
+ }
1675
+ }
1676
+
1677
+ my @mappings;
1678
+
1679
+ sub get_mappings {
1680
+ if (@mappings != 0) {
1681
+ return \@mappings;
1682
+ }
1683
+
1684
+ while (my($name, $fields) = each %classes) {
1685
+ #example: FileSystemUsage -> file_system_usage
1686
+ (my $cname = $name) =~ s/([a-z])([A-Z])/$1_$2/g;
1687
+ $cname = lc $cname;
1688
+
1689
+ my $func = {
1690
+ name => $name,
1691
+ cname => $cname,
1692
+ };
1693
+ push @mappings, $func;
1694
+
1695
+ if (($cname =~ /^proc_(\w+)/ and !$proc_no_arg{$1}) ||
1696
+ ($cname =~ /^thread_cpu/))
1697
+ {
1698
+ $func->{num_args} = 1;
1699
+ $func->{arg_type} = 'sigar_pid_t';
1700
+ $func->{arg} = 'pid';
1701
+ $func->{is_proc} = 1;
1702
+ }
1703
+ elsif ($has_name_arg{$name}) {
1704
+ $func->{num_args} = 1;
1705
+ $func->{arg_type} = 'const char *';
1706
+ $func->{arg} = 'name';
1707
+ }
1708
+ else {
1709
+ $func->{num_args} = 0;
1710
+ }
1711
+
1712
+ if ($get_not_impl{$cname}) {
1713
+ $func->{has_get} = 0;
1714
+ }
1715
+ else {
1716
+ $func->{has_get} = 1;
1717
+ }
1718
+
1719
+ my $sigar_prefix = $func->{sigar_prefix} = join '_', 'sigar', $cname;
1720
+
1721
+ $func->{sigar_function} = join '_', $sigar_prefix, 'get';
1722
+
1723
+ $func->{sigar_type} = join '_', $sigar_prefix, 't';
1724
+
1725
+ $func->{fields} = $fields;
1726
+
1727
+ for my $field (@$fields) {
1728
+ $field->{type} ||= 'Long';
1729
+ }
1730
+ }
1731
+
1732
+ return \@mappings;
1733
+ }
1734
+
1735
+ package SigarWrapper::File;
1736
+
1737
+ use vars qw(@ISA);
1738
+ @ISA = qw(IO::File);
1739
+
1740
+ my $DEVNULL = '/dev/null';
1741
+ my $has_dev_null = -e $DEVNULL;
1742
+
1743
+ sub println {
1744
+ shift->print(@_, "\n");
1745
+ }
1746
+
1747
+ sub create {
1748
+ my($class, $file) = @_;
1749
+
1750
+ my $handle = $class->SUPER::new($file || devnull(), "w") or die "open $file: $!";
1751
+ print "generating $file\n" if $file;
1752
+ return $handle;
1753
+ }
1754
+
1755
+ sub devnull {
1756
+ if ($has_dev_null) {
1757
+ return $DEVNULL;
1758
+ }
1759
+ else {
1760
+ return "./nul"; #win32 /dev/null equiv
1761
+ }
1762
+ }
1763
+
1764
+ package SigarWrapper::Java;
1765
+
1766
+ use vars qw(@ISA);
1767
+ @ISA = qw(SigarWrapper);
1768
+
1769
+ my %field_types = (
1770
+ Long => "J",
1771
+ Double => "D",
1772
+ Int => "I",
1773
+ Char => "C",
1774
+ String => "Ljava/lang/String;",
1775
+ );
1776
+
1777
+ my %init = (
1778
+ String => 'null',
1779
+ );
1780
+
1781
+ my %type = (
1782
+ String => 'String',
1783
+ );
1784
+
1785
+ #alias
1786
+ for my $j (\%field_types, \%init, \%type) {
1787
+ $j->{'NetAddress'} = $j->{'String'};
1788
+ }
1789
+
1790
+ #XXX kinda ugly having this here
1791
+ #will consider moving elsewhere if there
1792
+ #are more cases like this.
1793
+ my %extra_code = (
1794
+ FileSystem => <<'EOF',
1795
+ public static final int TYPE_UNKNOWN = 0;
1796
+ public static final int TYPE_NONE = 1;
1797
+ public static final int TYPE_LOCAL_DISK = 2;
1798
+ public static final int TYPE_NETWORK = 3;
1799
+ public static final int TYPE_RAM_DISK = 4;
1800
+ public static final int TYPE_CDROM = 5;
1801
+ public static final int TYPE_SWAP = 6;
1802
+
1803
+ public String toString() {
1804
+ return this.getDirName();
1805
+ }
1806
+ EOF
1807
+ NetConnection => <<'EOF',
1808
+ public native String getTypeString();
1809
+
1810
+ public native static String getStateString(int state);
1811
+
1812
+ public String getStateString() {
1813
+ return getStateString(this.state);
1814
+ }
1815
+ EOF
1816
+ Mem => <<'EOF',
1817
+ public String toString() {
1818
+ return
1819
+ "Mem: " +
1820
+ (this.total / 1024) + "K av, " +
1821
+ (this.used / 1024) + "K used, " +
1822
+ (this.free / 1024) + "K free";
1823
+ }
1824
+ EOF
1825
+ ResourceLimit => <<'EOF',
1826
+ public static native long INFINITY();
1827
+ EOF
1828
+ Swap => <<'EOF',
1829
+ public String toString() {
1830
+ return
1831
+ "Swap: " +
1832
+ (this.total / 1024) + "K av, " +
1833
+ (this.used / 1024) + "K used, " +
1834
+ (this.free / 1024) + "K free";
1835
+ }
1836
+ EOF
1837
+ ProcState => <<'EOF',
1838
+ public static final char SLEEP = 'S';
1839
+ public static final char RUN = 'R';
1840
+ public static final char STOP = 'T';
1841
+ public static final char ZOMBIE = 'Z';
1842
+ public static final char IDLE = 'D';
1843
+ EOF
1844
+ ProcMem => <<'EOF',
1845
+ /**
1846
+ * @deprecated
1847
+ * @see #getResident()
1848
+ */
1849
+ public long getRss() { return getResident(); }
1850
+ /**
1851
+ * @deprecated
1852
+ * @see #getSize()
1853
+ */
1854
+ public long getVsize() { return getSize(); }
1855
+ EOF
1856
+ );
1857
+
1858
+ sub new {
1859
+ my $class = shift;
1860
+ my $self = $class->SUPER::new(@_);
1861
+ $self->{jsrc} = 'org/hyperic/sigar';
1862
+ return $self;
1863
+ }
1864
+
1865
+ my $jni_file = 'javasigar_generated';
1866
+
1867
+ sub sources {
1868
+ return map { "$jni_file.$_" } qw(c h);
1869
+ }
1870
+
1871
+ sub start {
1872
+ my $self = shift;
1873
+ $self->SUPER::start;
1874
+ my $jsrc = $self->{jsrc};
1875
+ File::Path::mkpath([$jsrc], 0, 0755) unless -d $jsrc;
1876
+ $self->{package} = 'org.hyperic.sigar';
1877
+
1878
+ $self->{cfh} = $self->create("$jni_file.c");
1879
+ my $hfh = $self->{hfh} = $self->create("$jni_file.h");
1880
+
1881
+ my %field_cache;
1882
+ my $i = 0;
1883
+ while (my($class, $fields) = each %SigarWrapper::classes) {
1884
+ next if $field_cache{$class}++;
1885
+ print $hfh "#define JSIGAR_FIELDS_\U$class $i\n";
1886
+ $i++;
1887
+ my $n = 0;
1888
+ for my $field (@$fields) {
1889
+ my $name = $field->{name};
1890
+ print $hfh "# define JSIGAR_FIELDS_\U${class}_${name} $n\n";
1891
+ $n++;
1892
+ }
1893
+ print $hfh "# define JSIGAR_FIELDS_\U${class}_MAX $n\n";
1894
+ }
1895
+ print $hfh "#define JSIGAR_FIELDS_MAX $i\n";
1896
+ }
1897
+
1898
+ sub jname {
1899
+ my $jname = shift;
1900
+ #special case for nfs
1901
+ return $jname eq 'null' ? "_$jname" : $jname;
1902
+ }
1903
+
1904
+ #using mega-method pattern here
1905
+ sub generate_class {
1906
+ my($self, $func) = @_;
1907
+
1908
+ my $cfh = $self->{cfh};
1909
+ my $hfh = $self->{hfh};
1910
+
1911
+ my $class = $func->{name};
1912
+ my $cname = $func->{cname};
1913
+
1914
+ my $java_class = "$self->{package}.$class";
1915
+ (my $jni_prefix = "Java.$java_class") =~ s/\./_/g;
1916
+
1917
+ my $args_proto = "";
1918
+ my $args = "";
1919
+ my $decl_string = "";
1920
+ my $get_string = "";
1921
+ my $release_string = "";
1922
+
1923
+ my $jname = lcfirst $class;
1924
+
1925
+ if ($func->{num_args} == 1) {
1926
+ $args = " $func->{arg}, ";
1927
+ if ($func->{is_proc}) {
1928
+ $args_proto = ", jlong pid";
1929
+ }
1930
+ else {
1931
+ $args_proto = ", jstring jname";
1932
+ $decl_string = "const char *name;";
1933
+ $get_string = "name = jname ? JENV->GetStringUTFChars(env, jname, 0) : NULL;";
1934
+ $release_string = "if (jname) JENV->ReleaseStringUTFChars(env, jname, name);";
1935
+ }
1936
+ }
1937
+
1938
+ my $nativefunc = join '_', $jni_prefix, 'gather';
1939
+
1940
+ my $proto = join "\n",
1941
+ "JNIEXPORT void JNICALL $nativefunc",
1942
+ "(JNIEnv *env, jobject obj, jobject sigar_obj$args_proto)";
1943
+
1944
+ my $jfh = $self->create_jfile($class);
1945
+
1946
+ print $cfh <<EOF if $func->{has_get};
1947
+
1948
+ $proto;
1949
+
1950
+ $proto
1951
+ {
1952
+ $func->{sigar_type} s;
1953
+ int status;
1954
+ jclass cls = JENV->GetObjectClass(env, obj);
1955
+ $decl_string
1956
+ dSIGAR_VOID;
1957
+
1958
+ $get_string
1959
+
1960
+ status = $func->{sigar_function}(sigar,${args}&s);
1961
+
1962
+ $release_string
1963
+
1964
+ if (status != SIGAR_OK) {
1965
+ sigar_throw_error(env, jsigar, status);
1966
+ return;
1967
+ }
1968
+
1969
+ EOF
1970
+
1971
+ my $jargs_proto = 'Sigar sigar';
1972
+ my $jargs = 'sigar';
1973
+
1974
+ if ($func->{is_proc}) {
1975
+ $jargs_proto .= ', long pid';
1976
+ $jargs .= ", pid";
1977
+ }
1978
+ elsif ($func->{num_args} == 1) {
1979
+ $jargs_proto .= ', String name';
1980
+ $jargs .= ", name";
1981
+ }
1982
+
1983
+ my $cache_field_ids = 1;
1984
+
1985
+ my $uid = 0;
1986
+
1987
+ for my $field (@{ $func->{fields} }) {
1988
+ $uid +=
1989
+ SigarWrapper::hash($field->{type}) +
1990
+ SigarWrapper::hash($field->{name});
1991
+ }
1992
+
1993
+ print $jfh <<EOF;
1994
+ package $self->{package};
1995
+
1996
+ import java.util.HashMap;
1997
+ import java.util.Map;
1998
+
1999
+ /**
2000
+ * $class sigar class.
2001
+ */
2002
+ public class $class implements java.io.Serializable {
2003
+
2004
+ private static final long serialVersionUID = ${uid}L;
2005
+
2006
+ public $class() { }
2007
+
2008
+ public native void gather($jargs_proto) throws SigarException;
2009
+
2010
+ /**
2011
+ * This method is not intended to be called directly.
2012
+ * use Sigar.get$class() instead.
2013
+ * \@exception SigarException on failure.
2014
+ * \@see $self->{package}.Sigar#get$class
2015
+ */
2016
+ static $class fetch($jargs_proto) throws SigarException {
2017
+ $class $jname = new $class();
2018
+ $jname.gather($jargs);
2019
+ return $jname;
2020
+ }
2021
+
2022
+ EOF
2023
+
2024
+ my(@copy, @tostring);
2025
+ my $setter = "JAVA_SIGAR_SET_FIELDS_\U$class";
2026
+ my $getter = "JAVA_SIGAR_GET_FIELDS_\U$class";
2027
+ my @setter = ("\#define $setter(cls, obj, s)");
2028
+ my @getter = ("\#define $getter(obj, s)");
2029
+ my $init_define = "JAVA_SIGAR_INIT_FIELDS_\U$class";
2030
+ my $field_class_ix = "JSIGAR_FIELDS_\U$class";
2031
+ my $field_class_ix = "JSIGAR_FIELDS_\U$class";
2032
+ my $field_class_max = $field_class_ix . '_MAX';
2033
+ my $field_class = "jsigar->fields[$field_class_ix]";
2034
+
2035
+ my @init_fields = ("#define $init_define(cls)",
2036
+ " if (!$field_class) {",
2037
+ " $field_class = ",
2038
+ " malloc(sizeof(*$field_class));",
2039
+ " $field_class->classref = ",
2040
+ " (jclass)JENV->NewGlobalRef(env, cls);",
2041
+ " $field_class->ids = ",
2042
+ " malloc($field_class_max *",
2043
+ " sizeof(*$field_class->ids));");
2044
+
2045
+ for my $field (@{ $func->{fields} }) {
2046
+ my $type = $field->{type};
2047
+ my $name = $field->{name};
2048
+ my $member = $field->{member} || $name;
2049
+ my $desc = $field->{desc} || $name;
2050
+ (my $jname = $name) =~ s/_(\w)/\u$1/g;
2051
+ my $getter = "get\u$jname";
2052
+ $jname = jname($jname);
2053
+ my $sig = qq("$field_types{$type}");
2054
+ my $set = "JENV->Set${type}Field";
2055
+ my $get = "JENV->Get${type}Field";
2056
+
2057
+ my $field_ix = $field_class_ix . "_\U$name";
2058
+ my $get_id = qq|JENV->GetFieldID(env, cls, "$jname", $sig)|;
2059
+ my $id_cache = "$field_class->ids[$field_ix]";
2060
+
2061
+ my $id_lookup = $cache_field_ids ?
2062
+ $id_cache : $get_id;
2063
+
2064
+ push @init_fields,
2065
+ " $id_cache = ",
2066
+ " $get_id;";
2067
+
2068
+ push @setter,
2069
+ qq| $set(env, obj, $id_lookup, s.$member);|;
2070
+ push @getter,
2071
+ qq| s.$member = $get(env, obj, $id_lookup);|;
2072
+
2073
+ my $init = $init{$type} || '0';
2074
+ my $jtype = $type{$type} || lcfirst($type);
2075
+ my $platforms = SigarWrapper::supported_platforms($field->{plat});
2076
+
2077
+ print $jfh " $jtype $jname = $init;\n\n";
2078
+ push @copy, " copy.$jname = this.$jname;\n";
2079
+ push @tostring, $jname;
2080
+
2081
+ #documentation
2082
+ print $jfh " /**\n";
2083
+ print $jfh " * Get the $desc.<p>\n";
2084
+ print $jfh " * Supported Platforms: $platforms.\n";
2085
+ print $jfh " * <p>\n";
2086
+ if (my $cmd = ($field->{cmd} || $SigarWrapper::cmds{$class})) {
2087
+ print $jfh " * System equivalent commands:<ul>\n";
2088
+ for my $p (sort keys %$cmd) {
2089
+ print $jfh " * <li> $p: <code>$cmd->{$p}</code><br>\n";
2090
+ }
2091
+ print $jfh " * </ul>\n";
2092
+ }
2093
+ print $jfh " * \@return $desc\n";
2094
+ print $jfh " */\n";
2095
+
2096
+ print $jfh " public $jtype $getter() { return $jname; }\n";
2097
+ }
2098
+
2099
+ print $jfh "\n void copyTo($class copy) {\n", @copy, " }\n";
2100
+
2101
+ my $code = $extra_code{$class};
2102
+ if ($code) {
2103
+ print $jfh $code;
2104
+ }
2105
+
2106
+ my $num_fields = @tostring;
2107
+ print $jfh "\n public Map toMap() {\n";
2108
+ print $jfh " Map map = new HashMap();\n";
2109
+ for (my $i=0; $i<$num_fields; $i++) {
2110
+ my $jfield = $tostring[$i];
2111
+ my $sfield = "str${jfield}";
2112
+ print $jfh " String $sfield = \n";
2113
+ print $jfh " String.valueOf(this.$jfield);\n";
2114
+ print $jfh qq{ if (!"-1".equals($sfield))\n};
2115
+ print $jfh qq{ map.put("\u$jfield", $sfield);\n};
2116
+ }
2117
+ print $jfh " return map;\n";
2118
+ print $jfh " }\n";
2119
+
2120
+ if (!$code or $code !~ /toString/) {
2121
+ print $jfh "\n public String toString() {\n";
2122
+ print $jfh " return toMap().toString();\n";
2123
+ print $jfh " }\n";
2124
+ }
2125
+
2126
+ push @init_fields, " }";
2127
+
2128
+ if ($cache_field_ids) {
2129
+ print $hfh join(' \\' . "\n", @init_fields), "\n\n";
2130
+ print $cfh "\n\n $init_define(cls);\n\n" if $func->{has_get};
2131
+ }
2132
+ else {
2133
+ print $hfh "#define $init_define(cls)\n";
2134
+ }
2135
+
2136
+ print $hfh join(' \\' . "\n", @setter), "\n\n";
2137
+ print $hfh join(' \\' . "\n", @getter), "\n\n";
2138
+ print $cfh "\n\n $setter(cls, obj, s);" if $func->{has_get};
2139
+
2140
+ print $cfh "\n}\n" if $func->{has_get};
2141
+ print $jfh "\n}\n";
2142
+
2143
+ close $jfh;
2144
+ }
2145
+
2146
+ sub finish {
2147
+ my $self = shift;
2148
+ $self->SUPER::finish;
2149
+ }
2150
+
2151
+ sub create_jfile {
2152
+ my($self, $name) = @_;
2153
+ my $jsrc = $self->{jsrc};
2154
+ my $jfile = "$jsrc/$name.java";
2155
+ if (-e "../../src/$jsrc/$name.java") {
2156
+ print "skipping $jfile\n";
2157
+ #dont generate .java if already exists
2158
+ $jfile = undef;
2159
+ }
2160
+ return $self->create($jfile);
2161
+ }
2162
+
2163
+ package SigarWrapper::Perl;
2164
+
2165
+ use vars qw(@ISA);
2166
+ @ISA = qw(SigarWrapper);
2167
+
2168
+ my %field_types = (
2169
+ Long => "sigar_uint64_t",
2170
+ Double => "double",
2171
+ Int => "IV",
2172
+ Char => "char",
2173
+ String => "char *",
2174
+ NetAddress => "Sigar::NetAddress",
2175
+ );
2176
+
2177
+ my $xs_file = 'Sigar_generated.xs';
2178
+
2179
+ sub sources {
2180
+ return $xs_file;
2181
+ }
2182
+
2183
+ sub start {
2184
+ my $self = shift;
2185
+ $self->SUPER::start;
2186
+ $self->{xfh} = $self->create($xs_file);
2187
+ }
2188
+
2189
+ sub generate_class {
2190
+ my($self, $func) = @_;
2191
+
2192
+ my $fh = $self->{xfh};
2193
+ my $class = $func->{name};
2194
+ my $cname = $func->{cname};
2195
+ my $perl_class = "Sigar::$class";
2196
+ my $proto = 'VALUE obj';
2197
+ my $args = 'sigar';
2198
+
2199
+ if ($func->{num_args} == 1) {
2200
+ $args .= ", $func->{arg}";
2201
+ }
2202
+
2203
+ print $fh "\nMODULE = Sigar PACKAGE = Sigar PREFIX = sigar_\n\n";
2204
+
2205
+ print $fh <<EOF if $func->{has_get};
2206
+ $perl_class
2207
+ $cname($args)
2208
+ Sigar sigar
2209
+ EOF
2210
+ if ($func->{arg}) {
2211
+ print $fh " $func->{arg_type} $func->{arg}\n" if $func->{has_get};
2212
+ }
2213
+
2214
+ print $fh <<EOF if $func->{has_get};
2215
+
2216
+ PREINIT:
2217
+ int status;
2218
+
2219
+ CODE:
2220
+ RETVAL = safemalloc(sizeof(*RETVAL));
2221
+ if ((status = $func->{sigar_function}($args, RETVAL)) != SIGAR_OK) {
2222
+ SIGAR_CROAK(sigar, "$cname");
2223
+ }
2224
+
2225
+ OUTPUT:
2226
+ RETVAL
2227
+ EOF
2228
+
2229
+ print $fh <<EOF;
2230
+
2231
+ MODULE = Sigar PACKAGE = $perl_class PREFIX = sigar_
2232
+
2233
+ void
2234
+ DESTROY(obj)
2235
+ $perl_class obj
2236
+
2237
+ CODE:
2238
+ safefree(obj);
2239
+
2240
+ EOF
2241
+
2242
+ for my $field (@{ $func->{fields} }) {
2243
+ my $name = $field->{name};
2244
+ my $type = $field_types{ $field->{type} };
2245
+
2246
+ print $fh <<EOF;
2247
+ $type
2248
+ $name($cname)
2249
+ $perl_class $cname
2250
+
2251
+ CODE:
2252
+ RETVAL = $cname->$name;
2253
+
2254
+ OUTPUT:
2255
+ RETVAL
2256
+
2257
+ EOF
2258
+ }
2259
+ }
2260
+
2261
+ sub finish {
2262
+ my $self = shift;
2263
+ $self->SUPER::finish;
2264
+ }
2265
+
2266
+ package SigarWrapper::Ruby;
2267
+
2268
+ use vars qw(@ISA);
2269
+ @ISA = qw(SigarWrapper);
2270
+
2271
+ my %field_types = (
2272
+ Long => "rb_ll2inum",
2273
+ Double => "rb_float_new",
2274
+ Int => "rb_int2inum",
2275
+ Char => "CHR2FIX",
2276
+ String => "rb_str_new2",
2277
+ NetAddress => "rb_sigar_net_address_to_s",
2278
+ );
2279
+
2280
+ my $rx_file = 'rbsigar_generated.rx';
2281
+
2282
+ sub sources {
2283
+ return $rx_file;
2284
+ }
2285
+
2286
+ sub start {
2287
+ my $self = shift;
2288
+ $self->SUPER::start;
2289
+ $self->{cfh} = $self->create($rx_file);
2290
+ }
2291
+
2292
+ sub add_method {
2293
+ my($self, $class, $name) = @_;
2294
+ push @{ $self->{methods}->{$class} }, $name;
2295
+ }
2296
+
2297
+ sub generate_class {
2298
+ my($self, $func) = @_;
2299
+
2300
+ my $fh = $self->{cfh};
2301
+ my $class = $func->{name};
2302
+ my $cname = $func->{cname};
2303
+ my $ruby_class = "rb_cSigar$class";
2304
+ my $proto = 'VALUE obj';
2305
+ my $args = 'sigar';
2306
+
2307
+ if ($func->{num_args} == 1) {
2308
+ my $arg_type;
2309
+ if ($func->{is_proc}) {
2310
+ $arg_type = 'OBJ2PID';
2311
+ }
2312
+ else {
2313
+ $arg_type = 'StringValuePtr';
2314
+ }
2315
+ $proto .= ", VALUE $func->{arg}";
2316
+ $args .= ", $arg_type($func->{arg})";
2317
+ }
2318
+
2319
+ print $fh <<EOF if $func->{has_get};
2320
+ static VALUE $ruby_class;
2321
+
2322
+ static VALUE rb_sigar_$cname($proto)
2323
+ {
2324
+ int status;
2325
+ sigar_t *sigar = rb_sigar_get(obj);
2326
+ $func->{sigar_type} *RETVAL = malloc(sizeof(*RETVAL));
2327
+
2328
+ if ((status = $func->{sigar_function}($args, RETVAL)) != SIGAR_OK) {
2329
+ free(RETVAL);
2330
+ rb_raise(rb_eArgError, "%s", sigar_strerror(sigar, status));
2331
+ return Qnil;
2332
+ }
2333
+
2334
+ return Data_Wrap_Struct($ruby_class, 0, rb_sigar_free, RETVAL);
2335
+ }
2336
+ EOF
2337
+
2338
+ for my $field (@{ $func->{fields} }) {
2339
+ my $name = $field->{name};
2340
+ my $type = $field_types{ $field->{type} };
2341
+
2342
+ $self->add_method($class, $name);
2343
+
2344
+ print $fh <<EOF;
2345
+ static VALUE rb_sigar_${class}_${name}(VALUE self)
2346
+ {
2347
+ $func->{sigar_type} *$cname;
2348
+ Data_Get_Struct(self, $func->{sigar_type}, $cname);
2349
+ return $type($cname->$name);
2350
+ }
2351
+ EOF
2352
+ }
2353
+ }
2354
+
2355
+ sub finish {
2356
+ my $self = shift;
2357
+
2358
+ my $fh = $self->{cfh};
2359
+
2360
+ print $fh "static void rb_sigar_define_module_methods(VALUE rclass)\n{\n";
2361
+
2362
+ my $mappings = SigarWrapper::get_mappings();
2363
+
2364
+ for my $func (@$mappings) {
2365
+ my $name = $func->{cname};
2366
+ my $args = $func->{num_args};
2367
+ next unless $func->{has_get};
2368
+ print $fh qq{ rb_define_method(rclass, "$name", rb_sigar_$name, $args);\n};
2369
+ }
2370
+
2371
+ for my $class (sort keys %{ $self->{methods} }) {
2372
+ my $rclass = "rb_cSigar$class";
2373
+ print $fh qq{ $rclass = rb_define_class_under(rclass, "$class", rb_cObject);\n};
2374
+ for my $method (@{ $self->{methods}->{$class} }) {
2375
+ print $fh qq{ rb_define_method($rclass, "$method", rb_sigar_${class}_$method, 0);\n};
2376
+ }
2377
+ }
2378
+
2379
+ print $fh "}\n";
2380
+
2381
+ $self->SUPER::finish;
2382
+ }
2383
+
2384
+ package SigarWrapper::PHP;
2385
+
2386
+ use vars qw(@ISA);
2387
+ @ISA = qw(SigarWrapper);
2388
+
2389
+ my %field_types = (
2390
+ Long => "RETURN_LONG",
2391
+ Double => "RETURN_DOUBLE",
2392
+ Int => "RETURN_LONG",
2393
+ Char => "RETURN_LONG",
2394
+ String => "PHP_SIGAR_RETURN_STRING",
2395
+ NetAddress => "PHP_SIGAR_RETURN_NETADDR",
2396
+ );
2397
+
2398
+ my $php_file = 'php_sigar_generated.c';
2399
+
2400
+ sub sources {
2401
+ return $php_file;
2402
+ }
2403
+
2404
+ sub start {
2405
+ my $self = shift;
2406
+ $self->SUPER::start;
2407
+ $self->{cfh} = $self->create($php_file);
2408
+ }
2409
+
2410
+ sub generate_class {
2411
+ my($self, $func) = @_;
2412
+
2413
+ my $cfh = $self->{cfh};
2414
+ my $class = $func->{name};
2415
+ my $cname = $func->{cname};
2416
+ my $php_class = "Sigar::$class";
2417
+ my $parse_args = "";
2418
+ my $vars = "";
2419
+ my $args = 'sigar';
2420
+ my $arginfo = $args;
2421
+
2422
+ if ($func->{num_args} == 1) {
2423
+ if ($func->{is_proc}) {
2424
+ $parse_args = 'zSIGAR_PARSE_PID;';
2425
+ $arginfo .= '_pid';
2426
+ $vars = "long $func->{arg};\n";
2427
+ }
2428
+ else {
2429
+ $parse_args .= 'zSIGAR_PARSE_NAME;';
2430
+ $arginfo .= '_name';
2431
+ $vars = "char *$func->{arg}; int $func->{arg}_len;\n";
2432
+ }
2433
+ $args .= ", $func->{arg}";
2434
+ }
2435
+
2436
+ my $prefix = "php_$func->{sigar_prefix}_";
2437
+ my $functions = $prefix . 'functions';
2438
+ my $handlers = $prefix . 'object_handlers';
2439
+ my $init = $prefix . 'init';
2440
+
2441
+ my $ctor = $prefix . 'new';
2442
+
2443
+ my(@functions);
2444
+
2445
+ for my $field (@{ $func->{fields} }) {
2446
+ my $name = $field->{name};
2447
+ my $type = $field_types{ $field->{type} };
2448
+ my $method = $prefix . $name;
2449
+
2450
+ push @functions, { name => $name, me => $method };
2451
+ print $cfh <<EOF;
2452
+ static PHP_FUNCTION($method)
2453
+ {
2454
+ $func->{sigar_type} *$cname = ($func->{sigar_type} *)zSIGAR_OBJ;
2455
+ $type($cname->$name);
2456
+ }
2457
+ EOF
2458
+ }
2459
+
2460
+ print $cfh <<EOF;
2461
+ static zend_object_handlers $handlers;
2462
+
2463
+ static zend_object_value $ctor(zend_class_entry *class_type TSRMLS_DC)
2464
+ {
2465
+ return php_sigar_ctor(php_sigar_obj_dtor,
2466
+ &$handlers,
2467
+ NULL,
2468
+ class_type);
2469
+ }
2470
+
2471
+ static zend_function_entry ${functions}[] = {
2472
+ EOF
2473
+
2474
+ for my $func (@functions) {
2475
+ print $cfh " PHP_ME_MAPPING($func->{name}, $func->{me}, NULL)\n";
2476
+ }
2477
+
2478
+ print $cfh <<EOF;
2479
+ {NULL, NULL, NULL}
2480
+ };
2481
+ EOF
2482
+
2483
+ print $cfh <<EOF;
2484
+ static void $init(void)
2485
+ {
2486
+ zend_class_entry ce;
2487
+
2488
+ PHP_SIGAR_INIT_HANDLERS($handlers);
2489
+ INIT_CLASS_ENTRY(ce, "$php_class", $functions);
2490
+ ce.create_object = $ctor;
2491
+ zend_register_internal_class(&ce TSRMLS_CC);
2492
+ }
2493
+ EOF
2494
+
2495
+ print $cfh <<EOF if $func->{has_get};
2496
+ static PHP_FUNCTION($func->{sigar_function})
2497
+ {
2498
+ int status;
2499
+ zSIGAR;
2500
+
2501
+ $func->{sigar_type} *RETVAL = emalloc(sizeof(*RETVAL));
2502
+ $vars
2503
+ $parse_args
2504
+
2505
+ if ((status = $func->{sigar_function}($args, RETVAL)) != SIGAR_OK) {
2506
+ efree(RETVAL);
2507
+ RETURN_FALSE;
2508
+ }
2509
+ else {
2510
+ php_sigar_obj_new("$php_class", return_value)->ptr = RETVAL;
2511
+ }
2512
+ }
2513
+ EOF
2514
+ }
2515
+
2516
+ sub finish {
2517
+ my $self = shift;
2518
+
2519
+ my $mappings = $self->get_mappings;
2520
+ my $cfh = $self->{cfh};
2521
+ my $nl = '\\' . "\n";
2522
+
2523
+ print $cfh "#define PHP_SIGAR_FUNCTIONS $nl";
2524
+ for my $func (@$mappings) {
2525
+ next unless $func->{has_get};
2526
+ #XXX PHP_ME_MAPPING has another arg in 5.2
2527
+ print $cfh " PHP_ME_MAPPING($func->{cname}, $func->{sigar_function}, NULL)";
2528
+ if ($func == $mappings->[-1]) {
2529
+ print $cfh "\n";
2530
+ }
2531
+ else {
2532
+ print $cfh $nl;
2533
+ }
2534
+ }
2535
+
2536
+ print $cfh "#define PHP_SIGAR_INIT $nl";
2537
+ for my $func (@$mappings) {
2538
+ print $cfh " php_$func->{sigar_prefix}_init()";
2539
+ if ($func == $mappings->[-1]) {
2540
+ print $cfh "\n";
2541
+ }
2542
+ else {
2543
+ print $cfh ";$nl";
2544
+ }
2545
+ }
2546
+
2547
+ $self->SUPER::finish;
2548
+ }
2549
+
2550
+ package SigarWrapper::Python;
2551
+
2552
+ use vars qw(@ISA);
2553
+ @ISA = qw(SigarWrapper);
2554
+
2555
+ my %field_types = (
2556
+ Long => "PyLong_FromUnsignedLongLong",
2557
+ Double => "PyFloat_FromDouble",
2558
+ Int => "PyInt_FromLong",
2559
+ Char => "PySigarInt_FromChar",
2560
+ String => "PyString_FromString",
2561
+ NetAddress => "PySigarString_FromNetAddr",
2562
+ );
2563
+
2564
+ my $c_file = '_sigar_generated.c';
2565
+
2566
+ sub sources {
2567
+ return $c_file;
2568
+ }
2569
+
2570
+ sub start {
2571
+ my $self = shift;
2572
+ $self->SUPER::start;
2573
+ $self->{cfh} = $self->create($c_file);
2574
+ }
2575
+
2576
+ sub pyclass {
2577
+ my $class = shift;
2578
+ return "Sigar.$class";
2579
+ }
2580
+
2581
+ sub pytype {
2582
+ my $class = shift;
2583
+ return 'pysigar_PySigar' . $class . 'Type';
2584
+ }
2585
+
2586
+ sub generate_class {
2587
+ my($self, $func) = @_;
2588
+
2589
+ my $cfh = $self->{cfh};
2590
+ my $pyclass = pyclass($func->{name});
2591
+ my $pytype = pytype($func->{name});
2592
+ my $cname = $func->{cname};
2593
+ my $parse_args = "";
2594
+ my $vars = "";
2595
+ my $args = 'sigar';
2596
+
2597
+ if ($func->{num_args} == 1) {
2598
+ if ($func->{is_proc}) {
2599
+ $parse_args = 'PySigar_ParsePID;';
2600
+ $vars = "long $func->{arg};\n";
2601
+ }
2602
+ else {
2603
+ $parse_args .= 'PySigar_ParseName;';
2604
+ $vars = "char *$func->{arg}; int $func->{arg}_len;\n";
2605
+ }
2606
+ $args .= ", $func->{arg}";
2607
+ }
2608
+
2609
+ my $prefix = "py$func->{sigar_prefix}_";
2610
+ my $methods = $prefix . 'methods';
2611
+ my $dtor = 'pysigar_free';
2612
+
2613
+ for my $field (@{ $func->{fields} }) {
2614
+ my $name = $field->{name};
2615
+ my $type = $field_types{ $field->{type} };
2616
+ my $method = $prefix . $name;
2617
+
2618
+ print $cfh <<EOF;
2619
+ static PyObject *$method(PyObject *self, PyObject *args)
2620
+ {
2621
+ $func->{sigar_type} *$cname = ($func->{sigar_type} *)PySIGAR_OBJ->ptr;
2622
+ return $type($cname->$name);
2623
+ }
2624
+ EOF
2625
+ }
2626
+
2627
+ print $cfh "static PyMethodDef $methods [] = {\n";
2628
+ for my $field (@{ $func->{fields} }) {
2629
+ my $name = $field->{name};
2630
+ print $cfh qq( { "$name", ${prefix}$name, METH_NOARGS, "$name" },\n);
2631
+ }
2632
+ print $cfh " {NULL}\n};\n";
2633
+
2634
+ print $cfh <<EOF;
2635
+ static PyTypeObject $pytype = {
2636
+ PyObject_HEAD_INIT(NULL)
2637
+ 0, /*ob_size*/
2638
+ "$pyclass", /*tp_name*/
2639
+ sizeof(PySigarObject), /*tp_basicsize*/
2640
+ 0, /*tp_itemsize*/
2641
+ pysigar_free, /*tp_dealloc*/
2642
+ 0, /*tp_print*/
2643
+ 0, /*tp_getattr*/
2644
+ 0, /*tp_setattr*/
2645
+ 0, /*tp_compare*/
2646
+ 0, /*tp_repr*/
2647
+ 0, /*tp_as_number*/
2648
+ 0, /*tp_as_sequence*/
2649
+ 0, /*tp_as_mapping*/
2650
+ 0, /*tp_hash */
2651
+ 0, /*tp_call*/
2652
+ 0, /*tp_str*/
2653
+ 0, /*tp_getattro*/
2654
+ 0, /*tp_setattro*/
2655
+ 0, /*tp_as_buffer*/
2656
+ PySigar_TPFLAGS, /*tp_flags*/
2657
+ 0, /*tp_doc*/
2658
+ 0, /*tp_traverse*/
2659
+ 0, /*tp_clear*/
2660
+ 0, /*tp_richcompare*/
2661
+ 0, /*tp_weaklistoffset*/
2662
+ 0, /*tp_iter*/
2663
+ 0, /*tp_iternext*/
2664
+ $methods, /*tp_methods*/
2665
+ 0, /*tp_members*/
2666
+ 0, /*tp_getset*/
2667
+ 0, /*tp_base*/
2668
+ 0, /*tp_dict*/
2669
+ 0, /*tp_descr_get*/
2670
+ 0, /*tp_descr_set*/
2671
+ 0, /*tp_dictoffset*/
2672
+ 0, /*tp_init*/
2673
+ 0, /*tp_alloc*/
2674
+ 0 /*tp_new*/
2675
+ };
2676
+ EOF
2677
+
2678
+ print $cfh <<EOF if $func->{has_get};
2679
+ static PyObject *py$func->{sigar_function}(PyObject *self, PyObject *args)
2680
+ {
2681
+ int status;
2682
+ sigar_t *sigar = PySIGAR;
2683
+ $func->{sigar_type} *RETVAL = malloc(sizeof(*RETVAL));
2684
+ $vars
2685
+ $parse_args
2686
+
2687
+ if ((status = $func->{sigar_function}($args, RETVAL)) != SIGAR_OK) {
2688
+ free(RETVAL);
2689
+ PySigar_Croak();
2690
+ return NULL;
2691
+ }
2692
+ else {
2693
+ PyObject *self = PySigar_new($pytype);
2694
+ PySIGAR_OBJ->ptr = RETVAL;
2695
+ return self;
2696
+ }
2697
+ }
2698
+ EOF
2699
+ }
2700
+
2701
+ sub finish {
2702
+ my $self = shift;
2703
+
2704
+ my $mappings = $self->get_mappings;
2705
+ my $cfh = $self->{cfh};
2706
+ my $nl = '\\' . "\n";
2707
+
2708
+ print $cfh "#define PY_SIGAR_METHODS $nl";
2709
+ for my $func (@$mappings) {
2710
+ next unless $func->{has_get};
2711
+ my $arginfo = $func->{num_args} ? 'METH_VARARGS' : 'METH_NOARGS';
2712
+ print $cfh qq( {"$func->{cname}", py$func->{sigar_function}, $arginfo, NULL},);
2713
+ if ($func == $mappings->[-1]) {
2714
+ print $cfh "\n";
2715
+ }
2716
+ else {
2717
+ print $cfh $nl;
2718
+ }
2719
+ }
2720
+
2721
+ print $cfh "#define PY_SIGAR_ADD_TYPES $nl";
2722
+ for my $func (@$mappings) {
2723
+ my $pyclass = pyclass($func->{name});
2724
+ my $pytype = pytype($func->{name});
2725
+ print $cfh qq{ PySigar_AddType("$pyclass", $pytype)};
2726
+ if ($func == $mappings->[-1]) {
2727
+ print $cfh "\n";
2728
+ }
2729
+ else {
2730
+ print $cfh ";$nl";
2731
+ }
2732
+ }
2733
+
2734
+ $self->SUPER::finish;
2735
+ }
2736
+
2737
+ package SigarWrapper::Erlang;
2738
+
2739
+ use vars qw(@ISA);
2740
+ @ISA = qw(SigarWrapper);
2741
+
2742
+ my %field_types = (
2743
+ Long => "esigar_encode_ulonglong",
2744
+ Double => "esigar_encode_double",
2745
+ Int => "esigar_encode_long",
2746
+ Char => "esigar_encode_char",
2747
+ String => "esigar_encode_string",
2748
+ NetAddress => "esigar_encode_netaddr",
2749
+ );
2750
+
2751
+ my $c_file = 'priv/gen/sigar_drv_gen.c';
2752
+ my $h_file = 'priv/gen/sigar.hrl';
2753
+ my $g_file = 'priv/gen/sigar_gen.hrl';
2754
+
2755
+ sub sources {
2756
+ return $c_file;
2757
+ }
2758
+
2759
+ sub start {
2760
+ my $self = shift;
2761
+ $self->SUPER::start;
2762
+ $self->{cfh} = $self->create($c_file);
2763
+ $self->{hfh} = $self->create($h_file);
2764
+ $self->{gfh} = $self->create($g_file);
2765
+ }
2766
+
2767
+ sub generate_class {
2768
+ my($self, $func) = @_;
2769
+
2770
+ my $cfh = $self->{cfh};
2771
+ my $cname = $func->{cname};
2772
+ my $parse_args = "";
2773
+ my $vars = "";
2774
+ my $args = 'sigar';
2775
+
2776
+ if ($func->{num_args} == 1) {
2777
+ if ($func->{is_proc}) {
2778
+ $parse_args = 'pid = esigar_pid_get(sigar, bytes);';
2779
+ $vars = "long $func->{arg};\n";
2780
+ }
2781
+ else {
2782
+ $parse_args .= 'name = bytes;';
2783
+ $vars = "char *$func->{arg};\n";
2784
+ }
2785
+ $args .= ", $func->{arg}";
2786
+ }
2787
+
2788
+ my $encoder = "esigar_encode_$cname";
2789
+ my $n = scalar @{ $func->{fields} };
2790
+
2791
+ print $cfh <<EOF;
2792
+ static void $encoder(ei_x_buff *x,
2793
+ $func->{sigar_type} *$cname)
2794
+ {
2795
+ ei_x_encode_list_header(x, $n);
2796
+ EOF
2797
+
2798
+ for my $field (@{ $func->{fields} }) {
2799
+ my $name = $field->{name};
2800
+ my $type = $field_types{ $field->{type} };
2801
+
2802
+ print $cfh qq{ $type(x, "$name", $cname->$name);\n};
2803
+ }
2804
+
2805
+ print $cfh " ei_x_encode_empty_list(x);\n}\n\n";
2806
+
2807
+ print $cfh <<EOF if $func->{has_get};
2808
+ static int e$func->{sigar_function}(ErlDrvPort port, sigar_t *sigar, char *bytes)
2809
+ {
2810
+ int status;
2811
+ ei_x_buff x;
2812
+ $func->{sigar_type} $cname;
2813
+ $vars
2814
+ $parse_args
2815
+
2816
+ ESIGAR_NEW(&x);
2817
+ if ((status = $func->{sigar_function}($args, &$cname)) == SIGAR_OK) {
2818
+ ESIGAR_OK(&x);
2819
+
2820
+ $encoder(&x, &$cname);
2821
+
2822
+ ESIGAR_SEND(port, &x);
2823
+ }
2824
+ else {
2825
+ ESIGAR_ERROR(&x, sigar, status);
2826
+ }
2827
+ return status;
2828
+ }
2829
+ EOF
2830
+ }
2831
+
2832
+ my(@nongens) =
2833
+ qw{net_interface_list net_route_list net_connection_list
2834
+ file_system_list cpu_info_list who_list
2835
+ loadavg};
2836
+
2837
+ sub finish {
2838
+ my $self = shift;
2839
+
2840
+ my $mappings = $self->get_mappings;
2841
+ my $cfh = $self->{cfh};
2842
+ my $hfh = $self->{hfh};
2843
+ my $gfh = $self->{gfh};
2844
+ my $ncmd = 1;
2845
+
2846
+ for my $ngen (@nongens) {
2847
+ my $cmd = uc $ngen;
2848
+ print $cfh "#define ESIGAR_$cmd $ncmd\n";
2849
+ print $hfh "-define($cmd, $ncmd).\n";
2850
+ $ncmd++;
2851
+ }
2852
+
2853
+ for my $func (@$mappings) {
2854
+ next unless $func->{has_get};
2855
+ my $name = $func->{cname};
2856
+ my $cmd = uc $name;
2857
+ my $nargs = 1 + $func->{num_args};
2858
+ print $cfh "#define ESIGAR_$cmd $ncmd\n";
2859
+ print $hfh "-define($cmd, $ncmd).\n";
2860
+ print $hfh "-export([$name/$nargs]).\n";
2861
+ $ncmd++;
2862
+ }
2863
+
2864
+ print $cfh <<EOF;
2865
+
2866
+ static int esigar_dispatch(ErlDrvPort port, sigar_t *sigar, int cmd, char *bytes) {
2867
+ switch (cmd) {
2868
+ EOF
2869
+ for my $func (@$mappings) {
2870
+ next unless $func->{has_get};
2871
+ my $name = $func->{cname};
2872
+ my $cmd = uc $name;
2873
+ my $arg = "";
2874
+ if ($func->{num_args}) {
2875
+ $arg = ", Arg";
2876
+ }
2877
+
2878
+ print $gfh <<EOF;
2879
+ $name({sigar, S}$arg) ->
2880
+ do_command(S, ?$cmd$arg).
2881
+
2882
+ EOF
2883
+ print $cfh <<EOF
2884
+ case ESIGAR_$cmd:
2885
+ return e$func->{sigar_function}(port, sigar, bytes);
2886
+ EOF
2887
+ }
2888
+ print $cfh <<EOF;
2889
+ default:
2890
+ esigar_notimpl(port, sigar, cmd);
2891
+ return SIGAR_ENOTIMPL;
2892
+ }
2893
+ }
2894
+ EOF
2895
+
2896
+ $self->SUPER::finish;
2897
+ }
2898
+
2899
+ #XXX not currently supporting netware
2900
+ package SigarWrapper::Netware;
2901
+
2902
+ use vars qw(@ISA);
2903
+ @ISA = qw(SigarWrapper);
2904
+
2905
+ sub start {
2906
+ my $self = shift;
2907
+ $self->SUPER::start;
2908
+ $self->{dfh} = $self->create('javasigar_generated.def');
2909
+ }
2910
+
2911
+ sub finish {
2912
+ my $self = shift;
2913
+ my $fh = $self->{dfh};
2914
+ for my $func (@{ $self->{nativefunc} }) {
2915
+ #$fh->println($nativefunc) if $impl;
2916
+ }
2917
+ my $jsigar = "../../src/jni/javasigar.c";
2918
+ my(%alias) = (x => 'Sigar');
2919
+ open JSIGAR, $jsigar or die "open $jsigar: $!";
2920
+ while (<JSIGAR>) {
2921
+ next unless /SIGAR_JNI([a-z]?)\(([A-Za-z_]+)\)/;
2922
+ my $class = "";
2923
+ if ($1) {
2924
+ $class = $alias{$1} . "_";
2925
+ }
2926
+ $fh->println("Java_org_hyperic_sigar_$class$2");
2927
+ }
2928
+ close JSIGAR;
2929
+
2930
+ $self->SUPER::finish;
2931
+ }
2932
+
2933
+ 1;
2934
+ __END__