kobee12
Messages postés153Date d'inscriptiondimanche 26 janvier 2003StatutMembreDernière intervention31 octobre 2006
-
20 déc. 2003 à 17:48
sfave
Messages postés3Date d'inscriptionsamedi 20 novembre 2004StatutMembreDernière intervention29 avril 2008
-
29 avril 2008 à 08:50
Je dois realiser un prog en C qui permet de recuperer le taux de CPU utilise, la memoire disque disponible, espace disque disponible, et pouvoir envoyer toutes ces infos a une machine principale.
J'ai apppris que l'on pouvait utiliser le protocole SNMP. Seulement je ne le connais pas du tout. Je suppose qu'il existe des bibliotheques en C du style snmp.h mais je ne connais pas les fonctions qui me permettent de realiser les operations que je dois mettre en oeuvre.
Si quelqu'un s'y connait en SNMP et connait les fonctions necessaires a mon prog, qu'il me fasse signe.
Merci d'avance kobee
:big)
// ntdll.NtQuerySystemInformation (NT specific!)
//
// The function copies the system information of the
// specified type into a buffer
//
// NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(
// IN UINT SystemInformationClass, // information type
// OUT PVOID SystemInformation, // pointer to buffer
// IN ULONG SystemInformationLength, // buffer size in bytes
// OUT PULONG ReturnLength OPTIONAL // pointer to a 32-bit variable that receives
// // the number of bytes written to the buffer
// );
typedef long (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
PROCNTQSI NtQuerySystemInformation=NULL;
// The function ...
float GetCPUusage()
{
SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
SYSTEM_TIME_INFORMATION SysTimeInfo;
SYSTEM_BASIC_INFORMATION SysBaseInfo;
double dbIdleTime;
double dbSystemTime;
long status;
static LARGE_INTEGER liOldIdleTime = {0,0};
static LARGE_INTEGER liOldSystemTime = {0,0};
// Get number of processors in the system
status=NtQuerySystemInformation(SystemBasicInformation, &SysBaseInfo, sizeof(SysBaseInfo), NULL);
if(status!=NO_ERROR) return -1;
// Get new system time
status=NtQuerySystemInformation(SystemTimeInformation, &SysTimeInfo, sizeof(SysTimeInfo), 0);
if(status!=NO_ERROR) return -1;
// Get new CPU's idle time
status=NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
if(status!=NO_ERROR) return -1;