hello , someone please explain how i can display running mosquito process??
i am running my Ha on raspberry , hassbian
ssh to your pi, and as root type the following command
ps ax | grep mosq
or sudo ps ax | grep mosq
if you are a regular user
cheers
392 ? S 3:02 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
27840 pts/0 S+ 0:00 grep --color=auto mosq
- platform: systemmonitor
resources:- type: disk_free
arg: / - type: memory_free
- type: processor_use
- type: last_boot
- type: since_last_boot
- type: process
arg: HERE PUT WHATT?
- type: disk_free
What are you trying to achieve? Are you trying to see if mosquitto is running or not in a HA sensor?
I personaly have never used the system monitor component, but reading the page of it says, that the argument of type: process is a binary, which means to me that you should put an executable command there. So why not try and paste the complete:
āps ax|grep mosquittoā
(probably surrounded with the tick marks)
If you are running this a pi or any other linux type box you may run into permission problems, so maybe you should add your HA user the sudoers file first.
hope this helps
tom
or you can try the āpgrep -f mosquittoā which returns only the pid of the process
I havenāt tried it, but I think it needs the location of the executable, i.e. the output of
which mosquitto
in my case this is
pi@raspberrypi:~
$ which mosquitto
/usr/sbin/mosquitto
But to be honest, I think the best way of getting the status of mosquitto would be to use a command line sensor to decode the output of
pi@raspberrypi:~
$ systemctl status mosquitto.service
ā mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto)
Active: active (running) since Wed 2017-02-08 16:17:23 UTC; 3 weeks 0 days ago
CGroup: /system.slice/mosquitto.service
āā409 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Edit 2:
Actually the output of
systemctl show mosquitto.service
is much easier to parse.
@towme i am trying to do this:
but i only want mosquitto no glances.
but i dont know what i should put on my config.
platform: systemmonitor
resources:
type: disk_free
arg: /
type: memory_free
type: processor_use
type: last_boot
type: since_last_boot
type: process
arg: systemctl show mosquitto.service
this configuration is right?
Thatās not what I meant. Iām not sure how your image was created, but I mean this:
sensor:
- platform: command_line
name: "mosquitto status"
command: systemctl show mosquitto.service | awk -F= '/^SubState=/ {print $2}'
scan_interval: 60
thank you. works very good.
This is what I use. It is a script that runs via cron every couple minutes and publishes results to MQTT. I then pick it up in HA and a Mac. When the mac detects something down it sends me a SMS via Messages.
#!/bin/bash
list of apps seperated by a space
apps=āmotion appdaemon influxdb docker glances mosquitto mysql webmin home-assistant@hass homebridgeā
mqtthost=ālocalhostā # mqtt broker address
mqtttopic=āappcheckā # first part of topic
mqtttopichost=āvostroā # second part of topic
pos_mess=ā1ā # positive message
neg_mess=ā0ā # negative message
for app in $apps
do
ps_out=ps -ef | grep $app | grep -v 'grep' | grep -v $0
result=$(echo $ps_out | grep ā$appā)
if [[ ā$resultā != āā ]];then
echo $pos_mess
/usr/bin/mosquitto_pub -h $mqtthost -q 0 -t $mqtttopic/$mqtttopichost/$app -m $pos_mess
elseecho $neg_mess
/usr/bin/mosquitto_pub -h $mqtthost -q 0 -t $mqtttopic/$mqtttopichost/$app -m $neg_mess
fi
done
I run this on another box and a similar script on the mac.