class_cpu.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // $Id: class_cpu.inc,v 1.4 2002/11/29 10:45:46 dijkstra Exp $
  3. require_once("class_graph.inc");
  4. class CPU_Graph extends Graph {
  5. function CPU_Graph() {
  6. // get all the sensible defaults from our parent class
  7. $this->init();
  8. }
  9. function execute($url) {
  10. $this->url2options($url);
  11. // and add a few private things
  12. $this->graphsettings["rawcmdline"] .=" -v '% cpu(".$this->get("name").")' -u 100 --rigid ";
  13. $this->shortcut = array_merge($this->shortcut, array(
  14. "cpu" => array(
  15. "brief" => array(
  16. "dsdefinition" => array(
  17. "DEF:A=".$this->get("rrdfile").":user:AVERAGE",
  18. "DEF:B=".$this->get("rrdfile").":nice:AVERAGE",
  19. "DEF:C=".$this->get("rrdfile").":system:AVERAGE",
  20. "DEF:D=".$this->get("rrdfile").":interrupt:AVERAGE",
  21. "DEF:E=".$this->get("rrdfile").":idle:AVERAGE"),
  22. "graphdefinition" => array(
  23. "AREA:A#00FF00:'user'",
  24. "GPRINT:A:AVERAGE:'%.0lf\g'",
  25. "STACK:B#00FFFF:'nice'",
  26. "GPRINT:B:AVERAGE:'%.0lf\g'",
  27. "STACK:C#DDA0DD:'system'",
  28. "GPRINT:C:AVERAGE:'%.0lf\g'",
  29. "STACK:D#9932CC:'interrupt'",
  30. "GPRINT:D:AVERAGE:'%.0lf\g'",
  31. "STACK:E#F5FFFA:'idle'",
  32. "GPRINT:E:AVERAGE:'%.0lf\g'")),
  33. "detailed" => array(
  34. "dsdefinition" => array(
  35. "DEF:A=".$this->get("rrdfile").":user:AVERAGE",
  36. "DEF:B=".$this->get("rrdfile").":nice:AVERAGE",
  37. "DEF:C=".$this->get("rrdfile").":system:AVERAGE",
  38. "DEF:D=".$this->get("rrdfile").":interrupt:AVERAGE",
  39. "DEF:E=".$this->get("rrdfile").":idle:AVERAGE"),
  40. "graphdefinition" => array(
  41. 'COMMENT:" min avg max last\n"',
  42. "AREA:A#00FF00:'user '",
  43. 'GPRINT:A:MIN:" %6.2lf %%"',
  44. 'GPRINT:A:AVERAGE:"%6.2lf %%"',
  45. 'GPRINT:A:MAX:"%6.2lf %%"',
  46. 'GPRINT:A:LAST:"%6.2lf %%\n"',
  47. "STACK:B#00FFFF:'nice '",
  48. 'GPRINT:B:MIN:" %6.2lf %%"',
  49. 'GPRINT:B:AVERAGE:"%6.2lf %%"',
  50. 'GPRINT:B:MAX:"%6.2lf %%"',
  51. 'GPRINT:B:LAST:"%6.2lf %%\n"',
  52. "STACK:C#DDA0DD:'system '",
  53. 'GPRINT:C:MIN:" %6.2lf %%"',
  54. 'GPRINT:C:AVERAGE:"%6.2lf %%"',
  55. 'GPRINT:C:MAX:"%6.2lf %%"',
  56. 'GPRINT:C:LAST:"%6.2lf %%\n"',
  57. "STACK:D#9932CC:'interrupt'",
  58. 'GPRINT:D:MIN:" %6.2lf %%"',
  59. 'GPRINT:D:AVERAGE:"%6.2lf %%"',
  60. 'GPRINT:D:MAX:"%6.2lf %%"',
  61. 'GPRINT:D:LAST:"%6.2lf %%\n"',
  62. "STACK:E#F5FFFA:'idle '",
  63. 'GPRINT:E:MIN:" %6.2lf %%"',
  64. 'GPRINT:E:AVERAGE:"%6.2lf %%"',
  65. 'GPRINT:E:MAX:"%6.2lf %%"',
  66. 'GPRINT:E:LAST:"%6.2lf %%\n"')))));
  67. $this->graphdefaults = array_merge($this->graphdefaults,
  68. $this->shortcut["cpu"]["brief"]);
  69. $this->url2options($url);
  70. }
  71. }
  72. ?>