ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/network_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/network_stats.c (file contents):
Revision 1.52 by tdb, Mon Mar 8 11:58:53 2004 UTC vs.
Revision 1.53 by tdb, Mon Mar 8 12:31:01 2004 UTC

# Line 180 | Line 180 | network_stat_t *get_network_stats(int *entries){
180                          kstat_read(kc, ksp, NULL);
181  
182   #ifdef SOL7
183 < #define RLOOKUP "rbytes"
184 < #define WLOOKUP "obytes"
183 > #define LRX "rbytes"
184 > #define LTX "obytes"
185 > #define LIPACKETS "ipackets"
186 > #define LOPACKETS "opackets"
187   #define VALTYPE value.ui32
188   #else
189 < #define RLOOKUP "rbytes64"
190 < #define WLOOKUP "obytes64"
189 > #define LRX "rbytes64"
190 > #define LTX "obytes64"
191 > #define LIPACKETS "ipackets64"
192 > #define LOPACKETS "opackets64"
193   #define VALTYPE value.ui64
194   #endif
195  
196 <                        if((knp=kstat_data_lookup(ksp, RLOOKUP))==NULL){
196 >                        /* Read rx */
197 >                        if((knp=kstat_data_lookup(ksp, LRX))==NULL){
198                                  /* This is a network interface, but it doesn't
199                                   * have the rbytes/obytes values; for instance,
200                                   * the loopback devices have this behaviour
# Line 197 | Line 202 | network_stat_t *get_network_stats(int *entries){
202                                  continue;
203                          }
204  
205 +                        /* Create new network_stats */
206                          network_stats=network_stat_malloc((interfaces+1), &sizeof_network_stats, network_stats);
207                          if(network_stats==NULL){
208                                  return NULL;
209                          }
210                          network_stat_ptr=network_stats+interfaces;
211 +
212 +                        /* Finish reading rx */
213                          network_stat_ptr->rx=knp->VALTYPE;
214  
215 <                        if((knp=kstat_data_lookup(ksp, WLOOKUP))==NULL){
215 >                        /* Read tx */
216 >                        if((knp=kstat_data_lookup(ksp, LTX))==NULL){
217                                  continue;
218                          }
219                          network_stat_ptr->tx=knp->VALTYPE;
220 +
221 +                        /* Read ipackets */
222 +                        if((knp=kstat_data_lookup(ksp, LIPACKETS))==NULL){
223 +                                continue;
224 +                        }
225 +                        network_stat_ptr->ipackets=knp->VALTYPE;
226 +
227 +                        /* Read opackets */
228 +                        if((knp=kstat_data_lookup(ksp, LOPACKETS))==NULL){
229 +                                continue;
230 +                        }
231 +                        network_stat_ptr->opackets=knp->VALTYPE;
232 +
233 +                        /* Read ierrors */
234 +                        if((knp=kstat_data_lookup(ksp, "ierrors"))==NULL){
235 +                                continue;
236 +                        }
237 +                        network_stat_ptr->ierrors=knp->value.ui32;
238 +
239 +                        /* Read oerrors */
240 +                        if((knp=kstat_data_lookup(ksp, "oerrors"))==NULL){
241 +                                continue;
242 +                        }
243 +                        network_stat_ptr->oerrors=knp->value.ui32;
244 +
245 +                        /* Read collisions */
246 +                        if((knp=kstat_data_lookup(ksp, "collisions"))==NULL){
247 +                                continue;
248 +                        }
249 +                        network_stat_ptr->collisions=knp->value.ui32;
250 +
251 +                        /* Read interface name */
252                          if(network_stat_ptr->interface_name!=NULL){
253                                  free(network_stat_ptr->interface_name);
254                          }
255                          network_stat_ptr->interface_name=strdup(ksp->ks_name);
256  
257 +                        /* Store systime */
258                          network_stat_ptr->systime=time(NULL);
259 +
260                          interfaces++;
261                  }
262          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines