File: 1.01.4b/server/base/view.inc.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie 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: function LocalTestDesc($ltid) 24: { 25: global $NATS; 26: $q="SELECT nodeid,testtype,testparam,testname FROM fnlocaltest WHERE localtestid=".ss($ltid); 27: $r=$NATS->DB->Query($q); 28: if ($row=$NATS->DB->Fetch_Array($r)) 29: { 30: if ($row['testname']!="") $ret=$row['testname']; 31: else 32: { 33: $ret=lText($row['testtype']); 34: //if ($row['testparam']!="") $ret.=" (".substr($row['testparam'],0,20).")"; 35: if ($row['testparam']!="") $ret.=" (".$row['testparam'].")"; 36: } 37: $ret.=" on ".$row['nodeid']; 38: } 39: else $ret="Unknown2 on Unknown".$ltid; 40: return $ret; 41: } 42: 43: function GetTestDesc($tid) 44: { 45: global $NATS; 46: $class=$tid[0]; 47: if (is_numeric($class)) $class="L"; 48: else $tid=substr($tid,1); 49: 50: if ($class=="L") return LocalTestDesc($tid); 51: else if ($class=="N") 52: { 53: $q="SELECT nodeid,testtype,testname,testdesc FROM fnnstest WHERE nstestid=".ss($tid)." LIMIT 0,1"; 54: $r=$NATS->DB->Query($q); 55: if (!$row=$NATS->DB->Fetch_Array($r)) return "Unknown on Unknown"; 56: $t=""; 57: if ($row['testname']!="") $t=$row['testname']; 58: else if ($row['testdesc']!="") $t=$row['testdesc']; 59: else $t=$row['testtype']; 60: $t.=" on ".$row['nodeid']; 61: return $t; 62: } 63: 64: return "Unknown on Unknown"; 65: } 66: 67: function ViewItemTxt($type,$option) 68: { 69: global $NATS; // must be set if you're using a view! 70: switch ($type) 71: { 72: case "node": return "Node - ".$option; 73: case "allnodes": return "All Active Nodes"; 74: case "alertnodes": return "All Alerting Nodes"; 75: 76: case "group": 77: $q="SELECT groupname FROM fngroup WHERE groupid=".ss($option)." LIMIT 0,1"; 78: $r=$NATS->DB->Query($q); 79: if ($row=$NATS->DB->Fetch_Array($r)) $ret="Group - ".$row['groupname']; 80: else $ret="Group (".$option.")"; 81: $NATS->DB->Free($r); 82: return $ret; 83: 84: case "allgroups": return "All Groups"; 85: case "alertgroups": return "All Alerting Groups"; 86: case "alerts": return "Current Alerts"; 87: case "title": return "Title (".$option.")"; 88: case "testdetail": 89: //$tt=substr($option,0,1); 90: //$tid=substr($option,1,128); 91: return "Test Detail for ".GetTestDesc($option); 92: //return "Detail for Test (".$option.")"; 93: case "testgraph": 94: 95: $tid=$option; 96: 97: $sl=strpos($tid,"/"); 98: if ($sl===false) return "Test Graph for ".GetTestDesc($tid)." (default)"; // will break on non-local sets, refine logic here 99: // otherwise as a return 100: $hrs=substr($tid,$sl+1,32); 101: $tid=substr($tid,0,$sl); 102: if ($hrs=="") $hrs="default"; 103: return "Test Graph for ".GetTestDesc($tid)." (".$hrs." hours)"; 104: //return "History Graph for Test (".$option.")"; 105: default: return "Unknown Item Type (".$type."/".$option.")"; 106: } 107: } 108: 109: 110: 111: ?>