From e7312012ed283f2ecc8cd2b76fbe99efef339adf Mon Sep 17 00:00:00 2001 From: Someone Date: Tue, 10 Jul 2012 11:17:48 +0200 Subject: [PATCH] muninplugins moved out of private root scripts --- cron/cron_portage.sh | 44 +++++++ cron/cyrus.sh | 5 + cron/ircstats.pl | 56 +++++++++ cron/servicestats.sh | 11 ++ cyrus | 23 ++++ ircch | 20 +++ irccomp | 35 ++++++ ircd | 26 ++++ ircsvc | 29 +++++ ircsvcdb | 26 ++++ isup | 26 ++++ portage_sync | 35 ++++++ portage_tree_stats | 24 ++++ portage_updates | 24 ++++ threads | 282 +++++++++++++++++++++++++++++++++++++++++++ 15 files changed, 666 insertions(+) create mode 100755 cron/cron_portage.sh create mode 100755 cron/cyrus.sh create mode 100755 cron/ircstats.pl create mode 100755 cron/servicestats.sh create mode 100755 cyrus create mode 100755 ircch create mode 100755 irccomp create mode 100755 ircd create mode 100755 ircsvc create mode 100755 ircsvcdb create mode 100755 isup create mode 100755 portage_sync create mode 100755 portage_tree_stats create mode 100755 portage_updates create mode 100755 threads diff --git a/cron/cron_portage.sh b/cron/cron_portage.sh new file mode 100755 index 0000000..8ad28b2 --- /dev/null +++ b/cron/cron_portage.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +if [ ! -e "/tmp/munin_portage/timestamp.chk" -o -n "`diff -N -q /tmp/munin_portage/timestamp.chk /usr/portage/metadata/timestamp.chk`" ]; then +mkdir -p /tmp/munin_portage/ + +if [ -e "/tmp/munin_portage/running.lock" ]; then + echo 'another instance is still running. rm "/tmp/munin_portage/running.lock"'>&2 + exit 0; +else + echo "running since: `date`" > /tmp/munin_portage/running.lock +fi + +if [ -e "/tmp/munin_portage/ebuilds.txt" ]; then + mv /tmp/munin_portage/ebuilds.txt /var/lib/munin_portage_ebuilds.txt +fi +if [ -e "/tmp/munin_portage/packages.txt" ]; then + mv /tmp/munin_portage/packages.txt /var/lib/munin_portage_packages.txt +fi + +find /usr/portage/ -mindepth 3 -maxdepth 3 -iname '*.ebuild' | grep -v "/usr/portage/distfiles" | grep -v "/usr/portage/metadata" | grep -v "/usr/portage/profiles" | sort > /tmp/munin_portage/ebuilds.txt +find /usr/portage/ -mindepth 2 -maxdepth 2 -type d | grep -v "/usr/portage/profiles/" | grep -v "/usr/portage/metadata/" | grep -v "/usr/portage/distfiles/" | grep -v "/usr/portage/eclass/" | sort > /tmp/munin_portage/packages.txt + +if [ ! -e "/var/lib/munin_portage_ebuilds.txt" ]; then + cp /tmp/munin_portage/ebuilds.txt /var/lib/munin_portage_ebuilds.txt +fi +if [ ! -e "/var/lib/munin_portage_packages.txt" ]; then + cp /tmp/munin_portage/packages.txt /var/lib/munin_portage_packages.txt +fi + +echo "packages.value `cat /tmp/munin_portage/packages.txt | wc -l`" > /tmp/munin_portage/packages.stat +echo "ebuilds.value `cat /tmp/munin_portage/ebuilds.txt | wc -l`" > /tmp/munin_portage/ebuilds.stat +echo "ebadded.value `diff -u0 /var/lib/munin_portage_ebuilds.txt /tmp/munin_portage/ebuilds.txt | grep -v @@ | grep '+/' | wc -l`" > /tmp/munin_portage/ebuilds_added.stat +echo "ebremoved.value `diff -u0 /var/lib/munin_portage_ebuilds.txt /tmp/munin_portage/ebuilds.txt | grep -v @@ | grep -e '-/' | wc -l`" > /tmp/munin_portage/ebuilds_removed.stat +echo "pkgadded.value `diff -u0 /var/lib/munin_portage_packages.txt /tmp/munin_portage/packages.txt | grep -v @@ | grep '+/' | wc -l`" > /tmp/munin_portage/packages_added.stat +echo "pkgremoved.value `diff -u0 /var/lib/munin_portage_packages.txt /tmp/munin_portage/packages.txt | grep -v @@ | grep -e '-/' | wc -l`" > /tmp/munin_portage/packages_removed.stat + +emerge -qpuDN --package-moves=n --with-bdeps=y --color n @world | sed 's/^\[[^]]*\] //' > /tmp/munin_portage/updates.txt +echo "updates.extinfo `cat /tmp/munin_portage/updates.txt | awk '{ printf "%s ", $0 }'`" > /tmp/munin_portage/updates.list +echo "updates.value `cat /tmp/munin_portage/updates.txt | wc -l`" > /tmp/munin_portage/updates.stat + +cp /usr/portage/metadata/timestamp.chk /tmp/munin_portage/timestamp.chk +rm /tmp/munin_portage/running.lock +fi + diff --git a/cron/cyrus.sh b/cron/cyrus.sh new file mode 100755 index 0000000..f3dcdd5 --- /dev/null +++ b/cron/cyrus.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +find /var/spool/imap/ -mindepth 3 -maxdepth 3 -type d -exec du -sb {} + | grep '/user/' | sort -nr | sed -e 's#/var/spool/imap/./##' -e 's#/#_#' > /tmp/munin_cyrus.txt +du -sb /var/spool/imap/s/spam | sed -e 's#/var/spool/imap/./##' >> /tmp/munin_cyrus.txt + diff --git a/cron/ircstats.pl b/cron/ircstats.pl new file mode 100755 index 0000000..31b6050 --- /dev/null +++ b/cron/ircstats.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +require Net::IRC; + +mkdir("/tmp/irc", 0775); +open (STATS, '>/tmp/irc/stats.txt'); +open (CHANS, '>/tmp/irc/channels.txt'); +my $irc = new Net::IRC; +my $conn = $irc->newconn(Nick => 'srv254-stats', Server => 'localhost'); +$conn->debug(0); +$conn->add_global_handler('luserclient', \&luserclient); +$conn->add_global_handler('luserchannels', \&luserchannels); +$conn->add_global_handler('endofmotd', \&ask); +$conn->add_global_handler('list', \&list); +$conn->add_global_handler('listend', \&quit); + + +sub luserclient { + my($self, $event) = @_; + if(($event->args)[1] =~ /There are (\d+) users and (\d+) invisible on (\d+) servers/) { +# printf STATS "".(($event->args)[1])."\n"; + printf STATS "clients.value ".($1 + $2 -1)."\n"; + printf STATS "servers.value $3\n"; + } +} + +sub luserchannels { + my($self, $event) = @_; + if(($event->args)[1] =~ /^(\d+)/) { + printf STATS "channels.value $1\n"; + } +} + +sub ask { + my($self, $event) = @_; + $conn->list(); +} + +sub list { + my($self, $event) = @_; + printf CHANS (($event->args)[1])." ".(($event->args)[2])." ".(($event->args)[3])."\n"; +} + +sub quit { + my($self, $event) = @_; + $self->quit(); + close (STATS); + close (CHANS); + exit 0; +} + + + +while(1) { + $irc->do_one_loop(); +} + diff --git a/cron/servicestats.sh b/cron/servicestats.sh new file mode 100755 index 0000000..3ef493b --- /dev/null +++ b/cron/servicestats.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +mkdir -p /tmp/irc/ +chmod 775 /tmp/irc/ + +echo "dbsize.value `du -b data/anope.flat.db | awk '{print $1}'`" > /tmp/irc/servicestats.txt +echo "channels.value `egrep '^OBJECT ChannelInfo' data/anope.flat.db | wc -l`" >> /tmp/irc/servicestats.txt +echo "nickaliases.value `egrep '^OBJECT NickAlias' data/anope.flat.db | wc -l`" >> /tmp/irc/servicestats.txt +echo "nickcores.value `egrep '^OBJECT NickCore' data/anope.flat.db | wc -l`" >> /tmp/irc/servicestats.txt +echo "memos.value `egrep '^OBJECT Memo' data/anope.flat.db | wc -l`" >> /tmp/irc/servicestats.txt + diff --git a/cyrus b/cyrus new file mode 100755 index 0000000..6ae9cce --- /dev/null +++ b/cyrus @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + + +if [ "$1" = "config" ]; then + echo "graph_title User's mailstorage size" + echo "graph_info This graph shows every user's mailstorage size. Also spam-dir." + echo "graph_category mail" + echo "graph_order `cat /tmp/munin_cyrus.txt | awk '{printf $2" " }'`" + cat /tmp/munin_cyrus.txt 2> /dev/null | awk '{print $2".draw LINE2" }' + cat /tmp/munin_cyrus.txt 2> /dev/null | awk '{print $2".label "$2 }' +# echo "graph_printf %.0lf" +# echo "graph_scale no" + echo "graph_args -l 0" + exit 0 +fi + +cat /tmp/munin_cyrus.txt | awk '{print $2".value "$1 }' +exit 0 diff --git a/ircch b/ircch new file mode 100755 index 0000000..8b34df6 --- /dev/null +++ b/ircch @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title irc channel users" + echo "graph_info This graph shows the usercounts in selected channels" + echo "graph_category irc" + echo "graph_printf %.0lf" + echo "graph_scale no" + cat /tmp/irc/channels.txt | grep "#" | sed -E -e 's~#~~g' -e 's~[^a-zA-Z0-9 ]~_~g' | sort -u | sort -k 2nr | awk '{print $1".label "$1"\n"$1".draw LINE2" }' | head -n 15 + exit 0 +fi + +cat /tmp/irc/channels.txt | grep "#" | sed -E -e 's~#~~g' -e 's~[^a-zA-Z0-9 ]~_~g' | sort -u | sort -k 2nr | awk '{print $1".value "$2 }' | head -n 15 + +exit 0 diff --git a/irccomp b/irccomp new file mode 100755 index 0000000..07617d2 --- /dev/null +++ b/irccomp @@ -0,0 +1,35 @@ +#!/bin/sh + +NETIDLIST="sno fro otu" + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title ircnet comparison" + echo "graph_info This graph compares IRC Networks" + echo "graph_category irc" + echo "graph_printf %.0lf" + echo "graph_scale no" + echo "graph_args -l 0" + + for net in $NETIDLIST; do + echo "channels_${net}.label ${net}:channels" + echo "channels_${net}.draw LINE2" + echo "users_${net}.label ${net}:clients" + echo "users_${net}.draw LINE2" + echo "servers_${net}.label ${net}:servers" + echo "servers_${net}.draw LINE2" + done + exit 0 +fi + +for net in $NETIDLIST; do + grep -i "There are" /tmp/irc_${net}_lusers.txt 2>/dev/null | sed -E 's~^There are .*? on ([0-9]+) servers.*$~servers_'${net}'.value \1~' + grep -i "Current Global Users" /tmp/irc_${net}_lusers.txt 2>/dev/null | sed -E 's~^Current Global Users: ([0-9]+) .*$~users_'${net}'.value \1~' + grep -i "channels" /tmp/irc_${net}_lusers.txt 2>/dev/null | sed -E 's~^([0-9]+).*$~channels_'${net}'.value \1~' +done + +exit 0 diff --git a/ircd b/ircd new file mode 100755 index 0000000..7941cb1 --- /dev/null +++ b/ircd @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title ircd status" + echo "graph_info This graph shows the IRC daemon's status" + echo "graph_category irc" + echo "graph_order clients channels servers" + echo "graph_printf %.0lf" + echo "graph_scale no" + echo "graph_args -l 0" + echo "channels.label channels" + echo "channels.draw LINE2" + echo "clients.label clients" + echo "clients.draw LINE2" + echo "servers.label servers" + echo "servers.draw LINE2" + exit 0 +fi + +cat /tmp/irc/stats.txt +exit 0 diff --git a/ircsvc b/ircsvc new file mode 100755 index 0000000..a5ed102 --- /dev/null +++ b/ircsvc @@ -0,0 +1,29 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title service registrations" + echo "graph_info This graph shows the IRC service's registration counts. Including the count of registered channels and nicknames." + echo "graph_category irc" + echo "graph_order channels nickaliases nickcores" + echo "graph_printf %.0lf" + echo "graph_scale no" + echo "graph_args -l 0" + echo "channels.label Registered channels" + echo "channels.draw LINE2" + echo "nickaliases.label Registered nicks + aliases" + echo "nickaliases.draw LINE2" + echo "nickcores.label Registered nicks" + echo "nickcores.draw LINE2" + exit 0 +fi + +grep -i "channels.value" /tmp/irc/servicestats.txt +grep -i "nickaliases.value" /tmp/irc/servicestats.txt +grep -i "nickcores.value" /tmp/irc/servicestats.txt + +exit 0 diff --git a/ircsvcdb b/ircsvcdb new file mode 100755 index 0000000..7d48521 --- /dev/null +++ b/ircsvcdb @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title service's database" + echo "graph_info This graph shows the IRC service's database stats." + echo "graph_category irc" + echo "graph_order dbsize" + echo "graph_scale yes" + echo "graph_args --logarithmic -l 0.1" + echo "dbsize.label DB size" + echo "dbsize.draw LINE2" + echo "memos.label Stored memos" + echo "memos.draw LINE2" + exit 0 +fi + +grep -i "dbsize.value" /tmp/irc/servicestats.txt +grep -i "memos.value" /tmp/irc/servicestats.txt + +exit 0 + diff --git a/isup b/isup new file mode 100755 index 0000000..a07ad29 --- /dev/null +++ b/isup @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title is node up?" + echo "graph_info This graph will show a red *up* in the overview, if the node is up." + echo "graph_category *up*" + echo "graph_order up" + echo "graph_printf %.0lf" + echo "graph_scale no" + echo "graph_args -l 0" + echo "contacts no" + echo "up.label up" + echo "up.critical 1" + echo "up.draw AREA" + echo "up.info Always value=2 and critical=1" + echo "up.max 2" + exit 0 +fi +echo "up.value 2" +echo "up.extinfo Last timestamp: `date --rfc-3339=seconds`" +exit 0 diff --git a/portage_sync b/portage_sync new file mode 100755 index 0000000..e1bb036 --- /dev/null +++ b/portage_sync @@ -0,0 +1,35 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title portage sync" + echo "graph_info This graph shows the count of added and removed ebuilds and packages by the last sync operation" + echo "graph_category portage" + echo "graph_order pkgremoved pkgadded ebremoved ebadded" + echo "graph_scale no" + echo "pkgremoved.label packages del" + echo "pkgremoved.draw LINE2" + echo "pkgremoved.graph no" + echo "pkgadded.label packages" + echo "pkgadded.draw LINE2" + echo "pkgadded.negative pkgremoved" + echo "ebremoved.label ebuilds del" + echo "ebremoved.draw LINE2" + echo "ebremoved.graph no" + echo "ebadded.label ebuilds" + echo "ebadded.draw LINE2" + echo "ebadded.negative ebremoved" + exit 0 +fi + +cat /tmp/munin_portage/packages_added.stat +cat /tmp/munin_portage/packages_removed.stat +cat /tmp/munin_portage/ebuilds_added.stat +cat /tmp/munin_portage/ebuilds_removed.stat + +exit 0 + diff --git a/portage_tree_stats b/portage_tree_stats new file mode 100755 index 0000000..d37bae0 --- /dev/null +++ b/portage_tree_stats @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title portage tree stats" + echo "graph_info This graph shows the count of packages and ebuilds available on this system" + echo "graph_category portage" + echo "graph_order packages ebuilds" + echo "graph_printf %.0lf" + echo "graph_scale no" + echo "packages.label packages" + echo "packages.draw LINE2" + echo "ebuilds.label ebuilds" + echo "ebuilds.draw LINE2" + exit 0 +fi + +cat /tmp/munin_portage/packages.stat +cat /tmp/munin_portage/ebuilds.stat +exit 0 diff --git a/portage_updates b/portage_updates new file mode 100755 index 0000000..78fed3c --- /dev/null +++ b/portage_updates @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ "$1" = "autoconf" ]; then + echo "yes" + exit 0 +fi + +if [ "$1" = "config" ]; then + echo "graph_title portage pending updates" + echo "graph_info This graph shows the pending updates on this system" + echo "graph_category portage" + echo "graph_order updates" + echo "graph_printf %.0lf" + echo "graph_scale no" + echo "updates.label pending updates" + echo "updates.draw AREA" + echo "updates.warning :0" + echo "updates.critical 0:25" + exit 0 +fi + +cat /tmp/munin_portage/updates.stat +cat /tmp/munin_portage/updates.list +exit 0 diff --git a/threads b/threads new file mode 100755 index 0000000..d98977b --- /dev/null +++ b/threads @@ -0,0 +1,282 @@ +#!/bin/sh +# -*- sh -*- + +: << =cut + +=head1 NAME + +threads - copy of threads, with another ps option. commented out all but linux. + +=cut + +# Search for program in $PATH unless predefined. +[ $awk ] || awk="awk" +[ $ps ] || ps="ps" + +# Find operating system +[ $OPERSYS ] || OPERSYS=`uname` || exit 1 + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +. $MUNIN_LIBDIR/plugins/plugin.sh + +# Define colours +RUNNABLE='22ff22' # Green +SLEEPING='0022ff' # Blue +STOPPED='cc0000' # Darker red +ZOMBIE='990000' # Darkest red +UNINTERRUPTIBLE='ffa500' # Orange +IDLE='4169e1' # Royal blue +PAGING='00aaaa' # Darker turquoise +INTERRUPT='ff00ff' # Fuchsia +LOCK='ff3333' # Lighter red +RUNNING='00ff7f' # Spring green +DEAD='ff0000' # Red +SUSPENDED='ff1493' # Deep pink +TOTAL='c0c0c0' # Silver + +# Taken from ps(1) +# R - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (runable) +# S - Linux, SunOS, FreeBSD*, OpenBSD*, NetBSD*, OSX* (sleeping) +# T - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (stopped) +# Z - Linux, SunOS, FreeBSD, OpenBSD, NetBSD, OSX (zombie) +# D - Linux, FreeBSD, OpenBSD, NetBSD (uninterruptible) +# I - FreeBSD, OpenBSD, NetBSD, OSX (idle) +# W - Linux*, FreeBSD* (paging/interrupt) +# L - FreeBSD (lock) +# O - SunOS (running) +# X - Linux (dead) +# U - OSX, NetBSD* (uninterruptible/suspended) +# *) Differ meaning + +if [ "$1" = "config" ]; then + echo "graph_title Threads" + echo "graph_info This graph shows the number of threads" + echo "graph_category system" + echo "graph_args --base 1000 -l 0" + echo "graph_vlabel Number of threads" + + # OS specific flags +# if [ "$OPERSYS" = "Linux" ]; then + echo "graph_order sleeping stopped zombie dead paging uninterruptible runnable threads" + echo "dead.label dead" + echo "dead.draw STACK" + echo "dead.colour $DEAD" + echo "dead.info The number of dead threads." + print_warning dead + print_critical dead + echo "paging.label paging" + echo "paging.draw STACK" + echo "paging.colour $PAGING" + echo "paging.info The number of paging threads (<2.6 kernels only)." + print_warning paging + print_critical paging + +# elif [ "$OPERSYS" = "SunOS" ]; then +# echo "graph_order sleeping stopped zombie runnable running total" +# echo "running.label running" +# echo "running.draw STACK" +# echo "running.colour $RUNNING" +# echo "running.info The number of threads that are running on a processor." +# print_warning running +# print_critical running +# # Be backwards compatible. +# echo "total.label total" +# echo "total.draw LINE1" +# echo "total.colour $TOTAL" +# echo "total.info The total number of threads." +# print_warning total +# print_critical total +# +# elif [ "$OPERSYS" = "FreeBSD" ]; then +# echo "graph_order sleeping idle stopped zombie lock uninterruptible interrupt runnable threads" +# echo "lock.label lock" +# echo "lock.draw STACK" +# echo "lock.colour $LOCK" +# echo "lock.info The number of threads that are waiting to acquire a lock." +# print_warning lock +# print_critical lock +# echo "interrupt.label interrupt" +# echo "interrupt.draw STACK" +# echo "interrupt.colour $INTERRUPT" +# echo "interrupt.info The number of idle interrupt threads." +# print_warning interrupt +# print_critical interrupt +# +# elif [ "$OPERSYS" = "OpenBSD" ]; then +# echo "graph_order sleeping idle stopped zombie uninterruptible runnable threads" +# +# elif [ "$OPERSYS" = "NetBSD" ]; then +# echo "graph_order sleeping idle stopped zombie uninterruptible suspended runnable threads" +# echo "suspended.label suspended" +# echo "suspended.draw STACK" +# echo "suspended.colour $SUSPENDED" +# echo "suspended.info The number of threads that are suspended." +# print_warning suspended +# print_critical suspended +# +# elif [ "$OPERSYS" = "Darwin" ]; then +# echo "graph_order sleeping idle stopped zombie uninterruptible running threads" +# echo "uninterruptible.label uninterruptible" +# echo "uninterruptible.draw STACK" +# echo "uninterruptible.colour $UNINTERRUPTIBLE" +# echo "uninterruptible.info The number of uninterruptible threads (usually IO)." +# print_warning uninterruptible +# print_critical uninterruptible +# fi +# +# # Common flags for some OS +# if [ "$OPERSYS" = "FreeBSD" ] || [ "$OPERSYS" = "OpenBSD" ] || +# [ "$OPERSYS" = "NetBSD" ] || [ "$OPERSYS" = "Darwin" ]; then +# echo "idle.label idle" +# echo "idle.draw STACK" +# echo "idle.colour $IDLE" +# echo "idle.info The number of threads that are idle (sleeping for longer than about 20 seconds)." +# print_warning idle +# print_critical idle +# echo "sleeping.label sleeping" +# echo "sleeping.draw AREA" +# echo "sleeping.colour $SLEEPING" +# echo "sleeping.info The number of threads that are sleeping for less than about 20 seconds." +# print_warning sleeping +# print_critical sleeping +# else + echo "sleeping.label sleeping" + echo "sleeping.draw AREA" + echo "sleeping.colour $SLEEPING" + echo "sleeping.info The number of sleeping threads." + print_warning sleeping + print_critical sleeping +# fi + + if [ "$OPERSYS" = "Linux" ] || [ "$OPERSYS" = "FreeBSD" ] || + [ "$OPERSYS" = "OpenBSD" ] || [ "$OPERSYS" = "NetBSD" ]; then + echo "uninterruptible.label uninterruptible" + echo "uninterruptible.draw STACK" + echo "uninterruptible.colour $UNINTERRUPTIBLE" + echo "uninterruptible.info The number of uninterruptible threads (usually IO)." + print_warning uninterruptible + print_critical uninterruptible + fi + + # Common flags + echo "zombie.label zombie" + echo "zombie.draw STACK" + echo "zombie.colour $ZOMBIE" + echo "zombie.info The number of defunct ("zombie") threads (thread terminated and parent not waiting)." + print_warning zombie + print_critical zombie + + echo "stopped.label stopped" + echo "stopped.draw STACK" + echo "stopped.colour $STOPPED" + echo "stopped.info The number of stopped or traced threads." + print_warning stopped + print_critical stopped + + echo "runnable.label runnable" + echo "runnable.draw STACK" + echo "runnable.colour $RUNNABLE" + echo "runnable.info The number of runnable threads (on the run queue)." + print_warning runnable + print_critical runnable + + if [ "$OPERSYS" != "SunOS" ]; then + # Not using 'graph_total' due to backwards compability. SunOS uses 'total'. + #echo 'graph_total total' + echo "threads.label total" + echo "threads.draw LINE1" + echo "threads.colour $TOTAL" + echo "threads.info The total number of threads." + print_warning threads + print_critical threads + fi + + exit 0 +fi + +#if [ "$OPERSYS" = "Linux" ]; then + $ps --no-header -eTo s | $awk ' +{ threads++; stat[$1]++ } +END { +print "threads.value " 0+threads; +print "uninterruptible.value " 0+stat["D"]; +print "runnable.value " 0+stat["R"]; +print "sleeping.value " 0+stat["S"]; +print "stopped.value " 0+stat["T"]; +print "paging.value " 0+stat["W"]; +print "dead.value " 0+stat["X"]; +print "zombie.value " 0+stat["Z"]; +}' + +#elif [ "$OPERSYS" = "SunOS" ]; then +# $ps -e -o s | $awk ' +#{ total++; stat[$1]++ } +#END { +#print "total.value " 0+total; +#print "running.value " 0+stat["O"]; +#print "sleeping.value " 0+stat["S"]; +#print "runnable.value " 0+stat["R"]; +#print "stopped.value " 0+stat["T"]; +#print "zombie.value " 0+stat["Z"]; +#}' +#elif [ "$OPERSYS" = "FreeBSD" ]; then +# $ps -axo state= | sed -e 's/^\(.\).*/\1/' | $awk ' +#{ threads++; stat[$1]++ } +#END { +#print "threads.value " 0+threads; +#print "uninterruptible.value " 0+stat["D"]; +#print "idle.value " 0+stat["I"]; +#print "lock.value " 0+stat["G"]; +#print "runnable.value " 0+stat["R"]; +#print "sleeping.value " 0+stat["S"]; +#print "stopped.value " 0+stat["T"]; +#print "interrupt.value " 0+stat["W"]; +#print "zombie.value " 0+stat["Z"]; +#}' +#elif [ "$OPERSYS" = "OpenBSD" ]; then +# # First line is header. Remove it. +# $ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk ' +#{ threads++; stat[$1]++ } +#END { +#print "threads.value " 0+threads; +#print "uninterruptible.value " 0+stat["D"]; +#print "idle.value " 0+stat["I"]; +#print "runnable.value " 0+stat["R"]; +#print "sleeping.value " 0+stat["S"]; +#print "stopped.value " 0+stat["T"]; +#print "zombie.value " 0+stat["Z"]; +#}' +#elif [ "$OPERSYS" = "NetBSD" ]; then +# # First line is header. Remove it. +# $ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk ' +#{ threads++; stat[$1]++ } +#END { +#print "threads.value " 0+threads; +#print "uninterruptible.value " 0+stat["D"]; +#print "idle.value " 0+stat["I"]; +#print "suspended.value " 0+stat["U"]; +#print "runnable.value " 0+stat["R"]; +#print "sleeping.value " 0+stat["S"]; +#print "stopped.value " 0+stat["T"]; +#print "zombie.value " 0+stat["Z"]; +#}' +# +#elif [ "$OPERSYS" = "Darwin" ]; then +# # First line is header. Remove it. +# $ps -axo state= | sed '1d' | sed -e 's/^\(.\).*/\1/' | $awk ' +#{ threads++; stat[$1]++ } +#END { +#print "threads.value " 0+threads; +#print "uninterruptible.value " 0+stat["U"]; +#print "idle.value " 0+stat["I"]; +#print "runnable.value " 0+stat["R"]; +#print "sleeping.value " 0+stat["S"]; +#print "stopped.value " 0+stat["T"]; +#print "zombie.value " 0+stat["Z"]; +#}' +#fi + -- 2.43.0