mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/package/base/oprofile/pulpstoned.sh
  11. # ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. period=600
  25. report_script=pulpstoner
  26. report_dir=/var/log/pulpstone
  27. pidfile=/var/run/pulpstoned.pid
  28. cd /; mkdir -p $report_dir
  29. echo "pulpstone daemon: writing logs to $report_dir ..."
  30. (
  31. psd_end() {
  32. opcontrol -h
  33. echo "Shutting down on signal."
  34. rm -f $pidfile
  35. date +"=== <%Y/%m/%d %H:%M:%S> ==="
  36. exit 0
  37. }
  38. trap psd_end INT TERM
  39. echo $$ > $pidfile
  40. while true; do
  41. now=`date +"%Y%m%d%H"`
  42. exec >> $report_dir/$now.log 2>&1
  43. for x in $report_dir/*.log; do
  44. [ "$x" = "$report_dir/$now.log" ] && continue
  45. echo; echo "Uploading $report_dir/$now.log ..."
  46. res="$( curl -s -F data=@$x http://www.rocklinux.net/pulpstone/upload.cgi )"
  47. if [ "$res" = "ok" ]; then
  48. echo "File upload succesfull."
  49. mv $x ${x%.log}.old
  50. else
  51. echo "Error while uploading."
  52. fi
  53. done
  54. date +"%n=== <%Y/%m/%d %H:%M:%S> ==="
  55. opcontrol -s
  56. opcontrol --reset
  57. opcontrol --event="CPU_CLK_UNHALTED:100000:0:1:1"
  58. for ((c=0; c<period; c++)); do sleep 1; done
  59. opcontrol -h
  60. date +"=== <%Y/%m/%d %H:%M:%S> ==="
  61. nice -n 99 $report_script | unexpand -a
  62. date +"=== <%Y/%m/%d %H:%M:%S> ==="
  63. done
  64. ) &