networksensor.h
00001 /*************************************************************************** 00002 * Copyright (C) 2003 by Hans Karlsson * 00003 * karlsson.h@home.se * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 ***************************************************************************/ 00010 #ifndef NETWORKSENSOR_H 00011 #define NETWORKSENSOR_H 00012 00013 #include "sensor.h" 00014 00015 #include <tqdatetime.h> 00016 #include <tqfile.h> 00017 #include <tqregexp.h> 00018 #ifdef __FreeBSD__ 00019 #include <sys/types.h> 00020 #include <sys/socket.h> 00021 #include <net/if.h> 00022 #include <net/if_mib.h> 00023 #endif 00024 00025 class NetworkSensor : public Sensor 00026 { 00027 Q_OBJECT 00028 00029 public: 00030 NetworkSensor( TQString device, int interval ); 00031 ~NetworkSensor(); 00032 void update(); 00033 00034 00035 private: 00036 unsigned long receivedBytes; 00037 unsigned long transmittedBytes; 00038 TQTime netTimer; 00039 TQString device; 00040 #ifdef __FreeBSD__ 00041 int if_number; 00042 ifmibdata if_mib; 00043 #endif 00044 void getInOutBytes (unsigned long &in,unsigned long &out) const; 00045 00046 }; 00047 #endif // NETWORKSENSOR_H 00048