Application: Linux System Script


Recommended Posts

Hi Haggis, getting a couple of bugs on Arch:

First off, line 245 is emitting an error 'Command "arch" not found'. Quick Google tells me that Arch Linux doesn't have an arch command, you might have to use "uname -m" instead.

Second, line 61 which greps for the "-release" files doesn't work right. It lists the contents of /etc okay, but seems to get stuck searching my entire home directory for something. Quick check seems that its trying to run the command:

grep -r -e -l -e -a -s -e

I've seen this before with grep, and I think it might be a bug thats there for historical reasons or something. Either way, the fix would be to use 'grep "\-release"' instead. The backslash stops grep from bugging out.

Here's the patch for the bugs, tested on Arch only, so others will need to test for their own OS...

*** stats.sh	2012-12-23 23:59:10.000000000 +0000
--- copy of stats.sh	2013-01-06 22:54:01.409394805 +0000
***************
*** 58,64 ****
  # Print a pretty logo for the Linux distribution the user is running.
  function print_logo
  {
! exists=`ls /etc/ | grep "-release" | wc -l`
  if [ "$exists" -gt "0" ]; then
  #if [ -e /etc/*-release ]; then
	  id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
--- 58,64 ----
  # Print a pretty logo for the Linux distribution the user is running.
  function print_logo
  {
! exists=`ls /etc/ | grep "\-release" | wc -l`
  if [ "$exists" -gt "0" ]; then
  #if [ -e /etc/*-release ]; then
	  id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
***************
*** 242,248 ****
	  res=$(xdpyinfo | grep dimensions | awk {'print $2'})
	  load=$(uptime | awk -F 'load average:' '{ print $2 }')
	  # AFAIK there is no standard identification strings between CPU architectures.
!	 case $(arch) in
		  x86_64|i386|i486|i586|i686)
			  cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
			  ;;
--- 242,248 ----
	  res=$(xdpyinfo | grep dimensions | awk {'print $2'})
	  load=$(uptime | awk -F 'load average:' '{ print $2 }')
	  # AFAIK there is no standard identification strings between CPU architectures.
!	 case $(uname -m) in
		  x86_64|i386|i486|i586|i686)
			  cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
			  ;;

Also, I have made for myself a PKGBUILD for this script so that I could install your script into the Arch package system. Would you like me to submit it as an AUR package that all Arch users can install and run it as the command "haggis-stats"?

  On 06/01/2013 at 23:17, Majesticmerc said:

First off, line 245 is emitting an error 'Command "arch" not found'. Quick Google tells me that Arch Linux doesn't have an arch command, you might have to use "uname -m" instead.

I admit, that bug was introduced in a patch I submitted a while back. I do not run Arch Linux, and, therefore, didn't test my patch against it. I do find it slightly ironic that Arch Linux doesn't ship the arch utility, if for no other reason than their namesake!

Hey guys i have a problem

the lsb-release package is not on all distros so i need your help

can you post the output of


cat /etc/issue
[/CODE]

and also tell me the Distro your running

  On 07/01/2013 at 11:05, Haggis said:
can you post the output of

cat /etc/issue
[/CODE]

[code]Ubuntu 12.04.1 LTS \n \l

Ubuntu Server.

This is \n.\O (\s \m \r) \t

Gentoo's default, although I've long since changed it.

  On 07/01/2013 at 12:03, Haggis said:
Max does my script pick up Gentoo ok?

Works for the most part, a few errors at the beginning, but it's not running an X server or DE either like my previous posts. (No lsb_release, xdpyinfo or mate-session.) Displays the Tux penguin for its ASCII art. The OS field comes up as blank however.

One more, finally got around to toying with the latest release. (Fine, I'll use one of these new fangled graphical thingies instead of my usual consoles.)

Chakra Linux (2013.01.03 - Claire) \r  (\n) (\l)

./stats.sh: line 245: arch: command not found


				 .88888888:.				
				88888888.88888.			
			  .8888888888888888.			
			  888888888888888888			
			  88| _`88|_  `88888			
			  88 88 88 88  88888			
			  88_88_::_88_:88888			
			  88:::,::,:::::8888			
			  88`:::::::::``8888			
			 .88  `::::`	8:88.		  
			8888			`8:888.		
		  .8888`			 `888888.	  
		 .8888:..  .::.  ...:`8888888:.	
		.8888.|	 :|	 `|::`88:88888	
	   .8888		`		 `.888:8888.  
	  888:8		 .		   888:88888  
	.888:88		.:		   888:88888:  
	8888888.	   ::		   88:888888  
	`.::.888.	  ::		  .88888888	
   .::::::.888.	::		 :::`8888`.:.  
  ::::::::::.888   |		 .::::::::::::  
  ::::::::::::.8	|	  .:8::::::::::::.
.::::::::::::::.		.:888:::::::::::::
:::::::::::::::88:.__..:88888:::::::::::`  
  ``.:::::::::::88888888888.88:::::::::`	
		``:::_:` -- `` -`-` ``:_::::``	  


	OS: Chakra Linux
	Hostname: vm12
	Uptime: 17 minutes
	CPU:Unknown
	RAM (used / total): 477 / 2006 Mb
	Desktop Enviroment: KDE 4.9.5
	Logged in as: maxnorris
	Kernel: 3.6.6-1-CHAKRA
	Resolution: 1680x944 pixels
	Load Averages: 0.63, 0.53, 0.23
	Top Process (by memory use): kdeinit4:

This run didn't pick up the CPU, even though /proc/cpuinfo has correct info. (*shrug* it's a VM, but it picked it up with other distros properly.)

  On 07/01/2013 at 14:56, Haggis said:
ok so what does this give you

cat /proc/cpuinfo | grep 'model name[/CODE]

[code][maxnorris@vm12 ~]$ cat /proc/cpuinfo | grep 'model name'
model name	  : Intel(R) Core(TM)2 Duo CPU	 E8400  @ 3.00GHz
model name	  : Intel(R) Core(TM)2 Duo CPU	 E8400  @ 3.00GHz

  • 4 weeks later...

Despite the fact that OS X and GNU/Linux are both UNIX-ey, most of the stuff that Haggis implemented in the script are actually Linux specific. For example, OS X has no /proc/cpuinfo or lsb_release (Linux Standard Base release information).

Also, the script is implemented in BASH. While virtually every modern Linux distribution has BASH 4.0 or greater, OS X is stuck on the ancient BASH 3, which doesn't have many of the BASHisms modern scripts rely on. (For example, I have BASH 4.2 on Debian 7, but even Debian 6 has 4.1.)

That said, I didn't write the script; Haggis did. Its up to him whether he wants to support it. Although, if you patched it to work on OS X and submitted the diff, he would probably be willing to accept it.

Aren't there Mac OS X alternatives to accomplish the same tasks perhaps an alternative script as a port or something is in order; something could use "awk", "grep", and "tail" and such against "uname" and such to aquire info? Or against "system_profiler | more"

By the way...


Ryans-MacBook-Air:~ ryan$ uname -a
Darwin Ryans-MacBook-Air.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
Ryans-MacBook-Air:~ ryan$ bash -version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
Ryans-MacBook-Air:~ ryan$
[/CODE]

Glad you like it

As per above only issue i have with making it work on MAC etc is i have no way of testing it

Still working on making it better and more sleek too

  • 8 months later...
  On 31/01/2013 at 07:49, Yorak said:

Hey man, forgot to test this earlier but it seems to work well. Nice job. Great script. :)

pmNlQA6l.jpg

 

What script is that you were running here? Is the 1st terminal an Arch linux thing, or script? (Or is that Haggis Script?)

  • 2 years later...
  On 22/05/2016 at 06:38, Haggis said:

Not used centos but it should work fine

 

It wont log anything though it just displays real time

Expand  

Would you be able to add a bandwidth logger? After 24 hours record it, at the end of the month it displays the total bandwidth used.

 

Trying to figure out how to do that, and have those stats posted on our website. I suck at coding right now :(

it would mean running the script in the back ground or taking a snapshot

 

sort of like a "bandwidth used since last run"

 

there are much better apps for this though :)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • TP-Link Tri-Band AXE5400 Wi-Fi 6E Gaming Router Archer GXE75 is just $135 by Sayan Sen If you’re juggling gaming consoles, 4K streams and a growing roster of smart devices, the TP-Link Archer GXE75 Tri-Band AXE5400 Wi-Fi 6E Gaming Router is a good option to look at right now, considering the device is currently on sale at just $135 (purchase link under the specs table below). The Archer GXE75 promises up to 5.4 Gbps of throughput across three bands: 574 Mbps on 2.4 GHz, 2402 Mbps on 5 GHz and 2402 Mbps on 6 GHz (HE160 channels enabled). A 2.5 Gbps WAN/LAN port pairs with three 1 Gbps LAN ports and a USB 3.0 port for fast file sharing or printer access (purchase link down below). The quad-core CPU and 512 MB of RAM should help to handle multiple streams without bogging down, while MU-MIMO, OFDMA and 1024-QAM improve efficiency when several devices connect simultaneously. The router’s built-in Game Accelerator engine is said to automatically prioritize gaming packets (both wired and wireless), and TP-Link’s GPN (Gamers Private Network) acceleration can reduce packet loss for supported titles. HomeShield security brings firewall protection, device quarantining and parental controls. The technical specifications of the router are given below: Specification Details Wireless Standards IEEE 802.11ax 6 GHz; IEEE 802.11ax/ac/n/a 5 GHz; IEEE 802.11ax/n/g/b 2.4 GHz Wi-Fi Speeds 6 GHz: 2402 Mbps (802.11ax); 5 GHz: 2402 Mbps (802.11ax); 2.4 GHz: 574 Mbps (802.11ax) Spatial Streams 6 streams (tri-band OFDMA/MU-MIMO) Processor 1.7 GHz 64-bit Quad-Core CPU Memory 512 MB high-speed RAM Ethernet Ports 1× 2.5 Gbps WAN/LAN; 1× 1 Gbps WAN/LAN; 3× 1 Gbps LAN USB 1× USB 3.0 SuperSpeed port (up to 10× faster than USB 2.0) Antennas 4× high-performance external antennas with Beamforming Buttons Power On/Off; Reset; WPS/Wi-Fi; LED On/Off Working Modes Router Mode; Access Point Mode Security WPA, WPA2, WPA3, WPA/WPA2-Enterprise; SPI firewall; Access Control; IP/MAC binding; Application-layer gateway; HomeShield security suite VPN OpenVPN, PPTP, L2TP (server & client); WireGuard (server & client) Software & Services IPv4/IPv6; TP-Link HomeShield; EasyMesh; Parental controls; QoS by device; WAN types (Dynamic IP, Static IP, PPPoE, PPTP, L2TP); DDNS (TP-Link, NO-IP, DynDNS); auto firmware updates Gaming Features Game QoS boost; gaming-port priority; Gamers Private Network acceleration; game-port forwarding; real-time game panel with stats & RGB control Operating Environment 0 °C – 40 °C; 10 %– 90 % non-condensing humidity Get the TP-Link Tri-Band AXE5400 Wi-Fi 6E Gaming Router Archer GXE75 at the link below: TP-Link Tri-Band AXE5400 Wi-Fi 6E Gaming Router Archer GXE75 | EasyMesh, HomeShield: $159.99 + $25 off with coupon => $134.99 (Sold and Shipped by Amazon US This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • Oh no... here we go again. Tha same sh*t that happaned to Mail & Calendar...
    • I too have worked with pro gear for decades and so I found the interface to be unintuitive from both the pro and casual side (a rare "accomplishment" by what are obviously otherwise skilled coders, hehe). I eventually got it to work, thanks for offering, but I found other compatibility issues with my own use case, so I just dropped it entirely. Right now, I just use an analog line out/line in approach which works as expected across all usage scenarios. With both machines on the same power block/outlet, I'm not getting any analog hum or hiss. My next step will be to try the updated Multiplicity 4 when a bug, addressing this very issue unfortunately, is resolved. Knowing Stardock, that could be tomorrow or five years from now, so I check back every few months to see it it's fixed and I want to upgrade. Again, thanks for offering to help.
    • We recognize that performance can use some improvements, and we continue to work on improving it. However, it's worth noting that massive performance improvements don't happen overnight, they take a lot of work and effort, and in most cases, the improvements are more noticeable when you compare across several updates. That said, Files is open-source and everyone is invited to help with these efforts 🙂
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      494
    2. 2
      Michael Scrip
      203
    3. 3
      ATLien_0
      197
    4. 4
      Xenon
      137
    5. 5
      +FloatingFatMan
      116
  • Tell a friend

    Love Neowin? Tell a friend!