linux_stat 1.3.1 → 2.0.1

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.
data/bin/console CHANGED
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  $-v = true
3
- %w(linux_stat irb).each(&method(:require))
3
+
4
+ begin
5
+ %w(linux_stat irb).each(&method(:require))
6
+ rescue LoadError
7
+ abort "LinuxStat and IRB shoud be installed before you can run LinuxStat console"
8
+ end
9
+
4
10
  IRB.start(__FILE__)
data/exe/linuxstat.rb CHANGED
@@ -7,6 +7,12 @@ rescue LoadError
7
7
  abort "The Gem needs to be installed before this test can be run!"
8
8
  end
9
9
 
10
+ Integer.class_exec do
11
+ define_method(:clamp) { |min, max|
12
+ self < min ? min : self > max ? max : self
13
+ }
14
+ end unless 1.respond_to?(:clamp)
15
+
10
16
  # Gradient colour to strings
11
17
  class String
12
18
  def colourize(colour = 1, flip: false)
@@ -138,7 +144,8 @@ execute.sort.each do |c|
138
144
  param << "#{p[1] || 'arg'}#{_arg}, "
139
145
  end
140
146
  end
141
- param.delete_suffix!(", ")
147
+
148
+ param.chomp!(", ")
142
149
 
143
150
  disp_meth = "#{meth}"
144
151
  disp_meth.concat(arg ? "(#{param})" : "(#{param})")
@@ -18,16 +18,16 @@ static VALUE statfs(VALUE obj, VALUE dir) {
18
18
 
19
19
  if(statvfs(d, &buf) < 0) return hash ;
20
20
 
21
- rb_hash_aset(hash, ID2SYM(rb_intern("block_size")), INT2FIX(buf.f_bsize)) ;
22
- rb_hash_aset(hash, ID2SYM(rb_intern("fragment_size")), INT2FIX(buf.f_frsize)) ;
23
- rb_hash_aset(hash, ID2SYM(rb_intern("blocks")), INT2FIX(buf.f_blocks)) ;
24
- rb_hash_aset(hash, ID2SYM(rb_intern("block_free")), INT2FIX(buf.f_bfree)) ;
25
- rb_hash_aset(hash, ID2SYM(rb_intern("block_avail_unpriv")), INT2FIX(buf.f_bavail)) ;
26
- rb_hash_aset(hash, ID2SYM(rb_intern("inodes")), INT2FIX(buf.f_files)) ;
27
- rb_hash_aset(hash, ID2SYM(rb_intern("free_inodes")), INT2FIX(buf.f_ffree)) ;
28
- rb_hash_aset(hash, ID2SYM(rb_intern("filesystem_id")), INT2FIX(buf.f_fsid)) ;
29
- rb_hash_aset(hash, ID2SYM(rb_intern("mount_flags")), INT2FIX(buf.f_flag)) ;
30
- rb_hash_aset(hash, ID2SYM(rb_intern("max_filename_length")), INT2FIX(buf.f_namemax)) ;
21
+ rb_hash_aset(hash, ID2SYM(rb_intern("block_size")), INT2FIX((unsigned int)buf.f_bsize)) ;
22
+ rb_hash_aset(hash, ID2SYM(rb_intern("fragment_size")), ULL2NUM((unsigned long long)buf.f_frsize)) ;
23
+ rb_hash_aset(hash, ID2SYM(rb_intern("blocks")), ULL2NUM((unsigned long long)buf.f_blocks)) ;
24
+ rb_hash_aset(hash, ID2SYM(rb_intern("block_free")), ULL2NUM((unsigned long long)buf.f_bfree)) ;
25
+ rb_hash_aset(hash, ID2SYM(rb_intern("block_avail_unpriv")), ULL2NUM((unsigned long long)buf.f_bavail)) ;
26
+ rb_hash_aset(hash, ID2SYM(rb_intern("inodes")), ULL2NUM((unsigned long long)buf.f_files)) ;
27
+ rb_hash_aset(hash, ID2SYM(rb_intern("free_inodes")), ULL2NUM((unsigned long long)buf.f_ffree)) ;
28
+ rb_hash_aset(hash, ID2SYM(rb_intern("filesystem_id")), ULL2NUM((unsigned long long)buf.f_fsid)) ;
29
+ rb_hash_aset(hash, ID2SYM(rb_intern("mount_flags")), ULL2NUM((unsigned long long)buf.f_flag)) ;
30
+ rb_hash_aset(hash, ID2SYM(rb_intern("max_filename_length")), ULL2NUM((unsigned long long)buf.f_namemax)) ;
31
31
 
32
32
  return hash ;
33
33
  }
data/ext/nproc/nproc.c CHANGED
@@ -18,9 +18,9 @@
18
18
  static VALUE count_cpu_for_pid(VALUE obj, VALUE pid) {
19
19
  cpu_set_t set ;
20
20
  CPU_ZERO(&set) ;
21
- short int stat = sched_getaffinity(FIX2INT(pid), sizeof(set), &set) ;
21
+ char status = sched_getaffinity(FIX2INT(pid), sizeof(set), &set) ;
22
22
 
23
- if (stat < 0) return Qnil ;
23
+ if (status < 0) return Qnil ;
24
24
  return INT2FIX(CPU_COUNT(&set)) ;
25
25
  }
26
26
 
@@ -0,0 +1,11 @@
1
+ require 'mkmf'
2
+
3
+ unless have_const('linux') || RbConfig::CONFIG['arch'].to_s[/linux/]
4
+ abort('Platform is not linux')
5
+ end
6
+
7
+ unless have_header('unistd.h') && have_header('ruby.h')
8
+ abort('Missing header')
9
+ end
10
+
11
+ create_makefile 'linux_stat/procfs'
@@ -0,0 +1,11 @@
1
+ VALUE last_pid(VALUE obj) {
2
+ FILE *f = fopen("/proc/loadavg", "r") ;
3
+ if (!f) return Qnil ;
4
+
5
+ unsigned long long _last_pid ;
6
+ char status = fscanf(f, "%*f %*f %*f %*s %llu", &_last_pid) ;
7
+ fclose(f) ;
8
+ if (status != 1) return Qnil ;
9
+
10
+ return ULL2NUM(_last_pid) ;
11
+ }
@@ -0,0 +1,42 @@
1
+ // ProcFS doesn't include all the /proc/ files.
2
+ // It includes some of them that can add potential
3
+ // performance boost to the LinuxStat modules.
4
+ //
5
+ // Some LinuxStat modules reads /proc/ files
6
+ // that are not present here. That is because
7
+ // Ruby can handle them well with little wastage.
8
+ // Adding C may be a potential risk in such places.
9
+ //
10
+ // In this ProcFS module, we will define the methods
11
+ // that really gets the benefit.
12
+
13
+ #include <stdio.h>
14
+ #include <unistd.h>
15
+ #include <string.h>
16
+ #include "ruby.h"
17
+ #include "uptime.h"
18
+ #include "statm.h"
19
+ #include "stat.h"
20
+ #include "loadavg_pid.h"
21
+
22
+ int Init_procfs() {
23
+ VALUE _linux_stat = rb_define_module("LinuxStat") ;
24
+ VALUE _procfs = rb_define_module_under(_linux_stat, "ProcFS") ;
25
+
26
+ // uptime
27
+ rb_define_module_function(_procfs, "uptime_f", uptime_f, 0) ;
28
+
29
+ // statm
30
+ rb_define_module_function(_procfs, "statm_memory", statm_memory, 1) ;
31
+ rb_define_module_function(_procfs, "statm", statm, 1) ;
32
+ rb_define_module_function(_procfs, "statm_virtual", statm_virtual, 1) ;
33
+ rb_define_module_function(_procfs, "statm_resident", statm_resident, 1) ;
34
+ rb_define_module_function(_procfs, "statm_shared", statm_shared, 1) ;
35
+
36
+ // loadavg last PID
37
+ rb_define_module_function(_procfs, "last_pid", last_pid, 0) ;
38
+
39
+ // stat
40
+ rb_define_module_function(_procfs, "ps_state", ps_state, 1) ;
41
+ rb_define_module_function(_procfs, "ps_stat", ps_stat, 1) ;
42
+ }
data/ext/procfs/stat.h ADDED
@@ -0,0 +1,92 @@
1
+ VALUE ps_state(VALUE obj, VALUE pid) {
2
+ char _path[22] ;
3
+ sprintf(_path, "/proc/%lu/stat", FIX2UINT(pid)) ;
4
+
5
+ FILE *f = fopen(_path, "r") ;
6
+ if (!f) return rb_str_new_cstr("") ;
7
+
8
+ char _s[1] ;
9
+
10
+ char status = fscanf(f, "%*llu (%*[^)]%*[)] %s", _s) ;
11
+ fclose(f) ;
12
+
13
+ if (status != 1) return rb_str_new_cstr("") ;
14
+ return rb_str_new_cstr(_s) ;
15
+ }
16
+
17
+ VALUE ps_stat(VALUE obj, VALUE pid) {
18
+ char _path[22] ;
19
+ sprintf(_path, "/proc/%lu/stat", FIX2UINT(pid)) ;
20
+
21
+ FILE *f = fopen(_path, "r") ;
22
+
23
+ if (!f)
24
+ return rb_ary_new() ;
25
+
26
+ // ?? JEEZ !!
27
+ // We need to do this because the datatypes are different
28
+ // Can't make an array like Ruby out of String
29
+ // This is hard to write and check, but tested, and works.
30
+ //
31
+ // For this struct,
32
+ // follow https://man7.org/linux/man-pages/man5/proc.5.html
33
+ int ppid, pgrp, session, tty_nr, tpgid ;
34
+ unsigned flags ;
35
+ long unsigned minflt, cminflt, majflt, cmajflt, utime, stime ;
36
+ long cutime, cstime, priority, nice, num_threads, itrealvalue ;
37
+ long long unsigned starttime ;
38
+ long unsigned vsize ;
39
+ long rss ;
40
+ long unsigned rsslim, startcode, endcode, startstack, kstkesp, kstkeip ;
41
+ long unsigned signal, blocked, sigignore, sigcatch, wchan, nswap, cnswap ;
42
+ int exit_signal, processor ;
43
+ unsigned rt_priority, policy ;
44
+ long long unsigned delayacct_blkio_ticks ;
45
+ long unsigned guest_time ;
46
+ long cguest_time ;
47
+ long unsigned start_data, end_data, start_brk, arg_start, arg_end ;
48
+ long unsigned env_start, env_end ;
49
+ int exit_code ;
50
+
51
+ char status = fscanf(
52
+ f, "%*llu (%*[^)]%*[)] %*c "
53
+ "%d %d %d %d %d %u "
54
+ "%lu %lu %lu %lu %lu %lu "
55
+ "%ld %ld %ld %ld %ld %ld "
56
+ "%llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
57
+ "%d %d %u %u %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %d", &ppid, &pgrp,
58
+ &session, &tty_nr, &tpgid, &flags, &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime, &cutime,
59
+ &cstime, &priority, &nice, &num_threads, &itrealvalue, &starttime, &vsize, &rss, &rsslim,
60
+ &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, &sigignore,
61
+ &sigcatch, &wchan, &nswap, &cnswap, &exit_signal, &processor, &rt_priority, &policy,
62
+ &delayacct_blkio_ticks, &guest_time, &cguest_time, &start_data, &end_data,
63
+ &start_brk, &arg_start, &arg_end, &env_start, &env_end, &exit_code
64
+ ) ;
65
+
66
+ fclose(f) ;
67
+
68
+ if (status != 49)
69
+ return rb_ary_new() ;
70
+
71
+ return rb_ary_new_from_args(49,
72
+ INT2NUM(ppid), INT2NUM(pgrp), INT2NUM(session), INT2NUM(tty_nr), INT2NUM(tpgid),
73
+ UINT2NUM(flags),
74
+ ULONG2NUM(minflt), ULONG2NUM(cminflt), ULONG2NUM(majflt), ULONG2NUM(cmajflt),
75
+ ULONG2NUM(utime), ULONG2NUM(stime),
76
+ LONG2NUM(cutime), LONG2NUM(cstime), LONG2NUM(priority),
77
+ LONG2NUM(nice), LONG2NUM(num_threads), LONG2NUM(itrealvalue),
78
+ ULL2NUM(starttime),
79
+ ULONG2NUM(vsize),
80
+ LONG2NUM(rss),
81
+ ULONG2NUM(rsslim), ULONG2NUM(startcode), ULONG2NUM(endcode),
82
+ ULONG2NUM(startstack), ULONG2NUM(kstkesp), ULONG2NUM(kstkeip),
83
+ ULONG2NUM(signal), ULONG2NUM(blocked), ULONG2NUM(sigignore), ULONG2NUM(sigcatch),
84
+ ULONG2NUM(wchan), ULONG2NUM(nswap), ULONG2NUM(cnswap),
85
+ INT2NUM(exit_signal), INT2NUM(processor),
86
+ UINT2NUM(rt_priority), UINT2NUM(policy),
87
+ ULL2NUM(delayacct_blkio_ticks), ULONG2NUM(guest_time), LONG2NUM(cguest_time), ULONG2NUM(start_data),
88
+ ULONG2NUM(end_data), ULONG2NUM(start_brk), ULONG2NUM(arg_start), ULONG2NUM(arg_end),
89
+ ULONG2NUM(env_start), ULONG2NUM(env_end),
90
+ INT2NUM(exit_code)
91
+ ) ;
92
+ }
@@ -0,0 +1,99 @@
1
+ #define PAGESIZE sysconf(_SC_PAGESIZE)
2
+
3
+ VALUE statm(VALUE obj, VALUE pid) {
4
+ char _path[22] ;
5
+ sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
6
+
7
+ FILE *f = fopen(_path, "r") ;
8
+
9
+ VALUE hash = rb_hash_new() ;
10
+
11
+ if (!f) return hash ;
12
+
13
+ unsigned int _virtual, resident, shared ;
14
+ char status = fscanf(f, "%u %u %u", &_virtual, &resident, &shared) ;
15
+ fclose(f) ;
16
+
17
+ if (status != 3) return hash ;
18
+
19
+ int pagesize = PAGESIZE ;
20
+
21
+ _virtual *= pagesize ;
22
+ resident *= pagesize ;
23
+ shared *= pagesize ;
24
+
25
+ unsigned int v = resident - shared ;
26
+
27
+ rb_hash_aset(hash, ID2SYM(rb_intern("memory")), UINT2NUM(v)) ;
28
+ rb_hash_aset(hash, ID2SYM(rb_intern("virtual_memory")), UINT2NUM(_virtual)) ;
29
+ rb_hash_aset(hash, ID2SYM(rb_intern("resident_memory")), UINT2NUM(resident)) ;
30
+ rb_hash_aset(hash, ID2SYM(rb_intern("shared_memory")), UINT2NUM(shared)) ;
31
+
32
+ return hash ;
33
+ }
34
+
35
+ VALUE statm_virtual(VALUE obj, VALUE pid) {
36
+ char _path[22] ;
37
+ sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
38
+
39
+ FILE *f = fopen(_path, "r") ;
40
+ VALUE hash = rb_hash_new() ;
41
+
42
+ if (!f) return hash ;
43
+ unsigned int _virtual ;
44
+ char status = fscanf(f, "%u", &_virtual) ;
45
+ fclose(f) ;
46
+
47
+ if (status != 1) return Qnil ;
48
+ return UINT2NUM(_virtual * PAGESIZE) ;
49
+ }
50
+
51
+ VALUE statm_resident(VALUE obj, VALUE pid) {
52
+ char _path[22] ;
53
+ sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
54
+
55
+ FILE *f = fopen(_path, "r") ;
56
+ VALUE hash = rb_hash_new() ;
57
+
58
+ if (!f) return hash ;
59
+ unsigned int resident ;
60
+ char status = fscanf(f, "%*u %u", &resident) ;
61
+ fclose(f) ;
62
+
63
+ if (status != 1) return Qnil ;
64
+ return UINT2NUM(resident * PAGESIZE) ;
65
+ }
66
+
67
+ VALUE statm_shared(VALUE obj, VALUE pid) {
68
+ char _path[22] ;
69
+ sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
70
+
71
+ FILE *f = fopen(_path, "r") ;
72
+ VALUE hash = rb_hash_new() ;
73
+
74
+ if (!f) return hash ;
75
+ unsigned int shared ;
76
+ char status = fscanf(f, "%*u %*u %u", &shared) ;
77
+ fclose(f) ;
78
+
79
+ if (status != 1) return Qnil ;
80
+ return UINT2NUM(shared * PAGESIZE) ;
81
+ }
82
+
83
+ VALUE statm_memory(VALUE obj, VALUE pid) {
84
+ char _path[22] ;
85
+ sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
86
+
87
+ FILE *f = fopen(_path, "r") ;
88
+
89
+ if (!f) return Qnil ;
90
+
91
+ unsigned int resident, shared ;
92
+ char status = fscanf(f, "%*u %u %u", &resident, &shared) ;
93
+ fclose(f) ;
94
+
95
+ if (status != 2) return Qnil ;
96
+
97
+ unsigned int v = (resident - shared) * PAGESIZE ;
98
+ return UINT2NUM(v) ;
99
+ }
@@ -0,0 +1,12 @@
1
+ VALUE uptime_f(VALUE obj) {
2
+ FILE *f = fopen("/proc/uptime", "r") ;
3
+ if (!f) return Qnil ;
4
+
5
+ double up_f ;
6
+ char status = fscanf(f, "%lf", &up_f) ;
7
+ fclose(f) ;
8
+
9
+ if (status != 1) return Qnil ;
10
+
11
+ return DBL2NUM(up_f) ;
12
+ }
@@ -4,7 +4,7 @@ unless have_const('linux') || RbConfig::CONFIG['arch'].to_s[/linux/]
4
4
  abort('Platform is not linux')
5
5
  end
6
6
 
7
- unless have_header('sys/unistd.h') && have_header('ruby.h')
7
+ unless have_header('unistd.h') && have_header('ruby.h')
8
8
  abort('Missing header')
9
9
  end
10
10
 
@@ -12,7 +12,7 @@
12
12
  #endif
13
13
 
14
14
  static VALUE getTick(VALUE obj) {
15
- short int val = sysconf(_SC_CLK_TCK) ;
15
+ int val = sysconf(_SC_CLK_TCK) ;
16
16
  if (val < 0) return Qnil ;
17
17
 
18
18
  return INT2FIX(val) ;
@@ -22,84 +22,84 @@ static VALUE getChildMax(VALUE obj) {
22
22
  long long int val = sysconf(_SC_CHILD_MAX) ;
23
23
  if (val < 0) return Qnil ;
24
24
 
25
- return INT2FIX(val) ;
25
+ return LL2NUM(val) ;
26
26
  }
27
27
 
28
28
  static VALUE getHostnameMax(VALUE obj) {
29
- int val = sysconf(_SC_HOST_NAME_MAX) ;
29
+ long long val = sysconf(_SC_HOST_NAME_MAX) ;
30
30
  if (val < 0) return Qnil ;
31
31
 
32
- return INT2FIX(val) ;
32
+ return LL2NUM(val) ;
33
33
  }
34
34
 
35
35
  static VALUE getLoginNameMax(VALUE obj) {
36
- int val = sysconf(_SC_LOGIN_NAME_MAX) ;
36
+ long long val = sysconf(_SC_LOGIN_NAME_MAX) ;
37
37
  if (val < 0) return Qnil ;
38
38
 
39
- return INT2FIX(val) ;
39
+ return LL2NUM(val) ;
40
40
  }
41
41
 
42
42
  static VALUE getOpenMax(VALUE obj) {
43
- int val = sysconf(_SC_OPEN_MAX) ;
43
+ long long val = sysconf(_SC_OPEN_MAX) ;
44
44
  if (val < 0) return Qnil ;
45
45
 
46
- return INT2FIX(val) ;
46
+ return LL2NUM(val) ;
47
47
  }
48
48
 
49
49
  static VALUE getPageSize(VALUE obj) {
50
- short int val = sysconf(_SC_PAGESIZE) ;
50
+ int val = sysconf(_SC_PAGESIZE) ;
51
51
  if (val < 0) return Qnil ;
52
52
 
53
53
  return INT2FIX(val) ;
54
54
  }
55
55
 
56
56
  static VALUE getStreamMax(VALUE obj) {
57
- int val = sysconf(_SC_STREAM_MAX) ;
57
+ long long val = sysconf(_SC_STREAM_MAX) ;
58
58
  if (val < 0) return Qnil ;
59
59
 
60
- return INT2FIX(val) ;
60
+ return LL2NUM(val) ;
61
61
  }
62
62
 
63
63
  static VALUE getTTYNameMax(VALUE obj) {
64
- int val = sysconf(_SC_TTY_NAME_MAX) ;
64
+ long long val = sysconf(_SC_TTY_NAME_MAX) ;
65
65
  if (val < 0) return Qnil ;
66
66
 
67
- return INT2FIX(val) ;
67
+ return LL2NUM(val) ;
68
68
  }
69
69
 
70
70
  static VALUE getPosixVersion(VALUE obj) {
71
- int val = sysconf(_SC_VERSION) ;
71
+ long long val = sysconf(_SC_VERSION) ;
72
72
  if (val < 0) return Qnil ;
73
73
 
74
- return INT2FIX(val) ;
74
+ return LL2NUM(val) ;
75
75
  }
76
76
 
77
77
  static VALUE getLineMax(VALUE obj) {
78
- int val = sysconf(_SC_LINE_MAX) ;
78
+ long long val = sysconf(_SC_LINE_MAX) ;
79
79
  if (val < 0) return Qnil ;
80
80
 
81
- return INT2FIX(val) ;
81
+ return LL2NUM(val) ;
82
82
  }
83
83
 
84
84
  static VALUE getExprNestMax(VALUE obj) {
85
- int val = sysconf(_SC_EXPR_NEST_MAX) ;
85
+ long long val = sysconf(_SC_EXPR_NEST_MAX) ;
86
86
  if (val < 0) return Qnil ;
87
87
 
88
- return INT2FIX(val) ;
88
+ return LL2NUM(val) ;
89
89
  }
90
90
 
91
91
  static VALUE getProcessorConfigured(VALUE obj) {
92
- short int val = sysconf(_SC_NPROCESSORS_CONF) ;
92
+ long val = sysconf(_SC_NPROCESSORS_CONF) ;
93
93
  if (val < 0) return Qnil ;
94
94
 
95
- return INT2FIX(val) ;
95
+ return LONG2NUM(val) ;
96
96
  }
97
97
 
98
98
  static VALUE getProcessorOnline(VALUE obj) {
99
- short int val = sysconf(_SC_NPROCESSORS_ONLN) ;
99
+ long val = sysconf(_SC_NPROCESSORS_ONLN) ;
100
100
  if (val < 0) return Qnil ;
101
101
 
102
- return INT2FIX(val) ;
102
+ return LONG2NUM(val) ;
103
103
  }
104
104
 
105
105
  static VALUE getUser(VALUE obj) {
@@ -108,22 +108,22 @@ static VALUE getUser(VALUE obj) {
108
108
  }
109
109
 
110
110
  static VALUE getUID(VALUE obj) {
111
- return INT2FIX(getuid()) ;
111
+ return UINT2NUM((unsigned int) getuid()) ;
112
112
  }
113
113
 
114
114
  static VALUE getGID(VALUE obj) {
115
- return INT2FIX(getgid()) ;
115
+ return UINT2NUM((unsigned int) getgid()) ;
116
116
  }
117
117
 
118
118
  static VALUE getEUID(VALUE obj) {
119
- return INT2FIX(geteuid()) ;
119
+ return UINT2NUM((unsigned int) geteuid()) ;
120
120
  }
121
121
 
122
122
  static VALUE getHostname(VALUE obj) {
123
123
  int h_max = sysconf(_SC_HOST_NAME_MAX) + 1 ;
124
124
  char hostname[h_max] ;
125
125
 
126
- short int status = gethostname(hostname, h_max) ;
126
+ char status = gethostname(hostname, h_max) ;
127
127
 
128
128
  return (status < 0) ? rb_str_new_cstr("") : rb_str_new_cstr(hostname) ;
129
129
  }