summaryrefslogtreecommitdiff
path: root/ifpps.c
AgeCommit message (Collapse)AuthorFilesLines
2017-09-13ifpps: use uint32_t instead of u32Tobias Klauser1-4/+4
Use type uint32_t instead of u32 (which is typedef'ed to uint32_t in built_in.h) in order to avoid confusion wrt. kernel-/user-space types. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-08all: Remove unused longindex parameter to getopt_long()Tobias Klauser1-2/+2
All tools (except mausezahn) use getopt_long() and pass a pointer to a local opt_index variable for the longindex parameter. However, this variable is never read afterwards. According to getopt(3) it's perfectly fine to pass NULL as the longindex parameter instead, so do that. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-09-15ifpps: Prevent division by zeroTobias Klauser1-15/+25
Even though it's very unlikely we ever read zero values from the cpu lines in /proc/stat, we should still protect against division by zero. Detected using UBSan. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-26ifpps: Mark arg parameter of on_panic_handler() as unusedTobias Klauser1-1/+1
This fixes the following -Wunused-parameter warning: ifpps.c: In function ‘on_panic_handler’: ifpps.c:1128:36: warning: unused parameter ‘arg’ [-Wunused-parameter] static void on_panic_handler(void *arg) Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-05ifpps: Remove unnecessary memset before ethtool_drvinf()Tobias Klauser1-2/+0
ethtool_drvinf() already clears the struct ethtool_drvinfo, so there is no need to do it manually before calling it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-10-28all: Change reporting bugs emailVadim Kochan1-1/+1
Replace bugs@netsniff-ng.com with netsniff-ng@googlegroups.com which is used in REPORTING-BUGS file. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-07-26ifpps: Cleanup screen on panicVadim Kochan1-0/+8
Clean up ncurses screen when panic was caused. There will be limitation that error message will be printed on stderr after ncurses cleanup, so it will be needed now to use redirect to error file ... ifpps -d <dev> 2> /tmp/err ... to see error message. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2015-07-26ifpps: Fix panic when dev name contains "_"Vadim Kochan1-1/+1
Add match device name with "_" in /proc/net/dev. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2014-12-12all: Reduce amount of empty liens in usage and version output a bitTobias Klauser1-5/+5
No need for some of the empty lines, remove them to make the output a bit denser. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05ifpps: Don't duplicate copyright/bug report/license stringTobias Klauser1-16/+12
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of ifpps.o slightly smaller: before: text data bss dec hex filename 22146 0 1456 23602 5c32 ifpps/ifpps.o after: text data bss dec hex filename 21807 0 1456 23263 5adf ifpps/ifpps.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-06-25xmalloc: Add and use xcallocTobias Klauser1-2/+2
Add a wrapper for calloc which checks for integer overflows in the calculation of the size to allocate. Use xcalloc to allocate an array of objects instead of calculating the size ourselves, which might cause an integer overflow. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-05-03all: Use macros for printf/scanf format specifiersJames McCoy1-30/+31
Any types that are fixed width should use the standard format specifier macros (PRI... for printf-type functions, SCN... for scanf-type functions) to ensure proper data access. Prior to this ifpps was crashing in 32-bit environments due to the following call mvwprintw(screen, (*voff)++, 2, "%s,%s %s (%s%s), t=%lums, cpus=%u%s/%u" " ", uts.release, machine, ifname, drvinf.driver, buff, ms_interval, top_cpus, top_cpus > 0 && top_cpus < cpus ? "+1" : "", cpus); since ms_interval is a uint64_t but %lu expects an unsigned long, which is only 32 bits. Signed-off-by: James McCoy <vega.james@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-04-25ifpps: Fix coding styleTobias Klauser1-4/+6
Fix spacing and move a pointer increment out of the for loop initializer. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-04-25ifpps: fix matching wrong interface/deviceJesper Dangaard Brouer1-1/+7
There were a bug in ifpps, that would match the first occurance of a device/interface name in /proc/net/dev, because it located the device based on a substring. If the device name were starting with the same characters, e.g. having a device named eth4 and a VLAN device named eth4.100. If specifying --dev eth4, then depending on the order of /proc/net/dev the wrong device could be choosen for stats. (Note kernel does not guarantee the order of devices in proc file) Fix the bug, by matching with a colon ':' appended to the device name, as the kernel proc format prints a ':' behind the device name. Fixes #119 Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2014-02-26ifpps: Reorder buffer allocation and file opening in stats_proc_interruptsTobias Klauser1-4/+4
We don't need the file open to allocate the buffer so open it just before it's used for the first time. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-02-22ifpps: Exit gracefully for all possible termination signalsTobias Klauser1-0/+4
Handle all termination signals that we're allowed to handle (SIGKILL can't be handled) in order to exit gracefully in any regular termination case. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-10-02ifpps: Simplify logic wrt. omit_header in term_main()Tobias Klauser1-6/+3
We can reuse the omit_header variable to get rid of the existing variable 'first', which was used to make sure the header gets only printed once at the beginning. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-10-02ifpps: Mark omit_header parameter to screen_main() as unusedTobias Klauser1-1/+1
Otherwise we get a warning when compiling with "-W -Wall". Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-10-02ifpps: min: minor: Keep options sorted alphabeticallyTobias Klauser1-3/+3
Keep the options sorted alphabetically, argument options first. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-10-02ifpps: add option that omits CSV headerJon Schipp1-6/+16
Adds option -o|--omit-header which does not print the CSV header e.g. when the user does not need it. Signed-off-by: Jon Schipp <jonschipp@gmail.com> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-09-09ifpps: correct calculation of line rate percentageTobias Klauser1-2/+2
The line rate is given in Mbit rather than MiB (in which {rx,tx}_bytes were converted). Correct the calculation by converting {rx,tx}_bytes to Mbit: (n bytes * 8 bits per byte) / 1000^2 = (n bytes) / 125000 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-09-05ifpps: make display of line rate percentage optionalTobias Klauser1-4/+11
In order to not to clutter the display too much, make the display of the percentage of the theoretical line rate dependent on a command line option. Suggested-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-09-04ifpps: show percentage of theoretical line-rateTobias Klauser1-0/+17
Also show the percentage of the (theoretical) line rate, not just the current rate. Suggested-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-09-04ifpps: Reuse device bitrate for screen_header()Tobias Klauser1-3/+2
Instead of issuing another call to device_bitrate(), reuse the the value acquired in screen_update() and pass it to screen_header(). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-08-30ifpps: Skip reading IRQ number from /proc/interruptsTobias Klauser1-7/+5
We don't use the IRQ number we read from /proc/interrupts, so just skip it while reading. This also allows us to drop the irq_nr member from struct ifstat. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-08-29ifpps: Don't bug out if interface went downTobias Klauser1-2/+5
In case the interface ifpps is running on went down, ifpps bugged out because the stats didn't look plausible anymore, due to the IRQ count being reset: ifpps: ifpps.c:563: stats_diff: Assertion `!((new->irqs[i] - old->irqs[i]) > (new->irqs[i]))' failed Fix this by setting the difference to 0 in this case. ifpps will thus display a irqs/t value of 0 instead of bugging out. This fixes #74. Reported-by: Jon Schipp <jonschipp@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-08-29ifpps: Use unsigned int to store number of cpusTobias Klauser1-23/+24
The number of CPUs can never be negative and get_number_cpus() returns unsigned int too, so consistently conver all variables holding a CPU number or number of CPUs to type unsigned int. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-08-13ifpps: minor: Add parentheses to do {} while in padding_from_num()Tobias Klauser1-2/+3
Even though the loop contains only one statement, add parentheses around it to make it more readable. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-08-09dev: Integrate `promisc' module into `dev' moduleTobias Klauser1-3/+2
Since entering/leaving promiscuous mode also is a device specific function and all users of the `promisc' module also use `dev', integrate it there. Also rename the functions to have a `device_' prefix like the other functions in the module. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-13ifpps: Remove unused parameter to term_csv()Tobias Klauser1-3/+2
term_csv() doesn't use the ifname and ms_interval parameters, they're only used in term_csv_header(). Thus remove them from term_csv(). This fixes a warning when compiling with -W/-Wunused-parameter. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-13ifpps: Use unsigned int to store number of CPUsTobias Klauser1-3/+4
Since get_number_cpus() now returns unsigned int store it's return value and derived values in unsigned int variables as well. This fixes the some warnings when compiling with -W/-Wsign-compare: Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-13misc: fix multiple NULL pointer sparse warningsDaniel Borkmann1-1/+1
Those are fixes for the following warnings: pcap_mm.c:119:29: warning: Using plain integer as NULL pointer pcap_mm.c:141:29: warning: Using plain integer as NULL pointer ring.c:24:31: warning: Using plain integer as NULL pointer flowtop.c:1114:22: warning: Using plain integer as NULL pointer ifpps.c:1133:29: warning: Using plain integer as NULL pointer Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-13ifpps: help: reduce option description to one lineDaniel Borkmann1-2/+1
Make this conform to trafgen/netsniff-ng and reduce it to 1 line description. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-13ifpps: release stats on exitDaniel Borkmann1-0/+20
The stack trace of valgrind --leak-check=full --show-reachable=yes ifpps \ -lpcd wlan0 showed that at exit members from stats are still reachable. They have been alloced through stats_alloc, but not freed. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-13ifpps: warn when 1Gbit/s and interval < 1secDaniel Borkmann1-2/+6
It is possible to use a interval even of 0, although it would not really make sense. It's not a bug either, so throw a warning to the user in that case on 1Gbit/s. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-13ifpps: Correct calculation of median values for CPU loadTobias Klauser1-10/+11
ifpps always reported the same values for median as for average in the CPU load fields (usr, sys, idle, iowait). This is of course incorrect. The bug was due to 3 sub-problems: - Summing up long double values (m_cpu_*) in an uint64_t (all) - Not using %Lf (for long double) in mvwprintw() - Explicitely use floating point division in MEDIAN_EVEN Fix the bug by summing up in a separate accumulator of type long double, use the correct format string for long double and divide by 2.0 in MEDIAN_EVEN to force the result to be (long) double. Reported-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-12ifpps: Consistently list command line optionsTobias Klauser1-5/+5
Instead of (more or less) arbitrarily listing the command line options, sort them according to the following rule: - options with required argument, alphabetically by short option - options without argument, alphabetically by short option - common options -v/--version and -h/--help Do this in the short options string, the long options struct, the in-program usage and the man page. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-12ifpps: median: add whitespace padding in one occurenceDaniel Borkmann1-2/+2
Add whitespace padding in one occurence of 'med:' output. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-12ifpps: Update usage with respect to median valuesTobias Klauser1-0/+1
This was missing in commit 971b1d95 ("ifpps: Optionally display median values for CPU load and interrupts"). Update the usage to reflect the changes too. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-12ifpps: Optionally display median values for CPU load and interruptsTobias Klauser1-1/+91
Using the -m/--median command line option, median values across all CPUs are displayed for CPU load, interrupts per interval, sw interrupts per interval and absolute number of interrupts. Also update the manpage accordingly. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-11ifpps: align avg on systems with >8 CPUsDaniel Borkmann1-5/+8
When running ifpps on systems with 16, 32 or more CPUs, 'avg:...' field is not being padded with witespaces as the rest of the CPU lines. This patch does that. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: warn about increase -t when high speedDaniel Borkmann1-8/+28
Collecting device statistics on high speed every second can be very costly, so warn about this in ncurses mode. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: show machine type only if not in already release nameDaniel Borkmann1-3/+9
In Fedora or RHEL/CentOS releases the machine type is already part of the package name, so show it only, if it does not appear there. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: show kernel version and machine typeDaniel Borkmann1-2/+6
Lets make the headline output a bit more useful and show the current kernel version and well as the machine/hardware type. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: make '+' to '-' sort more clearDaniel Borkmann1-15/+14
If will now look like the following: cpu6 +: 237357 irqs cpu2 |: 117538 irqs cpu0 |: 8419 irqs cpu7 |: 4523 irqs cpu5 |: 4312 irqs cpu1 -: 1432 irqs avg: 47606.8 This makes it a bit more precise/intuitive that we sort from max to min. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: align avg numbers and remove unitDaniel Borkmann1-8/+8
In order to get a better overview, lets align the avg numbers to the other shown decimals. However, for this we would need to remove the avg units as we deal with floats here. But we know the units from the above numbers anyway. I think this makes it more clear to follow. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: align string to format stringDaniel Borkmann1-12/+12
Just a whitespace fix to align the strings to the fmt string. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-07-11ifpps: Remove unnecessary memset()Tobias Klauser1-1/+0
stats_avg will be reset to 0 on the first call to stats_top() before displaying any results, thus this memset() is not necessary. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-10ifpps: Remove unecessary whitespaces in mvwprintw() callsTobias Klauser1-8/+8
Remove trailing whitespace where they're not necessary for the background to extend beyond the text. Replace whitespaces needed for tabbing by setting the appropriate format string field width modifiers. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-07-10ifpps: Reduce default number of top hitter CPUs to 5Tobias Klauser1-2/+2
Since we now also display the average (and in the future possibly also the standard deviation), reduce the default number of CPUs displayed to 5, to keep terminal space usage low. Suggested-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>