Operating System - HP-UX
1751981 Members
4680 Online
108784 Solutions
New Discussion

Re: top command output not running in html page

 
Aamir14
Regular Advisor

top command output not runnibg in html page

Hi,
 
I want to run top command in html page
and i created script all command run in html page but
top command and sasmgr not running
 
This is my script:-----------------
 
#!/usr/bin/sh
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "<h1>General system information for host $(hostname -s)</h1>"
echo "<form action="/cgi-bin/top">
  <p style="margin: 2em 20%;">
    <input type="submit" value="DATE" >
  </p>
 </form>"
echo "<button type="button" onclick="/cgi-bin/top">Click Me!</button>"
echo "<h1>Memory Info</h1>"
echo "<pre> $(machinfo) </pre>"
echo "<h1>Disk Info:</h1>"
echo "<pre> $(bdf) </pre>"
print "`top -d 1 > top4.txt`\n";
echo "<pre> $(more top4.txt)</pre>"
echo "<pre> $(tail -1000000 /var/adm/syslog/syslog.log |grep error) </pre>"
echo "<pre> $(tail -1000000 /var/adm/syslog/syslog.log |grep Warning) </pre>"
echo "<pre> $(tail -1000000 /var/adm/syslog/syslog.log |grep CRITICAL) </pre>"
echo "<pre> $(tail -1000000 /var/adm/syslog/syslog.log |grep MAJOR) </pre>"
echo "<pre> $(tail -1000000 /var/adm/syslog/syslog.log |grep failed) </pre>"
echo "<pre> $(tail -1000000 /var/adm/syslog/syslog.log |grep NOTICE) </pre>"
echo "<pre> $(sasmgr get_info -D /dev/sasd0 -q raid |grep /dev/rdsk |awk '{print $5}') </pre>"
echo "<pre> '$(sasmgr get_info -D /dev/sasd0 -q raid |grep /dev/rdsk |awk '{print $5}')' </pre>"
echo "<pre> $(sasmgr get_info -D /dev/sasd0 -q raid > disk.txt) </pre>"
echo "<pre> $(more  disk.txt) </pre>"
 
echo "<pre> $(top -d 1) </pre>
#sasmgr get_info -D /dev/sasd0 -q raid | sleep 2
echo "<pre> $( sasmgr get_info -D /dev/sasd0 -q raid ) </pre>"
 
echo "<center>Information generated on $(date)</center>"
echo "</body></html>"
 
How can we run top and sasmgr command on html page
 
Thanks
aamir
10 REPLIES 10
Dennis Handly
Acclaimed Contributor

Re: top command output not running in html page

In order to get the text formatted top output, you must use the -f option to send it to a file.

echo "<pre> $(top -d 1 -f top-file; cat top-file; rm -f top-file) </pre>

 

>print "`top -d 1 > top4.txt`\n";
>echo "<pre> $(more top4.txt)</pre>"
 
You would need -f here too.  And not use more(1).

 

>echo "<pre> $(more  disk.txt) </pre>"

 

You should also replace more(1) by cat or:

echo "<pre> $(<  disk.txt) </pre>"

Aamir14
Regular Advisor

Re: top command output not running in html page

Hello

 

when i run my script1 on shell its run 

but when i run (or refresh) on html page its not run

 

my question is that 

when i run script1 every single command  run properly is on the script1 and its output shown in html page

 

 

but top command output not shown in the html page  .

 

This is the html output :----------------------------------------------------------------

 

 

General system information for host

Click Me!

Firmware info

 Firmware info:
   Firmware revision:  04.32
   FP SWA driver revision: 1.18
   IPMI is supported on this system.
   BMC firmware revision: 5.26 

Platform info

 Platform info:
   Model:                  "ia64 hp server rx3600"
   Machine ID number:      27220f96-383d-11de-ad39-ef4b35b5d5c9
   Machine serial number:  SGH4913M52 

OS info

 OS info:
   Nodename:  billdev1
   Release:   HP-UX B.11.31
   Version:   U (unlimited-user license)
   Machine:   ia64
   ID Number: 0656543638
   vmunix _release_version:               
@(#) $Revision: vmunix:    B.11.31_LR FLAVOR=perf  

CPU info

 CPU info:
  1 Intel(R) Itanium 2 9100 series processor (1.67 GHz, 18 MB)
          666 MT/s bus, CPU version A1
          2 logical processors (2 per socket) 

/Memory

 Memory: 8161 MB (7.97 GB) 
 
 

Disk Info:

 Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    2097152  274320 1808688   13% /
/dev/vg00/lvol1    3145728  312248 2811432   10% /stand
/dev/vg00/lvol8    25690112 2189912 23316688    9% /var
/dev/vg00/lvol7    5210112 3261024 1933920   63% /usr
/dev/vg00/lvol6    3145728  669744 2456784   21% /tmp
/dev/vg00/lvol5    10485760 6616760 3838784   63% /opt
/dev/vg00/lvol4    1048576   52424  988496    5% /home
appsdev2:/backupserver/appsdev1
                   235929600 131457725 98131283   57% /share 
 
 Nov 22 00:30:13 billdev1 sshd[15224]: error: PAM: Authentication failed for root from 192.168.29.9
Dec  4 13:32:48 billdev1 sshd[5885]: error: PAM: Authentication failed for root from 192.168.10.60
Dec  4 13:32:54 billdev1 sshd[5885]: error: PAM: Authentication failed for root from 192.168.10.60
Dec  5 17:03:40 billdev1 sshd[18427]: error: setsockopt SO_KEEPALIVE: Invalid argument 
 
 
 
 Nov 22 00:30:13 billdev1 sshd[15224]: error: PAM: Authentication failed for root from 192.168.29.9
Dec  4 13:32:48 billdev1 sshd[5885]: error: PAM: Authentication failed for root from 192.168.10.60
Dec  4 13:32:54 billdev1 sshd[5885]: error: PAM: Authentication failed for root from 192.168.10.60 
 Nov 10 15:30:16 billdev1 vmunix: NOTICE: nfs_client_pv3_install(): nfs3 File system was registered at index 10.
Nov 10 15:30:16 billdev1 vmunix: NOTICE: nfs_client_pv4_install(): nfs4 File system was registered at index 11.
Nov 10 15:30:16 billdev1 vmunix: NOTICE: cachefsc_install: cachefs File system was registered at index 13. 
 
 '' 

 

please suggest me how can do this

 

Thanks

Aamir

Dennis Handly
Acclaimed Contributor

Re: top command output not running in html page

>please suggest me how can do this

 

I did.  Did you try -f top-file?

Aamir14
Regular Advisor

Re: top command output not running in html page

yes i done that.

 

see it.

 

echo "<pre> $(top -d 1 -f top-file; < top-file) </pre>"
echo "<pre> $(more top-file)</pre>"
 
 
but cant run on html page.
 
 

Thanks

aamir

Dennis Handly
Acclaimed Contributor

Re: top command output not running in html page

>echo "<pre> $(more top-file)</pre>"

 

No need for that more(1) line, the cat on previous should do it.

 

What's in top-file?  You may need to capture stderr:

echo "<pre> $(top -d 1 -f top-file 2>> top-file; cat top-file) </pre>"

Aamir14
Regular Advisor

Re: top command output not running in html page

hello

 

i already ran on sh shell 

but when i refresh html page on browser it shown older entry.

 

I already run the command on shell 

 

i want to  refresh command output on every single click(refresh) in browser.

 

 

Thanks

aamir

 

 

 

Dennis Handly
Acclaimed Contributor

Re: top command output not running in html page

>i want to  refresh command output on every single click(refresh) in browser.

 

Are the other (non-top) values changing?  Make sure you remove that output file.

Aamir14
Regular Advisor

Re: top command output not running in html page

Hi,

 

This is my file:-----------------------------------

 

#!/usr/bin/sh
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "<h1>General system information for host $(hostname -s)</h1>"
echo "<pre> $(top -d 1 -f top-file 2> top-file; cat top-file) </pre>"
echo "<center>Information generated on $(date)</center>"
echo "</body></html>"
 
and this is my html output:-----------------------------
----------------------------------------------------------------------------------
 
General system information for host
 
Information generated on Tue Dec 31 11:45:53 IST 2013
 
 
Please suggest me what is a problem ?
 
Thanks
aamir
 
 
 
 
 
 
 
 
Dennis Handly
Acclaimed Contributor

Re: top command output not running in html page

>Please suggest me what is a problem?

 

What's in top-file?  Also "2>" should probably be "2>>".

 

What happens when you invoke:

top -d 1 -f top-file 2> top-file; cat top-file