Skip to content

NicksonJacksonWilfest/server-performance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Server Performance

A small shell script to collect basic server performance metrics and optionally send them to stdout, a CSV file, or a remote collector.

Features

  • Capture CPU, memory, disk, and load metrics
  • Timestamped, human- and machine-friendly output
  • Optional CSV logging for historical analysis
  • Simple CLI flags for flexible behavior
  • Designed for cron or interactive use

Requirements

  • POSIX-compatible shell (bash/sh)
  • coreutils: date, awk, grep
  • vmstat, free, df, iostat (optional but recommended)
  • Network tools for remote send (curl or netcat) if using remote export

Installation

  1. git clone https://github.com/NicksonJacksonWilfest/server-performance.git
  2. Place the script in a directory on the server, e.g. /usr/local/bin/server-performance
  3. Make it executable: chmod +x /usr/local/bin/server-performance

Usage

Basic run (print human-readable summary): ./server_stats

Write a CSV line to a file: ./server_stats --output /var/log/server-performance.csv

Send metrics to an HTTP collector: ./server_stats --send http://collector.example.org/ingest

Show help: ./server_stats --help

Options

  • --help, -h Print usage and options.
  • --output Append a CSV-formatted line to the given file (creates file if missing).
  • --send POST metrics to a remote HTTP endpoint as JSON.
  • --interval When combined with --daemon, sample at this interval.
  • --daemon Run continuously, emitting metrics at the configured interval.
  • --fields Comma-separated subset of metrics to collect (cpu,mem,disk,load).

Output format

  • Human mode: plain text summary with totals and percentages.
  • CSV mode: one line per sample with ISO8601 timestamp and fields: timestamp,cpu_percent,load1,load5,load15,mem_total_kB,mem_used_kB,disk_root_percent
  • JSON (for --send): { "timestamp": "...", "cpu": ..., "mem": {...}, "disk": {...}, "load": [...] }

Scheduling

Add a cron job for periodic sampling, for example every 5 minutes: */5 * * * * /usr/local/bin/server-performance --output /var/log/server-performance.csv

Logging & Retention

Rotate CSV logs using logrotate or include a log-rotation step in cron. Keep retention policies according to storage and compliance needs.

Troubleshooting

  • Missing commands: ensure required utilities are installed and in PATH.
  • Permissions: ensure the script can write to the output path and has execute permission.
  • Remote send failures: verify network access and endpoint authentication/format.

Contributing

Open a pull request with a focused change, include tests or usage notes where applicable.

License

None

Made with ❤️ by:

Distrodev

Project URL

https://roadmap.sh/projects/server-stats

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages