class_cpu.inc 2.4 KB

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