import java io import java text DateFormat import java util Date publi

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
import java.io.*;
import java.text.DateFormat;
import java.util.Date;
public class mediamon extends Thread {
public static void main (String[] args) {
String[] name=new String[trans_amount];
name[0]=" Kontinent: ";
name[1]=" EuropaFM: ";
name[2]="EuroFm(west): ";
name[3]=" NasheRadio: ";
name[4]=" OTV: ";
name[5]=" Kont(west): ";
name[6]=" City: ";
name[7]=" NRKU 1th: ";
name[8]=" NRKU Inter: ";
name[9]=" NRKU 3th: ";
String[] condition= new String[trans_amount];
DateFormat d = DateFormat.getTimeInstance(DateFormat.MEDIUM);
try {
if (args[0].equals("-nosound")){sound=false;}
}
catch (Exception e) {}
try{
while (true){
media_alarm=false;
condition[0]=run_mon("mms://212.26.129.194/kontinent");
condition[1]=run_mon("mms://212.26.129.194/EuropaFM");
condition[2]=run_mon("mms://212.26.129.197:1758/wmtencoder/EuropaFM");
condition[3]=run_mon("mms://212.26.129.222:8000/wmtencoder/NasheRadio");
condition[4]=run_mon("mms://212.26.129.194/OTV");
condition[5]=run_mon("mms://212.26.129.2/wmtencoder/Kontinent");
condition[6]=run_mon("http://212.26.128.214:8080");
//condition[6]=run_mon("mms://212.26");
condition[7]=run_mon("rtsp://real.nrcu.gov.ua:7553/encoder/ru1channel.rm");
condition[8]=run_mon("rtsp://real.nrcu.gov.ua:7554/encoder/rui.rm");
condition[9]=run_mon("rtsp://real2.nrcu.gov.ua:7555/encoder/ru3channel.rm");
System.out.println("Checking at "+d.format(new Date())+":");
for (int i=0;i<trans_amount;i++)
System.out.println(name[i]+condition[i]);
System.out.println(" ");
if (media_alarm){play_alarm(sound);}
mediamon.sleep(41785);
}
}
catch (Exception e) {System.out.println("Waiting error!");}
}
private static String run_mon (String adr)
{
String tmp_str;
boolean ok_flag=false;
String retrn="Missing url...";
try {
Runtime r=Runtime.getRuntime();
Process p=r.exec("mplayer -quiet -af volume=-1000 -novideo -endpos 0 "+ adr);
BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((tmp_str=in.readLine())!=null)
// {
// System.out.println(tmp_str);
if (tmp_str.equals(cmp_str)){ok_flag=true;}
//System.out.println(tmp_str);
//System.out.println(tmp_str);
// else if (tmp_str.equals(cmp_str2)){ok_flag=false;}
//}
in.close();
if (ok_flag){retrn="OK";}
else {retrn="FAILED"; media_alarm=true;}
}
catch (Exception e) {System.out.println("Missing url...");}
return retrn;
}
private static void play_alarm(boolean sound){
if (sound)
try
{
Runtime r = Runtime.getRuntime();
Process p = r.exec("esdplay /usr/share/sounds/KDE_Critical_Error.wav");
}
catch (Exception e){System.out.println("No sound");}
}
private static String cmp_str="Starting playback...";
private static String cmp_str1="ASF file format detected.";
private static String cmp_str2="No stream found.";
private static boolean media_alarm=false;
private static int trans_amount=10;
private static boolean sound=true;
}