@@ -74,60 +74,21 @@ async function getNetworkStats() {
7474
7575async  function  getTemperatureInfo ( )  { 
7676  try  { 
77-     const  platform  =  os . platform ( ) ; 
78- 
79-     if  ( platform  ===  'linux' )  { 
80-       // Logika khusus Linux seperti sebelumnya 
81-       const  thermalZonesDir  =  '/sys/class/thermal' ; 
82-       try  { 
83-         await  fs . access ( thermalZonesDir ) ; 
84-       }  catch  ( err )  { 
85-         return  ( await  si . cpuTemperature ( ) ) . main ; 
86-       } 
87- 
88-       const  thermalItems  =  await  fs . readdir ( thermalZonesDir ) ; 
89-       const  thermalZones  =  thermalItems . filter ( item  =>  item . startsWith ( 'thermal_zone' ) ) ; 
90- 
91-       if  ( thermalZones . length  ===  0 )  { 
92-         // console.log("No thermal zones found"); 
93-         return  null ; 
94-       } 
95- 
96-       const  temperatures  =  [ ] ; 
97-       for  ( const  zone  of  thermalZones )  { 
98-         try  { 
99-           const  tempPath  =  path . join ( thermalZonesDir ,  zone ,  'temp' ) ; 
100-           const  tempContent  =  await  fs . readFile ( tempPath ,  'utf8' ) ; 
101-           const  temp  =  parseInt ( tempContent . trim ( ) )  /  1000 ; 
102-           if  ( ! isNaN ( temp ) )  { 
103-             temperatures . push ( temp ) ; 
104-           } 
105-         }  catch  ( err )  { 
106-           continue ; 
107-         } 
108-       } 
77+     const  tempData  =  await  si . cpuTemperature ( ) ; 
10978
110-       if  ( temperatures . length  ===  0 )  { 
111-         return  null ; 
112-       } 
113- 
114-       const  avgTemp  =  temperatures . reduce ( ( sum ,  t )  =>  sum  +  t ,  0 )  /  temperatures . length ; 
115-       return  `${ avgTemp . toFixed ( 1 ) }  °C` ; 
79+     if  ( tempData  &&  typeof  tempData . main  ===  'number'  &&  ! isNaN ( tempData . main ) )  { 
80+       return  `${ tempData . main . toFixed ( 1 ) }  °C` ; 
11681    }  else  { 
117-       // Windows / macOS: gunakan systeminformation 
118-       const  tempData  =  await  si . cpuTemperature ( ) ; 
119-       if  ( tempData . main  &&  ! isNaN ( tempData . main ) )  { 
120-         return  `${ tempData . main . toFixed ( 1 ) }  °C` ; 
121-       }  else  { 
122-         return  null ; 
123-       } 
82+       console . warn ( "Temperature data not available." ) ; 
83+       return  null ; 
12484    } 
12585  }  catch  ( err )  { 
12686    console . error ( "Error getting temperature information:" ,  err ) ; 
12787    return  null ; 
12888  } 
12989} 
13090
91+ 
13192// Get Node.js heap memory statistics 
13293async  function  getHeapStats ( )  { 
13394  const  memoryUsage  =  process . memoryUsage ( ) ; 
@@ -152,7 +113,7 @@ async function getProcessCount() {
152113      running : processes . running , 
153114      blocked : processes . blocked , 
154115      sleeping : processes . sleeping 
155-     } ; 
116+       } ; 
156117  }  catch  ( err )  { 
157118    console . error ( "Error getting process count:" ,  err ) ; 
158119    return  {  all : 0 ,  running : 0 ,  blocked : 0 ,  sleeping : 0  } ; 
0 commit comments