linux centos stress离线安装

  • v7_662805
    了解作者
  • 46.7MB
    文件大小
  • 文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-27 18:20
    上传日期
linux centos stress离线安装 ,stress-1.0.4.tar,包含附件的,Linux性能压测, 包含sar 命令
stress.tar.gz
内容介绍
/* A program to put stress on a POSIX system (stress). * * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 * Amos Waterland <apw@rossby.metr.ou.edu rel='nofollow' onclick='return false;'> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ctype.h> #include <errno.h> #include <libgen.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <time.h> #include <unistd.h> #include <sys/wait.h> /* By default, print all messages of severity info and above. */ static int global_debug = 2; /* Name of this program */ static char *global_progname = PACKAGE; /* Implemention of runtime-selectable severity message printing. */ #define dbg(OUT, STR, ARGS...) if (global_debug >= 3) \ fprintf (stdout, "%s: dbug: [%lli] ", \ global_progname, (long long)getpid()), \ fprintf(OUT, STR, ##ARGS), fflush(OUT) #define out(OUT, STR, ARGS...) if (global_debug >= 2) \ fprintf (stdout, "%s: info: [%lli] ", \ global_progname, (long long)getpid()), \ fprintf(OUT, STR, ##ARGS), fflush(OUT) #define wrn(OUT, STR, ARGS...) if (global_debug >= 1) \ fprintf (stderr, "%s: WARN: [%lli] (%d) ", \ global_progname, (long long)getpid(), __LINE__), \ fprintf(OUT, STR, ##ARGS), fflush(OUT) #define err(OUT, STR, ARGS...) if (global_debug >= 0) \ fprintf (stderr, "%s: FAIL: [%lli] (%d) ", \ global_progname, (long long)getpid(), __LINE__), \ fprintf(OUT, STR, ##ARGS), fflush(OUT) /* Implementation of check for option argument correctness. */ #define assert_arg(A) \ if (++i == argc || ((arg = argv[i])[0] == '-' && \ !isdigit ((int)arg[1]) )) \ { \ err (stderr, "missing argument to option '%s'\n", A); \ exit (1); \ } /* Prototypes for utility functions. */ int usage (int status); int version (int status); long long atoll_s (const char *nptr); long long atoll_b (const char *nptr); /* Prototypes for worker functions. */ int hogcpu (void); int hogio (void); int hogvm (long long bytes, long long stride, long long hang, int keep); int hoghdd (long long bytes); int main (int argc, char **argv) { int i, pid, children = 0, retval = 0; long starttime, stoptime, runtime, forks; /* Variables that indicate which options have been selected. */ int do_dryrun = 0; long long do_backoff = 3000; long long do_timeout = 0; long long do_cpu = 0; long long do_io = 0; long long do_vm = 0; long long do_vm_bytes = 256 * 1024 * 1024; long long do_vm_stride = 4096; long long do_vm_hang = -1; int do_vm_keep = 0; long long do_hdd = 0; long long do_hdd_bytes = 1024 * 1024 * 1024; /* Record our start time. */ if ((starttime = time (NULL)) == -1) { err (stderr, "failed to acquire current time: %s\n", strerror (errno)); exit (1); } /* SuSv3 does not define any error conditions for this function. */ global_progname = basename (argv[0]); /* For portability, parse command line options without getopt_long. */ for (i = 1; i < argc; i++) { char *arg = argv[i]; if (strcmp (arg, "--help") == 0 || strcmp (arg, "-?") == 0) { usage (0); } else if (strcmp (arg, "--version") == 0) { version (0); } else if (strcmp (arg, "--verbose") == 0 || strcmp (arg, "-v") == 0) { global_debug = 3; } else if (strcmp (arg, "--quiet") == 0 || strcmp (arg, "-q") == 0) { global_debug = 0; } else if (strcmp (arg, "--dry-run") == 0 || strcmp (arg, "-n") == 0) { do_dryrun = 1; } else if (strcmp (arg, "--backoff") == 0) { assert_arg ("--backoff"); if (sscanf (arg, "%lli", &do_backoff) != 1) { err (stderr, "invalid number: %s\n", arg); exit (1); } if (do_backoff < 0) { err (stderr, "invalid backoff factor: %lli\n", do_backoff); exit (1); } dbg (stdout, "setting backoff coeffient to %llius\n", do_backoff); } else if (strcmp (arg, "--timeout") == 0 || strcmp (arg, "-t") == 0) { assert_arg ("--timeout"); do_timeout = atoll_s (arg); if (do_timeout <= 0) { err (stderr, "invalid timeout value: %llis\n", do_timeout); exit (1); } } else if (strcmp (arg, "--cpu") == 0 || strcmp (arg, "-c") == 0) { assert_arg ("--cpu"); do_cpu = atoll_b (arg); if (do_cpu <= 0) { err (stderr, "invalid number of cpu hogs: %lli\n", do_cpu); exit (1); } } else if (strcmp (arg, "--io") == 0 || strcmp (arg, "-i") == 0) { assert_arg ("--io"); do_io = atoll_b (arg); if (do_io <= 0) { err (stderr, "invalid number of io hogs: %lli\n", do_io); exit (1); } } else if (strcmp (arg, "--vm") == 0 || strcmp (arg, "-m") == 0) { assert_arg ("--vm"); do_vm = atoll_b (arg); if (do_vm <= 0) { err (stderr, "invalid number of vm hogs: %lli\n", do_vm); exit (1); } } else if (strcmp (arg, "--vm-bytes") == 0) { assert_arg ("--vm-bytes"); do_vm_bytes = atoll_b (arg); if (do_vm_bytes <= 0) { err (stderr, "invalid vm byte value: %lli\n", do_vm_bytes); exit (1); } } else if (strcmp (arg, "--vm-stride") == 0) { assert_arg ("--vm-stride"); do_vm_stride = atoll_b (arg); if (do_vm_stride <= 0) { err (stderr, "invalid stride value: %lli\n", do_vm_stride); exit (1); } } else if (strcmp (arg, "--vm-hang") == 0) { assert_arg ("--vm-hang"); do_vm_hang = atoll_b (arg); if (do_vm_hang < 0) { err (stderr, "invalid value: %lli\n", do_vm_hang); exit (1); } } else if (strcmp (arg, "--vm-keep") == 0) { do_vm_keep = 1; } else if (strcmp (arg, "--hdd") == 0 || strcmp (arg, "-d") == 0) { assert_arg ("--hdd"); do_hdd = atoll_b (arg); if (do_hdd <= 0) { err (stderr, "invalid number of hdd hogs: %lli\n", do_hdd); exit (1); } } else if (strcmp (arg, "--hdd-bytes") == 0) { assert_arg ("--hdd-bytes"); do_hdd_bytes = atoll_b (arg); if (do_hdd_bytes <= 0) { err (stderr, "invalid hdd byte value: %lli\n", do_hdd_bytes); exit (1); } } else { err (stderr, "unrecognized option: %s\n", arg); exit (1); } } /* Print startup message if we have work to do, bail otherwise. */ if (do_cpu + do_io + do_vm + do_hdd) { out (stdout, "dispatching hogs: %lli cpu, %lli io, %lli vm, %lli hdd\n", do_cpu, do_io, do_vm, do_hdd); } else usag
评论
    相关推荐