LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: [lvs-users] Weird values for lvsServiceStatsInBytes

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [lvs-users] Weird values for lvsServiceStatsInBytes
From: "Laurentiu C. Badea (L.C.)" <lc@xxxxxxxx>
Date: Fri, 03 Oct 2008 12:06:15 -0700

> But we never got as far as fixing it in the code, if anyone knows how
> I'd be happy to sponsor them to do it.
>

I was looking at this last night. The problem was that ASN_COUNTER64 expects a "struct counter64" and is given a "long long" (__u64) instead. The attached patch should correct this problem.

--
Laurentiu Badea
Fix the bad values returned for the 64-bit byte counters.

--- lvs.c.orig  2006-01-02 14:31:54.000000000 +0000
+++ lvs.c       2008-10-03 18:43:48.000000000 +0000
@@ -131,6 +131,17 @@
        }
 }
 
+/** set a counter64 snmp response field from a __u64 value
+
+**/
+static
+void netsnmp_set_var_counter64_value(netsnmp_variable_list *var, __u64 *val){
+       struct counter64 val64;
+       val64.high = *val >> 32;
+       val64.low = *val & 0xffffffff;
+       snmp_set_var_typed_value(var, ASN_COUNTER64, (u_char *)&val64, 
sizeof(val64));
+}
+
 /** returns the first data point within the lvsServiceTable table data.
 
     Set the my_loop_context variable to the first data point structure
@@ -271,10 +282,10 @@
                                snmp_set_var_typed_value(var, ASN_COUNTER, 
(u_char *) &stats->outpkts, sizeof(stats->outpkts));
                                break;
                            case COLUMN_LVSSERVICESTATSINBYTES:
-                               snmp_set_var_typed_value(var, ASN_COUNTER64, 
(u_char *) &stats->inbytes, sizeof(stats->inbytes));
+                               netsnmp_set_var_counter64_value(var, 
&stats->inbytes);
                                break;
                            case COLUMN_LVSSERVICESTATSOUTBYTES:
-                               snmp_set_var_typed_value(var, ASN_COUNTER64, 
(u_char *)&stats->outbytes, sizeof(stats->outbytes));
+                               netsnmp_set_var_counter64_value(var, 
&stats->outbytes);
                                break;
                            case COLUMN_LVSSERVICERATECPS:
                                snmp_set_var_typed_value(var, ASN_GAUGE, 
(u_char *) &stats->cps, sizeof(stats->cps));
@@ -434,10 +445,10 @@
                                snmp_set_var_typed_value(var, ASN_COUNTER, 
(u_char *) &stats->outpkts, sizeof(stats->outpkts) );
                                break;
                            case COLUMN_LVSREALSTATSINBYTES:
-                               snmp_set_var_typed_value(var, ASN_COUNTER64, 
(u_char *) &stats->inbytes, sizeof(stats->inbytes));
+                               netsnmp_set_var_counter64_value(var, 
&stats->inbytes);
                                break;
                            case COLUMN_LVSREALSTATSOUTBYTES:
-                               snmp_set_var_typed_value(var, ASN_COUNTER64, 
(u_char *) &stats->outbytes, sizeof(stats->outbytes));
+                               netsnmp_set_var_counter64_value(var, 
&stats->outbytes);
                                break;
                            case COLUMN_LVSREALRATECPS:
                                snmp_set_var_typed_value(var, ASN_GAUGE, 
(u_char *) &stats->cps, sizeof(stats->cps));




<Prev in Thread] Current Thread [Next in Thread>