...
Code Block | ||||
---|---|---|---|---|
| ||||
#!/usr/bin/php <?php // HTTP thread monitoring - Chun Kang (ck@ckii.com) at 2021-11-02 foreach($argv as $v) { $v = strtolower($v); } $loop_limit=99999; $hostname = gethostname(); for($i=0; $i<$loop_limit; $i++) { if ($i) sleep(1); $resp = shell_exec( "ss | grep http | wc -l"); $process_count = intval($resp); if ($process_count<100) $bar_str = "\033[32m"; else if ($process_count<200) $bar_str = "\033[33m"; else if ($process_count<500) $bar_str = "\033[35m"; else { $bar_str = "\033[31m"; } $bar_str = ""; if ($process_count) { $bar_count = round( $process_count/20, 0); while( $bar_count>0 ) { $bar_str .= "#"; $bar_count--; } if ($process_count) $bar_str .= "#"; $bar_str .= "\033[0m "; } echo "[{$hostname}] {$bar_str}{$process_count}\n"; } |
...