0

I'm writing a kernel-level program in Solaris that monitors the workload of the system and reports the stats --something similar to netstats in linux and kstat in Solaris. Where the source code for kstat is located in Solaris 11+ * source code?

*Edit: 12 -> 11

  • Solaris is proprietary now, so you can't get its source code. But it sounds like an XY problem, why you can't use Solaris 11 as the reference platform? – myaut Jul 8 '15 at 18:44
  • Did you mean Solaris 11? I don't think 12 has been announced. I'm pretty sure Oracle doesn't supply source code, either. Maybe through OTN? – Jeff Schaller Jul 8 '15 at 18:45
  • What those guys said. Perhaps the illumos source will help you: github.com/illumos/illumos-gate/tree/master/usr/src/lib/… – Steve Wills Jul 8 '15 at 18:46
1

I guess you mean Solaris 11.2 as Solaris 12 is not yet released, possibly next year (2016) according to a roadmap.

/usr/bin/kstat is a Perl script in Solaris 11.2 so while still proprietary code, you can certainly read its source code.

An alternative, C based open source version of the kstat command is available here https://github.com/illumos/illumos-gate/tree/09f79f7c66b85f056db11f58210dc6182c9b1aef/usr/src/cmd/stat/kstat

It likely compiles and works fine with current and possibly future Solaris releases.

| improve this answer | |
  • kstat is actually a kernel interface for providing various statistics. See kstat_lookup(3KSTAT) for example. /usr/bin/kstat is one of the possible interfaces. – myaut Jul 8 '15 at 19:27
  • @myaut I doubt the OP wants to rewrite an alternative to the low level kstat API. I then assume he is looking to the code of the kstat command. The fact he mentioned netstat, which is also based on the kstat library on Solaris but on the proc pseudo file system on Linux reinforced that impression. – jlliagre Jul 8 '15 at 19:47
  • @jilliagre: depends on language he uses. If you write it in C or C++, using native libkstat is definitely better than calling perlprogram and parsing its output. – myaut Jul 8 '15 at 19:52
  • 1
    @AliAbbasinasab A link to an open source C kstat implementation is already in my answer. – jlliagre Jul 8 '15 at 20:26
  • 1
    @myaut Absolutely. I have written such programs and the source code of mpstat, netstat, iostat and similar commands is available under the github.com/illumos/illumos-gate/tree/… directory, along with the already mentioned kstat command. – jlliagre Jul 8 '15 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.