File: 1.19.1b/server/base/tests/nslast.inc.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008-20117PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: /* Get the last time nodeside data was received from the node, 24: * alert if it's been so long we think the node isn't responding 25: */ 26: 27: if (isset($NATS)) 28: { 29: class FreeNATS_NSLast_Test extends FreeNATS_Local_Test 30: { 31: 32: function DoTest($testname,$param,$hostname,$timeout,$params) 33: { 34: global $NATS; 35: 36: $q="SELECT nsenabled,nslastx FROM fnnode WHERE nodeid=\"".ss($param)."\" LIMIT 0,1"; 37: $r=$NATS->DB->Query($q); 38: 39: if ($row=$NATS->DB->Fetch_Array($r)) 40: { 41: if ($row['nsenabled'] != 1) 42: return -2; // nodeside not enabled 43: $last = $row['nslastx']; 44: $elapsed = time() - $last; 45: return $elapsed; 46: } 47: else 48: return -1; // nodeid not found 49: } 50: 51: function Evaluate($result) 52: { 53: if ($result<0) return 2; // failure (test failed for reason) 54: else if ($result>(60*60)) return 2; // an hour 55: else if ($result>(20*60)) return 1; // over 20 mins warning 56: else return 0; //passed 57: } 58: 59: function DisplayForm(&$row) 60: { 61: echo ""; 62: echo ""; 67: echo ""; 68: } 69: 70: } 71: 72: $params=array(); 73: $NATS->Tests->Register("nslast","FreeNATS_NSLast_Test",$params,"Nodelast Last Data",1,"FreeNATS Nodeside Data Tester"); 74: $NATS->Tests->SetUnits("nslast","Seconds","s"); 75: } 76: 77: 78: ?>
"; 63: echo "Node ID :"; 64: echo ""; 65: echo ""; 66: echo "
 (will default to the nodeid of this node)