Q:

Vlc Check Stream Status

I am using VLC to rebroadcast a stream and this side of things is working very well. After a few hours however, I need to re authenticate and re-request the stream.
I have a script that simply needs to be run and this will handle the re-authentication and starting vlc.
The problem I am having is how to figure out if the stream is no longer working.
When using say:
pidof vlc

I get the pid of the process VLC. When checking top, I can see VLC running and consuming cpu. However, when I try to play the stream nothing happens. If I run my script again, the stream restarts and I can then watch it again.
So even if the stream has stopped, VLC continues to run giving me no indication of whether the stream itself is actually running or just VLC.
The only thing I have spotted so far is that when the stream is not running the CPU usage seems to spike according to top.
When the stream is running, the cpu usage is around the 1% mark, when it is not running it seems to spike past 40%. I have observed this a couple of times, but I can only assume that this would potentially be a way I could ensure the stream is running, but I am not 100% confident in the approach.
Does anyone have any knowledge on how I could confirm if the actual stream is running or if it is just the VLC process?

A:

should give credits to @mundu 
here is a script I created for checking if vlc is streaming. 
// vlc_verify1.sh
#!/bin/bash

VLC_CONF="$1"
VLC_COMMAND="$2"
VLC_PASS="videolan"

echo "" > nohup.out

nohup vlc --intf telnet --vlm-conf $VLC_CONF --telnet-password $VLC_PASS &
vlc_pid=$!
echo "vlc has a pid of $vlc_pid"

sleep 5

echo  "nc start"
nc localhost 4212 < $VLC_COMMAND

kill $vlc_pid
exit 0

// vlm-conf, you have to replace $url with the actual url
new channel1 broadcast enabled
setup channel1 input $url
control channel1 play
show

// command.txt
videolan
show

the vlc_verify1.sh would output the status of current playing as mentioned by @mundu. what I did is to grep the output and see if it's state is 'playing'.
Notice, I didn't specify the output like setup channel1 output #std{access=udp,mux=ts,dst=239.192.174.105:1234}. 
a reason for that is sometime vlc would use 100% cpu time. I have no clue why so. but if I get rid of that, I didn't experience similar issues. a downside for this is that there will be a pop-up window playing the streamings. but I don't think it's a big deal. 

