Last change
on this file since 1095 was
1095,
checked in by quentin, 15 years ago
|
Documentation when given an unrecognized user
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1093] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | docnagios() { |
---|
| 4 | echo q | env TERM=ansi LINES=1000 COLS=80 /usr/local/nagios/bin/cnagios -b "$@" | sed 's/ |
---|
| 5 | \[B/\n/g; s/ |
---|
| 6 | /\n/g' | perl -pe ' |
---|
| 7 | s/^.*(?=sipb-nagios)//; # remove garbage at beginning |
---|
| 8 | s/(.)\\[(\d+)b/$1x($2+1)/ge; # (\d+)b means repeat previous character n times |
---|
| 9 | s/\\[(\d+)d//g; # absolute go to line; ignored |
---|
| 10 | s/\\[(\d+)G/" "x($1-$-[0]-1)/ge; # go to absolute horizontal position |
---|
| 11 | s/\\[\d+;(\d+)H/" "x($1-$-[0]-1)/ge; # go to absolute position; line ignored |
---|
| 12 | ' |
---|
| 13 | } |
---|
| 14 | |
---|
[1094] | 15 | gethostgroups() { |
---|
| 16 | cat /etc/nagios3/*.cfg | perl -ne 'print if ( /^(\s*)define hostgroup [\{[]/ ... /[\}\]]/ )' | perl -ne 'm|hostgroup_name\s+(\S+)| and $name = $1; m|members\s+(.+)\s*$| and $members = $1; m|\}| and print "$name\t$members\n"' |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | gethgmembers() { |
---|
| 20 | gethostgroups | grep "^$1\t" | cut -f 2 -d " " | sed 's/,/\n/g' | perl -pe 's/\n/|/g' | sed 's/|$//' |
---|
| 21 | } |
---|
| 22 | |
---|
[1093] | 23 | read line |
---|
| 24 | case "$line" in |
---|
| 25 | status*) |
---|
| 26 | docnagios |
---|
| 27 | ;; |
---|
| 28 | broken*) |
---|
| 29 | docnagios -l w |
---|
| 30 | ;; |
---|
[1094] | 31 | xvm*) |
---|
| 32 | docnagios -g "/$(gethgmembers "xvm.*")/" |
---|
| 33 | ;; |
---|
[1093] | 34 | *) |
---|
[1095] | 35 | cat <<EOF |
---|
| 36 | Available information: |
---|
| 37 | finger status@sipb-noc -- all services |
---|
| 38 | finger broken@sipb-noc -- services that are not OKAY |
---|
| 39 | finger xvm@sipb-noc -- only XVM servers |
---|
| 40 | EOF |
---|
| 41 | |
---|
[1093] | 42 | ;; |
---|
| 43 | esac |
---|
| 44 | #s/\\[\d*[a-zA-Z]//g' |
---|
| 45 | #perl -pe 's/^.*?\[H //s; s/.\[\d+;1H/\n/g; s/^\s+//mg;' |
---|
| 46 | |
---|
| 47 | # s/^\s+$//mg; s/Command: .*//s; s/$/\[0m/' |
---|
Note: See
TracBrowser
for help on using the repository browser.