Advertisement
Guest User

Untitled

a guest
Sep 15th, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html><head>
  3. <title>SimpleNode Network Monitor</title>
  4. <meta charset="UTF-8">
  5. <meta name="description" content="" />
  6. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  7. <!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  8. <script type="text/javascript" src="js/prettify.js"></script>                                   <!-- PRETTIFY -->
  9. <script type="text/javascript" src="js/kickstart.js"></script>                                  <!-- KICKSTART -->
  10. <link rel="stylesheet" type="text/css" href="css/kickstart.css" media="all" />                  <!-- KICKSTART -->
  11. <link rel="stylesheet" type="text/css" href="style.css" media="all" />                          <!-- CUSTOM STYLES -->
  12. </head><body><a id="top-of-page"></a><div id="wrap" class="clearfix">
  13. <!-- ===================================== END HEADER ===================================== -->
  14.  
  15. <?php
  16.     //Node 1 (Argon)
  17.     //$node1xml = file_get_contents("https://argon.node.simpleno.de/phpsysinfo/xml.php");
  18.     $node1xml = file_get_contents("xmlcache/node1.xml");
  19.     $node1 = new SimpleXMLElement($node1xml);
  20.    
  21.     //Node 2 (Beryllium)
  22.     //$node2xml = file_get_contents("http://beryllium.node.simpleno.de/phpsysinfo/xml.php");
  23.     $node2xml = file_get_contents("xmlcache/node2.xml");
  24.     $node2 = new SimpleXMLElement($node2xml);
  25.  
  26. //Gets Uptime from all nodes
  27.     //Node 1 (Argon)
  28.     //Extracts RAM amount from the XML
  29.     $node1uptime = $node1->Vitals['Uptime'];
  30.     //Converts Array -> Floating Point
  31.     $node1uptime = (float)$node1uptime;
  32.     //Converts Seconds -> Days
  33.     $node1up = $node1uptime/86400;
  34.    
  35.     //Node 1 (Argon)
  36.     //Extracts RAM amount from the XML
  37.     $node2uptime = $node2->Vitals['Uptime'];
  38.     //Converts Array -> Floating Point
  39.     $node2uptime = (float)$node2uptime;
  40.     //Converts Seconds -> Days
  41.     $node2up = $node2uptime/86400;
  42.    
  43. //Get CPU Usage from all nodes
  44.     //Node 1 (Argon)
  45.     $node1cpuusage = $node1->Vitals['CPULoad'];
  46.     //Converts Array -> Floating Point
  47.     $node1cpu = (float)$node1cpuusage;
  48.    
  49.     //Node 1 (Argon)
  50.     $node2cpuusage = $node2->Vitals['CPULoad'];
  51.     //Converts Array -> Floating Point
  52.     $node2cpu = (float)$node2cpuusage;
  53.        
  54. //Gets RAM from all nodes
  55.     //Node 1 (Argon)
  56.     //Extracts RAM amount from the XML
  57.     $node1mem = $node1->Memory->Details['App'];
  58.     //Converts Array -> Floating Point
  59.     $node1mem = (float)$node1mem;
  60.     //Converts Bytes -> Gigabytes
  61.     $node1ram = $node1mem/1073751824;
  62.  
  63.     //Node 2 (Beryllium)
  64.     //Extracts RAM amount from the XML
  65.     $node2mem = $node2->Memory->Details['App'];
  66.     //Converts Array -> Floating Point
  67.     $node2mem = (float)$node2mem;
  68.     //Converts Bytes -> Gigabytes
  69.     $node2ram = $node2mem/1073751824;
  70.    
  71.     //Adds RAM together
  72.     $ramusage = $node1ram + $node2ram;
  73.     //Rounds Number to 2 decimal places
  74.     $ramusage = round($ramusage, 2);
  75.    
  76. //Gets usage of /vz from all nodes
  77.     //Node 1 (Argon)
  78.     //Extracts HDD usage of /vz from XML
  79.     $node1drive = $node1->FileSystem->Mount[3]['Used'];
  80.     //Converts Array -> Floating Point
  81.     $node1drive = (float)$node1drive;
  82.     //Converts Bytes -> Gigabytes
  83.     $node1hdd = $node1drive/1073751824;
  84.    
  85.     //Node 2 (Beryllium)
  86.     //Extracts HDD usage of /vz from XML
  87.     $node2drive = $node2->FileSystem->Mount[3]['Used'];
  88.     //Converts Array -> Floating Point
  89.     $node2drive = (float)$node2drive;
  90.     //Converts Bytes -> Gigabytes
  91.     $node2hdd = $node2drive/1073751824;
  92.  
  93.     //Adds Disk usage together
  94.     $diskusage = $node1hdd + $node2hdd;
  95.     //Rounds Number to 1 decimal place
  96.     $diskusage = round($diskusage, 1);
  97.    
  98. //Gets bandwidth usage since last restart from all nodes
  99.     //Node 1 (Argon)
  100.     //Gets B/W usage in and out
  101.     $node1bwRX = $node1->Network->NetDevice[1]['RxBytes'];
  102.     $node1bwTX = $node1->Network->NetDevice[1]['TxBytes'];
  103.     //Converts Arrays -> Floating Points
  104.     $node1bwRX = (float)$node1bwRX;
  105.     $node1bwTX = (float)$node1bwTX;
  106.     //Adds Tx and Rx together
  107.     $node1bwtotal = $node1bwRX + $node1bwTX;
  108.     //Converts Bytes -> Terabytes
  109.     $node1bw = $node1bwtotal/1099521867780;
  110.    
  111.     //Node 2 (Beryllium)
  112.     //Gets B/W usage in and out
  113.     $node2bwRX = $node2->Network->NetDevice[1]['RxBytes'];
  114.     $node2bwTX = $node2->Network->NetDevice[1]['TxBytes'];
  115.     //Converts Arrays -> Floating Points
  116.     $node2bwRX = (float)$node2bwRX;
  117.     $node2bwTX = (float)$node2bwTX;
  118.     //Adds Tx and Rx together
  119.     $node2bwtotal = $node2bwRX + $node2bwTX;
  120.     //Converts Bytes -> Terabytes
  121.     $node2bw = $node2bwtotal/1099521867780;
  122.    
  123.     //Adds Bandwidth usage together
  124.     $bandwidth = $node2bw + $node1bw;
  125.     //Rounds to 2 decimal places
  126.     $bandwidth = round($bandwidth, 2);
  127. ?>
  128. <div class="col_12">
  129. <h1 style="text-align:center;">SimpleNode Network Monitor</h1>
  130. <br/>
  131. <h4>Detailed Statistics</h4>
  132. <div>
  133. <table cellspacing="0" cellpadding="0" class="striped">
  134. <thead><tr>
  135.     <th> </th>
  136.     <th>Online</th>
  137.     <th>RAM Usage</th>
  138.     <th>CPU Usage</th>
  139.     <th>Bandwidth Usage</th>
  140.     <th>Hard Disk Usage</th>
  141.     <th>Uptime</th>
  142. </tr></thead>
  143. <tbody><tr>
  144.     <th>Node 1 (Argon)</th>
  145.     <td><span class="icon green medium" data-icon="C"></span></td>
  146.     <td><?php echo round($node1ram, 2)." GB"; ?></td>
  147.     <td><?php echo round($node1cpu, 2)."%"; ?></td>
  148.     <td><?php echo round($node1bw, 2)." TB"; ?></td>
  149.     <td><?php echo round($node1hdd, 2)." GB"; ?></td>
  150.     <td><?php echo round($node1up, 2)." Days"; ?></td>
  151. </tr><tr>
  152.     <th>Node 2 (Beryllium)</th>
  153.     <td><span class="icon green medium" data-icon="C"></span></td>
  154.     <td><?php echo round($node2ram, 2)." GB"; ?></td>
  155.     <td><?php echo round($node2cpu, 2)."%"; ?></td>
  156.     <td><?php echo round($node2bw, 2)." TB"; ?></td>
  157.     <td><?php echo round($node2hdd, 2)." GB"; ?></td>
  158.     <td><?php echo round($node2up, 2)." Days"; ?></td>
  159. </tr></tbody>
  160. </table>
  161. </div>
  162. </div>
  163.  
  164.  
  165. <!-- ===================================== START FOOTER ===================================== -->
  166. </div>
  167.  
  168. </div><!-- END WRAP -->
  169. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement