Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Wednesday, October 23, 2019

setting python version on Ubuntu




Adapted from this link

https://unix.stackexchange.com/questions/410579/change-the-python3-default-version-in-ubuntu


 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1

annoying note #1.  Pip install is fskced up on Ubuntu.  It installs a wrapper for python-pip, but doesn't install the underlying python 3 main version.

so do this:

sudo apt-get -y install python3-pip

if ubuntu unattended upgrade is running, kill it by editing

/etc/apt/apt.conf.d/10periodic
APT::Periodic::Update-Package-Lists "1";
 
change the 1 to 0, and reboot (easiest).  If update is in progress
killing the scripts is a big PITA. 

https://linoxide.com/ubuntu-how-to/enable-disable-unattended-upgrades-ubuntu-16-04/
if you have to remove pip to start over use:
sudo apt-get purge python-pip

upgrade pip with

pip3 install --user --upgrade pip

Install mongo db
https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-18-04





--30--


Wednesday, June 5, 2019



Article

https://medium.com/@kevalpatel2106/monitor-the-core-temperature-of-your-raspberry-pi-3ddfdf82989f


#!/usr/bin/python2.7
import os
import time

def measure_temp():
        temp = os.popen("vcgencmd measure_temp").readline()
        return (temp.replace("temp=",""))

while True:
        print(measure_temp())
        time.sleep(1)


Thru a web page using python direct listening

https://raspberrypi.stackexchange.com/questions/8689/how-do-i-display-the-temperature-from-the-internal-sensor-on-a-html-page

install python-tornado

#!/usr/bin/env python

import tornado.ioloop
import tornado.web
import os

class MainHandler(tornado.web.RequestHandler):
    def getCPUtemperature( self ):
        res = os.popen('vcgencmd measure_temp').readline()
        return(res.replace("temp=","").replace("'C\n",""))

    def get(self):
        self.write( "Temperature: %s" % ( self.getCPUtemperature() ) )

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
 

using RRD tool

http://lazydroid.com/2013/05/raspberry-pi-monitoring-cpu-temperature-with-rrdtool/

raw measurement of cpu temp
 
vcgencmd measure_temp
Monitor loop
watch -n 1 vcgencmd measure_temp


 

--30--

Wednesday, August 30, 2017

Installing s-tui and pre-requisites

s-tui is a nice terminal graphic performance monitor, showing utilization, frequency and system temperature. 

Here is an article about s-tui

https://linoxide.com/monitoring-2/s-tui-terminal-tool-monitoring-cpu-temperature-linux/

and the GIThub link

https://github.com/amanusk/s-tui

It is installable with pip, so pip must be installed.

To do that, first install pip

sudo apt-get install -y python-setuptools python-dev build-essential

then pull in pip

sudo easy_install pip

next one can install s-tui

pip install s-tui

It's been tried out on raspberry pi, raspian, and on ubuntu 16.04 on intel.

It needs work on armbian, at least on the orangepi zero system.


Monday, October 3, 2016

Upload Youtube videos from Linux command line

This might be handy for uploading surveillance videos or the like, generated on a system.

From Jean-Luc

http://www.cnx-software.com/2014/02/09/how-to-upload-youtube-videos-with-the-command-line-in-linux/

mkdir youtube-upload
cd youtube-upload
wget https://github.com/youtube/api-samples/raw/master/python/upload_video.py

Google API download

wget https://google-api-python-client.googlecode.com/files/google-api-python-client-1.2.tar.gz
tar xzvf google-api-python-client-1.2.tar.gz
cd google-api-python-client-1.2/
mv apiclient/ oauth2client/ uritemplate/ ..
cd ..

Sunday, July 19, 2015

vmesxi support on nagios or vmware esxi


monitoring python script can be had here:

https://www.thomas-krenn.com/en/wiki/VMware_ESXi_Hardware_with_Nagios_or_Icinga_Monitoring

instructions for installing it in the nagios system can be had here:

http://www.claudiokuenzler.com/nagios-plugins/check_esxi_hardware.php#CommandDefinition

Note: had a problem with minimal system install with setuptools for python environment not being installed.  This occurred on a system built up from a very minimal debian environment (ubuntu 14.10) and may happen other times.

http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources

to install setuptools

sudo su
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python

Service definition for icinga command.cfg:

# Check HP Server hardware
define service{
        use generic-service
        host_name vmesxi3
        service_description Hardware
        check_command check_esxi_hardware!root!<password>
}