3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* get system resource precentages */ function serverStatus() { /* cpu usage */ $cpuUsage=NULL; exec('ps -aux', $processes); foreach($processes as $process){ $cols = split(' ', ereg_replace(' +', ' ', $process)); if (strpos($cols[2], '.') > -1){ $cpuUsage += floatval($cols[2]); } } $sysLoad = sys_getloadavg(); /* get raspberry pi temp */ $rawTemp = shell_exec('/opt/vc/bin/vcgencmd measure_temp'); /* trim temp= from the response */ $temp_c = round(str_replace("temp=", "", $rawTemp),2); $temp_f = round((($temp_c * 9) / 5) + 32,2); /* memory usage */ foreach(file('/proc/meminfo') as $ri) $m[strtok($ri, ':')] = strtok(''); /* displays memory used precentage */ $memory = 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100); /* free memory in mB rounded to tenths */ $memoryFree = round($m['MemFree']/(1024), 2); /* Buffered memory in mB rounded to tenths */ $bufferedMem = round($m['Buffers']/(1024), 2); /* cached Memoty in mB and rounded to tenths */ $cachedMem = round($m['Cached']/(1024),2); /* total memory in mB rounded to tenths */ $TotleMem = round($m['MemTotal']/(1024),2); /* disk free space a gigabytes and rounded to tenths */ $freeSpace = round(disk_free_space("/")/(1024*1024*1024), 2); /* total disk space in gigabytes and rounded to tenths */ $totalSpace = round(disk_total_space("/")/(1024*1024*1024), 2); /* disk free space in precentage */ $freePrecent = round($freeSpace / $totalSpace * 100, 2); /* server uptime*/ $uptime = shell_exec("cut -d. -f1 /proc/uptime"); $days = floor($uptime/60/60/24); $hours = $uptime/60/60%24; $mins = $uptime/60%60; $secs = $uptime%60; /* current server time */ $obsTime= date("g:i a" ,time()).' on '.date("l, F d, Y" ,time()); /* build status array */ $status=array( 'cpu' => $cpuUsage.' %', 'system load' => $sysLoad, 'cpu temp_c' => $temp_c.' C', 'cpu temp_f' => $temp_f.' F', 'memory' => $memory.' %', 'memory free' => $memoryFree.' mB', 'buffered memory' => $bufferedMem.' mB', 'memory cached' => $cachedMem.' mB', 'total memory' => $TotleMem.' mB', 'free gb' => $freeSpace.' gB', 'free precent' => $freePrecent.' %', 'total gb' => $totalSpace.' gB', 'uptime' => $days.' days '.$hours.' hours '.$mins.' minutes and '.$secs.' seconds', 'observation time' => $obsTime ); return $status; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFrDu
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E > > RETURN                                                   1

Function serverstatus:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 28
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 27
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 58, Position 2 = 69
Branch analysis from position: 58
2 jumps found. (Code = 78) Position 1 = 59, Position 2 = 69
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
Branch analysis from position: 28
filename:       /in/PFrDu
function name:  serverStatus
number of ops:  206
compiled vars:  !0 = $cpuUsage, !1 = $processes, !2 = $process, !3 = $cols, !4 = $sysLoad, !5 = $rawTemp, !6 = $temp_c, !7 = $temp_f, !8 = $ri, !9 = $m, !10 = $memory, !11 = $memoryFree, !12 = $bufferedMem, !13 = $cachedMem, !14 = $TotleMem, !15 = $freeSpace, !16 = $totalSpace, !17 = $freePrecent, !18 = $uptime, !19 = $days, !20 = $hours, !21 = $mins, !22 = $secs, !23 = $obsTime, !24 = $status
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, null
    6     1        INIT_FCALL                                               'exec'
          2        SEND_VAL                                                 'ps+-aux'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
    7     5      > FE_RESET_R                                       $27     !1, ->28
          6    > > FE_FETCH_R                                               $27, !2, ->28
    8     7    >   INIT_FCALL_BY_NAME                                       'split'
          8        SEND_VAL_EX                                              '+'
          9        INIT_FCALL_BY_NAME                                       'ereg_replace'
         10        SEND_VAL_EX                                              '+%2B'
         11        SEND_VAL_EX                                              '+'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0  $28     
         14        SEND_VAR_NO_REF_EX                                       $28
         15        DO_FCALL                                      0  $29     
         16        ASSIGN                                                   !3, $29
    9    17        INIT_FCALL                                               'strpos'
         18        FETCH_DIM_R                                      ~31     !3, 2
         19        SEND_VAL                                                 ~31
         20        SEND_VAL                                                 '.'
         21        DO_ICALL                                         $32     
         22        IS_SMALLER                                               -1, $32
         23      > JMPZ                                                     ~33, ->27
   10    24    >   FETCH_DIM_R                                      ~34     !3, 2
         25        CAST                                          5  ~35     ~34
         26        ASSIGN_OP                                     1          !0, ~35
    7    27    > > JMP                                                      ->6
         28    >   FE_FREE                                                  $27
   13    29        INIT_FCALL                                               'sys_getloadavg'
         30        DO_ICALL                                         $37     
         31        ASSIGN                                                   !4, $37
   15    32        INIT_FCALL                                               'shell_exec'
         33        SEND_VAL                                                 '%2Fopt%2Fvc%2Fbin%2Fvcgencmd+measure_temp'
         34        DO_ICALL                                         $39     
         35        ASSIGN                                                   !5, $39
   17    36        INIT_FCALL                                               'round'
         37        INIT_FCALL                                               'str_replace'
         38        SEND_VAL                                                 'temp%3D'
         39        SEND_VAL                                                 ''
         40        SEND_VAR                                                 !5
         41        DO_ICALL                                         $41     
         42        SEND_VAR                                                 $41
         43        SEND_VAL                                                 2
         44        DO_ICALL                                         $42     
         45        ASSIGN                                                   !6, $42
   18    46        INIT_FCALL                                               'round'
         47        MUL                                              ~44     !6, 9
         48        DIV                                              ~45     ~44, 5
         49        ADD                                              ~46     ~45, 32
         50        SEND_VAL                                                 ~46
         51        SEND_VAL                                                 2
         52        DO_ICALL                                         $47     
         53        ASSIGN                                                   !7, $47
   20    54        INIT_FCALL                                               'file'
         55        SEND_VAL                                                 '%2Fproc%2Fmeminfo'
         56        DO_ICALL                                         $49     
         57      > FE_RESET_R                                       $50     $49, ->69
         58    > > FE_FETCH_R                                               $50, !8, ->69
         59    >   INIT_FCALL                                               'strtok'
         60        SEND_VAR                                                 !8
         61        SEND_VAL                                                 '%3A'
         62        DO_ICALL                                         $51     
         63        INIT_FCALL                                               'strtok'
         64        SEND_VAL                                                 ''
         65        DO_ICALL                                         $53     
         66        ASSIGN_DIM                                               !9, $51
         67        OP_DATA                                                  $53
         68      > JMP                                                      ->58
         69    >   FE_FREE                                                  $50
   22    70        INIT_FCALL                                               'round'
         71        FETCH_DIM_R                                      ~54     !9, 'MemFree'
         72        FETCH_DIM_R                                      ~55     !9, 'Buffers'
         73        ADD                                              ~56     ~54, ~55
         74        FETCH_DIM_R                                      ~57     !9, 'Cached'
         75        ADD                                              ~58     ~56, ~57
         76        FETCH_DIM_R                                      ~59     !9, 'MemTotal'
         77        DIV                                              ~60     ~58, ~59
         78        MUL                                              ~61     ~60, 100
         79        SEND_VAL                                                 ~61
         80        DO_ICALL                                         $62     
         81        SUB                                              ~63     100, $62
         82        ASSIGN                                                   !10, ~63
   24    83        INIT_FCALL                                               'round'
         84        FETCH_DIM_R                                      ~65     !9, 'MemFree'
         85        DIV                                              ~66     ~65, 1024
         86        SEND_VAL                                                 ~66
         87        SEND_VAL                                                 2
         88        DO_ICALL                                         $67     
         89        ASSIGN                                                   !11, $67
   26    90        INIT_FCALL                                               'round'
         91        FETCH_DIM_R                                      ~69     !9, 'Buffers'
         92        DIV                                              ~70     ~69, 1024
         93        SEND_VAL                                                 ~70
         94        SEND_VAL                                                 2
         95        DO_ICALL                                         $71     
         96        ASSIGN                                                   !12, $71
   28    97        INIT_FCALL                                               'round'
         98        FETCH_DIM_R                                      ~73     !9, 'Cached'
         99        DIV                                              ~74     ~73, 1024
        100        SEND_VAL                                                 ~74
        101        SEND_VAL                                                 2
        102        DO_ICALL                                         $75     
        103        ASSIGN                                                   !13, $75
   30   104        INIT_FCALL                                               'round'
        105        FETCH_DIM_R                                      ~77     !9, 'MemTotal'
        106        DIV                                              ~78     ~77, 1024
        107        SEND_VAL                                                 ~78
        108        SEND_VAL                                                 2
        109        DO_ICALL                                         $79     
        110        ASSIGN                                                   !14, $79
   32   111        INIT_FCALL                                               'round'
        112        INIT_FCALL                                               'disk_free_space'
        113        SEND_VAL                                                 '%2F'
        114        DO_ICALL                                         $81     
        115        DIV                                              ~82     $81, 1073741824
        116        SEND_VAL                                                 ~82
        117        SEND_VAL                                                 2
        118        DO_ICALL                                         $83     
        119        ASSIGN                                                   !15, $83
   34   120        INIT_FCALL                                               'round'
        121        INIT_FCALL                                               'disk_total_space'
        122        SEND_VAL                                                 '%2F'
        123        DO_ICALL                                         $85     
        124        DIV                                              ~86     $85, 1073741824
        125        SEND_VAL                                                 ~86
        126        SEND_VAL                                                 2
        127        DO_ICALL                                         $87     
        128        ASSIGN                                                   !16, $87
   36   129        INIT_FCALL                                               'round'
        130        DIV                                              ~89     !15, !16
        131        MUL                                              ~90     ~89, 100
        132        SEND_VAL                                                 ~90
        133        SEND_VAL                                                 2
        134        DO_ICALL                                         $91     
        135        ASSIGN                                                   !17, $91
   38   136        INIT_FCALL                                               'shell_exec'
        137        SEND_VAL                                                 'cut+-d.+-f1+%2Fproc%2Fuptime'
        138        DO_ICALL                                         $93     
        139        ASSIGN                                                   !18, $93
   39   140        INIT_FCALL                                               'floor'
        141        DIV                                              ~95     !18, 60
        142        DIV                                              ~96     ~95, 60
        143        DIV                                              ~97     ~96, 24
        144        SEND_VAL                                                 ~97
        145        DO_ICALL                                         $98     
        146        ASSIGN                                                   !19, $98
   40   147        DIV                                              ~100    !18, 60
        148        DIV                                              ~101    ~100, 60
        149        MOD                                              ~102    ~101, 24
        150        ASSIGN                                                   !20, ~102
   41   151        DIV                                              ~104    !18, 60
        152        MOD                                              ~105    ~104, 60
        153        ASSIGN                                                   !21, ~105
   42   154        MOD                                              ~107    !18, 60
        155        ASSIGN                                                   !22, ~107
   44   156        INIT_FCALL                                               'date'
        157        SEND_VAL                                                 'g%3Ai+a'
        158        INIT_FCALL                                               'time'
        159        DO_ICALL                                         $109    
        160        SEND_VAR                                                 $109
        161        DO_ICALL                                         $110    
        162        CONCAT                                           ~111    $110, '+on+'
        163        INIT_FCALL                                               'date'
        164        SEND_VAL                                                 'l%2C+F+d%2C+Y'
        165        INIT_FCALL                                               'time'
        166        DO_ICALL                                         $112    
        167        SEND_VAR                                                 $112
        168        DO_ICALL                                         $113    
        169        CONCAT                                           ~114    ~111, $113
        170        ASSIGN                                                   !23, ~114
   47   171        CONCAT                                           ~116    !0, '+%25'
        172        INIT_ARRAY                                       ~117    ~116, 'cpu'
   48   173        ADD_ARRAY_ELEMENT                                ~117    !4, 'system+load'
   49   174        CONCAT                                           ~118    !6, '+C'
        175        ADD_ARRAY_ELEMENT                                ~117    ~118, 'cpu+temp_c'
   50   176        CONCAT                                           ~119    !7, '+F'
        177        ADD_ARRAY_ELEMENT                                ~117    ~119, 'cpu+temp_f'
   51   178        CONCAT                                           ~120    !10, '+%25'
        179        ADD_ARRAY_ELEMENT                                ~117    ~120, 'memory'
   52   180        CONCAT                                           ~121    !11, '+mB'
        181        ADD_ARRAY_ELEMENT                                ~117    ~121, 'memory+free'
   53   182        CONCAT                                           ~122    !12, '+mB'
        183        ADD_ARRAY_ELEMENT                                ~117    ~122, 'buffered+memory'
   54   184        CONCAT                                           ~123    !13, '+mB'
        185        ADD_ARRAY_ELEMENT                                ~117    ~123, 'memory+cached'
   55   186        CONCAT                                           ~124    !14, '+mB'
        187        ADD_ARRAY_ELEMENT                                ~117    ~124, 'total+memory'
   56   188        CONCAT                                           ~125    !15, '+gB'
        189        ADD_ARRAY_ELEMENT                                ~117    ~125, 'free+gb'
   57   190        CONCAT                                           ~126    !17, '+%25'
        191        ADD_ARRAY_ELEMENT                                ~117    ~126, 'free+precent'
   58   192        CONCAT                                           ~127    !16, '+gB'
        193        ADD_ARRAY_ELEMENT                                ~117    ~127, 'total+gb'
   59   194        CONCAT                                           ~128    !19, '+days+'
        195        CONCAT                                           ~129    ~128, !20
        196        CONCAT                                           ~130    ~129, '+hours+'
        197        CONCAT                                           ~131    ~130, !21
        198        CONCAT                                           ~132    ~131, '+minutes+and+'
        199        CONCAT                                           ~133    ~132, !22
        200        CONCAT                                           ~134    ~133, '+seconds'
        201        ADD_ARRAY_ELEMENT                                ~117    ~134, 'uptime'
   60   202        ADD_ARRAY_ELEMENT                                ~117    !23, 'observation+time'
   46   203        ASSIGN                                                   !24, ~117
   62   204      > RETURN                                                   !24
   63   205*     > RETURN                                                   null

End of function serverstatus

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.97 ms | 1404 KiB | 39 Q