From 281db38124fefe8e417a90a0055fa90a9e4785ee Mon Sep 17 00:00:00 2001 From: Simon Kowallik Date: Sun, 12 Mar 2017 16:43:48 +0100 Subject: [PATCH] iHealth API compatibility fixes + improvements updated for iHealth API compatibility fixes and added small improvements in error handling --- README.md | 16 ++++++------- ihac-auth | 9 +++++-- ihac-commandlist | 8 +++++-- ihac-commandrun | 7 ++++-- ihac-diagnostics | 61 +++++++++++++++++++++++++++-------------------- ihac-fileget | 6 +++-- ihac-filelist | 7 ++++-- ihac-qkviewadd | 7 ++++-- ihac-qkviewdelete | 7 ++++-- ihac-qkviewget | 8 ++++--- ihac-qkviewlist | 35 ++++++++++++++------------- 11 files changed, 104 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 0af7e1e..dfc9f92 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ OK ### ihac-qkviewadd Adds qkview to iHealth, qkview file supplied as argument. You can specify as many qkviews as arguments as you want. ```sh -simon@bigip ~ $ ihac-qkviewadd ../qkviews/bigip1141.qkview ../qkviews/bigip1151.qkview ../qkviews/bigip1160.qkview +simon@bigip ~ $ ihac-qkviewadd ../bigip1141.qkview ./bigip1151.qkview bigip1160.qkview ################################################################## 100.0% 2257810 OK ################################################################## 100.0% @@ -134,10 +134,10 @@ simon@bigip ~ $ cat ../qkviews/bigip1151.qkview | ihac-qkviewadd Lists all qkviews available on iHealth ```sh simon@bigip ~ $ ihac-qkviewlist -2257819 bigip1151.example.com SerialNumber May 8 2014, 21:12:29 AM (GMT) OptionalCaseNumber -2257811 bigip1151.example.com SerialNumber May 8 2014, 21:10:19 AM (GMT) OptionalCaseNumber -2254055 bigip1151.example.com SerialNumber May 7 2014, 20:59:32 AM (GMT) OptionalCaseNumber -2254011 bigip1151.example.com SerialNumber May 7 2014, 20:32:39 AM (GMT) OptionalCaseNumber +2257819 bigip1151.example.com SerialNumber May 8 2014, 21:12:29 AM (GMT) OptionalCaseNumber +2257811 bigip1151.example.com SerialNumber May 8 2014, 21:10:19 AM (GMT) OptionalCaseNumber +2254055 bigip1151.example.com SerialNumber May 7 2014, 20:59:32 AM (GMT) OptionalCaseNumber +2254011 bigip1151.example.com SerialNumber May 7 2014, 20:32:39 AM (GMT) OptionalCaseNumber ``` The first column displays the qkview ID, which is important for all commands below. @@ -310,11 +310,11 @@ simon@bigip ~ $ rm -f $HOME/.ihac/auth.jar # Usage Examples Pipe credentials from local to remote system for authentication and list all qkviews available on iHealth ```sh -~ $ cat $HOME/auth.txt | ssh root@192.168.1.245 '/root/bin/ihac-auth; /root/bin/ihac-qkviewlist' +~ $ cat $HOME/auth.txt | ssh root@192.168.1.245 '/root/bin/ihac-auth;/root/bin/ihac-qkviewlist' Password: OK -2483776 bigip.example.com 0570271 Jun 30 2014, 06:59:43 PM (GMT) -2483760 bigip.example.com 0570271 Jun 30 2014, 06:54:47 PM (GMT) +2483776 bigip.example.com 0570271 Jun 30 2014, 06:59:43 PM (GMT) +2483760 bigip.example.com 0570271 Jun 30 2014, 06:54:47 PM (GMT) ``` Pipe local qkview file to remote system and upload to iHealth diff --git a/ihac-auth b/ihac-auth index 9738d78..8b05f62 100644 --- a/ihac-auth +++ b/ihac-auth @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.2 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -26,6 +26,8 @@ function urlencode() { done } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ -z "$1" ]] && [[ -t 0 ]] then echo -n "Username: " @@ -41,6 +43,9 @@ else if [[ -f "$IHACAUTH" ]]; then rm -f "$IHACAUTH"; fi echo "OK" exit 0 + elif [[ ! -z "$1" ]] && [[ -s "$1" ]] + then + USRPW=$(<$1) elif [[ ! -z "$1" ]] then USRPW=$1 @@ -54,7 +59,7 @@ else fi fi -result=`curl -si$IHACPROXY --user-agent "iHAC/1.0" --cookie-jar "$IHACAUTH" \ +result=`curl -si$IHACPROXY --user-agent "iHAC/2.0" --cookie-jar "$IHACAUTH" \ --data $USRPW \ -o - https://login.f5.com/resource/loginAction.jsp \ | sort -r \ diff --git a/ihac-commandlist b/ihac-commandlist index 072fece..af3af1e 100644 --- a/ihac-commandlist +++ b/ihac-commandlist @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.1 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,9 +11,13 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + + if [[ -n "$1" ]] && [[ "$1" =~ ^[0-9]+$ ]] then - curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/commands \ | perl -ne 's/\r\n//g; diff --git a/ihac-commandrun b/ihac-commandrun index 81b2384..09fbce1 100644 --- a/ihac-commandrun +++ b/ihac-commandrun @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.2 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,6 +11,9 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ -n "$1" ]] && [[ "$1" =~ ^[0-9]+$ ]] && [[ -n "$2" ]] then if command -v sha1sum > /dev/null @@ -19,7 +22,7 @@ then else cmdid=(`echo -n $2 | shasum`) fi - curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/commands/${cmdid[0]} \ | perl -MMIME::Base64 -ne 's/[\r\n]+//g; diff --git a/ihac-diagnostics b/ihac-diagnostics index dda872f..9d2f739 100644 --- a/ihac-diagnostics +++ b/ihac-diagnostics @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.1 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,35 +11,44 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ -n "$1" ]] && [[ "$1" =~ ^[0-9]+$ ]] then - curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/diagnostics?set=all \ - | perl -ne 's/\r\n//g; - if(m|http/1.. 200|gi) {$ok=1} else { - if(m|http/1.. 30\d|gi) {print STDERR "Error: not authenticated.\n";exit 1} - if(m|http/1.. 404|gi) {print STDERR "Error: qkview ID not found.\n";exit 1} - } - if($ok && m/<\?xml/gi) { - use XML::Simple; - eval {$xml = new XML::Simple->XMLin($_)}; - if ($@) {print STDERR "Error: Could not parse XML: $@\n";exit 1} - $hs_ver = $xml->{version}; $hs_sys = $xml->{system_information}; - print "Hostname: $hs_sys->{hostname}\t Serial: $hs_sys->{bigip_chassis_serial_num}\n"; - print "Version: $hs_ver->{version} $hs_ver->{edition}\t Platform: $hs_sys->{platform}\n\n"; - $diag = $xml->{diagnostics}->{diagnostic}; - foreach $hs ( sort { reverse($diag->{$a}->{run_data}->{h_importance}) cmp reverse($diag->{$b}->{run_data}->{h_importance}) } keys %{$diag} ) { - next if($diag->{$hs}->{run_data}->{match} eq "false"); - $hs_r = $diag->{$hs}->{results}; $hs_s = $hs_r->{h_sols}->{solution}; - print "* Severity: $diag->{$hs}->{run_data}->{h_importance} \tHeuristic: $hs_r->{h_name}\n"; - print "* Title:\t$hs_r->{h_header}\n"; - print "* Summary:\t$hs_r->{h_summary}\n"; - print "* SOLs:\t\t"; if (ref($hs_s) eq "ARRAY") {print join(", ", @{$hs_s})} else {print $hs_s} - print "\n\n"; - } - exit 0; - }' + | perl -e ' + my $xmldata; + while () { + s/\r\n//g; s/\n//g; s/\r//g; s/\t/ /g; + if(m|http/1.. 200|gi) {$response=1} else { + if(m|http/1.. 30\d|gi) {print STDERR "Error: not authenticated.\n";exit 1} + if(m|http/1.. 404|gi) {print STDERR "Error: qkview ID not found.\n";exit 1} + } + if($response && m/<\?xml/gi) {$xml_response=1} + if($xml_response) {$xmldata .= $_} + } + eval {require XML::Simple}; + if ($@) {print STDERR "Error: ihac-diagnostics requires perl module XML::Simple but it is not installed. Perl error: $@\n";exit 1} + eval {$xml = new XML::Simple->XMLin($xmldata)}; + if ($@) {print STDERR "Error: Could not parse XML: $@\n";exit 1} + $hs_ver = $xml->{version}; $hs_sys = $xml->{system_information}; + print "Hostname: $hs_sys->{hostname}\t Serial: $hs_sys->{bigip_chassis_serial_num}\n"; + print "Version: $hs_ver->{version} $hs_ver->{edition}\t Platform: $hs_sys->{platform}\n\n"; + $diag = $xml->{diagnostics}->{diagnostic}; + foreach $hs ( sort { reverse($diag->{$a}->{run_data}->{h_importance}) cmp reverse($diag->{$b}->{run_data}->{h_importance}) } keys %{$diag} ) { + next if($diag->{$hs}->{run_data}->{match} eq "false"); + $hs_r = $diag->{$hs}->{results}; $hs_s = $hs_r->{h_sols}->{solution}; + print "* Severity: $diag->{$hs}->{run_data}->{h_importance} \tHeuristic: $hs_r->{h_name}\n"; + print "* Title:\t$hs_r->{h_header}\n"; + print "* Summary:\t$hs_r->{h_summary}\n"; + print "* SOLs:\t\t"; if (ref($hs_s) eq "ARRAY") {print join(", ", @{$hs_s})} else {print $hs_s} + print "\n\n"; + } + exit 0; + ' else echoerr "Error: no qkview ID specified or not valid." echoerr "Use: `basename $0` ID" diff --git a/ihac-fileget b/ihac-fileget index 8555a83..d5adc28 100644 --- a/ihac-fileget +++ b/ihac-fileget @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.1 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,6 +11,8 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ -n "$1" ]] && [[ "$1" =~ ^[0-9]+$ ]] && [[ -n "$2" ]] then echo test | base64 -w0 > /dev/null 2>&1 @@ -20,7 +22,7 @@ then else fileid=`echo -n ${2#/} | base64 -b0` fi - curl -s$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl -s$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/files/${fileid//=/} else diff --git a/ihac-filelist b/ihac-filelist index d7d96d1..e3bc399 100644 --- a/ihac-filelist +++ b/ihac-filelist @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.2 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,9 +11,12 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ -n "$1" ]] && [[ "$1" =~ ^[0-9]+$ ]] then - curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/files \ | perl -ne 's/\r\n//g; diff --git a/ihac-qkviewadd b/ihac-qkviewadd index 870e58d..170a31f 100644 --- a/ihac-qkviewadd +++ b/ihac-qkviewadd @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.1 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,6 +11,9 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ "$#" -gt 0 ]] then QKVIEWS=("$@") @@ -26,7 +29,7 @@ fi for QKVIEW in "${QKVIEWS[@]}"; do if [[ -f "$QKVIEW" ]] || [[ "$QKVIEW" == "-" ]]; then -curl --progress-bar -i$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ +curl --progress-bar -i$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -F "qkview=@$QKVIEW" -F 'visible_in_gui=True' \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews \ diff --git a/ihac-qkviewdelete b/ihac-qkviewdelete index 648febe..a799553 100644 --- a/ihac-qkviewdelete +++ b/ihac-qkviewdelete @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.1 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,11 +11,14 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ "$#" -gt 0 ]] then for QKVIEWID in "$@"; do if [[ -n "$QKVIEWID" ]] && [[ "$QKVIEWID" =~ ^[0-9]+$ ]]; then - curl -si$IHACPROXY -X DELETE -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl -si$IHACPROXY -X DELETE -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$QKVIEWID \ | perl -ne 's/\r\n//g; diff --git a/ihac-qkviewget b/ihac-qkviewget index 89f5700..a763527 100644 --- a/ihac-qkviewget +++ b/ihac-qkviewget @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.1 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,18 +11,20 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="-x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + if [[ -n "$1" ]] && [[ "$1" =~ ^[0-9]+$ ]] then if [[ -n "$2" ]] then - curl $IHACPROXY --progress-bar -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl $IHACPROXY --progress-bar -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/files/qkview \ > $2 if [[ $? -eq 0 ]]; then echo "OK"; fi elif [[ ! -t 1 ]] then - curl $IHACPROXY --progress-bar -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ + curl $IHACPROXY --progress-bar -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$1/files/qkview else diff --git a/ihac-qkviewlist b/ihac-qkviewlist index 3d197b9..e9ac2cf 100644 --- a/ihac-qkviewlist +++ b/ihac-qkviewlist @@ -1,5 +1,5 @@ #!/bin/bash -#version: 1.2 +#version: 2.0 #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC @@ -11,7 +11,10 @@ if [[ ! -z "$IHACPROXY" ]]; then IHACPROXY="x $IHACPROXY"; fi function echoerr() { echo "$@" 1>&2; } -for id in `curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ +command -v perl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires perl but it is not installed."; exit 1; } +command -v curl >/dev/null 2>&1 || { echoerr "Error: $(basename $0) requires curl but it is not installed."; exit 1; } + +for id in `curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - https://ihealth-api.f5.com/qkview-analyzer/api/qkviews \ | perl -ne 's/\r\n//g; @@ -22,23 +25,23 @@ for id in `curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" -- do if [[ "$id" == "ERR" ]]; then exit 1; fi if [[ ! "$id" =~ ^[0-9]+$ ]]; then echoerr "Error: $id is not a valid qkview ID."; exit 1; fi - URLS="$URLS https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$id/bigip/system/hostname https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$id" + URLS="$URLS https://ihealth-api.f5.com/qkview-analyzer/api/qkviews/$id" done if [[ -z "$URLS" ]]; then echoerr "Error: no qkview IDs recevied."; exit 1; fi -curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/1.0" \ +curl -si$IHACPROXY -H"Accept: application/vnd.f5.ihealth.api.v1.0" --user-agent "iHAC/2.0" \ --cookie "$IHACAUTH" --cookie-jar "$IHACAUTH" \ -o - \ $URLS \ -| perl -ne 's/\r\n//g; - if(m|http/1.. 30\d|gi) {print STDERR "Error: not authenticated.\n";exit 1} - if(m|http/1.. (40\d)|gi) {print STDERR "Error: received $1 from server.\n";exit 1} - if(m|(.*)|gi) {$hostname=$1} - if(m|(.*)|gi) {$serial=$1} - if(m|(.*)|gi) {$case=$1} - if(m|(.*)|gi) {$date=$1} - if(m|.*/(\d+)/.*|gi) {$id=$1} - if (defined($hostname) && defined($serial) && defined($case) && defined($date) && defined($id)) { - printf "%d %-30s %-31s %-12s %s\n", $id, $hostname, $serial, $date, $case; - undef $id, $hostname, $serial, $date, $case; - }' \ No newline at end of file + | perl -ne 's/\r\n//g; + if(m|http/1.. 30\d|gi) {print STDERR "Error: not authenticated.\n";exit 1} + if(m|http/1.. (40\d)|gi) {print STDERR "Error: received $1 from server.\n";exit 1} + if(m|(.*)|gi) {$serial=$1} + if(m|(.*)|gi) {$hostname=$1} + if(m|(.*)|gi) {$case=$1} + if(m|(.*)000|gi) {$date=$1} + if(m|.*/(\d+)/.*|gi) {$id=$1} + if ( defined($id)) { + printf "%d %-30s %-31s %-12s %s\n", $id, $hostname, $serial, scalar localtime($date), $case; + undef $id, $hostname, $serial, $date, $case; + }' \ No newline at end of file