#!/usr/bin/php "gprs", "Summe der Verbindungskosten" => "summe", "Ihr Gesprächsguthaben für die aktuelle Abrechnungsperiode beträgt in Euro:" => "guthaben", "E-Plus zu E-Plus" => "netzintern", "E-Plus in andere Netze" => "netzextern" ); $user = $_SERVER['argv'][1]; $pw = $_SERVER['argv'][2]; $nr = $_SERVER['argv'][3]; $warn = (int)$_SERVER['argv'][4]/100; $critical = (int)$_SERVER['argv'][5]/100; $client->setDefaultHeader( array ( 'User-Agent' => 'Nagios Spider' ) ); $client->get ( 'http://www.eplus.de/' ); $client->post ( 'https://sso.eplus.de/amserver/UI/Login', array ( 'goto' => 'https://mein.eplus.de/pUframe.asp?ecc=1&setc=1&pUurl=https%3A%2F%2Fecc%2Eeplus%2Ede%2Fecc%2Flogin%2Edo&opener=https%3A%2F%2Fmein%2Eeplus%2Ede%2F1%2F1%5F0%2F1%5F0%2Easp%3Fld%3Decc%3Bgateway%3Berfolg', 'gotoOnFail' => '', 'module' => 'EccLDAP', 'IDToken1' => $user, 'IDToken2' => $pw ) ); //$buf = $client->currentResponse(); //print_r ( $buf ); $client->get ( 'https://ecc.eplus.de/ecc/cc.do?menu=Cost%20Control&msisdn=alle&parent=Rechnungen' ); $client->get ( 'https://ecc.eplus.de/ecc/cc.do?msisdn='.$nr ); $buf = $client->currentResponse(); $betrag = -1; $guthaben = -1; if ( !preg_match_all ( '@(?P[^<]+)[ \t\r\n]*(?P\d*),(?P\d{2})@', $buf['body'], $matches, PREG_SET_ORDER ) ) { echo $buf['body']; echo 'Regex failed!'; exit ( 3 ); } $perf_str = ''; foreach ( $matches as $match ) { if ( $match['text'] == 'Summe der Verbindungskosten' ) $betrag = $match['euro']+$match['cent']/100; if ( $match['text'] == 'Ihr Gesprächsguthaben für die aktuelle Abrechnungsperiode beträgt in Euro:' ) $guthaben = $match['euro']+$match['cent']/100; if ( isset ( $perf_map[$match['text']] ) ) $perf_str .= $perf_map[$match['text']]."=".($match['euro']+$match['cent']/100)."EUR;"; } /* if ( !preg_match ( '@Summe der Verbindungskosten[ \t\r\n]*(?P\d*),(?P\d{2})@', $buf['body'], $match ) ) { echo $buf['body']; echo 'Regex failed!'; exit ( 3 ); } $betrag = $match['euro']+$match['cent']/100; */ $str = ' - Kosten: '.$betrag.' EUR '; if ( $guthaben > 0 ) $str .= 'Guthaben: '.$guthaben.' EUR '; $str .= '+'.$nr.' | '.$perf_str."\n"; if ( $betrag < 0 ) { echo "UNKNOWN".$str; exit ( 3 ); } else if ( $betrag > $critical ) { echo "CRITCAL".$str; exit ( 2 ); } else if ( $betrag > $warn ) { echo "WARN".$str; exit ( 1 ); } else { echo "OK".$str; exit ( 0 ); } ?>