nethogs
is used to monitor network traffic. You can see which processes use the most bandwidth and hogs the network.Installtion on debian:
apt-get install nethogs
You can give the
nethogs
a network interface to see what's going on under the hood:nethogs eth0
The output would something like:
PID USER PROGRAM DEV SENT RECEIVED
9023 root python eth0 6.083 175.811 KB/sec
20745 root python eth0 2.449 45.715 KB/sec
11934 www-da.. nginx: worker process eth0 131.580 20.238 KB/sec
25925 root /usr/bin/python eth0 3.674 10.090 KB/sec
When
nethogs
is open, you can press r
in order to sort based on RECEIVED
or press s
to sort based on SENT
packets. To change the mode that it is shown for KB/sec
press m multiple times and see the output.#network #sysadmin #linux #nethogs #nethog #network #eth0
How to turn a dictionary into a string?
The output would be:
#python #dictionary #string
extra_data = {'iso': 'IR', 'address': 'Iran - Tehran - Azadi'}
' - '.join('{}:{}'.format(key, val) for key, val in extra_data.items())
The output would be:
iso:IR - address:Iran - Tehran - Azadi
NOTE:
it could come in handy in case you want to store a variable dictionary structure into NO-SQL database.#python #dictionary #string
https://askubuntu.com/questions/726601/nethogs-%E2%86%92-creating-socket-failed-while-establishing-local-ip-are-you-root
#nethogs #debian #linux #bug
#nethogs #debian #linux #bug
Ask Ubuntu
Nethogs → creating socket failed while establishing local IP - are you root?
Following update of my Kubuntu, I'm not able to monitor my network consumption using nethogs:
sudo nethogs enp1s0
creating socket failed while establishing local IP - are you root?
Kernel
$ unam...
sudo nethogs enp1s0
creating socket failed while establishing local IP - are you root?
Kernel
$ unam...
How do you upgrade
The short answer is that you need to do an incremental upgrade on its database.
But how exactly?
The content of
#linux #icinga2 #monitoring #icinga2 #icingaweb #upgrade
Icinga2
from a very old version?The short answer is that you need to do an incremental upgrade on its database.
But how exactly?
apt-get update
apt-cache policy icinga2-ido-mysqlThe candidate section displays what version is available for you system. Do the same for
icingaweb2
:apt-cache policy icingaweb2Upgrade these packages alltogether:
apt-get upgrade -o Dpkg::Options::="--force-confold" -yUpdate
icinga2
packages:apt-get upgrade icinga2 icinga2-bin icinga2-common icinga2-ido-mysql libicinga2Now check
apt-get install icinga2-bin
apt-get install icinga2
icinga2
log in tail -f /var/log/icinga2/icinga2.log
, you may see errors like:[2017-12-21 12:00:22 -0600] critical/IdoPgsqlConnection: Schema version '1.14.2' does not match the required version '1.14.3' (or newer)! Please check the upgrade documentation at https://docs.icinga.com/icinga2Here you need to upgrade
MySQL
schemas, go to /usr/share/icinga2-ido-mysql/schema/upgrade
path and now import new schemas to Icinga2 MySQL
database. As I was in version 2.6.0
I went for 2.8.0
:mysql -u icinga2 -p icinga2 < 2.8.0.sqlIt will prompt for password of user
icinga2
, enter the password and go on.The content of
MySQL Schemas
is as follows:2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql 2.4.0.sql 2.5.0.sql 2.6.0.sql 2.8.0.sql 2.8.1.sql
NOTE:
to get the password for user icinga2
open /etc/icinga2/features-enabled/ido-mysql.conf
file and get the password from here.#linux #icinga2 #monitoring #icinga2 #icingaweb #upgrade
How to get list of network interfaces using nagios?
In nagios plugins there is a script called
Give your host address in
#nagios #network #network_usage
In nagios plugins there is a script called
check_nwc_health
that can be used to report network interfaces of a remote server. In order to check interface usage of remote server network cards:cd /usr/lib/nagios/plugins
./check_nwc_health --mode interface-usage -H 172.17.131.12 -C YOUR_COMMUNITY_STRING
Give your host address in
-H
section and your community string in -C
param.#nagios #network #network_usage
The best explanation about load average:
http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
#linux #load #load_average #cpu
http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
#linux #load #load_average #cpu
Tech C**P
How do you upgrade Icinga2 from a very old version? The short answer is that you need to do an incremental upgrade on its database. But how exactly? apt-get update apt-cache policy icinga2-ido-mysql The candidate section displays what version is available…
In case your upgrade failed, try to start icinga service and in the meantime check the logs in another console:
Check logs to see what is the error:
If it point to a specific config file, change the config as reported or in case you don't need it remove it. It happened for me on another Icinga2 server and I removed the old config and tried to apply the new schemas. It gave another error on mysql grants, I gave all permissions to the icinga2 user:
Now all things should be up and working now.
#icinga2 #monitoring #upgrade #schema_update #icinga
service icinga2 start
Check logs to see what is the error:
tail -f /var/log/icinga2/icinga2.log
If it point to a specific config file, change the config as reported or in case you don't need it remove it. It happened for me on another Icinga2 server and I removed the old config and tried to apply the new schemas. It gave another error on mysql grants, I gave all permissions to the icinga2 user:
mysql -u root -p
GRANT ALL PRIVILEGES ON icinga2_database_name.* TO 'icinga2_username'@'localhost'
flush privileges;
Now all things should be up and working now.
#icinga2 #monitoring #upgrade #schema_update #icinga
Generate random valid users agent for your bot crawlers in
https://pypi.org/project/user_agent/
#python #user_agent #crawl #web_scraper
Python
:https://pypi.org/project/user_agent/
#python #user_agent #crawl #web_scraper
PyPI
user_agent
User-Agent generator
How to Load & Parse
To install
To load a
To convert a dictionary to a
#python #yaml #pyyaml #load #dump
YAML
file in Python
?To install
YAML
library:pip install pyyaml
To load a
YAML
file:>>> import yaml
>>> print yaml.load("""
... name: Vorlin Laruknuzum
... sex: Male
... class: Priest
... title: Acolyte
... hp: [32, 71]
... sp: [1, 13]
... gold: 423
... inventory:
... - a Holy Book of Prayers (Words of Wisdom)
... - an Azure Potion of Cure Light Wounds
... - a Silver Wand of Wonder
... """)
To convert a dictionary to a
YAML
file:>>> print yaml.dump({'name': "The Cloak 'Colluin'", 'depth': 5, 'rarity': 45, 'weight': 10, 'cost': 50000, 'flags': ['INT', 'WIS', 'SPEED', 'STEALTH']})
#python #yaml #pyyaml #load #dump
How to localize a
#localize #timezone #pytz #astimezone #replace
UTC
date?import pytz
import datetime
date_format = '%Y-%m-%d %H:%M:%S'
dt = datetime.datetime.strptime('2018-12-12 00:00:00', date_format)
utc_tz = pytz.timezone('UTC')
utc_d = utc_tz.localize(dt)
teh_tz = pytz.timezone('Asia/Tehran')
dt = utc_d.astimezone(teh_tz)
#localize #timezone #pytz #astimezone #replace
ngrok
something that ROCKS and is priceless!As
ngrok
itself says:Public URLs for exposing your local web server
Have you had an experience of when you need to test a tool and the 3rd party needs you to give a public accessible URL? Well, what would you do when you are developing a project on your PC, Laptop? You don't have any URL to give to 3rd party tools. Here
ngrok
truely rocks!Downlaod it from the URL below:
https://ngrok.com/
And extract the download binay for your OS. In order to run the
ngrok
just do like below:./ngrok http 5000
The above command will output some data and a part which is
Forwarding
for http and https:Forwarding http://76eec0f8.ngrok.io -> localhost:5000
Forwarding https://76eec0f8.ngrok.io -> localhost:5000
The URL
76eec0f8.ngrok.io
is the part that you will give to the 3rd party. and all the other part of the URL path will be forwardedto port
5000
on your local server.Yes, I know it's like a magic.
#ngrok #port #http #ngrok_io
https://stackoverflow.com/questions/23554872/why-does-pycharm-propose-to-change-method-to-static
#python #pycharm #static #staticmethod
#python #pycharm #static #staticmethod
Stack Overflow
Why does PyCharm propose to change method to static?
The new pycharm release (3.1.3 community edition) proposes to convert the methods that don't work with the current object's state to static.
What is the practical reason for that? Some kind of micro-
What is the practical reason for that? Some kind of micro-