| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | /* | 
					
						
							|  |  |  |  * Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org> | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2015-01-16 08:51:26 +00:00
										 |  |  |  * Process Listing | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  |  * @author Daniel Preussker <f0o@devilcode.org> | 
					
						
							|  |  |  |  * @copyright 2015 f0o, LibreNMS | 
					
						
							|  |  |  |  * @license GPL | 
					
						
							|  |  |  |  * @package LibreNMS | 
					
						
							|  |  |  |  * @subpackage Pages | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | switch ($vars['order']) { | 
					
						
							|  |  |  |     case 'vsz': | 
					
						
							|  |  |  |         $order = '`vsz`'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case 'rss': | 
					
						
							|  |  |  |         $order = '`rss`'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case 'cputime': | 
					
						
							|  |  |  |         $order = '`cputime`'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case 'user': | 
					
						
							|  |  |  |         $order = '`user`'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case 'command': | 
					
						
							|  |  |  |         $order = '`command`'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         $order = '`pid`'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | }//end switch
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($vars['by'] == 'desc') { | 
					
						
							|  |  |  |     $by = 'desc'; | 
					
						
							| 
									
										
										
										
											2016-08-18 20:28:22 -05:00
										 |  |  | } else { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     $by = 'asc'; | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $heads = array( | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     'PID'     => '', | 
					
						
							|  |  |  |     'VSZ'     => 'Virtual Memory', | 
					
						
							|  |  |  |     'RSS'     => 'Resident Memory', | 
					
						
							|  |  |  |     'cputime' => '', | 
					
						
							|  |  |  |     'user'    => '', | 
					
						
							|  |  |  |     'command' => '', | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "<div class='table-responsive'><table class='table table-hover'><thead><tr>"; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | foreach ($heads as $head => $extra) { | 
					
						
							|  |  |  |     unset($lhead, $bhead); | 
					
						
							|  |  |  |     $lhead = strtolower($head); | 
					
						
							|  |  |  |     $bhead = 'asc'; | 
					
						
							|  |  |  |     $icon  = ''; | 
					
						
							|  |  |  |     if ('`'.$lhead.'`' == $order) { | 
					
						
							| 
									
										
										
										
											2016-09-22 10:44:17 -04:00
										 |  |  |         $icon = " class='fa fa-chevron-"; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         if ($by == 'asc') { | 
					
						
							|  |  |  |             $bhead = 'desc'; | 
					
						
							|  |  |  |             $icon .= 'up'; | 
					
						
							| 
									
										
										
										
											2016-08-18 20:28:22 -05:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |             $icon .= 'down'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $icon .= "'"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-11 14:54:05 -07:00
										 |  |  |     echo '<th><a href="' . generate_url(array('page'=>'device','device'=>$device['device_id'], 'tab'=>'processes', 'order'=>$lhead, 'by'=>$bhead)) . '"><span'.$icon.'> '; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if (!empty($extra)) { | 
					
						
							|  |  |  |         echo "<abbr title='$extra'>$head</abbr>"; | 
					
						
							| 
									
										
										
										
											2016-08-18 20:28:22 -05:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         echo $head; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     echo '</span></a></th>'; | 
					
						
							|  |  |  | }//end foreach
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo '</tr></thead><tbody>'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { | 
					
						
							|  |  |  |     echo '<tr>'; | 
					
						
							|  |  |  |     echo '<td>'.$entry['pid'].'</td>'; | 
					
						
							|  |  |  |     echo '<td>'.format_si(($entry['vsz'] * 1024)).'</td>'; | 
					
						
							|  |  |  |     echo '<td>'.format_si(($entry['rss'] * 1024)).'</td>'; | 
					
						
							|  |  |  |     echo '<td>'.$entry['cputime'].'</td>'; | 
					
						
							|  |  |  |     echo '<td>'.$entry['user'].'</td>'; | 
					
						
							|  |  |  |     echo '<td>'.$entry['command'].'</td>'; | 
					
						
							|  |  |  |     echo '</tr>'; | 
					
						
							| 
									
										
										
										
											2015-01-15 07:18:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | echo '</tbody></table></div>'; |