| #!/bin/sh |
| |
| PROGRAM_DIR="`dirname \"$0\"`" |
| . "$PROGRAM_DIR/utils.sh" |
| load_config_file "$PROGRAM_DIR/performance-monitor.cfg" |
| load_config_file /etc/performance-monitor.cfg |
| handle_command_line_options "$@" |
| [ -z "$INTERVAL" ] && INTERVAL=5 |
| [ -z "$HOSTNAME" ] && HOSTNAME="`hostname`" |
| |
| while true; do |
| count=0 |
| for f in /proc/*; do |
| [ -h "$f" ] && continue |
| [ -d "$f" ] || continue |
| [ -f "$f/status" ] || continue |
| count=$((count+1)) |
| done |
| echo $count |
| http_post "${INFLUXDB_BASE_URL}write?db=$INFLUXDB_DB_NAME" \ |
| "procstat,host=$HOSTNAME nproc=$count" |
| sleep "$INTERVAL" |
| done |