kstat - format of output data?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers kstat - format of output data?
# 1  
Old 06-15-2005
kstat - format of output data?

Hi,

I am looking for a cpu usage data (%usr, %iowait, %idle, %kernel) using kstat. The output of kstat is below. How do I interpret those numeric values? In other words, how do I calculate the percentage value using the values below?

Thanks a lot!
Ozvena

Code:
module: cpu_stat                        instance: 9
name:   cpu_stat9                       class:    misc

.
.
.

        idle                            1033213481
        iowait                          0
        kernel                          13188786
        user                            40271834
.
.
.
.

# 2  
Old 06-15-2005
Even with a question like... no mention of which os is involved. Smilie There is no hope...

That looks like output from the SunOS kstat command. I really don't understand this kstat driver or kstat library on SunOS. Traditionally, this stuff would come from a sysinfo structure. "nm /dev/ksyms" shows that the sysinfo structure is there and the structure is documented in /usr/include/sys/sysinfo.h. So that is where I would expect SunOS to get this info. After studying the sar source code which Sun so kindly made available yesterday, it does appear that you are looking at the right data.

So how did you figure this much out? Were you reading the source code too, or did you have some kstat reference?

Roughly, you read the numbers once. And then you wait. And then you read them again. Then you subtract the first numbers from the second to get an array of deltas. You have 10 instances so I guess you have 10 cpus. Consider just one instance. (Or maybe you want to add the instances together to get a system-wide view.) You add the deltas up and you have total number of times that any of the counters for that cpu incremented during the wait period. Now you figure out how much of the total each piece is. That gives the percentages over the wait period.

You know, you could just run "sar 1 4" or something.
# 3  
Old 06-16-2005
Thank you for your response.

Yes, this is Sun OS kstat command.

“So how did you figure this much out?” “Were you reading the source code too, or did you have some kstat reference?”

Well, our product performance is monitored by a third party SW that we have no detail information about. This monitoring SW uses kstat as we have learned and data coming out of this monitor concern our customer. We did monitor our system (cpu utilization) using top, prstat, sar but we do not see spikes in cpu utilization as reported by this monitor based on kstat. Our goal is to understand kstat data.

I used man pages for kstat and learned syntax but it doesn't describe output data in any way. Smilie Also I used my intuition to figure out what data I am looking at.

Actually we have more than 10 CPUs and yes the example is for CPU #10.

“Roughly, you read the numbers once. And then you wait. And then you read them again. Then you subtract the first numbers from the second to get an array of deltas.”

“You add the deltas up and you have total number of times that any of the counters for that cpu incremented during the wait period. Now you figure out how much of the total each piece is. That gives the percentages over the wait period.”

I am not sure what you mean here but I guess it is too late for me to get it. I will re-read it tomorrow morning. Smilie

”You know, you could just run "sar 1 4" or something.” Yeah, sar is nice but not consistent with data we see on the third party monitor with a sampling rate of 15 seconds.
# 4  
Old 06-16-2005
Maybe thsi will help... every so often (HZ times a second I believe), a routine runs. It will increment one of those 4 counters. If 33% of the time it incremented idle, you want to say the cpu was 33% idle. So if you read the counters, wait 1 second, and read them again, you have two sets of counters. By subtracting you get the deltas (or differences). The deltas tell you how many times each counter was incremented over the past second. Now you need to calculate the % that each delta is of the total delta.
# 5  
Old 06-16-2005
Thnaks for directions!



Code:
/usr/src/cmd/sa/sadc.c
* load statistics, summing across CPUs where needed
.
.
.
static int all_stat_load(void)
.
.
* Accumulate cpu ticks for CPU_IDLE, CPU_USER, CPU_KERNEL and
* CPU_WAIT with respect to each of the cpus.
  for (j = 0; j < CPU_STATES; j++)
	cpu_tick[j] += tp[j];
.
.
.

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

2. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

3. Shell Programming and Scripting

Format data output result

Hi guys, need a guide to format desire output result here. Please guide me. Thanks in advance. 2012-08-30 00:01:56,554 DEBUG - Sending message<TTT232MM0N048YCI TTPC TTOF1A 289171092679389OOLU 1562340 TPM 641 KT$YES 20120830000156KK 12012301??????000011YGY> to... (7 Replies)
Discussion started by: ment0smintz
7 Replies

4. Shell Programming and Scripting

Help with perl script to output data in table format...

Hello, I need help with a perl script that will process a text file and match virtual server name to profile(s). the rest will be ignored. Virtual server name follows the word "virtual" in the begging of the line. There could be multiple profiles assigned to one virtual server. For example, ... (3 Replies)
Discussion started by: besogon
3 Replies

5. Solaris

Question on kstat output

I'm having a little trouble understanding the output I'm seeing from kstat for the "net" class. I'm seeing a lot of entries with "mac" as the name, like this. module: bge instance: 3 name: mac class: net ... (3 Replies)
Discussion started by: Midcain
3 Replies

6. Solaris

Issue with kstat

I have a server on Solaris 8 who had a sudden reboot once and now the messages log is filled with these errors: Mar 23 02:14:42 srt-hlr-b unix: NOTICE: kstat_create('unix', 0, 'icmp_minor_1'): cannot create kstat before kstat_init() Mar 23 02:14:42 srt-hlr-b unix: NOTICE: kstat_create('vmem',... (10 Replies)
Discussion started by: StarSol
10 Replies

7. Solaris

kstat on T5220

We used kstat on netra240/440 to check if the link is full duplex. So we do something like: bash-3.00# kstat -pc net bge:1::/'link_duplex'/ | cut -f2 2 The output 2 indicates the link is full duplex. This kind of check worked all right for Netra 240/440 systems. However, the nxge... (2 Replies)
Discussion started by: illcar
2 Replies

8. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

9. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies

10. Solaris

where can i get the variable tree for kvm & kstat

Hi all, I am working on the symbEL to get some specific value from the kernel recently. But I am not sure whether kvm and kstat have such specific value. i checked the examples included with the RICHPse but didn't get the answer. also the "kstat" seems not have any description. Is there a... (2 Replies)
Discussion started by: sleepy_11
2 Replies
Login or Register to Ask a Question