@@ -31,6 +31,7 @@ $(document).ready(() => {
3131
3232 const $status = $ ( '#node-red-status' ) ;
3333 const $memory = $ ( '#node-red-memory' ) ;
34+ const $cpu = $ ( '#node-red-cpu' ) ;
3435
3536 $alertSaved . hide ( ) ;
3637 $alertError . hide ( ) ;
@@ -56,10 +57,16 @@ $(document).ready(() => {
5657 let psTimeout ;
5758 let psInterval = 5000 ;
5859
60+ function cpu ( ) {
61+ $ . get ( `service.cgi?sid=${ sid } &cmd=cpu` , ( data , success ) => {
62+ $cpu . html ( data ? 'cpu ' + data : '' ) ;
63+ } ) ;
64+ }
65+
5966 function ps ( ) {
6067 clearTimeout ( psTimeout ) ;
6168 $ . get ( `service.cgi?sid=${ sid } &cmd=ps` , ( data , success ) => {
62- console . log ( data ) ;
69+ cpu ( ) ;
6370 const lines = data . split ( '\n' ) ;
6471 let found = false ;
6572 lines . forEach ( line => {
@@ -83,7 +90,7 @@ $(document).ready(() => {
8390 $linkRed . removeClass ( 'disabled' ) ;
8491 $linkUi . removeClass ( 'disabled' ) ;
8592 $start . addClass ( 'disabled' ) ;
86- psInterval = 10000 ;
93+ psInterval = 5000 ;
8794 return ;
8895 }
8996 match = line . match ( / ( [ 0 - 9 ] + [ a - z ] ? ) \s + ( [ 0 - 9 ] + [ a - z ] ? ) \s + .* r e d .j s / ) ;
@@ -117,7 +124,7 @@ $(document).ready(() => {
117124 $start . removeClass ( 'disabled' ) ;
118125 $linkRed . addClass ( 'disabled' ) ;
119126 $linkUi . addClass ( 'disabled' ) ;
120- psInterval = 10000 ;
127+ psInterval = 5000 ;
121128 }
122129 psTimeout = setTimeout ( ps , psInterval ) ;
123130 } ) ;
@@ -348,7 +355,7 @@ $(document).ready(() => {
348355 psInterval = 2000 ;
349356 setTimeout ( ( ) => {
350357 ps ( ) ;
351- } , 3000 ) ;
358+ } , 4000 ) ;
352359 alert ( $alertExec ) ;
353360 } else {
354361 alert ( $alertError ) ;
0 commit comments