From 1cb651d0e36df1a0b39eff5392bf73174b1858ac Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 14 Dec 2009 16:19:09 -0800 Subject: [PATCH] add ruby proc_port binding --- bindings/ruby/rbsigar.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bindings/ruby/rbsigar.c b/bindings/ruby/rbsigar.c index 0d8968cd..2dbb1119 100644 --- a/bindings/ruby/rbsigar.c +++ b/bindings/ruby/rbsigar.c @@ -548,6 +548,21 @@ static int rb_sigar_env_getall(void *data, return SIGAR_OK; } +static VALUE rb_sigar_proc_port(VALUE obj, VALUE protocol, VALUE port) +{ + SIGAR_GET; + + int status; + sigar_pid_t RETVAL; + + status = sigar_proc_port_get(sigar, NUM2INT(protocol), NUM2LL(port), &RETVAL); + if (status != SIGAR_OK) { + RB_SIGAR_CROAK; + } + + return rb_int2inum(RETVAL); +} + static VALUE rb_sigar_proc_env(VALUE obj, VALUE pid) { SIGAR_GET; @@ -765,6 +780,7 @@ void Init_rbsigar(void) rb_define_method(rclass, "proc_list", rb_sigar_proc_list, -1); rb_define_method(rclass, "proc_args", rb_sigar_proc_args, 1); rb_define_method(rclass, "proc_env", rb_sigar_proc_env, 1); + rb_define_method(rclass, "proc_port", rb_sigar_proc_port, 2); rb_define_method(rclass, "fqdn", rb_sigar_fqdn, 0); rb_define_singleton_method(rclass, "new", rb_sigar_new, 0);